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;
62 int AudioWin::write(char *buf, int len)
64 return 0; //write(fdAudio, buf, len);
67 int AudioWin::setStreamType(UCHAR type)
69 if (!initted) return 0;
73 int AudioWin::setChannel()
75 if (!initted) return 0;
79 int AudioWin::setSource()
81 if (!initted) return 0;
87 if (!initted) return 0;
93 if (!initted) return 0;
101 if (!initted) return 0;
105 int AudioWin::pause()
107 if (!initted) return 0;
111 int AudioWin::unPause()
113 if (!initted) return 0;
117 int AudioWin::reset()
119 if (!initted) return 0;
123 int AudioWin::setVolume(int tvolume)
125 // parameter: 0 for silence, 20 for full
126 if ((tvolume < 0) || (tvolume > 20)) return 0;
132 if (!initted) return 0;
133 ((VideoWin*)Video::getInstance())->SetAudioState(false);
137 int AudioWin::unMute()
139 if (!initted) return 0;
140 ((VideoWin*)Video::getInstance())->SetAudioState(true);
144 UINT AudioWin::DeliverMediaSample(MediaPacket packet,
148 /*First Check, if we have an audio sample*/
149 VideoWin *vw=(VideoWin*)Video::getInstance();
150 IMediaSample* ms=NULL;
151 REFERENCE_TIME reftime1=0;
152 REFERENCE_TIME reftime2=0;
155 if (packet.disconti) {
157 vw->DeliverVideoMediaSample();
162 /*Inspect PES-Header */
163 /* UINT header_length=buffer[(packet.pos_buffer+8)%bufferlength]+8/*is this right*;
165 if (*samplepos==0) {//stripheader
166 headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;
167 *samplepos+=headerstrip;
168 if ( packet.synched ) {
169 vw->DeliverAudioMediaSample();//write out old data
170 /* if (packet.presentation_time<0) { //Preroll?
171 *samplepos=packet.length;//if we have not processed at least one
172 return packet.length;//synched packet ignore it!
175 reftime1=packet.presentation_time;
179 if (!firstsynched) {//
180 *samplepos=packet.length;//if we have not processed at least one
181 return packet.length;//synched packet ignore it!
189 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
194 ms_pos=ms->GetActualDataLength();
195 ms_length=ms->GetSize();
196 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
197 if ((ms_length-ms_pos)<1) {
198 vw->DeliverAudioMediaSample(); //we are full!
199 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
204 ms_pos=ms->GetActualDataLength();
205 ms_length=ms->GetSize();
206 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
208 ms->GetPointer(&ms_buf);
210 if (ms_pos==0) {//will only be changed on first packet
211 if (packet.disconti) {
212 ms->SetDiscontinuity(TRUE);
214 ms->SetDiscontinuity(FALSE);
216 if (packet.synched) {
217 ms->SetSyncPoint(TRUE);
218 ms->SetTime(&reftime1,&reftime2);
220 //ms->SetTime(NULL,NULL);
221 ms->SetMediaTime(NULL, NULL);
222 if (reftime1<0) ms->SetPreroll(TRUE);
223 else ms->SetPreroll(FALSE);
225 ms->SetSyncPoint(FALSE);
226 ms->SetTime(NULL,NULL);
227 ms->SetMediaTime(NULL, NULL);
228 ms->SetPreroll(FALSE);
229 MessageBox(0,"here I'm","Hallo",0);
230 // ms->SetSyncPoint(TRUE);
235 memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);
236 ms->SetActualDataLength(haveToCopy+ms_pos);
238 *samplepos+=haveToCopy;
240 return haveToCopy+headerstrip;
244 long long AudioWin::SetStartOffset(long long curreftime, bool *rsync){
245 VideoWin *vw=(VideoWin*)Video::getInstance();
246 return vw->SetStartAudioOffset(curreftime,rsync);
249 void AudioWin::ResetTimeOffsets() {
250 VideoWin *vw=(VideoWin*)Video::getInstance();
251 return vw->ResetTimeOffsets();