Revision add73b22

View differences:

build_ul.sh
163 163
		
164 164
		#build from sources
165 165
		wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
166
		tar zxvf libiconv-1.13.tar.gz; mv libiconv-1.13 libiconv; cd libiconv
166
		tar zxvf libiconv-1.13.tar.gz; mv libiconv-1.13 libiconv; rm -f libiconv-1.13.tar.gz; cd libiconv
167 167
		./configure --enable-static ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBICONV
168 168
		make
169 169
		make install
170
		rm -f libiconv-1.13.tar.gz
171 170
	fi
172 171
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBICONV/include"
173
	LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBICONV/lib"
172
	#~ LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBICONV/lib"
174 173

  
175 174
	LOCAL_LIBINTL="$BASE_UL_DIR/$EXTERN_DIR/libintl/temp_libintl_install_mingw"
176 175
	if [ -f "$LOCAL_LIBINTL/lib/libintl.dll.a" ] || [ -f "$LOCAL_LIBINTL/lib/libintl.a" ]; then
......
181 180
		rm -fR libintl
182 181
		wget http://garr.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-lib.zip; unzip -o libintl-0.14.4-lib.zip -d libintl
183 182
		wget http://switch.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-bin.zip; unzip -o libintl-0.14.4-bin.zip -d libintl
183
		rm -f libintl-0.14.4-bin.zip; rm -f libintl-0.14.4-lib.zip
184 184
		cd libintl
185 185
		mkdir -p $LOCAL_LIBINTL;
186 186
		mv bin $LOCAL_LIBINTL/; mv lib $LOCAL_LIBINTL/; mv include $LOCAL_LIBINTL/
187 187
		mv man $LOCAL_LIBINTL/; mv share $LOCAL_LIBINTL/
188
		rm -f libintl-0.14.4-bin.zip; rm -f libintl-0.14.4-lib.zip
189 188
		
190 189
		# build from gettext sources
191 190
		#~ rm -fR gettext
......
569 568
		LOCAL_EVENT=`dirname $LOCAL_EVENT_A`/..
570 569
	fi
571 570
fi
571

  
572 572
$MAKE IO=$IO clean
573 573
LOCAL_CURL=$LOCAL_CURL ULPLAYER=$BASE_UL_DIR ULPLAYER_EXTERNAL_LIBS=$EXTERN_DIR LIBEVENT_DIR=$LOCAL_EVENT ML=$ML STATIC=$STATIC MONL=$MONL IO=$IO DEBUG=$DEBUG THREADS=$THREADS $MAKE
574 574

  
......
627 627
	cp napalogo*.bmp napaplayer/
628 628
	cp *.ttf napaplayer/
629 629
	cp "$C_PLAYER_EXE" napaplayer/
630
	cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/offerstreamer
631 630
	if [ -n "$MINGW" ]; then
632
		cp "$LOCAL_LIBICONV/bin/libiconv-2.dll" napaplayer/
631
		cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/
632
	else
633
		cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/offerstreamer
634
	fi
635
	if [ -n "$MINGW" ]; then
636
		cp "$LOCAL_LIBICONV/bin/libiconv-2.dll" napaplayer/libiconv2.dll
633 637
		if [ -f "$LOCAL_LIBINTL/bin/libintl-8.dll" ]; then
634 638
			cp "$LOCAL_LIBINTL/bin/libintl-8.dll" napaplayer/
635 639
		else
636 640
			cp "$LOCAL_LIBINTL/bin/libintl3.dll" napaplayer/libintl-8.dll
637 641
		fi
638 642
		cp "$LOCAL_PLIBC/bin/libplibc-1.dll" napaplayer/
643
		cp "$LOCAL_PTHREAD/bin/pthreadGC2.dll" napaplayer/
639 644
		cp "$LOCAL_ABS_SDL/bin/SDL.dll" napaplayer/
645
		cp player.bat napaplayer/
640 646
		rm -f -r napaplayer.zip
641 647
		zip -r napaplayer napaplayer
642 648
		if [ -s "napaplayer.zip" ]; then
