Merge pull request #2948 from ace20022/blu_lang_fix
[vuplus_xbmc] / xbmc / cdrip / EncoderFFmpeg.h
1 #ifndef _ENCODERFFMPEG_H
2 #define _ENCODERFFMPEG_H
3
4 /*
5  *      Copyright (C) 2005-2013 Team XBMC
6  *      http://www.xbmc.org
7  *
8  *  This Program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This Program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with XBMC; see the file COPYING.  If not, see
20  *  <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "Encoder.h"
25 #include "DllAvFormat.h"
26 #include "DllAvCodec.h"
27 #include "DllAvUtil.h"
28 #include "DllSwResample.h"
29
30 class CEncoderFFmpeg : public CEncoder
31 {
32 public:
33   CEncoderFFmpeg();
34   virtual ~CEncoderFFmpeg() {}
35   bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
36   int Encode(int nNumBytesRead, uint8_t* pbtStream);
37   bool Close();
38   void AddTag(int key, const char* value);
39
40 private:
41   DllAvCodec  m_dllAvCodec;
42   DllAvUtil   m_dllAvUtil;
43   DllAvFormat m_dllAvFormat;
44   DllSwResample m_dllSwResample;
45
46   AVFormatContext  *m_Format;
47   AVCodecContext   *m_CodecCtx;
48   SwrContext       *m_SwrCtx;
49   AVStream         *m_Stream;
50   AVPacket          m_Pkt;
51   AVSampleFormat    m_InFormat;
52   AVSampleFormat    m_OutFormat;
53   /* From libavformat/avio.h:
54    * The buffer size is very important for performance.
55    * For protocols with fixed blocksize it should be set to this
56    * blocksize.
57    * For others a typical size is a cache page, e.g. 4kb.
58    */
59   unsigned char     m_BCBuffer[4096];
60   static int        avio_write_callback(void *opaque, uint8_t *buf, int buf_size);
61   static int64_t    avio_seek_callback(void *opaque, int64_t offset, int whence);
62   void              SetTag(const CStdString tag, const CStdString value);
63
64
65   unsigned int      m_NeededFrames;
66   unsigned int      m_NeededBytes;
67   uint8_t          *m_Buffer;
68   unsigned int      m_BufferSize;
69   AVFrame          *m_BufferFrame;
70   uint8_t          *m_ResampledBuffer;
71   unsigned int      m_ResampledBufferSize;
72   AVFrame          *m_ResampledFrame;
73   bool              m_NeedConversion;
74
75   bool WriteFrame();
76 };
77
78 #endif // _ENCODERFFMPEG_H