Revision 0cd6b05d

View differences:

chunker_player/chunker_player.c
17 17
#include "player_gui.h"
18 18
#include <time.h>
19 19
#include <getopt.h>
20
#include <napa_log.h>
20 21

  
21 22
#define MANDATORY_PARAMS 3
22 23
#define OPTIONAL_PARAMS 1
......
44 45
    return -1;
45 46
}
46 47

  
48
void CheckForRepoAddress(char* Param)
49
{
50
    char* pch;
51
    if(strncasecmp(Param,"repo_address=",13)==0)
52
    {
53
        pch=strtok(Param+13,",");
54
        strncpy(RepoAddress,pch,2048);
55
    }
56
}
57

  
47 58
void sigproc()
48 59
{
49 60
	printf("you have pressed ctrl-c, terminating...\n");
......
75 86
	quit = 0;
76 87
	QueueFillingMode=1;
77 88
	LogTraces = 0;
89
	repoclient=NULL;
90
	LastTimeRepoPublish.tv_sec=0;
91
	LastTimeRepoPublish.tv_usec=0;
92
	
93
	napaInitLog(LOG_DEBUG, NULL, NULL);
94
    repInit("");
78 95

  
96
	
79 97
#ifndef __WIN32__
80 98
	static pid_t fork_pid = -1;
81 99
	P2PProcessHandle=&fork_pid;
......
559 577

  
560 578
		printf("OFFERSTREAMER LAUNCH STRING: %s %s\n", argv0, parameters_string);
561 579

  
562
#ifndef __WIN32__
580

  
563 581
		char* parameters_vector[255];
564 582
		parameters_vector[0] = argv0;
565 583
		
......
572 590
			// printf ("\tpch=%s\n",pch);
573 591
			parameters_vector[par_count] = (char*) malloc(sizeof(char)*(strlen(pch)+1));
574 592
			strcpy(parameters_vector[par_count], pch);
593
			// Find repo_address
594
			CheckForRepoAddress(parameters_vector[par_count]);
575 595
			pch = strtok (NULL, " ");
576 596
			par_count++;
577 597
		}
578 598
		parameters_vector[par_count] = NULL;
579

  
599
		
600
#ifndef __WIN32__
580 601
		int d;
581 602
		int stdoutS, stderrS;
582 603
		FILE* stream;
......
654 675
		}
655 676
#endif
656 677

  
678
        // Open Repository
679
        if(repoclient) repClose(repoclient);
680
        repoclient=NULL;
681
	    
682
	    repoclient = repOpen(RepoAddress,0);
683
	    //if (repoclient == NULL) fatal("Unable to initialize repoclient");
657 684
	}
658 685
	// Read the Network ID
659 686
	int Error=true;
