Beispiel #1
0
static int voip_changeURI(interfaceMenu_t *pMenu, char *value, void* pArg)
{
	int res, selectedIndex = ENTRY_INFO_GET_INDEX((int)pArg);
	char description[MENU_ENTRY_INFO_LENGTH];

	if (value == NULL)
	{
		return 1;
	}

	if((res = m3u_getEntry( ADDRESSBOOK_FILENAME, selectedIndex)) != 0)
	{
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
		return res;
	}
	strcpy(description, m3u_description);
	if((res = m3u_replaceEntryByIndex( ADDRESSBOOK_FILENAME, selectedIndex, value, description )) != 0)
	{
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
	} else
	{
		voip_fillAddressBookMenu(pMenu, NULL);
	}
	return res;
}
Beispiel #2
0
static int voip_addNewAddressBookEntry(interfaceMenu_t *pMenu, char *uri, char *nickname)
{
	FILE *file = m3u_initFile(ADDRESSBOOK_FILENAME, "r");
	if (file == NULL )
	{
		if( m3u_createFile(ADDRESSBOOK_FILENAME) != 0)
		{
			interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
			return -1;
		}
	} else
	{
		fclose(file);
	}

	if(m3u_findUrl(ADDRESSBOOK_FILENAME, uri) == 0)
	{
		interface_showMessageBox(_T("ADDED_TO_ADDRESS_BOOK"), thumbnail_yes, 3000);
		return 0;
	}

	if (m3u_addEntry(ADDRESSBOOK_FILENAME, uri, nickname) != 0)
	{
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
		return -1;
	}

	voip_fillAddressBookMenu(pMenu,NULL);
	interface_showMessageBox(_T("ADDED_TO_ADDRESS_BOOK"), thumbnail_yes, 3000);
	return 0;
}
Beispiel #3
0
static int rtsp_setChannelFromURL(interfaceMenu_t *pMenu, const char *value, const char* description, const char* thumbnail, void* pArg)
{
	int which = GET_NUMBER(pArg);
	int res;
	rtsp_stream_info sinfo;
	url_desc_t url;

	if( value == NULL )
		return 1;

	strcpy(rtsp_lasturl, value);

	memset(&sinfo, 0, sizeof(rtsp_stream_info));

	if ((res = parseURL(value, &url)) != 0)
	{
		interface_showMessageBox(_T("ERR_INCORRECT_URL"), thumbnail_error, 0);
		return -1;
	}

	if (url.protocol != mediaProtoRTSP)
	{
		interface_showMessageBox(_T("ERR_INCORRECT_PROTO"), thumbnail_error, 0);
		return -1;
	}

	inet_addr_prepare(url.address);
	if (inet_addr(url.address) == INADDR_NONE || inet_addr(url.address) == INADDR_ANY)
	{
		struct hostent * h = gethostbyname(url.address);
		if (!h){
			interface_showMessageBox(_T("ERR_INCORRECT_IP"), thumbnail_error, 0);
			return -1;
		}
		strcpy(url.address, inet_ntoa(*(struct in_addr*)h->h_addr));
		//eprintf ("%s: %s\n", __FUNCTION__, url.address);
	}

	strcpy(sinfo.ip, url.address);
	sinfo.port = url.port;
	strcpy(sinfo.streamname, url.stream);
	sinfo.custom_url = 1;
	memcpy(&stream_info, &sinfo, sizeof(rtsp_stream_info));

	if( !description )
		snprintf(appControlInfo.playbackInfo.description, sizeof(appControlInfo.playbackInfo.description),
			"%s: rtsp://%s:%d/%s", _T("MOVIE"), stream_info.ip, stream_info.port, stream_info.streamname);
	else
		strcpy(appControlInfo.playbackInfo.description, description);
	if( !thumbnail )
		appControlInfo.playbackInfo.thumbnail[0] = 0;
	else
		strcpy(appControlInfo.playbackInfo.thumbnail, thumbnail);

	dprintf("%s: Change to %s\n", __FUNCTION__, sinfo.streamname);

	return rtsp_stream_change(pMenu, CHANNEL_INFO_SET(which, CHANNEL_CUSTOM));
}
Beispiel #4
0
static int rtsp_stream_change(interfaceMenu_t *pMenu, void* pArg)
{
	int which = CHANNEL_INFO_GET_SCREEN(pArg);
	unsigned int streamNumber = CHANNEL_INFO_GET_CHANNEL(pArg);

	dprintf("%s(%d): in %d\n", __FUNCTION__, which, streamNumber);

	interface_removeEvent(rtsp_stream_start, pArg);

	if ( appControlInfo.rtspInfo.active != 0 )
	{
		eprintf("RTSP: stop video at %d\n", which);
		// force showState to NOT be triggered
		interfacePlayControl.activeButton = interfacePlayControlStop;
		rtsp_stopVideo(which);
	}

	if (streamNumber != CHANNEL_CUSTOM)
	{
		interface_setSelectedItem(_M &rtspStreamMenu, streamNumber);

		if ( pstream_head == NULL ) {
			int ret = get_rtsp_streams(ppstream_head);
			dprintf("%s: Found streams %i\n", __FUNCTION__,ret);
			if (ret != 0 || pstream_head == NULL) {
				interface_showMessageBox(_T("ERR_DEFAULT_STREAM"), thumbnail_warning, 0);
				eprintf("RTSP: Failed to find default stream\n");
				return -1;
			}
		}
		streams_struct* stream_ptr = get_stream(streamNumber);
		if ( !stream_ptr ) {
			interface_showMessageBox(_T("ERR_STREAM_IN_LIST"), thumbnail_error, 0);
			eprintf("RTSP: Stream number %d not found in linked list\n", streamNumber);
			return -1;
		}
		//dprintf("%s: stream_ptr->stream %s\n", __FUNCTION__, stream_ptr->stream);

		stream_info.port = appControlInfo.rtspInfo.RTSPPort;
		strcpy(stream_info.ip, appControlInfo.rtspInfo.streamIP);
		strcpy(stream_info.streamname, stream_ptr->stream);
		appControlInfo.playbackInfo.playlistMode = playlistModeNone;
		stream_info.custom_url = 0;
	}

	if ( rtsp_stream_start(pArg) == 0 )
	{
		interface_showMenu(0, 1);

		return 0;
	}

	return -1;
}
Beispiel #5
0
static int voip_changeParam(interfaceMenu_t *pMenu, char *value, void* pArg)
{
	char *dest;
	if( value == NULL )
		return 1;
	switch((int)pArg)
	{
		case PARAM_SERVER: dest = appControlInfo.voipInfo.server; break;
		case PARAM_LOGIN:  dest = appControlInfo.voipInfo.login; break;
		case PARAM_PASSWD: dest = appControlInfo.voipInfo.passwd; break;
		case PARAM_REALM:  dest = appControlInfo.voipInfo.realm; break;
		default: dest = NULL;
	}
	if( dest == NULL )
	{
		return -2;
	}
	strcpy(dest,value);
	if( saveAppSettings() != 0)
	{
		interface_showMessageBox(_T("SETTINGS_SAVE_ERROR"), thumbnail_warning, 0);
	}
	
	voip_fillAccountMenu(pMenu, (void*)-1);
	interface_displayMenu(1);

	return 0;
}
Beispiel #6
0
static int youtube_keyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg)
{
	int selectedIndex = interface_getSelectedItem((interfaceMenu_t*)&YoutubeMenu);
	char url[YOUTUBE_LINK_SIZE];
	if (selectedIndex > 0 )
	{
		switch( cmd->command )
		{
			case interfaceCommandGreen:
				snprintf(url, sizeof(url), "http://www.youtube.com/watch?v=%s", youtubeInfo.videos[selectedIndex-1].video_id);
				eprintf("Youtube: Stream %02d: '%s'\n", selectedIndex-1, url);
				interface_showMessageBox(url, -1, 0);
				return 0;
#ifdef ENABLE_FAVORITES
			case interfaceCommandYellow:
				char description[MENU_ENTRY_INFO_LENGTH];
				interface_getMenuEntryInfo( (interfaceMenu_t*)&YoutubeMenu, selectedIndex, description, sizeof(description) );
				snprintf(url, sizeof(url), "http://www.youtube.com/watch?v=%s", youtubeInfo.videos[selectedIndex-1].video_id);
				eprintf("Youtube: Add to Playlist '%s'\n", url);
				playlist_addUrl( url, description );
				return 0;
				
				break;
#endif
			default:;
		}
	}
	return 1;
}
Beispiel #7
0
static int voip_showEntryInfo( interfaceMenu_t *pMenu, void *pArg )
{
	int res;
	if( (res = voip_getEntryInfo( pArg )) == 0 )
	{
		interface_showMessageBox(m3u_url, thumbnail_info, 5000);
	}
	return res;
}
Beispiel #8
0
int rtsp_checkPlaybackState(void *notused)
{
	DFBVideoProviderStatus status = gfx_getVideoProviderStatus(screenMain);
	switch (status)
	{
		case DVSTATE_FINISHED:
		case DVSTATE_STOP:
			dprintf("%s: status = DVSTATE_STOP || DVSTATE_FINISHED\n", __FUNCTION__);
			
			if ( status == DVSTATE_FINISHED )
				interface_showMessageBox(_T("ERR_STREAM_NOT_SUPPORTED"), thumbnail_error, 0);
			interface_playControlSlider(0,0,0);
#ifdef ENABLE_VIDIMAX
			if (appControlInfo.vidimaxInfo.active){
				vidimax_stopVideoCallback();
			}
#endif
			rtsp_stopVideo(screenMain);
			interface_showMenu(1, 1);

			return 0;

#ifdef STBPNX
		case DVSTATE_STOP_REWIND:
			appControlInfo.playbackInfo.scale = 1.0;
			gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale);
			interface_playControlSelect(interfacePlayControlPlay);
			interface_notifyText(NULL, 1);
			// fall through
#endif
		default:
			if (!gfx_videoProviderIsPaused(screenMain))
			{
				double length_stream   = 0.0;
				double position_stream = 0.0;
				int ret_val = gfx_getPosition(&length_stream,&position_stream);
				if (ret_val == 0) {
					//dprintf("%s: got position %f, set it\n", __FUNCTION__, ret_val, position_stream);
					if (position_stream <= length_stream)
						interface_playControlSlider(0, (unsigned int)length_stream, (unsigned int)position_stream);
					else {
						eprintf("%s: RTSP played 'till the end\n", __FUNCTION__);
						rtsp_stopVideo(screenMain);

						return 0;
					}
				}
			}
	}
	rtsp_enableStateCheck();

	return 0;
}
Beispiel #9
0
static int voip_reloginToServer(interfaceMenu_t *pMenu, void* pArg)
{
	if(strlen( appControlInfo.voipInfo.server ) * strlen( appControlInfo.voipInfo.realm ) * strlen ( appControlInfo.voipInfo.login ) * strlen(appControlInfo.voipInfo.passwd) == 0 )
	{
		interface_showMessageBox(_T("ERR_NOT_ALL_FIELDS"), thumbnail_info, 3000);
		return -2;
	}

	voip_logoutFromServer(pMenu,pArg);
	usleep(100000); // wait for pjsua response
	voip_loginToServer();

	return 0;
}
Beispiel #10
0
static int voip_renameBuddy(interfaceMenu_t *pMenu, char *value, void* pArg)
{
	int res, selectedIndex = ENTRY_INFO_GET_INDEX((int)pArg);
	char uri[MAX_URL];

	if( value == NULL )
		return 1;

	if((res = m3u_getEntry( ADDRESSBOOK_FILENAME, selectedIndex )) != 0)
	{
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
		return 1;
	}
	strcpy(uri, m3u_url);
	if((res = m3u_replaceEntryByIndex( ADDRESSBOOK_FILENAME, selectedIndex, uri, value )) != 0)
	{
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
	} else
	{
		voip_fillAddressBookMenu(pMenu, NULL);
	}
	return res;
}
Beispiel #11
0
static int voip_toggleEnabled(interfaceMenu_t *pMenu, void* pArg)
{
	int showinfo = 1;

	appControlInfo.voipInfo.enabled = !appControlInfo.voipInfo.enabled;

	if( saveAppSettings() != 0)
	{
		interface_showMessageBox(_T("SETTINGS_SAVE_ERROR"), thumbnail_warning, 0);
		showinfo = 0;
	}

	voip_fillAccountMenu(pMenu, (void*)-1);
	interface_displayMenu(1);

	if (showinfo)
	{
		interface_showMessageBox(_T("PLEASE_WAIT"), thumbnail_info, 0);
	}

	if (appControlInfo.voipInfo.enabled)
	{
		system("/usr/local/etc/init.d/S95voip reload");
		sleep(5);
	} else
	{
		system("/usr/local/etc/init.d/S95voip stop");
		sleep(1);
	}

	if (showinfo)
	{
		interface_hideMessageBox();
	}

	return 0;
}
Beispiel #12
0
int open_browser_mw(interfaceMenu_t* pMenu, void* pArg)
{
#ifdef STBPNX
	char buf[MENU_ENTRY_INFO_LENGTH];
	char open_link[MENU_ENTRY_INFO_LENGTH];

	interface_showMessageBox(_T("LOADING_BROWSER"), thumbnail_internet, 0);
	interface_displayMenu(1); // fill second buffer with same frame

	getParam(BROWSER_CONFIG_FILE, "HomeURL", "", buf);
	if(buf[0]!=0)
		sprintf(open_link,"/usr/local/webkit/_start.sh %s",buf);
	else
		sprintf(open_link,"/usr/local/webkit/_start.sh");
	helperStartApp(open_link);
#endif
	return 0;
}
Beispiel #13
0
static int youtube_startVideoSearch(interfaceMenu_t *pMenu, char *value, void* pArg)
{
	int search_length;
	char buf[sizeof(youtubeInfo.search)];
	int thread_create = -1;
    
	if( value == NULL )
		return 1;
	interface_hideMessageBox();
	search_length = utf8_mbtouri(value, strlen(value), buf, sizeof(buf)-1 );
	if( search_length < 0 )
	{
		interface_showMessageBox(_T("ERR_INCORRECT_URL"), thumbnail_error, 5000);
		return 1;
	}
	buf[search_length] = 0;
	strncpy(youtubeInfo.search, buf, search_length+1);
	pthread_create(&youtubeInfo.search_thread, NULL, youtube_MenuVideoSearchThread, (void *) pMenu);
	pthread_detach(youtubeInfo.search_thread);
	return 0;
}
Beispiel #14
0
static int voip_deleteEntryFromList( interfaceMenu_t *pMenu, void *pArg )
{
	char *str = NULL;
	int entryIndex = ENTRY_INFO_GET_INDEX((int)pArg), listIndex = ENTRY_INFO_GET_LIST((int)pArg), res;
	if(entryIndex < 0)
	{
		eprintf("VoIP: Can't delete %d\n", entryIndex);
		return -2;
	}
	switch(listIndex)
	{
		case LIST_ADDRESS:  str = ADDRESSBOOK_FILENAME; break;
		case LIST_MISSED:   str = MISSED_FILENAME;      break;
		case LIST_ANSWERED: str = ANSWERED_FILENAME;    break;
		case LIST_DIALED:   str = DIALED_FILENAME;      break;
		default :;
	}
	if( str == NULL )
	{
		eprintf("VoIP: Can't delete %d: invalid list index %d\n", entryIndex, listIndex);
		return -2;
	}
	if( (res = m3u_deleteEntryByIndex( str, entryIndex)) == 0)
	{
		switch(listIndex)
		{
			case LIST_ADDRESS:  voip_fillAddressBookMenu(pMenu,NULL); break;
			case LIST_MISSED:   voip_fillMissedCallsMenu(pMenu,NULL); break;
			case LIST_ANSWERED: voip_fillAnsweredCallsMenu(pMenu,NULL); break;
			case LIST_DIALED:   voip_fillDialedNumbersMenu(pMenu,NULL); break;
			default :;
		}
	} else
	{
		eprintf("VoIP: Failed to delete %d from %s\n", entryIndex, str);
		interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
	}
	return res;
}
Beispiel #15
0
int rtsp_startVideo(int which)
{
	char rtsp_url[256+32];
	char *str;

	interface_showLoadingAnimation();

	mysem_get(rtsp_semaphore);
	dprintf("%s: got sem\n", __FUNCTION__);

	media_slideshowStop(1);

	gfx_stopVideoProviders(which);

	sprintf(rtsp_url,"rtsp://%s:%d/%s",
		stream_info.ip,
		stream_info.port,
		stream_info.streamname);
	// xWorks links workaround
	if( (str = strstr(rtsp_url, "?manualDetectVideoInfo")) != NULL )
		*str = 0;

	dprintf("%s: starting video %s\n", __FUNCTION__, rtsp_url);
	if (gfx_startVideoProvider(rtsp_url, which, 1, "") != 0)
	{
		mysem_release(rtsp_semaphore);
		interface_showMessageBox(_T("ERR_STREAM_UNAVAILABLE"), thumbnail_error, 0);
		eprintf("RTSP: Failed to start video provider '%s'\n", rtsp_url);
		return -1;
	}

#ifdef ENABLE_VERIMATRIX
	if (appControlInfo.useVerimatrix != 0)
	{
		eprintf("RTSP: Enable verimatrix...\n");
		if (gfx_enableVideoProviderVerimatrix(screenMain, VERIMATRIX_INI_FILE) != 0)
		{
			interface_showMessageBox(_T("ERR_VERIMATRIX_INIT"), thumbnail_error, 0);
		}
	}
#endif
#ifdef ENABLE_SECUREMEDIA
	if (appControlInfo.useSecureMedia != 0)
	{
		eprintf("RTSP: Enable securemedia...\n");
		if (gfx_enableVideoProviderSecureMedia(screenMain) != 0)
		{
			interface_showMessageBox(_T("ERR_SECUREMEDIA_INIT"), thumbnail_error, 0);
		}
	}
#endif

	if(!gfx_getVideoProviderHasVideo(screenMain))
	{
		if(appControlInfo.slideshowInfo.state == slideshowDisabled)
		{
			interface_setBackground(0,0,0,0xFF, INTERFACE_WALLPAPER_IMAGE);
		}
	}
	else
	{
		media_slideshowStop(1);
	}
	if (gfx_isTrickModeSupported(screenMain))
	{
		interface_playControlSetButtons( interface_playControlGetButtons()|interfacePlayControlFastForward|interfacePlayControlRewind );
	}

	appControlInfo.rtspInfo.active = 1;

	interface_playControlSelect(interfacePlayControlStop);
	interface_playControlSelect(interfacePlayControlPlay);

#ifdef STBPNX
	double length_stream = 0.0;
	double position_stream = 0.0;
	/// FIXME: should be done by gfx_startVideoProvider
	if(gfx_getPosition(&length_stream,&position_stream) == 0)
	{
		//dprintf("%s: start from pos %f\n", __FUNCTION__, position_stream);
		interface_playControlSlider(0, (unsigned int)length_stream, (unsigned int)position_stream);
	}else
	{
		interface_playControlSlider(0, 0, 0);
	}
#endif
	rtsp_enableStateCheck();

	dprintf("%s: release sem\n", __FUNCTION__);
	mysem_release(rtsp_semaphore);

	interface_hideLoadingAnimation();
	interface_displayMenu(1);

	return 0;
}
Beispiel #16
0
static int rtsp_keyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg)
{
	unsigned int streamNumber;
	char URL[MAX_URL];

	if( cmd->command == interfaceCommandBlue )
	{
		rtsp_enterURL(pMenu, (void*)screenMain);
		return 0;
	}

	if(pMenu->selectedItem < 0)
	{
		return 1;
	}

	streamNumber = CHANNEL_INFO_GET_CHANNEL(pArg);

	if (GET_NUMBER(pArg) >= 0)
	{
		if (cmd->command == interfaceCommandYellow || cmd->command == interfaceCommandGreen)
		{
			if ( pstream_head == NULL ) {
				int ret=get_rtsp_streams(ppstream_head);
				if (ret != 0 || pstream_head == NULL) {
					eprintf("%s: Failed to find default stream\n", __FUNCTION__);
					interface_showMessageBox(_T("ERR_DEFAULT_STREAM"), thumbnail_warning, 0);
					return 0;
				}
			}
			streams_struct* stream_ptr = get_stream(streamNumber);
			if ( !stream_ptr ) {
				interface_showMessageBox(_T("ERR_STREAM_IN_LIST"), thumbnail_error, 0);
				eprintf("RTSP: Stream number not found in linked list\n");
				return 0;
			}

			sprintf(URL, "rtsp://%s:%d/%s", appControlInfo.rtspInfo.streamIP, appControlInfo.rtspInfo.RTSPPort, stream_ptr->stream);
			if( cmd->command == interfaceCommandYellow )
			{
				eprintf("RTSP: Add to Playlist '%s'\n",URL);
				playlist_addUrl(URL, stream_ptr->name ? stream_ptr->name : stream_ptr->stream);
			} else if (cmd->command == interfaceCommandGreen ||
			           cmd->command == interfaceCommandInfo)
			{
				eprintf("RTSP: Stream %03d: '%s'\n", streamNumber, URL);
				if( stream_ptr->poster && stream_ptr->poster[0] )
				{
					interface_showPosterBox( stream_ptr->description,
					                         stream_ptr->name ? stream_ptr->name : stream_ptr->stream,
					                         INTERFACE_BORDER_RED, INTERFACE_BORDER_GREEN, INTERFACE_BORDER_BLUE, INTERFACE_BORDER_ALPHA,
					                         thumbnail_vod,
					                         stream_ptr->poster, NULL, SET_NUMBER(streamNumber));
				}
				//interface_showMessageBox(URL, thumbnail_info, 0);
			}
			return 0;
		}
	}

	return 1;
}
Beispiel #17
0
static int voip_addEntryToList( interfaceMenu_t *pMenu, void* pArg )
{
	char info[MENU_ENTRY_INFO_LENGTH], *filename = "";
	struct tm *t;
	FILE *file;

	switch((int)pArg)
	{
		case LIST_MISSED:
		case LIST_ANSWERED:
		case LIST_DIALED:
			switch((int)pArg)
			{
				case LIST_MISSED:   filename = MISSED_FILENAME;   break;
				case LIST_ANSWERED: filename = ANSWERED_FILENAME; break;
				case LIST_DIALED:   filename = DIALED_FILENAME;   break;
				default: break;
			}
			file = m3u_initFile(filename, "r");
			if (file == NULL )
			{
				if( m3u_createFile(filename) != 0)
				{
					interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
					return -1;
				}
			} else
			{
				fclose(file);
			}
			if((int)pArg == LIST_DIALED)
			{
				time(&voip_lastCallTime);
			}
			t = localtime(&voip_lastCallTime);
			strftime(info, MENU_ENTRY_INFO_LENGTH, _T("DATETIME_FORMAT"), t);
			snprintf(&info[strlen(info)], MENU_ENTRY_INFO_LENGTH - strlen(info), " %s", appControlInfo.voipInfo.lastSip);
			if (m3u_addEntry(filename, appControlInfo.voipInfo.lastSip, info) != 0)
			{
				interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
				return -1;
			}
			break;
		case LIST_ADDRESS:
			file = m3u_initFile(ADDRESSBOOK_FILENAME, "r");
			if (file == NULL )
			{
				if( m3u_createFile(ADDRESSBOOK_FILENAME) != 0)
				{
					interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
					return -1;
				}
			} else
			{
				fclose(file);
			}
			if (m3u_addEntry(ADDRESSBOOK_FILENAME, appControlInfo.voipInfo.lastSip, NULL) != 0)
			{
				interface_showMessageBox(_T("ERR_SAVE_FAILED"), thumbnail_error, 0);
				return -1;
			}
			break;
		default: return 0;
	}
	return 0;
}
Beispiel #18
0
static void *voip_readPipeThread(void *pArg)
{
	char buffer[BUFFER_SIZE], *buf, *str, *pos;
	int bytes_left, bytes_total;
	dprintf("%s: in\n", __FUNCTION__);
	
	while( appControlInfo.voipInfo.active )
	{
		//dprintf("%s: read loop\n", __FUNCTION__);
		if( (bytes_total = voip_pipe_read(buffer, sizeof(buffer))) > 0)
		{
			bytes_left = bytes_total;
			while (bytes_left > 0)
			{
				buf = &buffer[bytes_total-bytes_left];
				dprintf("%s: recieved '%s' %d/%d\n", __FUNCTION__,buf, bytes_left, bytes_total);
				bytes_left -= strlen(buf)+1;
				switch( buf[0] )
				{
					case 'A':
						if( strncasecmp( buf, "Account deleted", 15 ) == 0)
						{
							appControlInfo.voipInfo.connected = 0;
							voip_loggingIn = 0;
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
							voip_fillAccountMenu(interfaceInfo.currentMenu, NULL);
						}
						break;
					case 'I':
						str = &buf[2];
						pos = index(str,'\n');
						if(pos!=NULL)
						{
							time(&voip_lastCallTime);
							*pos = 0;
							strcpy(appControlInfo.voipInfo.lastSip,str); //from
							saveAppSettings();
							str = &pos[1];
							appControlInfo.voipInfo.status = voipStatus_incoming;
							voip_call_event(NULL);
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
							// to (ignored)
						}
						break;
					case 'D': // Disconnect
						voip_hangup(interfaceInfo.currentMenu,NULL);
						break;
					case 'C':
						if(strncasecmp(buf,"Calling",7) == 0)
						{
							appControlInfo.voipInfo.status = voipStatus_dialing;
							voip_call_event(NULL);
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
						} else if(strncasecmp(buf,"Connecting",10) == 0)
						{
							appControlInfo.voipInfo.status = voipStatus_talking;
							voip_call_event(NULL);
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
						}
						break;
					case 'L'://Logged In/Logged out
						if( strncasecmp(buf,"Logged ",7) == 0)
						{
							appControlInfo.voipInfo.connected = buf[7] == 'I';// In/Out
							voip_loggingIn = 0;
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
							voip_fillAccountMenu(interfaceInfo.currentMenu, NULL);
						} else if( strncasecmp(buf,"Logging ",8) == 0)
						{
							appControlInfo.voipInfo.connected = 0;
							voip_loggingIn = 1;
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
							voip_fillAccountMenu(interfaceInfo.currentMenu, NULL);
						}
						break;
					case 'O':
						strcpy(appControlInfo.voipInfo.lastSip, &buf[1]);
						voip_addEntryToList(interfaceInfo.currentMenu, (void*)LIST_DIALED);
						break;
					case 'R': //Registration Failed
						if( strncasecmp( buf, "Registration Failed", 19) == 0 )
						{
							appControlInfo.voipInfo.connected = 0;
							voip_loggingIn = 0;
							voip_fillMenu(interfaceInfo.currentMenu, (void*)0);
							voip_fillAccountMenu(interfaceInfo.currentMenu, NULL);
							interface_showMessageBox(_T("ERR_VOIP_REGISTER"), thumbnail_error, 3000);
						}
						break;
					case 'E':
						break;
					default: ; // ignore
				}
				interface_displayMenu(1);
			}
		} else
		{
			//eprintf("VoIP: Error reading NOTIFY pipe\n");
			/*voip_cleanup();
			break;*/
			usleep(1000000);
		}
	}
	dprintf("%s: done\n", __FUNCTION__);
	//close(voip_socket);
	return NULL;
}
Beispiel #19
0
static int smil_inputURL(interfaceMenu_t *pMenu, char *value, void* pArg)
{
	CURLcode ret;
	CURL *hnd;
	char data[DATA_BUFF_SIZE];
	char *content_type;
	int code, length;
	char proxy[32];
	char login[512];
	char *login_ptr;
	data[0] = 0;
	errbuff[0] = 0;

	if( value == NULL)
		return 1;

	strcpy( smil_lasturl, value );

	if (strncasecmp(value, URL_HTTP_MEDIA,  sizeof(URL_HTTP_MEDIA)-1) != 0 &&
		strncasecmp(value, URL_HTTPS_MEDIA, sizeof(URL_HTTPS_MEDIA)-1) != 0)
	{
		interface_showMessageBox(_T("ERR_INCORRECT_PROTO"), thumbnail_error, 0);
		return -1;
	}

	hnd = curl_easy_init();

	curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_data);
	curl_easy_setopt(hnd, CURLOPT_WRITEDATA, data);
	curl_easy_setopt(hnd, CURLOPT_URL, value);
	curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, errbuff);
	curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 5);
	curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 15);
	getParam(BROWSER_CONFIG_FILE, "HTTPProxyServer", "", proxy);
	if( proxy[0] != 0 )
	{
		curl_easy_setopt(hnd, CURLOPT_PROXY, proxy);
		getParam(BROWSER_CONFIG_FILE, "HTTPProxyLogin", "", login);
		if( login[0] != 0 )
		{
			login_ptr = &login[strlen(login)+1];
			getParam(BROWSER_CONFIG_FILE, "HTTPProxyPasswd", "", login_ptr);
			if( *login_ptr != 0 )
			{
				login_ptr[-1] = ':';
			}
			curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, login);
		}
	}

	ret = curl_easy_perform(hnd);

	if (ret == 0)
	{
		curl_easy_getinfo(hnd, CURLINFO_RESPONSE_CODE, &code);
		if (code != 200)
		{
			ret = code > 0 ? code : -1;
			interface_showMessageBox(_T("ERR_SERVICE_UNAVAILABLE"), thumbnail_error, 0);
		} else
		{
			length = strlen(data);
			if( CURLE_OK != curl_easy_getinfo(hnd, CURLINFO_CONTENT_TYPE, &content_type) )
			{
				content_type = NULL;
			}
			dprintf("%s: Content-Type: %s\n", __FUNCTION__, content_type);
			//dprintf("%s: streams data %d:\n%s\n\n", __FUNCTION__, length, data);
		}
	}
	else
		eprintf("SMIL: Failed(%d) to get '%s' with message:\n%s\n", ret, value, errbuff);

	if ( ret == 0 )
	{
		if((ret = smil_parseRTMPStreams((const char*)data, smil_rtmpurl, sizeof(smil_rtmpurl))) == 0 )
		{
			dprintf("%s: Playing '%s'\n", __FUNCTION__, smil_rtmpurl);
			media_playURL( screenMain, smil_rtmpurl, NULL, NULL );
		}
		else
		{
			eprintf("SMIL: Failed to parse SMIL at '%s'\n", value);
			interface_showMessageBox(_T("ERR_SERVICE_UNAVAILABLE"), thumbnail_error, 0);
		}
	} else
	{
		eprintf("SMIL: Failed to get SMIL playlist from '%s'\n", value);
		interface_showMessageBox(_T("ERR_SERVICE_UNAVAILABLE"), thumbnail_error, 0);
	}

	curl_easy_cleanup(hnd);

	return ret;
}
Beispiel #20
0
static int youtube_streamChange(interfaceMenu_t *pMenu, void *pArg)
{
	CURLcode ret;
	CURL *hnd;
	char proxy[32];
	char login[512];
	char *str;
	static char url[MAX_URL];
	static char url_tmp[MAX_URL];
	static char curl_data[YOUTUBE_INFO_BUFFER_SIZE];
	static char err_buff[CURL_ERROR_SIZE];
	static curlBufferInfo_t buffer;
	char *fmt_url_map;
	//int supported_formats[] = { 18, 17, 34, 5, 0 };
	int supported_formats[] = { 34, 18, 0 };
	/* 37/1920x1080/9/0/115
	   22/1280x720/9/0/115
	   35/854x480/9/0/115
	   34/640x360/9/0/115
	   5/320x240/7/0/0 */
	char *fmt_url;
	int i;
	int len_str;
	int len_url = 0;
	int videoIndex = (int)pArg;

	if( videoIndex == CHANNEL_CUSTOM )
	{
		str = strstr( appControlInfo.mediaInfo.lastFile, "watch?v=" );
		if( str == NULL )
		{
			eprintf("%s: can't file YouTube ID in %s\n", __FUNCTION__, appControlInfo.mediaInfo.lastFile);
			interface_showMessageBox(_T("ERR_PLAY_FILE"), thumbnail_error, 3000);
			return -1;
		}
		str += 8;
		str[sizeof(youtubeInfo.current_id)-1] = 0;
		if( strlen(str) != YOUTUBE_ID_LENGTH-1 )
		{
			eprintf("%s: invalid YouTube ID %s\n", __FUNCTION__, str);
			interface_showMessageBox(_T("ERR_PLAY_FILE"), thumbnail_error, 3000);
			return -1;
		}
		memcpy( youtubeInfo.current_id, str, sizeof(youtubeInfo.current_id) );
	} else if( videoIndex < 0 || videoIndex >= youtubeInfo.count )
	{
		eprintf("%s: there is no stream %d\n", __FUNCTION__, videoIndex);
		interface_showMessageBox(_T("ERR_PLAY_FILE"), thumbnail_error, 3000);
		return -1;
	} else
	{
		memcpy( youtubeInfo.current_id, youtubeInfo.videos[videoIndex].video_id, sizeof(youtubeInfo.current_id) );
	}

	buffer.data = curl_data;
	buffer.size = sizeof(curl_data);
	buffer.pos  = 0;

	curl_data[0] = 0;
	sprintf(url,"http://www.youtube.com/get_video_info?video_id=%s%s",youtubeInfo.current_id, "&eurl=&el=detailpage&ps=default&gl=US&hl=en");
	hnd = curl_easy_init();

	curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_data);
	curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &buffer);
	curl_easy_setopt(hnd, CURLOPT_URL, url);
	curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, err_buff);
	curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 2);
	curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0);
	curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 1);
	curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 15);
	curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 15);
	getParam(BROWSER_CONFIG_FILE, "HTTPProxyServer", "", proxy);
	if( proxy[0] != 0 )
	{
		curl_easy_setopt(hnd, CURLOPT_PROXY, proxy);
		getParam(BROWSER_CONFIG_FILE, "HTTPProxyLogin", "", login);
		if( login[0] != 0 )
		{
			str = &login[strlen(login)+1];
			getParam(BROWSER_CONFIG_FILE, "HTTPProxyPasswd", "", str);
			if( *str != 0 )
			{
				str[-1] = ':';
			}
			curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, login);
		}
	}

	ret = curl_easy_perform(hnd);

	eprintf("%s: video info for %s acquired (length %d)\n", __FUNCTION__, youtubeInfo.current_id, buffer.pos);
	eprintf("%s:  YouTube URL %s\n", __FUNCTION__, url);

	curl_easy_cleanup(hnd);

	if (ret != 0)
	{
		eprintf("Youtube: Failed to get video info from '%s': %s\n", url, err_buff);
		interface_showMessageBox(_T("ERR_PLAY_FILE"), thumbnail_error, 3000);
		return 1;
	}
