Revision 730c29f4 chunker_player/player_core.c

View differences:

chunker_player/player_core.c
13 13
void PacketQueueInit(PacketQueue *q, short int Type)
14 14
{
15 15
#ifdef DEBUG_QUEUE
16
	printf("QUEUE: INIT BEGIN: NPackets=%d Type=%d\n", q->nb_packets, q->queueType);
16
	printf("QUEUE: INIT BEGIN: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
17 17
#endif
18 18
	memset(q,0,sizeof(PacketQueue));
19 19
	q->mutex = SDL_CreateMutex();
......
29 29
	FirstTime = 1;
30 30
	FirstTimeAudio = 1;
31 31
#ifdef DEBUG_QUEUE
32
	printf("QUEUE: INIT END: NPackets=%d Type=%d\n", q->nb_packets, q->queueType);
32
	printf("QUEUE: INIT END: NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
33 33
#endif
34 34
}
35 35

  
......
37 37
{
38 38
	AVPacketList *tmp,*tmp1;
39 39
#ifdef DEBUG_QUEUE
40
	printf("QUEUE: RESET BEGIN: NPackets=%d Type=%d LastExtr=%d\n", q->nb_packets, q->queueType, q->last_frame_extracted);
40
	printf("QUEUE: RESET BEGIN: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
41 41
#endif
42 42
	SDL_LockMutex(q->mutex);
43 43

  
......
70 70
	FirstTime = 1;
71 71
	FirstTimeAudio = 1;
72 72
#ifdef DEBUG_QUEUE
73
	printf("QUEUE: RESET END: NPackets=%d Type=%d LastExtr=%d\n", q->nb_packets, q->queueType, q->last_frame_extracted);
73
	printf("QUEUE: RESET END: NPackets=%d Type=%s LastExtr=%d\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
74 74
#endif
75 75
	SDL_UnlockMutex(q->mutex);
76 76
}
......
82 82

  
83 83
	if(q->nb_packets > queue_filling_threshold*QUEUE_MAX_GROW_FACTOR) {
84 84
#ifdef DEBUG_QUEUE
85
		printf("QUEUE: PUT i have TOO MANY packets %d Type=%d, RESETTING\n", q->nb_packets, q->queueType);
85
		printf("QUEUE: PUT i have TOO MANY packets %d Type=%s, RESETTING\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
86 86
#endif
87 87
		PacketQueueReset(q);
88 88
  }
......
90 90
	//make a copy of the incoming packet
91 91
	if(av_dup_packet(pkt) < 0) {
92 92
#ifdef DEBUG_QUEUE
93
		printf("QUEUE: PUT in Queue cannot duplicate in packet	: NPackets=%d Type=%d\n",q->nb_packets, q->queueType);
93
		printf("QUEUE: PUT in Queue cannot duplicate in packet	: NPackets=%d Type=%s\n",q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
94 94
#endif
95 95
		return -1;
96 96
	}
......
485 485
	SDL_LockMutex(q->mutex);
486 486

  
487 487
#ifdef DEBUG_QUEUE
488
	printf("QUEUE: Get NPackets=%d Type=%d\n", q->nb_packets, q->queueType);
488
	printf("QUEUE: Get NPackets=%d Type=%s\n", q->nb_packets, (q->queueType==AUDIO) ? "AUDIO" : "VIDEO");
489 489
#endif
490 490

  
491 491
	if((q->queueType==AUDIO && QueueFillingMode) || QueueStopped)
......
500 500
		if(pkt1) { //yes we have them!
501 501
			if(pkt1->pkt.size-AudioQueueOffset > dimAudioQ) {
502 502
				//one packet if enough to give us the requested number of bytes by the audio_callback
503
#ifdef DEBUG_QUEUE
503
#ifdef DEBUG_QUEUE_DEEP
504 504
				printf("  AV=1 and Extract from the same packet\n");
505 505
#endif
506 506
				pkt->size = dimAudioQ;
......
511 511
				pkt->flags = 1;
512 512
				pkt->pos = -1;
513 513
				pkt->convergence_duration = -1;
514
#ifdef DEBUG_QUEUE
514
#ifdef DEBUG_QUEUE_DEEP
515 515
				printf("   Adjust timestamps Old = %lld New = %lld\n", pkt1->pkt.dts, (int64_t)(pkt1->pkt.dts + deltaAudioQ + deltaAudioQError));
516 516
#endif
517 517
				int64_t Olddts=pkt1->pkt.dts;
......
519 519
				pkt1->pkt.pts += deltaAudioQ + deltaAudioQError;
520 520
				deltaAudioQError=(float)Olddts + deltaAudioQ + deltaAudioQError - (float)pkt1->pkt.dts;
521 521
				AudioQueueOffset += dimAudioQ;
522
#ifdef DEBUG_QUEUE
522
#ifdef DEBUG_QUEUE_DEEP
523 523
				printf("   deltaAudioQError = %f\n",deltaAudioQError);
524 524
#endif
525 525
				//update overall state of queue
......
540 540
			}
541 541
			else {
542 542
				//we need bytes from two consecutive packets to satisfy the audio_callback
543
#ifdef DEBUG_QUEUE
543
#ifdef DEBUG_QUEUE_DEEP
544 544
				printf("  AV = 1 and Extract from 2 packets\n");
545 545
#endif
546 546
				//check for a valid next packet since we will finish the current packet
547 547
				//and also take some bytes from the next one
548 548
				pkt1->next = SeekAndDecodePacketStartingFrom(pkt1->next, q);
549 549
				if(pkt1->next) {
550
#ifdef DEBUG_QUEUE
550
#ifdef DEBUG_QUEUE_DEEP
551 551
					printf("   we have a next...\n");
552 552
#endif
553 553
					pkt->size = dimAudioQ;
......
559 559
					pkt->convergence_duration = -1;
560 560
					{
561 561
						SizeToCopy=pkt1->pkt.size-AudioQueueOffset;
562
#ifdef DEBUG_QUEUE
562
#ifdef DEBUG_QUEUE_DEEP
563 563
						printf("      SizeToCopy=%d\n",SizeToCopy);
564 564
#endif
565 565
						memcpy(pkt->data, pkt1->pkt.data+AudioQueueOffset, SizeToCopy);
......
585 585
					pkt1->pkt.dts += Offset + deltaAudioQError;
586 586
					pkt1->pkt.pts += Offset + deltaAudioQError;
587 587
					deltaAudioQError = (float)LastDts + (float)Offset + deltaAudioQError - (float)pkt1->pkt.dts;
588
#ifdef DEBUG_QUEUE
588
#ifdef DEBUG_QUEUE_DEEP
589 589
					printf("   Adjust timestamps Old = %lld New = %lld\n", LastDts, pkt1->pkt.dts);
590 590
#endif
591 591
					AudioQueueOffset = dimAudioQ - SizeToCopy;
......
596 596
				else {
597 597
					AudioQueueOffset=0;
598 598
				}
599
#ifdef DEBUG_QUEUE
599
#ifdef DEBUG_QUEUE_DEEP
600 600
				printf("   deltaAudioQError = %f\n",deltaAudioQError);
601 601
#endif
602 602
				//update index of last frame extracted
......
607 607
	else { //somebody requested a video packet, q is the video queue
608 608
		pkt1 = q->first_pkt;
609 609
		if(pkt1) {
610
#ifdef DEBUG_QUEUE
610
#ifdef DEBUG_QUEUE_DEEP
611 611
			printf("  AV not 1\n");
612 612
#endif
613 613
			pkt->size = pkt1->pkt.size;
......
644 644
#endif
645 645
	}
646 646
#ifdef DEBUG_QUEUE
647
	printf("QUEUE: Get LastFrameExtracted = %d\n",q->last_frame_extracted);
648
	printf("QUEUE: Get Tot lost frames = %d\n",q->total_lost_frames);
647
	printf("QUEUE: Get Last %s Frame Extracted = %d\n", (q->queueType==AUDIO) ? "AUDIO" : "VIDEO", q->last_frame_extracted);
649 648
#endif
650 649

  
651 650
	SDL_UnlockMutex(q->mutex);

Also available in: Unified diff