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
31 #include <sys/ioctl.h>
\r
39 #include "defines.h"
\r
41 #include "threadsystem.h"
\r
43 #define OMX_SKIP64BIT
\r
45 #include <IL/OMX_Core.h>
\r
46 #include <IL/OMX_Types.h>
\r
47 #include <IL/OMX_Component.h>
\r
48 #include <IL/OMX_Broadcom.h>
\r
51 struct VPE_OMX_EVENT {
\r
52 OMX_IN OMX_HANDLETYPE handle;
\r
53 OMX_IN OMX_PTR appdata;
\r
54 OMX_IN OMX_EVENTTYPE event_type;
\r
55 OMX_IN OMX_U32 data1;
\r
56 OMX_IN OMX_U32 data2;
\r
57 OMX_IN OMX_PTR event_data;
\r
65 class VideoOMX : public Video
\r
67 friend class AudioOMX;
\r
70 virtual ~VideoOMX();
\r
72 int init(UCHAR format);
\r
75 int setFormat(UCHAR format);
\r
76 int setConnection(UCHAR connection);
\r
77 int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching
\r
78 int setMode(UCHAR mode);
\r
79 int setTVsize(UCHAR size); // Is the TV a widescreen?
\r
80 int setDefaultAspect();
\r
82 int setPosition(int x, int y);
\r
89 int unFastForward();
\r
94 int attachFrameBuffer(); // What does this do?
\r
95 ULONG timecodeToFrameNumber(ULLONG timecode);
\r
96 ULLONG getCurrentTimestamp();
\r
97 bool displayIFrame(const UCHAR* bulibaver, UINT length);
\r
99 virtual bool dtsTimefix(){return false;} //please we need dts time values
\r
100 virtual int getTeletextBufferFaktor(){return 5;};
\r
102 // Writing Data to Videodevice
\r
103 virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);
\r
104 virtual UINT DeliverMediaSample(UCHAR* bulibaver, UINT* samplepos);
\r
107 virtual bool supportsh264(){return true;};
\r
109 int WriteOutTS(const unsigned char *bulibaver,int length, int type);
\r
110 void WriteOutPATPMT();
\r
114 virtual long long SetStartOffset(long long curreftime, bool *rsync);
\r
115 long long SetStartAudioOffset(long long curreftime, bool *rsync);
\r
116 virtual void ResetTimeOffsets();
\r
118 bool loadOptionsfromServer(VDR* vdr);
\r
119 bool saveOptionstoServer();
\r
120 bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
\r
121 bool handleOptionChanges(Option* option);
\r
131 static inline OMX_TICKS intToOMXTicks(long long pts) {
\r
134 temp.nHighPart=pts>>32;
\r
141 int EnterIframePlayback();
\r
143 bool InIframemode() {return iframemode;};
\r
145 UINT DeliverMediaPacket(MediaPacket packet,const UCHAR* bulibaver,UINT *samplepos);
\r
147 #define VPE_DECODER_OMX 1
\r
152 bool offsetvideonotset;
\r
153 bool offsetaudionotset;
\r
154 long long startoffset;
\r
155 long long lastrefvideotime;
\r
156 long long lastrefaudiotime;
\r
157 // long long cur_pts;
158 long long lastreftimeOMX;
\r
159 ULLONG lastreftimePTS;
\r
161 // long long playbacktimeoffset; //this is the offset between the media time and system clock
\r
162 // long long pausetimecode;
\r
165 /* static long long GetCurrentSystemTime();
\r
166 static void WaitUntil(long long time);
\r
167 void FrameWaitforDisplay(long long pts);
\r
168 bool FrameSkip(long long pts);
\r
170 void AdjustAudioPTS(long long pts);*/
\r
175 static OMX_ERRORTYPE EventHandler_OMX(OMX_IN OMX_HANDLETYPE handle,OMX_IN OMX_PTR appdata,
\r
176 OMX_IN OMX_EVENTTYPE event_type,OMX_IN OMX_U32 data1,
\r
177 OMX_IN OMX_U32 data2,OMX_IN OMX_PTR event_data);
\r
178 static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
\r
179 static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
\r
181 UINT DeliverMediaPacketOMX(MediaPacket packet,
\r
182 const UCHAR* bulibaver,
\r
185 bool detectIFrame(const UCHAR *buffer,unsigned int length);
\r
187 int PrepareInputBufsOMX();
\r
188 int DestroyInputBufsOMX();
\r
190 void AddOmxEvent(VPE_OMX_EVENT new_event);
\r
191 void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);
\r
193 int ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type);
\r
194 int CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data2);
\r
195 int WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event);
\r
196 int EnablePort(OMX_HANDLETYPE handle,OMX_U32 port,bool wait);
\r
197 int DisablePort(OMX_HANDLETYPE handle,OMX_U32 port,bool wait=true);
\r
201 int setClockExecutingandRunning();
\r
203 void destroyClock();
\r
205 int getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_clock_output_port);
\r
206 int getClockVideoandInit();
\r
207 void LockClock() {clock_mutex.Lock();};
\r
208 void UnlockClock() {clock_mutex.Unlock();};
\r
209 OMX_ERRORTYPE ProtOMXEmptyThisBuffer(OMX_HANDLETYPE handle, OMX_BUFFERHEADERTYPE* buffer);
\r
211 void clockUnpause();
\r
213 Mutex clock_mutex; //clock mutex is now responsible for all omx stuff
\r
214 long long cur_clock_time;
\r
218 OMX_HANDLETYPE omx_vid_dec;
\r
219 OMX_HANDLETYPE omx_vid_sched;
\r
220 OMX_HANDLETYPE omx_vid_deint;
\r
221 OMX_HANDLETYPE omx_vid_rend;
\r
222 OMX_HANDLETYPE omx_clock;
\r
223 int clock_references;
\r
224 bool dodeint; //deinterlacer was activated in omx filtergraph
\r
225 bool deint_first_frame; //handle frame change
\r
226 void DeinterlaceFix();
\r
229 OMX_U32 omx_codec_input_port;
\r
230 OMX_U32 omx_codec_output_port;
\r
231 OMX_U32 omx_deint_input_port;
\r
232 OMX_U32 omx_deint_output_port;
\r
233 OMX_U32 omx_rend_input_port;
\r
234 OMX_U32 omx_shed_input_port;
\r
235 OMX_U32 omx_shed_output_port;
\r
236 OMX_U32 omx_shed_clock_port;
\r
237 OMX_U32 omx_clock_output_port;
\r
238 // OMX_NALUFORMATSTYPE omx_nalu_format;
\r
242 int AllocateCodecsOMX();
\r
243 int DeAllocateCodecsOMX();
\r
244 int FlushRenderingPipe();
\r
246 vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;
\r
247 list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;
\r
248 Mutex input_bufs_omx_mutex;
\r
249 OMX_BUFFERHEADERTYPE* cur_input_buf_omx;
\r
251 void PutBufferToPres(OMX_BUFFERHEADERTYPE* buffer);
\r
256 bool omx_first_frame;
\r
258 Mutex omx_event_mutex;
\r
260 list<VPE_OMX_EVENT> omx_events;
\r
266 void updateMode();//called internally to adjust for different parameters
\r
267 void selectVideoMode(int interlaced);
\r
276 vector<MediaPacket> mediapackets;
\r