]> git.vomp.tv Git - vompclient.git/blob - audioomx.h
Fix bug in videoomx delivermediapacket for big mediapackets
[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   public:\r
44     AudioOMX();\r
45     virtual ~AudioOMX();\r
46 \r
47     int init(UCHAR streamType);\r
48     int shutdown();\r
49 \r
50     int setStreamType(UCHAR streamType);\r
51     int setChannel();\r
52     int setSource();\r
53     int sync();\r
54     int play();\r
55     int stop();\r
56     int pause();\r
57     int unPause();\r
58     int reset();\r
59     int setVolume(int volume);\r
60     int mute();\r
61     int unMute();\r
62     bool supportsAc3() { return true; }\r
63     virtual bool maysupportAc3(){return true;}\r
64 \r
65     //Writing Data to Audiodevice\r
66     virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);\r
67     virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos);\r
68     UINT DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer,UINT *samplepos);\r
69 \r
70     virtual long long SetStartOffset(long long curreftime, bool *rsync);\r
71     virtual void ResetTimeOffsets();\r
72 \r
73     virtual bool DrainTargetReady() {return omx_running;};\r
74 \r
75 \r
76         UCHAR getLastAType() {return lastAType;}\r
77 \r
78         bool loadOptionsfromServer(VDR* vdr);\r
79         bool saveOptionstoServer();\r
80         bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);\r
81         bool handleOptionChanges(Option* option);\r
82 \r
83 \r
84 #ifdef DEV\r
85     int test();\r
86 #endif\r
87 \r
88   private:\r
89     int initAllParams();\r
90     UCHAR streamType;\r
91         UCHAR lastAType;\r
92         bool firstsynched;\r
93 \r
94     MediaPacket packet;\r
95     UINT packetpos;\r
96 \r
97         bool paused;\r
98 \r
99     bool hdmi; // use hdmi as audio output\r
100     bool passthrough; // use audio passthrough for the current audio type\r
101 \r
102     bool canpass_ac3;\r
103     bool canpass_mp2;\r
104     bool canpass_mp3;\r
105     bool canpass_pcm_mch;\r
106 \r
107 \r
108     int prefered_ac3; //0 stereo PCM, 1 passthrough 2 Multichannel PCM\r
109     int prefered_mp2;\r
110     int prefered_mp3;\r
111 \r
112 \r
113 \r
114     static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
115         static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
116 \r
117 \r
118 \r
119     void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);\r
120 \r
121    // OMX_HANDLETYPE omx_aud_dec;\r
122         OMX_HANDLETYPE omx_aud_rend;\r
123         OMX_HANDLETYPE omx_clock;\r
124 \r
125         //OMX_U32 omx_codec_input_port;\r
126         //OMX_U32 omx_codec_output_port;\r
127         OMX_U32 omx_rend_input_port;\r
128         OMX_U32 omx_rend_clock_port;\r
129         OMX_U32 omx_clock_output_port;\r
130 \r
131         OMX_TICKS lastreftimeOMX;\r
132     ULLONG lastreftimePTS;\r
133 \r
134 \r
135 \r
136         int AllocateCodecsOMX();\r
137         int DeAllocateCodecsOMX();\r
138 \r
139         int PrepareInputBufsOMX();\r
140         int DestroyInputBufsOMX();\r
141 \r
142         int ChangeAudioPortConfig();\r
143         int ChangeAudioDestination();\r
144         long long correctAudioLatency(long long pts,int addsamples,int srate);\r
145 \r
146         vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;\r
147         list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;\r
148         Mutex input_bufs_omx_mutex;\r
149         OMX_BUFFERHEADERTYPE* cur_input_buf_omx;\r
150 \r
151     bool omx_running;\r
152     bool omx_first_frame;\r
153     Mutex libav_mutex;\r
154 \r
155         AVCodec *ac3codec_libav;\r
156         AVCodecContext *ac3codec_context_libav;\r
157         AVCodec *mp23codec_libav;\r
158     AVCodecContext *mp23codec_context_libav;\r
159     AVPacket incoming_paket_libav;\r
160     AVFrame *decode_frame_libav;\r
161 \r
162 \r
163 \r
164          int InitDecoderLibAV();\r
165          void DeinitDecoderLibAV();\r
166 \r
167 };\r
168 \r
169 #endif\r