]> git.vomp.tv Git - vompclient.git/blob - audiovpe.h
Add basic audio playback (stereo), fast forward, ThreadP bugfix and Stream interface...
[vompclient.git] / audiovpe.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon, 2009 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 AUDIOVPE_H\r
22 #define AUDIOVPE_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 "videovpeogl.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 AudioVPE : public Audio\r
42 {\r
43   public:\r
44     AudioVPE();\r
45     virtual ~AudioVPE();\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 \r
74         UCHAR getLastAType() {return lastAType;}\r
75 \r
76         bool loadOptionsfromServer(VDR* vdr);\r
77         bool saveOptionstoServer();\r
78         bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);\r
79         bool handleOptionChanges(Option* option);\r
80 \r
81 \r
82 #ifdef DEV\r
83     int test();\r
84 #endif\r
85 \r
86   private:\r
87     int initAllParams();\r
88     UCHAR streamType;\r
89         UCHAR lastAType;\r
90         bool firstsynched;\r
91 \r
92     MediaPacket packet;\r
93     UINT packetpos;\r
94 \r
95         bool paused;\r
96 \r
97     bool hdmi; // use hdmi as audio output\r
98     bool passthrough; // use audio passthrough for the current audio type\r
99 \r
100     bool canpass_ac3;\r
101     bool canpass_mp2;\r
102     bool canpass_mp3;\r
103     bool canpass_pcm_mch;\r
104 \r
105 \r
106     int prefered_ac3; //0 stereo PCM, 1 passthrough 2 Multichannel PCM\r
107     int prefered_mp2;\r
108     int prefered_mp3;\r
109 \r
110 \r
111 \r
112     static OMX_ERRORTYPE EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
113         static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);\r
114 \r
115 \r
116 \r
117     void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);\r
118 \r
119    // OMX_HANDLETYPE omx_aud_dec;\r
120         OMX_HANDLETYPE omx_aud_rend;\r
121         OMX_HANDLETYPE omx_clock;\r
122 \r
123         //OMX_U32 omx_codec_input_port;\r
124         //OMX_U32 omx_codec_output_port;\r
125         OMX_U32 omx_rend_input_port;\r
126         OMX_U32 omx_rend_clock_port;\r
127         OMX_U32 omx_clock_output_port;\r
128 \r
129         OMX_TICKS lastreftimeOMX;\r
130     ULLONG lastreftimePTS;\r
131 \r
132 \r
133 \r
134         int AllocateCodecsOMX();\r
135         int DeAllocateCodecsOMX();\r
136 \r
137         int PrepareInputBufsOMX();\r
138         int DestroyInputBufsOMX();\r
139 \r
140         int ChangeAudioPortConfig();\r
141         int ChangeAudioDestination();\r
142         long long correctAudioLatency(long long pts,int addsamples,int srate);\r
143 \r
144         vector<OMX_BUFFERHEADERTYPE*> input_bufs_omx_all;\r
145         list<OMX_BUFFERHEADERTYPE*> input_bufs_omx_free;\r
146         Mutex input_bufs_omx_mutex;\r
147         OMX_BUFFERHEADERTYPE* cur_input_buf_omx;\r
148 \r
149     bool omx_running;\r
150     bool omx_first_frame;\r
151 \r
152         AVCodec *ac3codec_libav;\r
153         AVCodecContext *ac3codec_context_libav;\r
154         AVCodec *mp23codec_libav;\r
155     AVCodecContext *mp23codec_context_libav;\r
156     AVPacket incoming_paket_libav;\r
157     AVFrame *decode_frame_libav;\r
158 \r
159 \r
160          int InitDecoderLibAV();\r
161          void DeinitDecoderLibAV();\r
162 \r
163 };\r
164 \r
165 #endif\r