]> git.vomp.tv Git - vompclient.git/blob - audioomx.h
Preparations for AC3 passthrough and parser for deinterlacing
[vompclient.git] / audioomx.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon, 2009,2012 Marten Richter\r
3 \r
4     This file is part of VOMP.\r
5 \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
10 \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
15 \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
19 */\r
20 \r
21 #ifndef AUDIOOMX_H\r
22 #define AUDIOOMX_H\r
23 \r
24 #include <stdio.h>\r
25 #include <unistd.h>\r
26 #include <fcntl.h>\r
27 #include <sys/ioctl.h>\r
28 \r
29 #include "defines.h"\r
30 #include "audio.h"\r
31 #include "videoomx.h"\r
32 \r
33 extern "C" {\r
34 #include <libavcodec/avcodec.h>\r
35 #include <libavformat/avformat.h>\r
36 }\r
37 \r
38 \r
39 \r
40 \r
41 class AudioOMX : public Audio\r
42 {\r
43   friend class VideoOMX;\r
44   public:\r
45     AudioOMX();\r
46     virtual ~AudioOMX();\r
47 \r
48     int init(UCHAR streamType);\r
49     int shutdown();\r
50 \r
51     int setStreamType(UCHAR streamType);\r
52     int setChannel();\r
53     int setSource();\r
54     int sync();\r
55     int play();\r
56     int stop();\r
57     int pause();\r
58     int unPause();\r
59     int reset();\r
60     int setVolume(int volume);\r
61     int mute();\r
62     int unMute();\r
63     bool supportsAc3() { return true; }\r
64     virtual bool maysupportAc3(){return true;}\r
65 \r
66     //Writing Data to Audiodevice\r
67     virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);\r
68     virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos);\r
69     UINT DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,UINT *samplepos);\r
70 \r
71     virtual long long SetStartOffset(long long curreftime, bool *rsync);\r
72     virtual void ResetTimeOffsets();\r
73 \r
74     virtual bool DrainTargetReady() {return omx_running;};\r
75 \r
76 \r
77         UCHAR getLastAType() {return lastAType;}\r
78 \r
79         bool loadOptionsfromServer(VDR* vdr);\r
80         bool saveOptionstoServer();\r
81         bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);\r
82         bool handleOptionChanges(Option* option);\r
83 \r
84 \r
85 #ifdef DEV\r
86     int test();\r
87 #endif\r
88 \r
89   private:\r
90     int initAllParams();\r
91     UCHAR streamType;\r
92         UCHAR lastAType;\r
93         bool firstsynched;\r
94 \r
95     MediaPacket packet;\r
96     UINT packetpos;\r
97 \r
98         bool paused;\r
99 \r
100     bool hdmi; // use hdmi as audio output\r
101     bool passthrough; // use audio passthrough for the current audio type\r
102 \r
103     bool canpass_ac3;\r
104     bool canpass_mp2;\r
105     bool canpass_mp3;\r
106     bool canpass_pcm_mch;\r
107 \r
108 \r
109     int prefered_ac3; //0 stereo PCM, 1 passthrough 2 Multichannel PCM\r
110     int prefered_mp2;\r
111     int prefered_mp3;\r
112 \r
113 \r
114 \r
115     static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
116         static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
117 \r
118 \r
119 \r
120         unsigned int AdvanceAc3AudioSync(UCHAR *data,unsigned int size,unsigned int *framesize);\r
121         unsigned int AdvanceMpAudioSync(UCHAR *data,unsigned int size,unsigned int *framesize);\r
122 \r
123 \r
124     void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);\r
125 \r
126    // OMX_HANDLETYPE omx_aud_dec;\r
127         OMX_HANDLETYPE omx_aud_rend;\r
128         OMX_HANDLETYPE omx_clock;\r
129 \r
130         //OMX_U32 omx_codec_input_port;\r
131         //OMX_U32 omx_codec_output_port;\r
132         OMX_U32 omx_rend_input_port;\r
133         OMX_U32 omx_rend_clock_port;\r
134         OMX_U32 omx_clock_output_port;\r
135 \r
136         long long lastreftimeOMX;\r
137     ULLONG lastreftimePTS;\r
138 \r
139 \r
140 \r
141         int AllocateCodecsOMX();\r
142         int DeAllocateCodecsOMX();\r
143 \r
144         int PrepareInputBufsOMX();\r
145         int DestroyInputBufsOMX();\r
146 \r
147         int ChangeAudioPortConfig(bool disport);\r
148         int ChangeAudioDestination();\r
149         long long correctAudioLatency(long long pts,int addsamples,int srate);\r
150 \r
151         vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;\r
152         list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;\r
153         Mutex input_bufs_omx_mutex;\r
154         OMX_BUFFERHEADERTYPE* cur_input_buf_omx;\r
155 \r
156     bool omx_running;\r
157     bool omx_first_frame;\r
158     Mutex libav_mutex;\r
159 \r
160         AVCodec *ac3codec_libav;\r
161         AVCodecContext *ac3codec_context_libav;\r
162         AVCodec *mp23codec_libav;\r
163     AVCodecContext *mp23codec_context_libav;\r
164     AVPacket incoming_paket_libav;\r
165     AVFrame *decode_frame_libav;\r
166 \r
167     UCHAR * decompress_buffer;\r
168     unsigned int decompress_buffer_size;\r
169     unsigned int decompress_buffer_filled;\r
170 \r
171 \r
172          int InitDecoderLibAV();\r
173          void DeinitDecoderLibAV();\r
174 \r
175 };\r
176 \r
177 #endif\r