[svn r498] Added function to get the current frame rate. trunk
authorrosfran
Wed Apr 04 16:12:16 2007 +0100 (2007-04-04)
branchtrunk
changeset 49332148e79242d
parent 492 63d9475228ac
child 494 f1411bd6f17e
[svn r498] Added function to get the current frame rate.
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_recorder.h
     1.1 --- a/gmyth/src/gmyth_livetv.c	Wed Apr 04 00:10:15 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_livetv.c	Wed Apr 04 16:12:16 2007 +0100
     1.3 @@ -480,27 +480,27 @@
     1.4  	{
     1.5  		gmyth_debug( "ProgramInfo is equals to NULL!!!" );
     1.6  		
     1.7 -    gint i;
     1.8 -    gchar *channame = NULL;
     1.9 -
    1.10 -    gmyth_debug( "Problem getting current proginfo!\n" );
    1.11 -
    1.12 -    /*
    1.13 -     * mythbackend must not be tuned in to a channel, so keep
    1.14 -     * changing channels until we find a valid one, or until
    1.15 -     * we decide to give up.
    1.16 -     */
    1.17 -    for (i=1; i<1000; i++) {
    1.18 -			if ( channame != NULL )
    1.19 -				g_free(channame);
    1.20 -      channame = g_strdup_printf( "%d", i );
    1.21 -      if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) {
    1.22 -      	continue;
    1.23 -      }
    1.24 -      prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP);
    1.25 -      if (prog_info != NULL)
    1.26 -      	break;
    1.27 -    }
    1.28 +        gint i;
    1.29 +        gchar *channame = NULL;
    1.30 +    
    1.31 +        gmyth_debug( "Problem getting current proginfo!\n" );
    1.32 +    
    1.33 +        /*
    1.34 +         * mythbackend must not be tuned in to a channel, so keep
    1.35 +         * changing channels until we find a valid one, or until
    1.36 +         * we decide to give up.
    1.37 +         */
    1.38 +        for (i=1; i<1000; i++) {
    1.39 +    		if ( channame != NULL )
    1.40 +    			g_free(channame);
    1.41 +            channame = g_strdup_printf( "%d", i );
    1.42 +            if (gmyth_recorder_set_channel_name(livetv->recorder, channame) < 0) {
    1.43 +                continue;
    1.44 +            }
    1.45 +            prog_info = gmyth_recorder_get_next_program_info(livetv->recorder, BROWSE_DIRECTION_UP);
    1.46 +            if (prog_info != NULL)
    1.47 +                break;
    1.48 +        }
    1.49  
    1.50  	} /* if - Program Info */
    1.51  	
     2.1 --- a/gmyth/src/gmyth_recorder.c	Wed Apr 04 00:10:15 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_recorder.c	Wed Apr 04 16:12:16 2007 +0100
     2.3 @@ -949,6 +949,7 @@
     2.4          GString *str=  NULL;
     2.5          if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL)
     2.6              pos = gmyth_util_decode_long_long( str_list, 0);
     2.7 +        g_string_free( str, TRUE );
     2.8      }
     2.9  
    2.10  #ifndef GMYTHTV_ENABLE_DEBUG
    2.11 @@ -1163,3 +1164,49 @@
    2.12  
    2.13      return ret;
    2.14  }
    2.15 +
    2.16 +/**
    2.17 + * Asks the MythTV backend server about the frame rate 
    2.18 + * of this LiveTV instance.
    2.19 + * 
    2.20 + * @param recorder The GMythRecorder instance.
    2.21 + * 
    2.22 + * @return The framerate (double value) of the current video.
    2.23 + */
    2.24 +gdouble
    2.25 +gmyth_recorder_get_framerate( GMythRecorder *recorder ) {
    2.26 +    gdouble fr = 0.0f;
    2.27 +    GString *query = g_string_new( GMYTHTV_RECORDER_HEADER);
    2.28 +
    2.29 +    GMythStringList *str_list = gmyth_string_list_new();
    2.30 +    
    2.31 +    g_mutex_lock( recorder->mutex );
    2.32 +
    2.33 +    g_string_append_printf( query, " %d", recorder->recorder_num);
    2.34 +
    2.35 +    gmyth_string_list_append_string(str_list, query);
    2.36 +    gmyth_string_list_append_char_array( str_list, "GET_FRAMERATE");
    2.37 +
    2.38 +    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
    2.39 +
    2.40 +    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
    2.41 +        GString *str=  NULL;
    2.42 +        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL)
    2.43 +            fr = g_ascii_strtod( str->str, NULL );
    2.44 +        
    2.45 +        g_string_free( str, TRUE );
    2.46 +    }
    2.47 +
    2.48 +#ifndef GMYTHTV_ENABLE_DEBUG
    2.49 +    gmyth_debug( "[%s] Got file position = %f\n", __FUNCTION__, fr);
    2.50 +#endif
    2.51 +    
    2.52 +    g_mutex_unlock( recorder->mutex );
    2.53 +
    2.54 +    if (str_list!=NULL)
    2.55 +        g_object_unref(str_list);
    2.56 +
    2.57 +    g_string_free (query, TRUE);
    2.58 +
    2.59 +    return fr;
    2.60 +}
    2.61 \ No newline at end of file
     3.1 --- a/gmyth/src/gmyth_recorder.h	Wed Apr 04 00:10:15 2007 +0100
     3.2 +++ b/gmyth/src/gmyth_recorder.h	Wed Apr 04 16:12:16 2007 +0100
     3.3 @@ -148,6 +148,8 @@
     3.4  
     3.5  gboolean    gmyth_recorder_free_tuner( GMythRecorder *recorder);
     3.6  
     3.7 +gdouble     gmyth_recorder_get_framerate( GMythRecorder *recorder );
     3.8 +
     3.9  G_END_DECLS
    3.10  
    3.11  #endif /* __GMYTH_REMOTE_ENCODER_H__ */