[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDCodecs / Audio / DVDAudioCodecPassthroughFFmpeg.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include <list>
24 #include "system.h"
25 #include "DllAvFormat.h"
26 #include "DllAvCodec.h"
27 #include "DllAvUtil.h"
28
29 #include "DVDAudioCodec.h"
30
31 class CDVDAudioCodecPassthroughFFmpeg : public CDVDAudioCodec
32 {
33 public:
34   CDVDAudioCodecPassthroughFFmpeg();
35   virtual ~CDVDAudioCodecPassthroughFFmpeg();
36
37   virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
38   virtual void Dispose();
39   virtual int Decode(uint8_t* pData, int iSize);
40   virtual int GetData(uint8_t** dst);
41   virtual void Reset();
42   virtual int GetChannels();
43   virtual CAEChannelInfo GetChannelMap();
44   virtual int  GetSampleRate();
45   virtual int  GetEncodedSampleRate();
46   virtual enum AEDataFormat GetDataFormat();
47   virtual int GetBitsPerSample();
48   virtual bool NeedPassthrough() { return true; }
49   virtual const char* GetName()  { return "PassthroughFFmpeg"; }
50   virtual int GetBufferSize();
51 private:
52   DllAvFormat m_dllAvFormat;
53   DllAvUtil   m_dllAvUtil;
54   DllAvCodec  m_dllAvCodec;
55
56   typedef struct
57   {
58     int      size;
59     uint8_t *data;
60   } DataPacket;
61
62   typedef struct
63   {
64     AVFormatContext       *m_pFormat;
65     AVStream              *m_pStream;
66     std::list<DataPacket*> m_OutputBuffer;
67     unsigned int           m_OutputSize;
68     bool                   m_WroteHeader;
69     unsigned char          m_BCBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
70     unsigned int           m_Consumed;
71     unsigned int           m_BufferSize;
72     uint8_t               *m_Buffer;
73   } Muxer;
74
75   Muxer      m_SPDIF, m_ADTS;
76   bool       SetupMuxer(CDVDStreamInfo &hints, CStdString muxerName, Muxer &muxer);
77   static int MuxerReadPacket(void *opaque, uint8_t *buf, int buf_size);
78   void       WriteFrame(Muxer &muxer, uint8_t *pData, int iSize);
79   int        GetMuxerData(Muxer &muxer, uint8_t** dst);
80   void       ResetMuxer(Muxer &muxer);
81   void       DisposeMuxer(Muxer &muxer);
82
83   bool m_bSupportsAC3Out;
84   bool m_bSupportsDTSOut;
85   bool m_bSupportsAACOut;
86
87   CDVDAudioCodec   *m_Codec;
88   uint8_t          *m_DecodeBuffer;
89   unsigned int      m_DecodeSize;
90   bool SupportsFormat(CDVDStreamInfo &hints);
91
92   uint8_t      m_NeededBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
93   unsigned int m_NeededUsed;
94   unsigned int m_Needed;
95   bool         m_LostSync;
96   int          m_SampleRate;
97   AVCodecID    m_codec;
98
99   unsigned int (CDVDAudioCodecPassthroughFFmpeg::*m_pSyncFrame)(uint8_t* pData, unsigned int iSize, unsigned int *fSize);
100   unsigned int SyncAC3(uint8_t* pData, unsigned int iSize, unsigned int *fSize);
101   unsigned int SyncDTS(uint8_t* pData, unsigned int iSize, unsigned int *fSize);
102   unsigned int SyncAAC(uint8_t* pData, unsigned int iSize, unsigned int *fSize);
103 };
104