# HG changeset patch # User rosfran # Date 1175699536 -3600 # Node ID 32148e79242d3c45c4ec8115f04de6e73f9442ca # Parent 63d9475228ac71dfa1a78cf41475363b979c083d [svn r498] Added function to get the current frame rate. diff -r 63d9475228ac -r 32148e79242d gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Wed Apr 04 00:10:15 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Wed Apr 04 16:12:16 2007 +0100 @@ -480,27 +480,27 @@ { gmyth_debug( "ProgramInfo is equals to NULL!!!" ); - gint i; - gchar *channame = NULL; - - gmyth_debug( "Problem getting current proginfo!\n" ); - - /* - * mythbackend must not be tuned in to a channel, so keep - * changing channels until we find a valid one, or until - * we decide to give up. - */ - for (i=1; i<1000; i++) { - if ( channame != NULL ) - g_free(channame); - channame = g_strdup_printf( "%d", i ); - if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) { - continue; - } - prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP); - if (prog_info != NULL) - break; - } + gint i; + gchar *channame = NULL; + + gmyth_debug( "Problem getting current proginfo!\n" ); + + /* + * mythbackend must not be tuned in to a channel, so keep + * changing channels until we find a valid one, or until + * we decide to give up. + */ + for (i=1; i<1000; i++) { + if ( channame != NULL ) + g_free(channame); + channame = g_strdup_printf( "%d", i ); + if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) { + continue; + } + prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP); + if (prog_info != NULL) + break; + } } /* if - Program Info */ diff -r 63d9475228ac -r 32148e79242d gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Wed Apr 04 00:10:15 2007 +0100 +++ b/gmyth/src/gmyth_recorder.c Wed Apr 04 16:12:16 2007 +0100 @@ -949,6 +949,7 @@ GString *str= NULL; if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL) pos = gmyth_util_decode_long_long( str_list, 0); + g_string_free( str, TRUE ); } #ifndef GMYTHTV_ENABLE_DEBUG @@ -1163,3 +1164,49 @@ return ret; } + +/** + * Asks the MythTV backend server about the frame rate + * of this LiveTV instance. + * + * @param recorder The GMythRecorder instance. + * + * @return The framerate (double value) of the current video. + */ +gdouble +gmyth_recorder_get_framerate( GMythRecorder *recorder ) { + gdouble fr = 0.0f; + GString *query = g_string_new( GMYTHTV_RECORDER_HEADER); + + GMythStringList *str_list = gmyth_string_list_new(); + + g_mutex_lock( recorder->mutex ); + + g_string_append_printf( query, " %d", recorder->recorder_num); + + gmyth_string_list_append_string(str_list, query); + gmyth_string_list_append_char_array( str_list, "GET_FRAMERATE"); + + gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list); + + if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) { + GString *str= NULL; + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL) + fr = g_ascii_strtod( str->str, NULL ); + + g_string_free( str, TRUE ); + } + +#ifndef GMYTHTV_ENABLE_DEBUG + gmyth_debug( "[%s] Got file position = %f\n", __FUNCTION__, fr); +#endif + + g_mutex_unlock( recorder->mutex ); + + if (str_list!=NULL) + g_object_unref(str_list); + + g_string_free (query, TRUE); + + return fr; +} \ No newline at end of file diff -r 63d9475228ac -r 32148e79242d gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Wed Apr 04 00:10:15 2007 +0100 +++ b/gmyth/src/gmyth_recorder.h Wed Apr 04 16:12:16 2007 +0100 @@ -148,6 +148,8 @@ gboolean gmyth_recorder_free_tuner( GMythRecorder *recorder); +gdouble gmyth_recorder_get_framerate( GMythRecorder *recorder ); + G_END_DECLS #endif /* __GMYTH_REMOTE_ENCODER_H__ */