2 Copyright 2004-2005 Chris Tallon, 2009,2012 Marten Richter
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
27 #include <sys/ioctl.h>
\r
29 #include "defines.h"
\r
31 #include "videoomx.h"
\r
34 #include <libavcodec/avcodec.h>
\r
35 #include <libavformat/avformat.h>
\r
41 class AudioOMX : public Audio
\r
43 friend class VideoOMX;
\r
46 virtual ~AudioOMX();
\r
48 int init(UCHAR streamType);
\r
51 int setStreamType(UCHAR streamType);
\r
60 int setVolume(int volume);
\r
63 bool supportsAc3() { return true; }
\r
64 bool maysupportAc3(){return true;}
\r
65 bool streamTypeSupported(int streamtype)
\r
67 switch (streamtype) {
\r
68 case 0x11: //AAC LATM packaging
\r
70 case 3: //mpeg 1 layer 1 and 2
\r
79 //Writing Data to Audiodevice
\r
80 virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);
\r
81 virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos);
\r
82 UINT DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,UINT *samplepos);
\r
84 virtual long long SetStartOffset(long long curreftime, bool *rsync);
\r
85 virtual void ResetTimeOffsets();
\r
87 virtual bool DrainTargetReady() {return omx_running;};
\r
90 UCHAR getLastAType() {return lastAType;}
\r
92 bool loadOptionsfromServer(VDR* vdr);
\r
93 bool saveOptionstoServer();
\r
94 bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
\r
95 bool handleOptionChanges(Option* option);
\r
103 int initAllParams();
\r
108 MediaPacket packet;
\r
113 bool hdmi; // use hdmi as audio output
\r
114 bool passthrough; // use audio passthrough for the current audio type
\r
120 bool canpass_pcm_mch;
\r
124 int prefered_ac3; //0 stereo PCM, 1 passthrough 2 Multichannel PCM
\r
130 static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
\r
131 static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
\r
135 unsigned int AdvanceAc3AudioSync(const UCHAR *data,unsigned int size,unsigned int *framesize);
\r
136 unsigned int AdvanceAacLatmAudioSync(const UCHAR *data,unsigned int size,unsigned int *framesize);
\r
137 unsigned int AdvanceMpAudioSync(const UCHAR *data,unsigned int size,unsigned int *framesize);
\r
140 void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);
\r
142 // OMX_HANDLETYPE omx_aud_dec;
\r
143 OMX_HANDLETYPE omx_aud_rend;
\r
144 OMX_HANDLETYPE omx_clock;
\r
146 //OMX_U32 omx_codec_input_port;
\r
147 //OMX_U32 omx_codec_output_port;
\r
148 OMX_U32 omx_rend_input_port;
\r
149 OMX_U32 omx_rend_clock_port;
\r
150 OMX_U32 omx_clock_output_port;
\r
152 long long lastreftimeOMX;
\r
153 ULLONG lastreftimePTS;
\r
157 int AllocateCodecsOMX();
\r
158 int DeAllocateCodecsOMX();
\r
160 int PrepareInputBufsOMX(bool setportdef);
\r
161 int DestroyInputBufsOMX();
\r
162 int DestroyInputBufsOMXwhilePlaying();
\r
164 int ChangeAudioPortConfig(bool disport);
\r
165 int ChangeAudioDestination();
\r
166 long long correctAudioLatency(long long pts,int addsamples,int srate);
\r
168 vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;
\r
169 list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;
\r
170 Mutex input_bufs_omx_mutex;
\r
171 OMX_BUFFERHEADERTYPE* cur_input_buf_omx;
\r
174 bool omx_first_frame;
\r
177 AVCodec *aaclatmcodec_libav;
\r
178 AVCodecContext *aaclatmcodec_context_libav;
\r
179 AVCodec *ac3codec_libav;
\r
180 AVCodecContext *ac3codec_context_libav;
\r
181 AVCodec *mp23codec_libav;
\r
182 AVCodecContext *mp23codec_context_libav;
\r
183 AVPacket incoming_paket_libav;
\r
184 AVFrame *decode_frame_libav;
\r
186 UCHAR * decompress_buffer;
\r
187 unsigned int decompress_buffer_size;
\r
188 unsigned int decompress_buffer_filled;
\r
192 int InitDecoderLibAV();
\r
193 void DeinitDecoderLibAV();
\r