/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.h

http://github.com/xbmc/xbmc · C Header · 104 lines · 72 code · 13 blank · 19 comment · 0 complexity · 398938924fc3f2dae06b7690574456d0 MD5 · raw file

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