[svn r288] Some refinements to put the change channel functions working.
1.1 --- a/gmyth/src/gmyth_livetv.c Fri Jan 19 22:05:38 2007 +0000
1.2 +++ b/gmyth/src/gmyth_livetv.c Sat Jan 20 00:20:20 2007 +0000
1.3 @@ -247,7 +247,9 @@
1.4 res = FALSE;
1.5 goto error;
1.6 }
1.7 -
1.8 +
1.9 + //livetv->recorder = GMYTH_RECORDER ( g_object_new(GMYTH_RECORDER_TYPE, NULL) );
1.10 +
1.11 livetv->is_livetv = TRUE;
1.12
1.13 livetv->local_hostname = gmyth_socket_get_local_hostname ();
1.14 @@ -267,6 +269,14 @@
1.15 goto error;
1.16 }
1.17
1.18 + // Init remote encoder. Opens its control socket.
1.19 + res = gmyth_recorder_setup(livetv->recorder);
1.20 + if ( !res ) {
1.21 + g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
1.22 + res = FALSE;
1.23 + goto error;
1.24 + }
1.25 +
1.26 // Creates livetv chain handler
1.27 livetv->tvchain = GMYTH_TVCHAIN ( g_object_new(GMYTH_TVCHAIN_TYPE, NULL) );
1.28 gmyth_tvchain_initialize ( livetv->tvchain, livetv->backend_info );
1.29 @@ -276,27 +286,6 @@
1.30 goto error;
1.31 }
1.32
1.33 - // Init remote encoder. Opens its control socket.
1.34 - res = gmyth_recorder_setup(livetv->recorder);
1.35 - if ( !res ) {
1.36 - g_warning ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
1.37 - res = FALSE;
1.38 - goto error;
1.39 - }
1.40 -
1.41 - if ( channel != -1 )
1.42 - {
1.43 - gint ch = channel;
1.44 - //if ( gmyth_recorder_check_channel( livetv->recorder, ch ) )
1.45 - //{
1.46 - if ( gmyth_recorder_set_channel( livetv->recorder, ch ) )
1.47 - {
1.48 - g_print( "[%s] Channel changed!!! [%d].\n", __FUNCTION__, ch );
1.49 - }
1.50 - //}
1.51 -
1.52 - }
1.53 -
1.54 // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
1.55 res = gmyth_recorder_spawntv ( livetv->recorder,
1.56 gmyth_tvchain_get_id(livetv->tvchain) );
1.57 @@ -314,6 +303,20 @@
1.58 goto error;
1.59 }
1.60
1.61 +/*
1.62 + if ( channel != -1 )
1.63 + {
1.64 + gint ch = channel;
1.65 + //if ( gmyth_recorder_check_channel( livetv->recorder, ch ) )
1.66 + //{
1.67 + if ( gmyth_recorder_set_channel_name( livetv->recorder, "abc1" ) )
1.68 + {
1.69 + g_print( "[%s] Channel changed!!! abc1 [%d].\n", __FUNCTION__, ch );
1.70 + }
1.71 + //}
1.72 +
1.73 + }
1.74 +*/
1.75 // Get program info from database using chanid and starttime
1.76 livetv->proginfo = gmyth_tvchain_get_program_at (livetv->tvchain, tvchain_curr_index++ );
1.77 if ( livetv->proginfo == NULL ) {
2.1 --- a/gmyth/src/gmyth_recorder.c Fri Jan 19 22:05:38 2007 +0000
2.2 +++ b/gmyth/src/gmyth_recorder.c Sat Jan 20 00:20:20 2007 +0000
2.3 @@ -342,6 +342,92 @@
2.4
2.5 }
2.6
2.7 +/** Send a SET_CHANNEL command request to the backend, to start streaming on another
2.8 + * TV content channel.
2.9 + *
2.10 + * @param recorder The GMythRecorder instance.
2.11 + * @param channel The new channel to be loaded.
2.12 + * @return true if success, false if any error happens.
2.13 + */
2.14 +gboolean
2.15 +gmyth_recorder_set_channel_name (GMythRecorder *recorder, const gchar* channel)
2.16 +{
2.17 + GMythStringList *str_list;
2.18 + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
2.19 +
2.20 + gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel);
2.21 +
2.22 + str_list = gmyth_string_list_new ();
2.23 +
2.24 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
2.25 +
2.26 + gmyth_string_list_append_string (str_list, tmp_str);
2.27 + gmyth_string_list_append_string (str_list, g_string_new ("SET_CHANNEL"));
2.28 + gmyth_string_list_append_char_array (str_list, channel);
2.29 +
2.30 + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
2.31 +
2.32 + g_string_free (tmp_str, TRUE);
2.33 +
2.34 + tmp_str = gmyth_string_list_get_string (str_list, 0);
2.35 + if (tmp_str == NULL) {
2.36 + g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
2.37 + return FALSE;
2.38 + }
2.39 +
2.40 + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) {
2.41 + g_warning ("[%s] SET_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
2.42 + g_object_unref (str_list);
2.43 + return FALSE;
2.44 + }
2.45 +
2.46 + g_object_unref (str_list);
2.47 + return TRUE;
2.48 +
2.49 +}
2.50 +
2.51 +/** Send a PAUSE command request to the backend, to pause streaming on another
2.52 + * TV content channel.
2.53 + *
2.54 + * @param recorder The GMythRecorder instance.
2.55 + * @return true if success, false if any error happens.
2.56 + */
2.57 +gboolean
2.58 +gmyth_recorder_pause_recording ( GMythRecorder *recorder )
2.59 +{
2.60 + GMythStringList *str_list;
2.61 + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
2.62 +
2.63 + gmyth_debug ("[%s] PAUSE", __FUNCTION__);
2.64 +
2.65 + str_list = gmyth_string_list_new ();
2.66 +
2.67 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
2.68 +
2.69 + gmyth_string_list_append_string (str_list, tmp_str);
2.70 + gmyth_string_list_append_string (str_list, g_string_new ("PAUSE"));
2.71 +
2.72 + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
2.73 +
2.74 + g_string_free (tmp_str, TRUE);
2.75 +
2.76 + tmp_str = gmyth_string_list_get_string (str_list, 0);
2.77 + if (tmp_str == NULL) {
2.78 + g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
2.79 + return FALSE;
2.80 + }
2.81 +
2.82 + if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
2.83 + g_warning ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
2.84 + g_object_unref (str_list);
2.85 + return FALSE;
2.86 + }
2.87 +
2.88 + g_object_unref (str_list);
2.89 + return TRUE;
2.90 +
2.91 +}
2.92 +
2.93 gint64
2.94 gmyth_recorder_get_file_position ( GMythRecorder *recorder )
2.95 {
3.1 --- a/gmyth/src/gmyth_recorder.h Fri Jan 19 22:05:38 2007 +0000
3.2 +++ b/gmyth/src/gmyth_recorder.h Sat Jan 20 00:20:20 2007 +0000
3.3 @@ -89,7 +89,12 @@
3.4 gboolean gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel);
3.5
3.6 gboolean gmyth_recorder_set_channel (GMythRecorder *recorder,
3.7 - gint channel);
3.8 + gint channel);
3.9 +
3.10 +gboolean gmyth_recorder_set_channel_name (GMythRecorder *recorder,
3.11 + const gchar* channel);
3.12 +
3.13 +gboolean gmyth_recorder_pause_recording ( GMythRecorder *recorder );
3.14
3.15 gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder );
3.16
4.1 --- a/gmyth/src/gmyth_tvchain.c Fri Jan 19 22:05:38 2007 +0000
4.2 +++ b/gmyth/src/gmyth_tvchain.c Sat Jan 20 00:20:20 2007 +0000
4.3 @@ -226,7 +226,7 @@
4.4 entry->inputname = g_string_new (msql_row[8]);
4.5
4.6 //m_maxpos = query.value(4).toInt() + 1;
4.7 - g_print( "[%s] Reading TV chain entry (channel %d): [%s, %s, %s]\n", __FUNCTION__, entry->channum, entry->chanid->str,
4.8 + g_print( "[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n", __FUNCTION__, entry->channum->str, entry->chanid->str,
4.9 (gchar*)msql_row[1], (gchar*)msql_row[2] );
4.10
4.11 /* add this to get the actual start timestamp of the last recording */