2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP 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 of the License, or
9 (at your option) any later version.
11 VOMP 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 VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43 int AudioWin::init(UCHAR tstreamType)
45 if (initted) return 0;
50 int AudioWin::shutdown()
52 if (!initted) return 0;
57 int AudioWin::write(char *buf, int len)
59 return 0; //write(fdAudio, buf, len);
62 int AudioWin::setStreamType(UCHAR type)
64 if (!initted) return 0;
68 int AudioWin::setChannel()
70 if (!initted) return 0;
74 int AudioWin::setSource()
76 if (!initted) return 0;
82 if (!initted) return 0;
88 if (!initted) return 0;
96 if (!initted) return 0;
100 int AudioWin::pause()
102 if (!initted) return 0;
106 int AudioWin::unPause()
108 if (!initted) return 0;
112 int AudioWin::reset()
114 if (!initted) return 0;
118 int AudioWin::setVolume(int tvolume)
120 // parameter: 0 for silence, 20 for full
121 if ((tvolume < 0) || (tvolume > 20)) return 0;
127 if (!initted) return 0;
128 ((VideoWin*)Video::getInstance())->SetAudioState(false);
132 int AudioWin::unMute()
134 if (!initted) return 0;
135 ((VideoWin*)Video::getInstance())->SetAudioState(true);
139 UINT AudioWin::DeliverMediaSample(MediaPacket packet,
143 /*First Check, if we have an audio sample*/
144 VideoWin *vw=(VideoWin*)Video::getInstance();
145 IMediaSample* ms=NULL;
146 REFERENCE_TIME reftime1=0;
147 REFERENCE_TIME reftime2=0;
150 if (packet.disconti) {
152 vw->DeliverVideoMediaSample();
157 /*Inspect PES-Header */
158 /* UINT header_length=buffer[(packet.pos_buffer+8)%bufferlength]+8/*is this right*;
160 if (*samplepos==0) {//stripheader
161 headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;
162 *samplepos+=headerstrip;
163 if ( packet.synched ) {
164 vw->DeliverAudioMediaSample();//write out old data
165 /* if (packet.presentation_time<0) { //Preroll?
166 *samplepos=packet.length;//if we have not processed at least one
167 return packet.length;//synched packet ignore it!
170 reftime1=packet.presentation_time;
174 if (!firstsynched) {//
175 *samplepos=packet.length;//if we have not processed at least one
176 return packet.length;//synched packet ignore it!
184 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
189 ms_pos=ms->GetActualDataLength();
190 ms_length=ms->GetSize();
191 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
192 if ((ms_length-ms_pos)<1) {
193 vw->DeliverAudioMediaSample(); //we are full!
194 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
199 ms_pos=ms->GetActualDataLength();
200 ms_length=ms->GetSize();
201 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
203 ms->GetPointer(&ms_buf);
205 if (ms_pos==0) {//will only be changed on first packet
206 if (packet.disconti) {
207 ms->SetDiscontinuity(TRUE);
209 ms->SetDiscontinuity(FALSE);
211 if (packet.synched) {
212 ms->SetSyncPoint(TRUE);
213 ms->SetTime(&reftime1,&reftime2);
215 //ms->SetTime(NULL,NULL);
216 ms->SetMediaTime(NULL, NULL);
217 if (reftime1<0) ms->SetPreroll(TRUE);
218 else ms->SetPreroll(FALSE);
220 ms->SetSyncPoint(FALSE);
221 ms->SetTime(NULL,NULL);
222 ms->SetMediaTime(NULL, NULL);
223 ms->SetPreroll(FALSE);
224 MessageBox(0,"here I'm","Hallo",0);
225 // ms->SetSyncPoint(TRUE);
230 memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);
231 ms->SetActualDataLength(haveToCopy+ms_pos);
233 *samplepos+=haveToCopy;
235 return haveToCopy+headerstrip;
239 long long AudioWin::SetStartOffset(long long curreftime, bool *rsync){
240 VideoWin *vw=(VideoWin*)Video::getInstance();
241 return vw->SetStartAudioOffset(curreftime,rsync);
244 void AudioWin::ResetTimeOffsets() {
245 VideoWin *vw=(VideoWin*)Video::getInstance();
246 return vw->ResetTimeOffsets();