chunker_player/channels.conf
1
PeerExecName = "offerstreamer"
1
#~ PeerExecName = "offerstreamer"
2
PeerExecName = "offerstreamer-ml-monl-httpevent-halfstatic.exe"
2 3

  
3 4
Channel TN-TV1
4 5
{
5
	LaunchString = "-c 5 -b 200 -o 200 -i 193.205.213.229 -p 6666 -n repo_address=193.205.213.37:9832"
6
	LaunchString = "-c 5 -b 200 -o 200 -i 193.205.213.229 -p 6666 -n repo_address=130.192.86.30:9832"
6 7
	AudioChannels = 2
7 8
	SampleRate = 48000
8 9
	Width = 704
9 10
	Height = 576
10
	Ratio = 3
11
	Ratio = 1.5
12
}
13

  
14
Channel TN-TV2
15
{
16
   LaunchString = "-c 5 -b 200 -o 200 -i 193.205.213.139 -p 6666 -n repo_address=130.192.86.30:9832"
17
   AudioChannels = 2
18
   SampleRate = 48000
19
   Width = 704
20
   Height = 576
21
   Ratio = 1.4
11 22
}
12 23

  
13 24
Channel TN-TV3
14 25
{
15
	LaunchString = "-c 5 -b 200 -o 200 -i 130.192.86.31 -p 6666 -n repo_address=193.205.213.37:9832"
26
	LaunchString = "-c 5 -b 200 -o 200 -i 130.192.86.31 -p 6666 -n repo_address=130.192.86.30:9832"
16 27
	AudioChannels = 2
17 28
	SampleRate = 48000
18 29
	Width = 704
......
22 33

  
23 34
Channel CT_Local_TV
24 35
{
25
	LaunchString = "-c 5 -b 200 -o 200 -i 127.0.0.1 -p 6666 -I lo -n repo_address=193.205.213.37:9832"
36
	LaunchString = "-c 5 -b 200 -o 200 -i 127.0.0.1 -p 6666 -I lo -n repo_address=130.192.86.30:9832"
26 37
	AudioChannels = 2
27 38
	SampleRate = 48000
28 39
	Width = 704
chunker_player/chunker_player.c
9 9
#include "chunker_player.h"
10 10
#include "player_gui.h"
11 11

  
12
#ifdef WIN32
13
#include <windows.h> 
14
#endif
15

  
12 16
int main(int argc, char *argv[])
13 17
{
14 18
	// some initializations
......
17 21
	SaveYUV = 0;
18 22
	quit = 0;
19 23
	QueueFillingMode=1;
20
	P2PProcessID = -1;
24

  
25
#ifndef __WIN32__
26
	static pid_t fork_pid = -1;
27
	P2PProcessHandle=&fork_pid;
28
#else
29
	static PROCESS_INFORMATION ProcessInfo;
30
	ZeroMemory( &ProcessInfo, sizeof(ProcessInfo) );
31
	P2PProcessHandle=&ProcessInfo;
32
#endif
21 33
	NChannels = 0;
22 34
	SelectedChannel = -1;
23 35
	char firstChannelName[255];
......
219 231
		}
220 232
		usleep(120000);
221 233
	}
222
	
223
	if(P2PProcessID > 0)
224
		KILL_PROCESS(P2PProcessID);
234

  
235
	KILL_PROCESS(P2PProcessHandle);
225 236

  
226 237
	//TERMINATE
227 238
	ChunkerPlayerCore_Stop();
......
325 336
	
326 337
	sprintf(OfferStreamerFilename, "%s", cfg_getstr(cfg, "PeerExecName"));
327 338
	
328
#ifdef __LINUX__
329 339
	FILE * tmp_file;
330 340
	if(tmp_file = fopen(OfferStreamerFilename, "r"))
331 341
    {
......
336 346
		printf("Could not find peer application (named '%s') into the current folder, please copy or link it into the player folder, then retry\n\n", OfferStreamerFilename);
337 347
		exit(1);
338 348
	}
339
#endif
340 349
	
341 350
	for(j = 0; j < cfg_size(cfg, "Channel"); j++)
342 351
	{
......
368 377
	if(ChunkerPlayerCore_IsRunning())
369 378
		ChunkerPlayerCore_Stop();
370 379

  
371
	if(P2PProcessID > 0)
372
		KILL_PROCESS(P2PProcessID);
380
	KILL_PROCESS(P2PProcessHandle);
373 381
	
374 382
	ratio = channel->Ratio;
375 383
	ChunkerPlayerGUI_SetChannelTitle(channel->Title);
......
385 393
		printf("ERROR, COULD NOT INITIALIZE CODECS\n");
386 394
		exit(2);
387 395
	}
396
	
397
	//reset quality info
398
	channel->startTime = time(NULL);
399
	channel->instant_score = 0.0;
400
	channel->average_score = 0.0;
401
	channel->history_index = 0;
402
	for(i=0; i<CHANNEL_SCORE_HISTORY_SIZE; i++)
403
		channel->score_history[i] = -1;
404
	sprintf(channel->quality, "EVALUATING...");
388 405
		
389
	char* parameters_vector[255];
390 406
	char argv0[255], parameters_string[511];
391 407
	sprintf(argv0, "%s", OfferStreamerFilename);
392 408
	
393
	sprintf(parameters_string, "%s %s %s %s %s %d %s %s:%d", argv0, channel->LaunchString, "-C", channel->Title, "-P", (HttpPort+channel->Index), "-F", PlayerIP, HttpPort);
394
	
395
	printf("OFFERSTREAMER LAUNCH STRING: %s\n", parameters_string);
409
	sprintf(parameters_string, "%s %s %s %s %d %s %s:%d", channel->LaunchString, "-C", channel->Title, "-P", (HttpPort+channel->Index), "-F", PlayerIP, HttpPort);
396 410
	
397
	int par_count=0;
411
	printf("OFFERSTREAMER LAUNCH STRING: %s %s\n", argv0, parameters_string);
412

  
413
#ifdef __LINUX__
414
	char* parameters_vector[255];
415
	parameters_vector[0] = argv0;
398 416
	
399 417
	// split parameters and count them
418
	int par_count=1;
400 419
	char* pch = strtok (parameters_string, " ");
401
	
402 420
	while (pch != NULL)
403 421
	{
404 422
		if(par_count > 255) break;
......
410 428
	}
411 429
	parameters_vector[par_count] = NULL;
412 430

  
413
	//reset quality info
414
	channel->startTime = time(NULL);
415
	channel->instant_score = 0.0;
416
	channel->average_score = 0.0;
417
	channel->history_index = 0;
418
	for(i=0; i<CHANNEL_SCORE_HISTORY_SIZE; i++)
419
		channel->score_history[i] = -1;
420
	sprintf(channel->quality, "EVALUATING...");
421

  
422
#ifdef __LINUX__
423

  
424 431
	int d;
425 432
	int stdoutS, stderrS;
426 433
	FILE* stream;
......
443 450
		exit(2);
444 451
	}
