Revision 7245fc85
chunker_player/player_core.c | ||
---|---|---|
129 | 129 |
void PacketQueueInit(PacketQueue *q, short int Type) |
130 | 130 |
{ |
131 | 131 |
#ifdef DEBUG_QUEUE |
132 |
printf("QUEUE: INIT BEGIN: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
132 |
fprintf(stderr,"QUEUE: INIT BEGIN: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
133 | 133 |
#endif |
134 | 134 |
memset(q,0,sizeof(PacketQueue)); |
135 | 135 |
q->mutex = SDL_CreateMutex(); |
... | ... | |
150 | 150 |
PacketQueueClearStats(q); |
151 | 151 |
|
152 | 152 |
#ifdef DEBUG_QUEUE |
153 |
printf("QUEUE: INIT END: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
153 |
fprintf(stderr,"QUEUE: INIT END: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
154 | 154 |
#endif |
155 | 155 |
} |
156 | 156 |
|
... | ... | |
158 | 158 |
{ |
159 | 159 |
AVPacketList *tmp,*tmp1; |
160 | 160 |
#ifdef DEBUG_QUEUE |
161 |
printf("QUEUE: RESET BEGIN: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
161 |
fprintf(stderr,"QUEUE: RESET BEGIN: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
162 | 162 |
#endif |
163 | 163 |
SDL_LockMutex(q->mutex); |
164 | 164 |
|
... | ... | |
169 | 169 |
av_free_packet(&(tmp1->pkt)); |
170 | 170 |
av_free(tmp1); |
171 | 171 |
#ifdef DEBUG_QUEUE |
172 |
printf("F ");
|
|
172 |
fprintf(stderr,"F ");
|
|
173 | 173 |
#endif |
174 | 174 |
q->PacketHistory.LostCount++; |
175 | 175 |
} |
176 | 176 |
#ifdef DEBUG_QUEUE |
177 |
printf("\n");
|
|
177 |
fprintf(stderr,"\n");
|
|
178 | 178 |
#endif |
179 | 179 |
|
180 | 180 |
QueueFillingMode=1; |
... | ... | |
193 | 193 |
//clean up statistics |
194 | 194 |
PacketQueueClearStats(q); |
195 | 195 |
#ifdef DEBUG_QUEUE |
196 |
printf("QUEUE: RESET END: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
196 |
fprintf(stderr,"QUEUE: RESET END: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
197 | 197 |
#endif |
198 | 198 |
SDL_UnlockMutex(q->mutex); |
199 | 199 |
} |
... | ... | |
215 | 215 |
|
216 | 216 |
int ChunkerPlayerCore_PacketQueuePut(PacketQueue *q, AVPacket *pkt) |
217 | 217 |
{ |
218 |
//~ printf("\tSTREAM_INDEX=%d\n", pkt->stream_index);
|
|
218 |
//~ fprintf(stderr,"\tSTREAM_INDEX=%d\n", pkt->stream_index);
|
|
219 | 219 |
short int skip = 0; |
220 | 220 |
AVPacketList *pkt1, *tmp, *prevtmp; |
221 | 221 |
int res = 0; |
222 | 222 |
|
223 | 223 |
if(q->nb_packets > queue_filling_threshold*QUEUE_MAX_GROW_FACTOR) { |
224 | 224 |
#ifdef DEBUG_QUEUE |
225 |
printf("QUEUE: PUT i have TOO MANY packets %d Type=%s, RESETTING\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
225 |
fprintf(stderr,"QUEUE: PUT i have TOO MANY packets %d Type=%s, RESETTING\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
226 | 226 |
#endif |
227 | 227 |
PacketQueueReset(q); |
228 | 228 |
} |
... | ... | |
230 | 230 |
//make a copy of the incoming packet |
231 | 231 |
if(av_dup_packet(pkt) < 0) { |
232 | 232 |
#ifdef DEBUG_QUEUE |
233 |
printf("QUEUE: PUT in Queue cannot duplicate in packet : NPackets=%d Type=%s\n",q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
233 |
fprintf(stderr,"QUEUE: PUT in Queue cannot duplicate in packet : NPackets=%d Type=%s\n",q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
234 | 234 |
#endif |
235 | 235 |
return -1; |
236 | 236 |
} |
... | ... | |
251 | 251 |
&& ((time(NULL) - last_auto_switch) > 10) |
252 | 252 |
) |
253 | 253 |
{ |
254 |
printf("file streaming loop detected => re-tune channel and start grabbing statistics\n");
|
|
254 |
fprintf(stderr,"file streaming loop detected => re-tune channel and start grabbing statistics\n");
|
|
255 | 255 |
last_auto_switch = time(NULL); |
256 | 256 |
SDL_LockMutex(q->mutex); |
257 | 257 |
ReTune(&(Channels[SelectedChannel])); |
... | ... | |
292 | 292 |
//we already have a frame with that index |
293 | 293 |
skip = 1; |
294 | 294 |
#ifdef DEBUG_QUEUE |
295 |
printf("%s QUEUE: PUT: we already have frame with index %d, skipping\n", ((q->queueType == AUDIO) ? "AUDIO" : "VIDEO"), pkt->stream_index);
|
|
295 |
fprintf(stderr,"%s QUEUE: PUT: we already have frame with index %d, skipping\n", ((q->queueType == AUDIO) ? "AUDIO" : "VIDEO"), pkt->stream_index);
|
|
296 | 296 |
#endif |
297 | 297 |
} |
298 | 298 |
else { |
... | ... | |
311 | 311 |
{ |
312 | 312 |
QueueFillingMode=0; |
313 | 313 |
#ifdef DEBUG_QUEUE |
314 |
printf("QUEUE: PUT: FillingMode set to zero\n");
|
|
314 |
fprintf(stderr,"QUEUE: PUT: FillingMode set to zero\n");
|
|
315 | 315 |
#endif |
316 | 316 |
} |
317 | 317 |
//set min |
... | ... | |
324 | 324 |
av_free_packet(&pkt1->pkt); |
325 | 325 |
av_free(pkt1); |
326 | 326 |
#ifdef DEBUG_QUEUE |
327 |
printf("QUEUE: PUT: NOT inserting because index %d <= last extracted %d\n", pkt->stream_index, q->last_frame_extracted);
|
|
327 |
fprintf(stderr,"QUEUE: PUT: NOT inserting because index %d <= last extracted %d\n", pkt->stream_index, q->last_frame_extracted);
|
|
328 | 328 |
#endif |
329 | 329 |
res = 1; |
330 | 330 |
} |
... | ... | |
344 | 344 |
aCodecCtx->channels = audio_channels; |
345 | 345 |
aCodec = avcodec_find_decoder_by_name(audio_codec); |
346 | 346 |
if(!aCodec) { |
347 |
printf("Codec not found!\n");
|
|
347 |
fprintf(stderr,"Codec not found!\n");
|
|
348 | 348 |
return -1; |
349 | 349 |
} |
350 | 350 |
if(avcodec_open(aCodecCtx, aCodec)<0) { |
351 | 351 |
fprintf(stderr, "could not open codec\n"); |
352 | 352 |
return -1; // Could not open codec |
353 | 353 |
} |
354 |
printf("using audio Codecid: %d ",aCodecCtx->codec_id);
|
|
355 |
printf("samplerate: %d ",aCodecCtx->sample_rate);
|
|
356 |
printf("channels: %d\n",aCodecCtx->channels);
|
|
354 |
fprintf(stderr,"using audio Codecid: %d ",aCodecCtx->codec_id);
|
|
355 |
fprintf(stderr,"samplerate: %d ",aCodecCtx->sample_rate);
|
|
356 |
fprintf(stderr,"channels: %d\n",aCodecCtx->channels);
|
|
357 | 357 |
|
358 | 358 |
return 1; |
359 | 359 |
} |
... | ... | |
376 | 376 |
wanted_spec->userdata = aCodecCtx; |
377 | 377 |
|
378 | 378 |
#ifdef DEBUG_AUDIO |
379 |
printf("wanted freq:%d\n",wanted_spec->freq);
|
|
380 |
printf("wanted format:%d\n",wanted_spec->format);
|
|
381 |
printf("wanted channels:%d\n",wanted_spec->channels);
|
|
382 |
printf("wanted silence:%d\n",wanted_spec->silence);
|
|
383 |
printf("wanted samples:%d\n",wanted_spec->samples);
|
|
379 |
fprintf(stderr,"wanted freq:%d\n",wanted_spec->freq);
|
|
380 |
fprintf(stderr,"wanted format:%d\n",wanted_spec->format);
|
|
381 |
fprintf(stderr,"wanted channels:%d\n",wanted_spec->channels);
|
|
382 |
fprintf(stderr,"wanted silence:%d\n",wanted_spec->silence);
|
|
383 |
fprintf(stderr,"wanted samples:%d\n",wanted_spec->samples);
|
|
384 | 384 |
#endif |
385 | 385 |
|
386 | 386 |
if (wanted_spec_old && |
... | ... | |
411 | 411 |
CurrentAudioSilence = wanted_spec->silence; |
412 | 412 |
|
413 | 413 |
#ifdef DEBUG_AUDIO |
414 |
printf("freq:%d\n",wanted_spec->freq);
|
|
415 |
printf("format:%d\n",wanted_spec->format);
|
|
416 |
printf("channels:%d\n",wanted_spec->channels);
|
|
417 |
printf("silence:%d\n",wanted_spec->silence);
|
|
418 |
printf("samples:%d\n",wanted_spec->samples);
|
|
419 |
printf("size:%d\n",wanted_spec->size);
|
|
420 |
printf("deltaAudioQ: %f\n",deltaAudioQ);
|
|
414 |
fprintf(stderr,"freq:%d\n",wanted_spec->freq);
|
|
415 |
fprintf(stderr,"format:%d\n",wanted_spec->format);
|
|
416 |
fprintf(stderr,"channels:%d\n",wanted_spec->channels);
|
|
417 |
fprintf(stderr,"silence:%d\n",wanted_spec->silence);
|
|
418 |
fprintf(stderr,"samples:%d\n",wanted_spec->samples);
|
|
419 |
fprintf(stderr,"size:%d\n",wanted_spec->size);
|
|
420 |
fprintf(stderr,"deltaAudioQ: %f\n",deltaAudioQ);
|
|
421 | 421 |
#endif |
422 | 422 |
|
423 | 423 |
return 1; |
... | ... | |
450 | 450 |
|
451 | 451 |
// Init audio buffers |
452 | 452 |
av_init_packet(&AudioPkt); |
453 |
//printf("AVCODEC_MAX_AUDIO_FRAME_SIZE=%d\n", AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
|
453 |
//fprintf(stderr,"AVCODEC_MAX_AUDIO_FRAME_SIZE=%d\n", AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
|
454 | 454 |
AudioPkt.data=(uint8_t *)malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); |
455 | 455 |
if(!AudioPkt.data) return -1; |
456 | 456 |
|
... | ... | |
516 | 516 |
audio_bufQ = (uint16_t *)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); |
517 | 517 |
if(audio_bufQ) { |
518 | 518 |
#ifdef DEBUG_AUDIO_BUFFER |
519 |
printf("AUDIO_BUFFER: about to decode packet %d, size %d, data %d\n", pkt->stream_index, pkt->size, pkt->data);
|
|
519 |
fprintf(stderr,"AUDIO_BUFFER: about to decode packet %d, size %d, data %d\n", pkt->stream_index, pkt->size, pkt->data);
|
|
520 | 520 |
#endif |
521 | 521 |
//decode the packet data |
522 | 522 |
lenQ = avcodec_decode_audio3(aCodecCtx, (int16_t *)audio_bufQ, &data_sizeQ, pkt); |
... | ... | |
540 | 540 |
} |
541 | 541 |
else { |
542 | 542 |
#ifdef DEBUG_AUDIO_BUFFER |
543 |
printf("AUDIO_BUFFER: cannot alloc space for decoded packet %d\n", pkt->stream_index);
|
|
543 |
fprintf(stderr,"AUDIO_BUFFER: cannot alloc space for decoded packet %d\n", pkt->stream_index);
|
|
544 | 544 |
#endif |
545 | 545 |
} |
546 | 546 |
} |
547 | 547 |
else { |
548 | 548 |
#ifdef DEBUG_AUDIO_BUFFER |
549 |
printf("AUDIO_BUFFER: cannot decode packet %d\n", pkt->stream_index);
|
|
549 |
fprintf(stderr,"AUDIO_BUFFER: cannot decode packet %d\n", pkt->stream_index);
|
|
550 | 550 |
#endif |
551 | 551 |
} |
552 | 552 |
av_free(audio_bufQ); |
553 | 553 |
} |
554 | 554 |
else { |
555 | 555 |
#ifdef DEBUG_AUDIO_BUFFER |
556 |
printf("AUDIO_BUFFER: cannot alloc decode buffer for packet %d\n", pkt->stream_index);
|
|
556 |
fprintf(stderr,"AUDIO_BUFFER: cannot alloc decode buffer for packet %d\n", pkt->stream_index);
|
|
557 | 557 |
#endif |
558 | 558 |
} |
559 | 559 |
return ret; //problems occurred |
... | ... | |
625 | 625 |
SDL_LockMutex(q->mutex); |
626 | 626 |
|
627 | 627 |
#ifdef DEBUG_QUEUE |
628 |
printf("QUEUE: Get NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
628 |
fprintf(stderr,"QUEUE: Get NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
|
|
629 | 629 |
#endif |
630 | 630 |
|
631 | 631 |
if((q->queueType==AUDIO && QueueFillingMode) || QueueStopped) |
... | ... | |
665 | 665 |
} |
666 | 666 |
|
667 | 667 |
#ifdef DEBUG_AUDIO_BUFFER |
668 |
printf("2: idx %d \taqo %d \tstc %d \taqe %f \tpsz %d\n", pkt1->pkt.stream_index, AudioQueueOffset, SizeToCopy, deltaAudioQError, pkt1->pkt.size);
|
|
668 |
fprintf(stderr,"2: idx %d \taqo %d \tstc %d \taqe %f \tpsz %d\n", pkt1->pkt.stream_index, AudioQueueOffset, SizeToCopy, deltaAudioQError, pkt1->pkt.size);
|
|
669 | 669 |
#endif |
670 | 670 |
|
671 | 671 |
//update index of last frame extracted |
... | ... | |
679 | 679 |
pkt1 = q->first_pkt; |
680 | 680 |
if(pkt1) { |
681 | 681 |
#ifdef DEBUG_QUEUE_DEEP |
682 |
printf(" AV not 1\n");
|
|
682 |
fprintf(stderr," AV not 1\n");
|
|
683 | 683 |
#endif |
684 | 684 |
pkt->size = pkt1->pkt.size; |
685 | 685 |
pkt->dts = pkt1->pkt.dts; |
... | ... | |
706 | 706 |
} |
707 | 707 |
#ifdef DEBUG_QUEUE |
708 | 708 |
else { |
709 |
printf(" VIDEO pk1 NULL!!!!\n");
|
|
709 |
fprintf(stderr," VIDEO pk1 NULL!!!!\n");
|
|
710 | 710 |
} |
711 | 711 |
#endif |
712 | 712 |
} |
... | ... | |
714 | 714 |
if(q->nb_packets==0 && q->queueType==AUDIO) { |
715 | 715 |
QueueFillingMode=1; |
716 | 716 |
#ifdef DEBUG_QUEUE |
717 |
printf("QUEUE: Get FillingMode ON\n");
|
|
717 |
fprintf(stderr,"QUEUE: Get FillingMode ON\n");
|
|
718 | 718 |
#endif |
719 | 719 |
} |
720 | 720 |
#ifdef DEBUG_QUEUE |
721 |
printf("QUEUE: Get Last %s Frame Extracted = %d\n", (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
721 |
fprintf(stderr,"QUEUE: Get Last %s Frame Extracted = %d\n", (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
|
|
722 | 722 |
#endif |
723 | 723 |
|
724 | 724 |
SDL_UnlockMutex(q->mutex); |
... | ... | |
755 | 755 |
FirstTime = 0; |
756 | 756 |
//SDL_UnlockMutex(timing_mutex); |
757 | 757 |
#ifdef DEBUG_AUDIO |
758 |
printf("AUDIO: audio_decode_frame - DeltaTimeAudio=%lld\n",DeltaTime);
|
|
758 |
fprintf(stderr,"AUDIO: audio_decode_frame - DeltaTimeAudio=%lld\n",DeltaTime);
|
|
759 | 759 |
#endif |
760 | 760 |
} |
761 | 761 |
} |
... | ... | |
763 | 763 |
#ifdef DEBUG_AUDIO |
764 | 764 |
if(audioq.first_pkt) |
765 | 765 |
{ |
766 |
printf("AUDIO: audio_decode_frame - Syncro params: Delta:%lld Now:%lld pts=%lld pts+Delta=%lld ",(long long)DeltaTime,Now,(long long)audioq.first_pkt->pkt.pts,(long long)audioq.first_pkt->pkt.pts+DeltaTime);
|
|
767 |
printf("AUDIO: QueueLen=%d ",(int)audioq.nb_packets);
|
|
768 |
printf("AUDIO: QueueSize=%d\n",(int)audioq.size);
|
|
766 |
fprintf(stderr,"AUDIO: audio_decode_frame - Syncro params: Delta:%lld Now:%lld pts=%lld pts+Delta=%lld ",(long long)DeltaTime,Now,(long long)audioq.first_pkt->pkt.pts,(long long)audioq.first_pkt->pkt.pts+DeltaTime);
|
|
767 |
fprintf(stderr,"AUDIO: QueueLen=%d ",(int)audioq.nb_packets);
|
|
768 |
fprintf(stderr,"AUDIO: QueueSize=%d\n",(int)audioq.size);
|
|
769 | 769 |
} |
770 | 770 |
else |
771 |
printf("AUDIO: audio_decode_frame - Empty queue\n");
|
|
771 |
fprintf(stderr,"AUDIO: audio_decode_frame - Empty queue\n");
|
|
772 | 772 |
#endif |
773 | 773 |
|
774 | 774 |
if(audioq.nb_packets>0) |
... | ... | |
789 | 789 |
{ |
790 | 790 |
SkipAudio = 0; |
791 | 791 |
#ifdef DEBUG_AUDIO |
792 |
printf("AUDIO: skipaudio: queue size=%d\n",audioq.size);
|
|
792 |
fprintf(stderr,"AUDIO: skipaudio: queue size=%d\n",audioq.size);
|
|
793 | 793 |
#endif |
794 | 794 |
if(PacketQueueGet(&audioq,&AudioPkt,1, &compressed_size) < 0) { |
795 | 795 |
return -1; |
... | ... | |
820 | 820 |
memcpy(audio_buf,AudioPkt.data,AudioPkt.size); |
821 | 821 |
audio_pkt_size = AudioPkt.size; |
822 | 822 |
#ifdef DEBUG_AUDIO |
823 |
printf("AUDIO: Decode audio\n");
|
|
823 |
fprintf(stderr,"AUDIO: Decode audio\n");
|
|
824 | 824 |
#endif |
825 | 825 |
|
826 | 826 |
ChunkerPlayerStats_UpdateAudioPlayedHistory(&(audioq.PacketHistory), AudioPkt.stream_index, compressed_size); |
... | ... | |
957 | 957 |
} |
958 | 958 |
pFrame=avcodec_alloc_frame(); |
959 | 959 |
if(pFrame==NULL) { |
960 |
printf("Memory error!!!\n");
|
|
960 |
fprintf(stderr,"Memory error!!!\n");
|
|
961 | 961 |
return -1; |
962 | 962 |
} |
963 | 963 |
|
964 | 964 |
#ifdef DEBUG_VIDEO |
965 |
printf("VIDEO: video_callback entering main cycle\n");
|
|
965 |
fprintf(stderr,"VIDEO: video_callback entering main cycle\n");
|
|
966 | 966 |
#endif |
967 | 967 |
|
968 | 968 |
while(AVPlaying && !quit) { |
... | ... | |
989 | 989 |
//SDL_UnlockMutex(timing_mutex); |
990 | 990 |
} |
991 | 991 |
#ifdef DEBUG_VIDEO |
992 |
printf("VIDEO: VideoCallback - DeltaTimeAudio=%lld\n",DeltaTime);
|
|
992 |
fprintf(stderr,"VIDEO: VideoCallback - DeltaTimeAudio=%lld\n",DeltaTime);
|
|
993 | 993 |
#endif |
994 | 994 |
} |
995 | 995 |
|
996 | 996 |
#ifdef DEBUG_VIDEO |
997 | 997 |
if(videoq.first_pkt) |
998 | 998 |
{ |
999 |
printf("VIDEO: VideoCallback - Syncro params: Delta:%lld Now:%lld pts=%lld pts+Delta=%lld ",(long long)DeltaTime,Now,(long long)videoq.first_pkt->pkt.pts,(long long)videoq.first_pkt->pkt.pts+DeltaTime);
|
|
1000 |
printf("VIDEO: Index=%d ", (int)videoq.first_pkt->pkt.stream_index);
|
|
1001 |
printf("VIDEO: QueueLen=%d ", (int)videoq.nb_packets);
|
|
1002 |
printf("VIDEO: QueueSize=%d\n", (int)videoq.size);
|
|
999 |
fprintf(stderr,"VIDEO: VideoCallback - Syncro params: Delta:%lld Now:%lld pts=%lld pts+Delta=%lld ",(long long)DeltaTime,Now,(long long)videoq.first_pkt->pkt.pts,(long long)videoq.first_pkt->pkt.pts+DeltaTime);
|
|
1000 |
fprintf(stderr,"VIDEO: Index=%d ", (int)videoq.first_pkt->pkt.stream_index);
|
|
1001 |
fprintf(stderr,"VIDEO: QueueLen=%d ", (int)videoq.nb_packets);
|
|
1002 |
fprintf(stderr,"VIDEO: QueueSize=%d\n", (int)videoq.size);
|
|
1003 | 1003 |
} |
1004 | 1004 |
else |
1005 |
printf("VIDEO: VideoCallback - Empty queue\n");
|
|
1005 |
fprintf(stderr,"VIDEO: VideoCallback - Empty queue\n");
|
|
1006 | 1006 |
#endif |
1007 | 1007 |
|
1008 | 1008 |
#ifdef DEBUG_VIDEO |
1009 |
printf("VIDEO: skipvideo:%d decodevideo:%d\n",SkipVideo,DecodeVideo);
|
|
1009 |
fprintf(stderr,"VIDEO: skipvideo:%d decodevideo:%d\n",SkipVideo,DecodeVideo);
|
|
1010 | 1010 |
#endif |
1011 | 1011 |
// ChunkerPlayerStats_UpdateVideoSkipHistory(&(videoq.PacketHistory), VideoPkt.stream_index, pFrame->pict_type, VideoPkt.size, pFrame); |
1012 | 1012 |
|
... | ... | |
1040 | 1040 |
long long earlier = target_pts - Now; |
1041 | 1041 |
|
1042 | 1042 |
#ifdef DEBUG_VIDEO |
1043 |
printf("VIDEO: FrameFinished\n");
|
|
1043 |
fprintf(stderr,"VIDEO: FrameFinished\n");
|
|
1044 | 1044 |
#endif |
1045 | 1045 |
decoded_vframes++; |
1046 | 1046 |
|
... | ... | |
1128 | 1128 |
av_free(pFrame); |
1129 | 1129 |
//fclose(frecon); |
1130 | 1130 |
#ifdef DEBUG_VIDEO |
1131 |
printf("VIDEO: video callback end\n");
|
|
1131 |
fprintf(stderr,"VIDEO: video callback end\n");
|
|
1132 | 1132 |
#endif |
1133 | 1133 |
|
1134 | 1134 |
#ifdef SAVE_YUV |
... | ... | |
1239 | 1239 |
* Doesn't seem to be necessary -> disabled |
1240 | 1240 |
*/ |
1241 | 1241 |
//int delay = 2 * 1000 * CurrentAudioSamples / CurrentAudioFreq; |
1242 |
// printf("SDL_Delay(%d)\n", delay*10);
|
|
1242 |
// fprintf(stderr,"SDL_Delay(%d)\n", delay*10);
|
|
1243 | 1243 |
//SDL_Delay(delay*10); |
1244 | 1244 |
} |
1245 | 1245 |
|
... | ... | |
1276 | 1276 |
void ChunkerPlayerCore_ResetAVQueues() |
1277 | 1277 |
{ |
1278 | 1278 |
#ifdef DEBUG_QUEUE |
1279 |
printf("QUEUE: MAIN SHOULD RESET\n");
|
|
1279 |
fprintf(stderr,"QUEUE: MAIN SHOULD RESET\n");
|
|
1280 | 1280 |
#endif |
1281 | 1281 |
PacketQueueReset(&audioq); |
1282 | 1282 |
PacketQueueReset(&videoq); |
... | ... | |
1307 | 1307 |
else |
1308 | 1308 |
random_threshold = ScheduledChunkLosses[CurrChunkLossIndex].Value; |
1309 | 1309 |
|
1310 |
printf("new ScheduledChunkLoss, time: %d, value: %d\n", (int)ScheduledChunkLosses[CurrChunkLossIndex].Time, random_threshold);
|
|
1310 |
fprintf(stderr,"new ScheduledChunkLoss, time: %d, value: %d\n", (int)ScheduledChunkLosses[CurrChunkLossIndex].Time, random_threshold);
|
|
1311 | 1311 |
} |
1312 | 1312 |
|
1313 | 1313 |
if(clp_frames > 0) |
... | ... | |
1347 | 1347 |
|
1348 | 1348 |
audio_bufQ = (uint16_t *)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); |
1349 | 1349 |
if(!audio_bufQ) { |
1350 |
printf("Memory error in audio_bufQ!\n");
|
|
1350 |
fprintf(stderr,"Memory error in audio_bufQ!\n");
|
|
1351 | 1351 |
return PLAYER_FAIL_RETURN; |
1352 | 1352 |
} |
1353 | 1353 |
|
1354 | 1354 |
gchunk = (Chunk *)malloc(sizeof(Chunk)); |
1355 | 1355 |
if(!gchunk) { |
1356 |
printf("Memory error in gchunk!\n");
|
|
1356 |
fprintf(stderr,"Memory error in gchunk!\n");
|
|
1357 | 1357 |
av_free(audio_bufQ); |
1358 | 1358 |
return PLAYER_FAIL_RETURN; |
1359 | 1359 |
} |
... | ... | |
1369 | 1369 |
last_chunk_id = gchunk->id; |
1370 | 1370 |
|
1371 | 1371 |
#ifdef DEBUG_CHUNKER |
1372 |
printf("CHUNKER: enqueueBlock: id %d decoded_size %d target size %d - out_of_order %d\n", gchunk->id, decoded_size, GRAPES_ENCODED_CHUNK_HEADER_SIZE + ExternalChunk_header_size + gchunk->size, chunks_out_of_order);
|
|
1372 |
fprintf(stderr,"CHUNKER: enqueueBlock: id %d decoded_size %d target size %d - out_of_order %d\n", gchunk->id, decoded_size, GRAPES_ENCODED_CHUNK_HEADER_SIZE + gchunk->size, chunks_out_of_order);
|
|
1373 | 1373 |
#endif |
1374 | 1374 |
if(decoded_size < 0) { |
1375 | 1375 |
//HINT here i should differentiate between various return values of the decode |
1376 | 1376 |
//in order to free what has been allocated there |
1377 |
printf("chunk probably corrupted!\n");
|
|
1377 |
fprintf(stderr,"chunk probably corrupted!\n");
|
|
1378 | 1378 |
av_free(audio_bufQ); |
1379 | 1379 |
free(gchunk); |
1380 | 1380 |
return PLAYER_FAIL_RETURN; |
... | ... | |
1382 | 1382 |
|
1383 | 1383 |
frame = (Frame *)malloc(sizeof(Frame)); |
1384 | 1384 |
if(!frame) { |
1385 |
printf("Memory error in Frame!\n");
|
|
1385 |
fprintf(stderr,"Memory error in Frame!\n");
|
|
1386 | 1386 |
if(gchunk) { |
1387 | 1387 |
if(gchunk->attributes) { |
1388 | 1388 |
free(gchunk->attributes); |
... | ... | |
1427 | 1427 |
} |
1428 | 1428 |
|
1429 | 1429 |
#ifdef DEBUG_SOURCE |
1430 |
printf("SOURCE: Insert video in queue pts=%lld %d %d sindex:%d\n",packet.pts,(int)frame->timestamp.tv_sec,(int)frame->timestamp.tv_usec,packet.stream_index);
|
|
1430 |
fprintf(stderr,"SOURCE: Insert video in queue pts=%lld %d %d sindex:%d\n",packet.pts,(int)frame->timestamp.tv_sec,(int)frame->timestamp.tv_usec,packet.stream_index);
|
|
1431 | 1431 |
#endif |
1432 | 1432 |
} |
1433 | 1433 |
else if(frame->type == 5) { // audio frame |
... | ... | |
1454 | 1454 |
} |
1455 | 1455 |
|
1456 | 1456 |
#ifdef DEBUG_SOURCE |
1457 |
printf("SOURCE: Insert audio in queue pts=%lld sindex:%d\n", packetaudio.pts, packetaudio.stream_index);
|
|
1457 |
fprintf(stderr,"SOURCE: Insert audio in queue pts=%lld sindex:%d\n", packetaudio.pts, packetaudio.stream_index);
|
|
1458 | 1458 |
#endif |
1459 | 1459 |
} |
1460 | 1460 |
else { |
1461 |
printf("SOURCE: Unknown frame type %d. Size %d\n", frame->type, frame->size);
|
|
1461 |
fprintf(stderr,"SOURCE: Unknown frame type %d. Size %d\n", frame->type, frame->size);
|
|
1462 | 1462 |
} |
1463 | 1463 |
if(frame->size > 0) |
1464 | 1464 |
j = j - sizeFrameHeader - frame->size; |
1465 | 1465 |
else { |
1466 |
printf("SOURCE: Corrupt frames (size %d) in chunk. Skipping it...\n", frame->size);
|
|
1466 |
fprintf(stderr,"SOURCE: Corrupt frames (size %d) in chunk. Skipping it...\n", frame->size);
|
|
1467 | 1467 |
j = -1; |
1468 | 1468 |
} |
1469 | 1469 |
} |
... | ... | |
1488 | 1488 |
{ |
1489 | 1489 |
// if(!MainScreen && !SilentMode) |
1490 | 1490 |
// { |
1491 |
// printf("Cannot find main screen, exiting...\n");
|
|
1491 |
// fprintf(stderr,"Cannot find main screen, exiting...\n");
|
|
1492 | 1492 |
// exit(1); |
1493 | 1493 |
// } |
1494 | 1494 |
|
... | ... | |
1507 | 1507 |
} |
1508 | 1508 |
|
1509 | 1509 |
// create video overlay for display of video frames |
1510 |
// printf("SDL_CreateYUVOverlay(%d, %d, SDL_YV12_OVERLAY, MainScreen)\n", width, height);
|
|
1510 |
// fprintf(stderr,"SDL_CreateYUVOverlay(%d, %d, SDL_YV12_OVERLAY, MainScreen)\n", width, height);
|
|
1511 | 1511 |
YUVOverlay = SDL_CreateYUVOverlay(width, height, SDL_YV12_OVERLAY, MainScreen); |
1512 | 1512 |
if ( YUVOverlay == NULL ) |
1513 | 1513 |
{ |
... | ... | |
1563 | 1563 |
video_avg_bitrate = (int)( ((double)videoq.cumulative_bitrate) / ((double)videoq.cumulative_samples) ); |
1564 | 1564 |
|
1565 | 1565 |
#ifdef DEBUG_STATS |
1566 |
printf("VIDEO: %d Kbit/sec; ", video_statistics.Bitrate);
|
|
1567 |
printf("AUDIO: %d Kbit/sec\n", audio_statistics.Bitrate);
|
|
1566 |
fprintf(stderr,"VIDEO: %d Kbit/sec; ", video_statistics.Bitrate);
|
|
1567 |
fprintf(stderr,"AUDIO: %d Kbit/sec\n", audio_statistics.Bitrate);
|
|
1568 | 1568 |
#endif |
1569 | 1569 |
|
1570 | 1570 |
// QUEUE DENSITY EVALUATION |
... | ... | |
1628 | 1628 |
LastTimeRepoPublish=r.timestamp; |
1629 | 1629 |
if(repPublish(repoclient,NULL,NULL,&r)!=NULL) { |
1630 | 1630 |
#ifdef DEBUG_PSNR |
1631 |
printf("PSNR publish: %s %e %s\n",r.originator,qoe,r.channel);
|
|
1631 |
fprintf(stderr,"PSNR publish: %s %e %s\n",r.originator,qoe,r.channel);
|
|
1632 | 1632 |
#endif |
1633 | 1633 |
} |
1634 | 1634 |
} |
... | ... | |
1668 | 1668 |
//double input_bitrate = a*((double)video_statistics.Bitrate) + b*((double)video_avg_bitrate); |
1669 | 1669 |
ChunkerPlayerStats_GetMeanVideoQuality(&(videoq.PacketHistory), input_bitrate, &qoe); |
1670 | 1670 |
#ifdef DEBUG_STATS |
1671 |
printf("rate %d avg %d wghtd %d cum_samp %d PSNR %f\n", video_statistics.Bitrate, video_avg_bitrate, (int)input_bitrate, videoq.cumulative_samples, (float)qoe);
|
|
1671 |
fprintf(stderr,"rate %d avg %d wghtd %d cum_samp %d PSNR %f\n", video_statistics.Bitrate, video_avg_bitrate, (int)input_bitrate, videoq.cumulative_samples, (float)qoe);
|
|
1672 | 1672 |
#endif |
1673 | 1673 |
last_qoe_evaluation = now; |
1674 | 1674 |
} |
Also available in: Unified diff