# HG changeset patch # User rosfran # Date 1169252420 0 # Node ID 42ce5f7bfa6ecb6bd4de3c3aca8638d907311f7c # Parent 8aa82fdb715ef69d503fa726b6a4cc38f0a49a82 [svn r288] Some refinements to put the change channel functions working. diff -r 8aa82fdb715e -r 42ce5f7bfa6e gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Fri Jan 19 22:05:38 2007 +0000 +++ b/gmyth/src/gmyth_livetv.c Sat Jan 20 00:20:20 2007 +0000 @@ -247,7 +247,9 @@ res = FALSE; goto error; } - + + //livetv->recorder = GMYTH_RECORDER ( g_object_new(GMYTH_RECORDER_TYPE, NULL) ); + livetv->is_livetv = TRUE; livetv->local_hostname = gmyth_socket_get_local_hostname (); @@ -267,6 +269,14 @@ goto error; } + // Init remote encoder. Opens its control socket. + res = gmyth_recorder_setup(livetv->recorder); + if ( !res ) { + g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__); + res = FALSE; + goto error; + } + // Creates livetv chain handler livetv->tvchain = GMYTH_TVCHAIN ( g_object_new(GMYTH_TVCHAIN_TYPE, NULL) ); gmyth_tvchain_initialize ( livetv->tvchain, livetv->backend_info ); @@ -276,27 +286,6 @@ goto error; } - // Init remote encoder. Opens its control socket. - res = gmyth_recorder_setup(livetv->recorder); - if ( !res ) { - g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__); - res = FALSE; - goto error; - } - - if ( channel != -1 ) - { - gint ch = channel; - //if ( gmyth_recorder_check_channel( livetv->recorder, ch ) ) - //{ - if ( gmyth_recorder_set_channel( livetv->recorder, ch ) ) - { - g_print( "[%s] Channel changed!!! [%d].\n", __FUNCTION__, ch ); - } - //} - - } - // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) res = gmyth_recorder_spawntv ( livetv->recorder, gmyth_tvchain_get_id(livetv->tvchain) ); @@ -314,6 +303,20 @@ goto error; } +/* + if ( channel != -1 ) + { + gint ch = channel; + //if ( gmyth_recorder_check_channel( livetv->recorder, ch ) ) + //{ + if ( gmyth_recorder_set_channel_name( livetv->recorder, "abc1" ) ) + { + g_print( "[%s] Channel changed!!! abc1 [%d].\n", __FUNCTION__, ch ); + } + //} + + } +*/ // Get program info from database using chanid and starttime livetv->proginfo = gmyth_tvchain_get_program_at (livetv->tvchain, tvchain_curr_index++ ); if ( livetv->proginfo == NULL ) { diff -r 8aa82fdb715e -r 42ce5f7bfa6e gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Fri Jan 19 22:05:38 2007 +0000 +++ b/gmyth/src/gmyth_recorder.c Sat Jan 20 00:20:20 2007 +0000 @@ -342,6 +342,92 @@ } +/** Send a SET_CHANNEL command request to the backend, to start streaming on another + * TV content channel. + * + * @param recorder The GMythRecorder instance. + * @param channel The new channel to be loaded. + * @return true if success, false if any error happens. + */ +gboolean +gmyth_recorder_set_channel_name (GMythRecorder *recorder, const gchar* channel) +{ + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); + + gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL")); + gmyth_string_list_append_char_array (str_list, channel); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + + g_string_free (tmp_str, TRUE); + + tmp_str = gmyth_string_list_get_string (str_list, 0); + if (tmp_str == NULL) { + g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str ); + return FALSE; + } + + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) { + g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; + } + + g_object_unref (str_list); + return TRUE; + +} + +/** Send a PAUSE command request to the backend, to pause streaming on another + * TV content channel. + * + * @param recorder The GMythRecorder instance. + * @return true if success, false if any error happens. + */ +gboolean +gmyth_recorder_pause_recording ( GMythRecorder *recorder ) +{ + GMythStringList *str_list; + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); + + gmyth_debug ("[%s] PAUSE", __FUNCTION__); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string (str_list, g_string_new ("PAUSE")); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + + g_string_free (tmp_str, TRUE); + + tmp_str = gmyth_string_list_get_string (str_list, 0); + if (tmp_str == NULL) { + g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); + return FALSE; + } + + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { + g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str); + g_object_unref (str_list); + return FALSE; + } + + g_object_unref (str_list); + return TRUE; + +} + gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder ) { diff -r 8aa82fdb715e -r 42ce5f7bfa6e gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Fri Jan 19 22:05:38 2007 +0000 +++ b/gmyth/src/gmyth_recorder.h Sat Jan 20 00:20:20 2007 +0000 @@ -89,7 +89,12 @@ gboolean gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel); gboolean gmyth_recorder_set_channel (GMythRecorder *recorder, - gint channel); + gint channel); + +gboolean gmyth_recorder_set_channel_name (GMythRecorder *recorder, + const gchar* channel); + +gboolean gmyth_recorder_pause_recording ( GMythRecorder *recorder ); gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder ); diff -r 8aa82fdb715e -r 42ce5f7bfa6e gmyth/src/gmyth_tvchain.c --- a/gmyth/src/gmyth_tvchain.c Fri Jan 19 22:05:38 2007 +0000 +++ b/gmyth/src/gmyth_tvchain.c Sat Jan 20 00:20:20 2007 +0000 @@ -226,7 +226,7 @@ entry->inputname = g_string_new (msql_row[8]); //m_maxpos = query.value(4).toInt() + 1; - g_print( "[%s] Reading TV chain entry (channel %d): [%s, %s, %s]\n", __FUNCTION__, entry->channum, entry->chanid->str, + g_print( "[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n", __FUNCTION__, entry->channum->str, entry->chanid->str, (gchar*)msql_row[1], (gchar*)msql_row[2] ); /* add this to get the actual start timestamp of the last recording */