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
41 int AudioWin::init(UCHAR tstreamType)
43 if (initted) return 0;
48 int AudioWin::shutdown()
50 if (!initted) return 0;
60 int AudioWin::write(char *buf, int len)
62 return 0; //write(fdAudio, buf, len);
65 int AudioWin::setStreamType(UCHAR type)
67 if (!initted) return 0;
71 int AudioWin::setChannel()
73 if (!initted) return 0;
77 int AudioWin::setSource()
79 if (!initted) return 0;
85 if (!initted) return 0;
91 if (!initted) return 0;
99 if (!initted) return 0;
103 int AudioWin::pause()
105 if (!initted) return 0;
109 int AudioWin::unPause()
111 if (!initted) return 0;
115 int AudioWin::reset()
117 if (!initted) return 0;
121 int AudioWin::setVolume(int tvolume)
123 // parameter: 0 for silence, 20 for full
124 if ((tvolume < 0) || (tvolume > 20)) return 0;
130 if (!initted) return 0;
131 ((VideoWin*)Video::getInstance())->SetAudioState(false);
135 int AudioWin::unMute()
137 if (!initted) return 0;
138 ((VideoWin*)Video::getInstance())->SetAudioState(true);
142 UINT AudioWin::DeliverMediaSample(MediaPacket packet,
146 /*First Check, if we have an audio sample*/
147 VideoWin *vw=(VideoWin*)Video::getInstance();
148 IMediaSample* ms=NULL;
149 REFERENCE_TIME reftime1=0;
150 REFERENCE_TIME reftime2=0;
153 if (packet.disconti) {
155 vw->DeliverVideoMediaSample();
160 /*Inspect PES-Header */
161 /* UINT header_length=buffer[(packet.pos_buffer+8)%bufferlength]+8/*is this right*;
163 if (*samplepos==0) {//stripheader
164 headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;
165 *samplepos+=headerstrip;
166 if ( packet.synched ) {
167 vw->DeliverAudioMediaSample();//write out old data
168 if (packet.presentation_time<0) { //Preroll?
169 *samplepos=packet.length;//if we have not processed at least one
170 return packet.length;//synched packet ignore it!
173 reftime1=packet.presentation_time;
177 if (!firstsynched) {//
178 *samplepos=packet.length;//if we have not processed at least one
179 return packet.length;//synched packet ignore it!
187 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
192 ms_pos=ms->GetActualDataLength();
193 ms_length=ms->GetSize();
194 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
195 if ((ms_length-ms_pos)<1) {
196 vw->DeliverAudioMediaSample(); //we are full!
197 if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
202 ms_pos=ms->GetActualDataLength();
203 ms_length=ms->GetSize();
204 haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
206 ms->GetPointer(&ms_buf);
208 if (ms_pos==0) {//will only be changed on first packet
209 if (packet.disconti) {
210 ms->SetDiscontinuity(TRUE);
212 ms->SetDiscontinuity(FALSE);
214 if (packet.synched) {
215 ms->SetSyncPoint(TRUE);
216 ms->SetTime(&reftime1,&reftime2);
217 //ms->SetTime(NULL,NULL);
218 ms->SetMediaTime(NULL, NULL);
220 ms->SetSyncPoint(FALSE);
221 ms->SetTime(NULL,NULL);
222 ms->SetMediaTime(NULL, NULL);
223 ms->SetSyncPoint(TRUE);
228 memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);
229 ms->SetActualDataLength(haveToCopy+ms_pos);
231 *samplepos+=haveToCopy;
233 return haveToCopy+headerstrip;
237 long long AudioWin::SetStartOffset(long long curreftime, bool *rsync){
238 VideoWin *vw=(VideoWin*)Video::getInstance();
239 return vw->SetStartAudioOffset(curreftime,rsync);