1 /***************************************************************************
2     \file   muxerAvi
3     \brief  avi muxer class
4     \author mean fixounet@free.Fr (c) 2002/2012
5  ***************************************************************************/
6 
7 /***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 #ifndef ADM_MUXER_AVI
16 #define ADM_MUXER_AVI
17 
18 #include "ADM_muxer.h"
19 #include "op_aviwrite.hxx"
20 #include "ADM_audioClock.h"
21 #include "avi_muxer.h"
22 /**
23     \enum set muxer type, i.e. generate openDml or plain avi
24 */
25 enum
26 {
27     AVI_MUXER_TYPE1=0,AVI_MUXER_AUTO=1,AVI_MUXER_TYPE2=2
28 };
29 
30 #define AUDIO_BUFFER_SIZE 48000*6*sizeof(float)
31 extern avi_muxer muxerConfig;
32 
33 class aviAudioPacket
34 {
35     public:
36             uint8_t     *buffer;
37             uint64_t    dts;
38             uint32_t    nbSamples;
39             uint32_t    sizeInBytes;
40             bool        present;
41             bool        eos;
42 
aviAudioPacket()43             aviAudioPacket() {buffer=new uint8_t[AUDIO_BUFFER_SIZE];eos=false;present=false;}
~aviAudioPacket()44             ~aviAudioPacket() {delete [] buffer;buffer=NULL;}
45 
46 };
47 /**
48     \class muxerAvi
49 */
50 class muxerAvi : public ADM_muxer
51 {
52 protected:
53         bool    setupAudio(int trackNumber, ADM_audioStream *audio);
54         bool    setupVideo(ADM_videoStream *video);
55         bool    fillAudio(uint64_t targetDts);
56         aviWrite  writter;
57         aviAudioPacket  *audioPackets;
58         uint8_t         *videoBuffer;
59         audioClock      **clocks;
60         uint64_t        audioDelay;
61         uint64_t        firstPacketOffset;
62         bool            firstVideoPacket;
63 public:
64                 muxerAvi();
65         virtual ~muxerAvi();
66         virtual bool open(const char *file, ADM_videoStream *s,uint32_t nbAudioTrack,ADM_audioStream **a);
67         virtual bool save(void) ;
68         virtual bool close(void) ;
preferH264AnnexB(void)69         virtual bool preferH264AnnexB(void) {return true;};
canDealWithTimeStamps(void)70         virtual bool canDealWithTimeStamps(void) {return false;}; // need perfect audio
71                 bool prefill(ADMBitstream *in);
72 
73 };
74 
75 #endif
76