4 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
25 #include "DllAvFormat.h"
26 #include "DllAvCodec.h"
27 #include "DllAvUtil.h"
29 #include "DVDAudioCodec.h"
31 class CDVDAudioCodecPassthroughFFmpeg : public CDVDAudioCodec
34 CDVDAudioCodecPassthroughFFmpeg();
35 virtual ~CDVDAudioCodecPassthroughFFmpeg();
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);
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();
52 DllAvFormat m_dllAvFormat;
53 DllAvUtil m_dllAvUtil;
54 DllAvCodec m_dllAvCodec;
64 AVFormatContext *m_pFormat;
66 std::list<DataPacket*> m_OutputBuffer;
67 unsigned int m_OutputSize;
69 unsigned char m_BCBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
70 unsigned int m_Consumed;
71 unsigned int m_BufferSize;
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);
83 bool m_bSupportsAC3Out;
84 bool m_bSupportsDTSOut;
85 bool m_bSupportsAACOut;
87 CDVDAudioCodec *m_Codec;
88 uint8_t *m_DecodeBuffer;
89 unsigned int m_DecodeSize;
90 bool SupportsFormat(CDVDStreamInfo &hints);
92 uint8_t m_NeededBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
93 unsigned int m_NeededUsed;
94 unsigned int m_Needed;
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);