445 452
	else
446
		P2PProcessID = pid;
453
		*((pid_t*)P2PProcessHandle) = pid;
447 454
	
448 455
	// restore backup descriptors in the parent process
449 456
	dup2(stdoutS, STDOUT_FILENO);
450 457
	dup2(stderrS, STDERR_FILENO);
451 458
	
452
	for(i=0; i<par_count; i++)
459
	for(i=1; i<par_count; i++)
453 460
		free(parameters_vector[i]);
454 461
		
455 462
	fclose(stream);
......
466 473
	ChunkerPlayerCore_Play();
467 474
	
468 475
	return 0;
469
#endif
470 476

  
477
#else
478
#ifdef __WIN32__
479
	STARTUPINFO sti;
480
	SECURITY_ATTRIBUTES sats = { 0 }; 
481
	DWORD writ, excode, read, available; 
482
	int ret = 0; 
483

  
484
	//set SECURITY_ATTRIBUTES struct fields 
485
	sats.nLength = sizeof(sats); 
486
	sats.bInheritHandle = TRUE; 
487
	sats.lpSecurityDescriptor = NULL;
488
	
489
	ZeroMemory( &sti, sizeof(sti) );
490
    sti.cb = sizeof(sti);
491
    ZeroMemory( P2PProcessHandle, sizeof(PROCESS_INFORMATION) );
492
    
493
	if(!CreateProcess(argv0, 
494
	  parameters_string,
495
	  &sats, 
496
	  &sats, 
497
	  TRUE, 
498
	  0, 
499
	  NULL, 
500
	  NULL, 
501
	  &sti, 
502
	  P2PProcessHandle))
503
	{ 
504
		printf("Unable to generate process \n"); 
505
		return -1; 
506
	}
507
	
471 508
	ChunkerPlayerCore_Play();
472
	//~ return 1;
473 509
	return 0;
510
#endif
511
#endif
512

  
513
	return 1;
474 514
}
475 515

  
476 516
void ZapDown()
chunker_player/chunker_player.h
32 32
int queue_filling_threshold;
33 33
int quit;
34 34
short int QueueFillingMode;
35
int P2PProcessID;
35

  
36
void* P2PProcessHandle;
36 37

  
37 38
#ifdef __WIN32__
38
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "taskkill /pid %d /F", pid); system(command_name);}
39
//~ #define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "taskkill /pid %d /F", pid); system(command_name);}
40
#define KILL_PROCESS(handle) {TerminateProcess(((PROCESS_INFORMATION*)handle)->hProcess, 0);}
39 41
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "taskkill /im %s /F", pname); system(command_name);}
40 42
#endif
41 43
#ifdef __LINUX__
42
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "kill %d", pid); system(command_name);}
44
#define KILL_PROCESS(handle) {if(*((pid_t*)handle)>0){char command_name[255]; sprintf(command_name, "kill %d", *((pid_t*)handle)); system(command_name);}}
43 45
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "killall %s -9", pname); system(command_name);}
44 46
#endif
45 47
#ifdef __MACOS__
46
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "kill %d", pid); system(command_name);}
48
#define KILL_PROCESS(handle) {if(*((pid_t*)handle)>0){char command_name[255]; sprintf(command_name, "kill %d", *((pid_t*)handle)); system(command_name);}}
47 49
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "killall %s -9", pname); system(command_name);}
48 50
#endif
49 51

  
50

  
51

  
52

  
53 52
SChannel Channels[MAX_CHANNELS_NUM];
54 53
int NChannels;
55 54
int SelectedChannel;
chunker_player/player_gui.c
117 117
	if(SilentMode)
118 118
		return;
119 119
		
120
	SDL_LockMutex(OverlayMutex);
121
		
120 122
	// printf("ChunkerPlayerGUI_HandleResize(%d, %d)\n", resize_w, resize_h);
121 123
	SetVideoMode(resize_w, resize_h, FullscreenMode?1:0);
122 124
	
......
141 143
	RedrawButtons();
142 144
	RedrawChannelName();
143 145
	RedrawStats();
146
	
147
	SDL_UnlockMutex(OverlayMutex);
144 148
}
145 149

  
146 150
void ChunkerPlayerGUI_HandleGetFocus()

Also available in: Unified diff