/*
	fmt_url_map = strstr(curl_data, "fmt_list=");
	if( fmt_url_map )
	{
		fmt_url_map += sizeof("fmt_list=")-1;
		for( str = fmt_url_map; *str && *str != '&'; str++ );
		if( *str != '&' )
			str = NULL;
		else
			*str = 0;

		if( utf8_urltomb(fmt_url_map, strlen(fmt_url_map)+1, url, sizeof(url)-1 ) > 0 )
		{
			eprintf("%s: fmt_list='%s'\n", __FUNCTION__, url);
		}
	}
*/
	//fmt_url_map = strstr(curl_data, "fmt_url_map=");
    fmt_url_map = strstr(curl_data, "url_encoded_fmt_stream_map=");
	if( fmt_url_map )
	{
		//fmt_url_map += sizeof("fmt_url_map=")-1;
		fmt_url_map += sizeof("url_encoded_fmt_stream_map=")-1;
		for( str = fmt_url_map; *str && *str != '&'; str++ );
		if( *str != '&' )
			str = NULL;
		else
			*str = 0;

		for( i = 0; supported_formats[i] != 0; i++ )
		{
			//sprintf(proxy, "%d%%7C", supported_formats[i]);
			sprintf(proxy, "itag%%3D%d", supported_formats[i]); // find format tag field
			if( (fmt_url = strstr( fmt_url_map, proxy )) != NULL )
			{
				fmt_url += strlen(proxy) + 9;// skip "%2Curl%3D"
				str = strstr( fmt_url, "%26quality" ); // find end url
				if( str )
					*str = 0;
				eprintf("%s:  URL %s\n", __FUNCTION__, fmt_url);
				if( utf8_urltomb(fmt_url, strlen(fmt_url)+1, url_tmp, sizeof(url_tmp)-1 ) < 0 )
				{
					eprintf("%s: Failed to decode '%s'\n", __FUNCTION__, fmt_url);
				} else
				{
					if( utf8_urltomb(url_tmp, strlen(url_tmp)+1, url, sizeof(url)-1 ) < 0 )
					{
						eprintf("%s: Failed to decode '%s'\n", __FUNCTION__, url_tmp);
					} else {
						eprintf("%s: selected format %d\n", __FUNCTION__, supported_formats[i]);
						break;
					}
				}
			}
		}
		if( supported_formats[i] == 0 )
		{
			interface_showMessageBox(_T("ERR_STREAM_NOT_SUPPORTED"), thumbnail_warning, 0);
			return 1;
		}
	}

	eprintf("Youtube: Playing '%s'\n", url);

	char *descr     = NULL;
	char *thumbnail = NULL;
	if( videoIndex != CHANNEL_CUSTOM )
	{
		youtubeInfo.index = videoIndex;
		if( interface_getMenuEntryInfo( (interfaceMenu_t*)&YoutubeMenu, videoIndex+1, login, sizeof(login) ) == 0 )
			descr = login;
		thumbnail = youtubeInfo.videos[videoIndex].thumbnail[0] ? youtubeInfo.videos[videoIndex].thumbnail : NULL;
		appControlInfo.playbackInfo.channel = videoIndex+1;
		appControlInfo.playbackInfo.playlistMode = playlistModeYoutube;
	} else
	{
		youtubeInfo.index = 0;
		descr     = appControlInfo.playbackInfo.description;
		thumbnail = appControlInfo.playbackInfo.thumbnail;
	}
	appControlInfo.playbackInfo.streamSource = streamSourceYoutube;
	media_playURL(screenMain, url, descr, thumbnail != NULL ? thumbnail : resource_thumbnails[thumbnail_youtube] );

	return 0;
}