3 * Copyright (C) 2010-2013 Team XBMC
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)
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.
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/>.
22 #if defined(HAVE_LIBOPENMAX)
24 #include "cores/dvdplayer/DVDStreamInfo.h"
25 #include "DVDVideoCodec.h"
26 #include "threads/Event.h"
29 #include <semaphore.h>
32 ////////////////////////////////////////////////////////////////////////////////////////////
35 #define OMX_DEBUG_VERBOSE
36 #define OMX_DEBUG_EVENTHANDLER
37 #define OMX_DEBUG_FILLBUFFERDONE
38 #define OMX_DEBUG_EMPTYBUFFERDONE
41 typedef struct omx_codec_capability {
42 // level is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE,
43 // or OMX_VIDEO_MPEG4PROFILETYPE depending on context.
45 // level is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE,
46 // or OMX_VIDEO_MPEG4PROFILETYPE depending on context.
48 } omx_codec_capability;
50 typedef struct omx_demux_packet {
65 enum OMX_CLIENT_STATE {
77 // initialize OpenMax and get decoder component
78 bool Initialize( const CStdString &decoder_name);
81 // OpenMax Decoder delegate callback routines.
82 static OMX_ERRORTYPE DecoderEventHandlerCallback(OMX_HANDLETYPE hComponent, OMX_PTR pAppData,
83 OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData);
84 static OMX_ERRORTYPE DecoderEmptyBufferDoneCallback(
85 OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBuffer);
86 static OMX_ERRORTYPE DecoderFillBufferDoneCallback(
87 OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBufferHeader);
89 // OpenMax decoder callback routines.
90 virtual OMX_ERRORTYPE DecoderEventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData,
91 OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData);
92 virtual OMX_ERRORTYPE DecoderEmptyBufferDone(
93 OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBuffer);
94 virtual OMX_ERRORTYPE DecoderFillBufferDone(
95 OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBufferHeader);
97 // OpenMax helper routines
98 OMX_ERRORTYPE WaitForState(OMX_STATETYPE state);
99 OMX_ERRORTYPE SetStateForComponent(OMX_STATETYPE state);
101 DllLibOpenMax *m_dll;
103 OMX_HANDLETYPE m_omx_decoder; // openmax decoder component reference
105 // OpenMax state tracking
106 OMX_CLIENT_STATE m_omx_client_state;
107 volatile int m_omx_decoder_state;
108 sem_t *m_omx_decoder_state_change;
109 std::vector<omx_codec_capability> m_omx_decoder_capabilities;
112 COpenMax(const COpenMax& other);
113 COpenMax& operator=(const COpenMax&);