Revision bd209760

View differences:

chunk_puller_nh.c
9 9
#define MY_IP "127.0.0.1"
10 10
#define MY_PORT 8888
11 11

  
12
#define BUFFSIZE 512000
12
#define BUFFSIZE 1024000
13 13

  
14 14
static struct nodeID *myID;
15 15

  
......
31 31
    struct nodeID *remote;
32 32
    static uint8_t buff[BUFFSIZE];
33 33

  
34
fprintf(stderr,"calling recv_from_peer\n");
34
//fprintf(stderr,"calling recv_from_peer\n");
35 35
    len = recv_from_peer(myID, &remote, buff, BUFFSIZE);
36
fprintf(stderr,"recv_from_peer returned\n");
36
//fprintf(stderr,"recv_from_peer returned\n");
37 37
    if (len < 0) {
38 38
      fprintf(stderr,"Error receiving message. Maybe larger than %d bytes\n", BUFFSIZE);
39 39
      nodeid_free(remote);
40 40
      continue;
41 41
    }
42 42
    //dprintf("Received message (%c) from %s\n", buff[0], node_addr(remote));
43
fprintf(stderr,"msglen: %d\n", len);
44
fprintf(stderr,"msgtype: %x\n", buff[0]);
43
//fprintf(stderr,"msglen: %d\n", len);
44
//fprintf(stderr,"msgtype: %x\n", buff[0]);
45 45
    switch (buff[0] /* Message Type */) {
46 46
      case MSG_TYPE_CHUNK:
47
if(len>510000) {
48
fprintf(stderr,"warning: big message %d\n", len);
49
}
47 50
        enqueueBlock(buff+1, len-1);
48 51
        break;
49 52
      default:
chunk_pusher.c
4 4
#include "external_chunk_transcoding.h"
5 5
#include "chunker_streamer.h"
6 6

  
7
#define DEBUG_PUSHER
7
//#define DEBUG_PUSHER
8 8

  
9 9

  
10 10
int pushChunkHttp(ExternalChunk *echunk, char *url);
......
20 20
	int tus3e1 = 0.0;
21 21
	int ret = STREAMER_FAIL_RETURN;
22 22
	
23
	attr_size = 5*sizeof(int) + 2*sizeof(time_t) + 2*sizeof(suseconds_t) + 1*sizeof(double);
23
	attr_size = 5*sizeof(int32_t) + 2*sizeof(time_t) + 2*sizeof(suseconds_t) + 1*sizeof(double);
24 24

  
25 25
	/* first pack the chunk info that we get from the streamer into an "attributes" block of a regular GRAPES chunk */
26 26
	if(	(grapes_chunk_attributes_block = packExternalChunkToAttributes(echunk, attr_size)) != NULL ) {
chunker.conf
1 1
#can be frames or size
2 2
strategyType = "frames"
3 3

  
4
strategyValue = 5
4
strategyValue = 50
5 5

  
6 6
#can be sequence or starttime
7
chunkID = "sequence"
7
chunkID = "starttime"
8 8

  
9 9
outsideWorldUrl = "http://localhost:5557/externalplayer"
chunker_player.c
37 37

  
38 38
#define SDL_AUDIO_BUFFER_SIZE 1024
39 39

  
40
#define QUEUE_FILLING_THRESHOLD 500
40
#define QUEUE_FILLING_THRESHOLD 200
41 41
#define MAX_TOLLERANCE 40
42 42
#define AUDIO	1
43 43
#define VIDEO	2
44 44

  
45
#define DEBUG_AUDIO
46
#define DEBUG_VIDEO
47
#define DEBUG_QUEUE
48
#define DEBUG_SOURCE
49
#define DEBUG_ENQUEUE
50
#define DEBUG_STATS
51
#define DEBUG_AUDIO_BUFFER
52
#define DEBUG_ENQUEUE
45
//#define DEBUG_AUDIO
46
//#define DEBUG_VIDEO
47
//#define DEBUG_QUEUE
48
//#define DEBUG_SOURCE
49
//#define DEBUG_ENQUEUE
50
//#define DEBUG_STATS
51
//#define DEBUG_AUDIO_BUFFER
52
//#define DEBUG_ENQUEUE
53 53

  
54 54
short int QueueFillingMode=1;
55 55
short int QueueStopped=0;
......
102 102
	//q->cond = SDL_CreateCond();
103 103
	QueueFillingMode=1;
104 104
	q->queueType=Type;
105
	q->last_frame_extracted = 0;
105
	q->last_frame_extracted = 3;
106 106
	q->total_lost_frames = 0;
107 107
	q->first_pkt= NULL;
108 108
	//q->last_pkt = NULL;
......
137 137
#endif
138 138

  
139 139
	QueueFillingMode=1;
140
	q->last_frame_extracted = 0;
140
	q->last_frame_extracted = 3;
141 141
	q->total_lost_frames = 0;
142 142
	q->first_pkt= NULL;
143 143
	//q->last_pkt = NULL;
......
1136 1136
	int data_sizeQ;
1137 1137
	int lenQ;
1138 1138
	int sizeFrame = 0;
1139
	sizeFrame = 3*sizeof(int)+sizeof(struct timeval);
1139
	sizeFrame = 3*sizeof(int32_t)+sizeof(struct timeval);
1140 1140
#ifdef DEBUG_ENQUEUE
1141 1141
printf("O\n");
1142 1142
#endif
......
1200 1200
	j=echunk->payload_len;
1201 1201
	while(j>0 && !quit) {
1202 1202
		//usleep(30000);
1203
		frame->number = *((int *)tempdata);
1204
		tempdata+=sizeof(int);
1203
		frame->number = *((int32_t *)tempdata);
1204
		tempdata+=sizeof(int32_t);
1205 1205
		frame->timestamp = *((struct timeval *)tempdata);
1206 1206
		tempdata += sizeof(struct timeval);
1207
		frame->size = *((int *)tempdata);
1208
		tempdata+=sizeof(int);
1209
		frame->type = *((int *)tempdata);
1210
		tempdata+=sizeof(int);
1207
		frame->size = *((int32_t *)tempdata);
1208
		tempdata+=sizeof(int32_t);
1209
		frame->type = *((int32_t *)tempdata);
1210
		tempdata+=sizeof(int32_t);
1211 1211

  
1212 1212
		buffer = tempdata; // here coded frame information
1213 1213
		tempdata+=frame->size;
chunker_streamer.c
335 335
		fprintf(stderr, "INIT: Memory error alloc Frame!!!\n");
336 336
		return -1;
337 337
	}
338
	sizeFrame = 3*sizeof(int)+sizeof(struct timeval);
338
	sizeFrame = 3*sizeof(int32_t)+sizeof(struct timeval);
339 339
	chunk = (ExternalChunk *)malloc(sizeof(ExternalChunk));
340 340
	if(!chunk) {
341 341
		fprintf(stderr, "INIT: Memory error alloc chunk!!!\n");
342 342
		return -1;
343 343
	}
344
	sizeChunk = 6*sizeof(int)+2*sizeof(struct timeval)+sizeof(double);
344
	sizeChunk = 6*sizeof(int32_t)+2*sizeof(struct timeval)+sizeof(double);
345 345
    chunk->data=NULL;
346 346
	initChunk(chunk, &seq_current_chunk);
347 347
	chunkaudio = (ExternalChunk *)malloc(sizeof(ExternalChunk));
......
350 350
		return -1;
351 351
	}
352 352
    chunkaudio->data=NULL;
353
	initChunk(chunkaudio, &seq_current_chunk);
353
	initChunk(chunkaudio, &seq_current_chunk+1);
354 354
	
355 355
	//av_init_packet(&packet);
356 356

  
......
484 484
#endif
485 485

  
486 486
					tempdata = chunk->data+chunk->payload_len;
487
					*((int *)tempdata) = frame->number;
488
					tempdata+=sizeof(int);
487
					*((int32_t *)tempdata) = frame->number;
488
					tempdata+=sizeof(int32_t);
489 489
					*((struct timeval *)tempdata) = frame->timestamp;
490 490
					tempdata+=sizeof(struct timeval);
491
					*((int *)tempdata) = frame->size;
492
					tempdata+=sizeof(int);
493
					*((int *)tempdata) = frame->type;
494
					tempdata+=sizeof(int);
491
					*((int32_t *)tempdata) = frame->size;
492
					tempdata+=sizeof(int32_t);
493
					*((int32_t *)tempdata) = frame->type;
494
					tempdata+=sizeof(int32_t);
495 495
					
496 496
					memcpy(chunk->data+chunk->payload_len+sizeFrame,outbuf,out_size); // insert new data
497 497
					chunk->payload_len += out_size + sizeFrame; // update payload length
......
642 642
				chunkaudio->frames_num++; // number of frames in the current chunk
643 643
				contFrameAudio++;
644 644
				tempdata = chunkaudio->data+chunkaudio->payload_len;
645
				*((int *)tempdata) = frame->number;
646
				tempdata+=sizeof(int);
645
				*((int32_t *)tempdata) = frame->number;
646
				tempdata+=sizeof(int32_t);
647 647
				*((struct timeval *)tempdata) = frame->timestamp;
648 648
				tempdata+=sizeof(struct timeval);
649
				*((int *)tempdata) = frame->size;
650
				tempdata+=sizeof(int);
651
				*((int *)tempdata) = frame->type;
652
				tempdata+=sizeof(int);
649
				*((int32_t *)tempdata) = frame->size;
650
				tempdata+=sizeof(int32_t);
651
				*((int32_t *)tempdata) = frame->type;
652
				tempdata+=sizeof(int32_t);
653 653
					
654 654
				memcpy(chunkaudio->data+chunkaudio->payload_len+sizeFrame,outbuf_audio,audio_size);
655 655
				chunkaudio->payload_len += audio_size + sizeFrame; // update payload length
......
673 673
					//saveChunkOnFile(chunkaudio);
674 674
					//Send the chunk via http to an external transport/player
675 675
					pushChunkHttp(chunkaudio, cmeta->outside_world_url);
676
					initChunk(chunkaudio, &seq_current_chunk);
676
					initChunk(chunkaudio, &seq_current_chunk+1);
677 677
				}
678 678
			}
679 679
		}

Also available in: Unified diff