[svn r115] Some API changes. trunk
authorrosfran
Mon Nov 27 19:24:43 2006 +0000 (2006-11-27)
branchtrunk
changeset 11404cead6ae39b
parent 113 7dcc53d63f37
child 115 9f3c698e34a7
[svn r115] Some API changes.
gst-plugins-mythtv/src/gstmythtvsrc.c
     1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c	Fri Nov 24 21:49:40 2006 +0000
     1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c	Mon Nov 27 19:24:43 2006 +0000
     1.3 @@ -291,10 +291,10 @@
     1.4  gst_mythtv_src_finalize (GObject * gobject)
     1.5  {
     1.6    GstMythtvSrc *this = GST_MYTHTV_SRC (gobject);
     1.7 -  
     1.8 +
     1.9    if ( this->th_read_ahead != NULL ) {
    1.10 -  	gst_task_stop( this->th_read_ahead );
    1.11 -  	this->th_read_ahead = NULL;
    1.12 +    gst_task_stop( this->th_read_ahead );
    1.13 +    this->th_read_ahead = NULL;
    1.14    }
    1.15  
    1.16    if (this->mythtv_caps) {
    1.17 @@ -307,7 +307,7 @@
    1.18      this->file_transfer = NULL;
    1.19    }
    1.20  
    1.21 -	if (this->spawn_livetv) {
    1.22 +  if (this->spawn_livetv) {
    1.23      g_object_unref (this->spawn_livetv);
    1.24      this->spawn_livetv = NULL;
    1.25    }
    1.26 @@ -319,10 +319,10 @@
    1.27    if (this->user_agent) {
    1.28      g_free (this->user_agent);
    1.29    }
    1.30 -  
    1.31 +
    1.32    if ( this->bytes_queue ) {
    1.33 -  	g_byte_array_free( this->bytes_queue, TRUE );
    1.34 -  	this->bytes_queue = NULL;
    1.35 +    g_byte_array_free( this->bytes_queue, TRUE );
    1.36 +    this->bytes_queue = NULL;
    1.37    }
    1.38  
    1.39    G_OBJECT_CLASS (parent_class)->finalize (gobject);
    1.40 @@ -536,7 +536,7 @@
    1.41  
    1.42  get_file_pos:
    1.43      g_usleep( 10 );
    1.44 -    size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer );
    1.45 +    size_tmp = gmyth_recorder_get_file_position( src->spawn_livetv->recorder );
    1.46      if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) )
    1.47        src->content_size = size_tmp;
    1.48      else if ( size_tmp > 0 && --max_tries > 0 )
    1.49 @@ -641,7 +641,7 @@
    1.50    }
    1.51  
    1.52    if ( src->live_tv ) {
    1.53 -  	gmyth_context_initialize();
    1.54 +  	//gmyth_context_initialize();
    1.55      src->spawn_livetv = gmyth_livetv_new( );
    1.56      if ( gmyth_livetv_setup( src->spawn_livetv ) == FALSE ) {
    1.57        ret = FALSE;
    1.58 @@ -653,21 +653,27 @@
    1.59      chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
    1.60      if ( chain_id_local != NULL ) {
    1.61        src->live_chain_id = g_strdup( chain_id_local->str );
    1.62 -      GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
    1.63 +      GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );      
    1.64      }
    1.65 +    if ( src->uri_name == NULL || strlen( src->uri_name ) <= 0 )
    1.66 +    	gmyth_context_initialize();
    1.67 +    	
    1.68      src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
    1.69      GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); 
    1.70    }
    1.71  
    1.72 -  src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
    1.73 -      g_string_new( src->uri_name ), -1, src->mythtv_version );
    1.74 +  //src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
    1.75 +  //    g_string_new( src->uri_name ), -1, src->mythtv_version );
    1.76 +	src->file_transfer = gmyth_file_transfer_new( );
    1.77  
    1.78    if ( src->file_transfer == NULL ) {
    1.79      goto init_failed;
    1.80    }
    1.81  
    1.82 +	ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) );
    1.83 +
    1.84    /* sets the Playback monitor connection */
    1.85 -  ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
    1.86 +  //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
    1.87  
    1.88    if ( src->live_tv == TRUE && ret == TRUE ) {
    1.89      /* loop finished, set the max tries variable to zero again... */
    1.90 @@ -680,11 +686,11 @@
    1.91      /* IS_RECORDING again, just like the MythTV backend does... */
    1.92  	  gmyth_livetv_is_recording( src->spawn_livetv );
    1.93  	  
    1.94 -	  sleep( 5 );  
    1.95 +	  sleep( 4 );  
    1.96  
    1.97    }
    1.98    /* sets the FileTransfer instance connection (video/audio download) */
    1.99 -  ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
   1.100 +  //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
   1.101  
   1.102    if ( ret == FALSE ) {
   1.103  #ifndef GST_DISABLE_GST_DEBUG  
   1.104 @@ -697,12 +703,13 @@
   1.105    src->content_size = src->file_transfer->filesize;
   1.106  
   1.107    src->do_start = FALSE;
   1.108 -
   1.109 +  
   1.110 +  /* this is used for the buffer cache */
   1.111    src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
   1.112 -  //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src );
   1.113 -  //gst_task_set_lock( src->th_read_ahead, &th_mutex );
   1.114 -  //gst_task_start( src->th_read_ahead );
   1.115    src->buffer_remain = 0;
   1.116 +  
   1.117 +  //gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
   1.118 +	//		gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) );
   1.119  
   1.120  done:
   1.121    return TRUE;
   1.122 @@ -787,15 +794,16 @@
   1.123      GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
   1.124    }
   1.125  
   1.126 -  src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
   1.127 -      g_string_new( src->uri_name ), -1, src->mythtv_version );
   1.128 +  src->file_transfer = gmyth_file_transfer_new();
   1.129  
   1.130    if ( src->file_transfer == NULL ) {
   1.131      goto init_failed;
   1.132    }
   1.133 +  
   1.134 +	ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) );
   1.135  
   1.136    /* sets the Playback monitor connection */
   1.137 -  ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
   1.138 +  //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
   1.139  
   1.140    if ( src->live_tv == TRUE && ret == TRUE ) {
   1.141      /* loop finished, set the max tries variable to zero again... */
   1.142 @@ -809,7 +817,7 @@
   1.143    }
   1.144  
   1.145    /* sets the FileTransfer instance connection (video/audio download) */
   1.146 -  ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
   1.147 +  //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
   1.148  
   1.149    if ( ret == FALSE ) {
   1.150  #ifndef GST_DISABLE_GST_DEBUG  
   1.151 @@ -835,6 +843,9 @@
   1.152    
   1.153    src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE );
   1.154    
   1.155 +  //gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
   1.156 +	//		gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) );
   1.157 +  
   1.158  done:
   1.159  	src->update_prog_chain = FALSE;
   1.160  	
   1.161 @@ -874,7 +885,7 @@
   1.162  	} else if ( src->live_tv && src->enable_timing_position && ( abs( src->content_size - src->bytes_read ) < 
   1.163  				GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
   1.164      
   1.165 -    gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer );
   1.166 +    gint64 new_offset = gmyth_recorder_get_file_position( src->spawn_livetv->recorder );
   1.167      if ( new_offset > 0 && new_offset > src->content_size ) {
   1.168  			src->content_size = new_offset;
   1.169      } else if ( new_offset < src->content_size ) {
   1.170 @@ -935,38 +946,8 @@
   1.171  	  gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL );
   1.172  	  gst_element_set_locked_state ( GST_ELEMENT (src), FALSE );
   1.173  	}
   1.174 -      } else 
   1.175 -	src->eos = TRUE;
   1.176 -      ret = TRUE;
   1.177 +      }
   1.178        break;
   1.179 -    case GST_EVENT_NEWSEGMENT:
   1.180 -      GST_INFO_OBJECT( src, "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ );
   1.181 -      ret = gst_pad_event_default (pad, event);
   1.182 -      break;
   1.183 -    case GST_EVENT_SEEK:  	  
   1.184 -      {
   1.185 -	gst_event_ref( event );
   1.186 -
   1.187 -	gdouble rate;
   1.188 -	GstFormat format;
   1.189 -	GstSeekType cur_type, stop_type;
   1.190 -	GstSeekFlags flags;
   1.191 -	gint64 cur = 0, stop = 0;
   1.192 -	gst_event_parse_seek ( event, &rate, &format,
   1.193 -	    &flags, &cur_type, &cur,
   1.194 -	    &stop_type, &stop );
   1.195 -
   1.196 -	GST_INFO_OBJECT( src, "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur );
   1.197 -	if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) {
   1.198 -	  GST_WARNING_OBJECT( src, "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ );
   1.199 -	}
   1.200 -	if ( format == GST_FORMAT_TIME && ( ret = gst_pad_event_default (pad, event) ) == FALSE ) {
   1.201 -	  gst_event_unref( event );
   1.202 -	  break;
   1.203 -	}
   1.204 -	
   1.205 -	break;
   1.206 -      }
   1.207      default:
   1.208        ret = gst_pad_event_default (pad, event);
   1.209    }
   1.210 @@ -985,15 +966,22 @@
   1.211  {
   1.212    gboolean res = FALSE;
   1.213    GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
   1.214 +  GstFormat formt;
   1.215  
   1.216    switch (GST_QUERY_TYPE (query)) {
   1.217      case GST_QUERY_POSITION:
   1.218 -      gst_query_set_position (query, GST_FORMAT_BYTES,
   1.219 -	  myth->read_offset );
   1.220 +    {
   1.221 +    	gint64 pos = -1;
   1.222 +      gst_query_parse_position (query, &formt, &pos );
   1.223        res = TRUE;
   1.224 -      GST_DEBUG_OBJECT (myth, "POS %d", myth->read_offset);
   1.225 +      if ( formt == GST_FORMAT_BYTES )
   1.226 +      	GST_DEBUG_OBJECT (myth, "POS %lld (BYTES).\n", pos );
   1.227 +      else if ( formt == GST_FORMAT_TIME )
   1.228 +      	GST_DEBUG_OBJECT (myth, "POS %lld (TIME).\n", pos );
   1.229        break;
   1.230 +    }
   1.231      case GST_QUERY_DURATION:
   1.232 +    {
   1.233  #if 0
   1.234        if (myth->duration != 0) {
   1.235  	gint64 total;
   1.236 @@ -1001,14 +989,23 @@
   1.237  
   1.238  	fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
   1.239  	total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
   1.240 +      }
   1.241  #endif
   1.242 +	gint64 dur = -1;
   1.243 +	gst_query_parse_duration( query, &formt, &dur );
   1.244  	//gst_query_set_duration (query, GST_FORMAT_TIME, myth->content_size);
   1.245 -	GST_DEBUG_OBJECT (myth, "DURATION %d", myth->content_size);
   1.246 -	res = FALSE;
   1.247 +  if ( formt == GST_FORMAT_BYTES )
   1.248 +  	GST_DEBUG_OBJECT (myth, "DURATION %lld (BYTES).\n", dur );
   1.249 +  else if ( formt == GST_FORMAT_TIME )
   1.250 +  	GST_DEBUG_OBJECT (myth, "DURATION %lld (TIME).\n", dur );
   1.251 +	res = TRUE;
   1.252        break;
   1.253 +    }
   1.254      default:
   1.255 +    {
   1.256        res = FALSE;
   1.257        break;
   1.258 +    }
   1.259    }
   1.260  
   1.261    gst_object_unref (myth);