chunker_player/chunker_player.h
4 4
#include "player_defines.h"
5 5
#include <SDL.h>
6 6
#include <SDL_mutex.h>
7
#include <repoclient.h>
7 8

  
8 9
typedef struct SChannel
9 10
{
......
35 36
short int QueueFillingMode;
36 37
int LogTraces;
37 38
char NetworkID[255];
39
char RepoAddress[2048];
40
HANDLE repoclient;
41
struct timeval LastTimeRepoPublish;
38 42

  
39 43
#ifdef EMULATE_CHUNK_LOSS
40 44
typedef struct
chunker_player/player_core.c
23 23
//int lastCheckedVideoFrame = -1;
24 24
long int last_video_frame_extracted = -1;
25 25

  
26
int timeval_subtract(struct timeval* x, struct timeval* y, struct timeval* result)
27
{
28
  // Perform the carry for the later subtraction by updating y.
29
  if (x->tv_usec < y->tv_usec)
30
  {
31
    int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
32
    y->tv_usec -= 1000000 * nsec;
33
    y->tv_sec += nsec;
34
  }
35
  if (x->tv_usec - y->tv_usec > 1000000)
36
  {
37
    int nsec = (x->tv_usec - y->tv_usec) / 1000000;
38
    y->tv_usec += 1000000 * nsec;
39
    y->tv_sec -= nsec;
40
  }
41

  
42
  // Compute the time remaining to wait. tv_usec is certainly positive.
43
  result->tv_sec = x->tv_sec - y->tv_sec;
44
  result->tv_usec = x->tv_usec - y->tv_usec;
45

  
46
  // Return 1 if result is negative.
47
  return x->tv_sec < y->tv_sec;
48
}
49

  
50

  
26 51
void PacketQueueInit(PacketQueue *q, short int Type)
27 52
{
28 53
#ifdef DEBUG_QUEUE
......
1420 1445
				ChunkerPlayerStats_PrintHistoryTrace(&(audioq.PacketHistory), AudioTraceFilename);
1421 1446
				ChunkerPlayerStats_PrintHistoryTrace(&(videoq.PacketHistory), VideoTraceFilename);
1422 1447
				
1423
//				if(SilentMode != 1 && SilentMode != 2)
1448
				//if(SilentMode != 1 && SilentMode != 2)
1424 1449
					ChunkerPlayerStats_PrintContextFile();
1425 1450
			}
1426 1451

  
......
1437 1462
				char est_psnr_string[255];
1438 1463
				sprintf(est_psnr_string, "");
1439 1464
				if(qoe)
1465
				{
1440 1466
					sprintf(est_psnr_string, " - Est. Mean PSNR: %.1f db", (float)qoe);
1467
					// Publish measure into repository
1468
					MeasurementRecord r;
1469
	                strcpy(r.originator,NetworkID);
1470
	                strcpy(r.targetA,NetworkID);
1471
	                strcpy(r.targetB,"");
1472
	                strcpy(r.published_name,"PSNR");
1473
	                r.value = qoe;
1474
	                r.string_value = NULL;
1475
	                strcpy(r.channel,Channels[SelectedChannel].Title);
1476
	                gettimeofday(&(r.timestamp), NULL);
1477
	                // One update every REPO_UPDATE_INTERVALL seconds
1478
	                struct timeval ElapsedTime;
1479
	                timeval_subtract(&(r.timestamp),&LastTimeRepoPublish,&ElapsedTime);
1480
                    if(ElapsedTime.tv_sec>=REPO_UPDATE_INTERVALL)
1481
                    {
1482
                        LastTimeRepoPublish=r.timestamp;
1483
                        if(repPublish(repoclient,NULL,NULL,&r)!=NULL)
1484
                            printf("VALORE PUBBLICATO: %s  %e  %s\n",r.originator,qoe,r.channel);
1485
                    }
1486
				}
1441 1487

  
1442 1488
				sprintf(video_stats_text, "[VIDEO] qdensity: %d\%% - losses: %d/sec (%ld tot) - skips: %d/sec (%ld tot)%s", (int)video_qdensity, video_statistics.Lossrate, videoq.PacketHistory.LostCount, video_statistics.Skiprate, videoq.PacketHistory.SkipCount, est_psnr_string);
1443 1489
			}
chunker_player/player_defines.h
98 98

  
99 99
#define VIDEO_DEINTERLACE
100 100

  
101
#define REPO_UPDATE_INTERVALL   10  // seconds
102

  
101 103
#endif // _CHUNKER_PLAYER_DEFINES_H
common.mak
12 12
else
13 13
CFLAGS = -pthread -g -O0 -Wall
14 14
LDFLAGS += -pthread
15
DYNAMIC_LDLIBS += -lm
15
DYNAMIC_LDLIBS += -lm -lrt
16 16
endif
17 17

  
18 18
CFLAGS += -DHAVE_OPENGL -Wl,--warn-common -Wl,--as-needed -Wl,-Bsymbolic
19
CPPFLAGS += -I../chunk_transcoding -I../
19
CPPFLAGS += -I../chunk_transcoding -I../ -I../../../NAPA-BASELIBS/include
20 20

  
21 21
#default fmmpeg here
22 22
LOCAL_FFMPEG_CPPFLAGS = -I$(LOCAL_FFMPEG)/include
......
30 30

  
31 31
LOCAL_COMMON_CPPFLAGS = -I$(LOCAL_X264)/include -I$(LOCAL_BZ2)/include -I$(LOCAL_Z)/include -I$(LOCAL_MP3LAME)/include
32 32
#LOCAL_COMMON_LDFLAGS = -L$(LOCAL_X264)/lib -L$(LOCAL_BZ2)/lib -L$(LOCAL_MP3LAME)/lib
33
LOCAL_COMMON_LDLIBS = $(LOCAL_X264)/lib/libx264.a $(LOCAL_BZ2)/lib/libbz2.a $(LOCAL_Z)/lib/libz.a $(LOCAL_MP3LAME)/lib/libmp3lame.a
33
LOCAL_COMMON_LDLIBS = $(LOCAL_X264)/lib/libx264.a $(LOCAL_BZ2)/lib/libbz2.a $(LOCAL_Z)/lib/libz.a $(LOCAL_MP3LAME)/lib/libmp3lame.a ../../../NAPA-BASELIBS/rep/librep.a ../../../NAPA-BASELIBS/dclog/libdclog.a ../../../NAPA-BASELIBS/common/libcommon.a ../../../NAPA-BASELIBS/ml/libml.a
34
LOCAL_COMMON_LDLIBS += ../../../3RDPARTY-LIBS/libevent/lib/libevent.a -L../../../3RDPARTY-LIBS/libconfuse/lib/libconfuse.a

Also available in: Unified diff