diff -r ce35e2e839f4 -r b90cf50ca3dc gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Fri Nov 24 18:51:42 2006 +0000 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Nov 27 21:20:57 2006 +0000 @@ -291,10 +291,10 @@ gst_mythtv_src_finalize (GObject * gobject) { GstMythtvSrc *this = GST_MYTHTV_SRC (gobject); - + if ( this->th_read_ahead != NULL ) { - gst_task_stop( this->th_read_ahead ); - this->th_read_ahead = NULL; + gst_task_stop( this->th_read_ahead ); + this->th_read_ahead = NULL; } if (this->mythtv_caps) { @@ -307,7 +307,7 @@ this->file_transfer = NULL; } - if (this->spawn_livetv) { + if (this->spawn_livetv) { g_object_unref (this->spawn_livetv); this->spawn_livetv = NULL; } @@ -319,10 +319,10 @@ if (this->user_agent) { g_free (this->user_agent); } - + if ( this->bytes_queue ) { - g_byte_array_free( this->bytes_queue, TRUE ); - this->bytes_queue = NULL; + g_byte_array_free( this->bytes_queue, TRUE ); + this->bytes_queue = NULL; } G_OBJECT_CLASS (parent_class)->finalize (gobject); @@ -536,7 +536,7 @@ get_file_pos: g_usleep( 10 ); - size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); + size_tmp = gmyth_recorder_get_file_position( src->spawn_livetv->recorder ); if ( size_tmp > ( src->content_size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) src->content_size = size_tmp; else if ( size_tmp > 0 && --max_tries > 0 ) @@ -641,7 +641,7 @@ } if ( src->live_tv ) { - gmyth_context_initialize(); + //gmyth_context_initialize(); src->spawn_livetv = gmyth_livetv_new( ); if ( gmyth_livetv_setup( src->spawn_livetv ) == FALSE ) { ret = FALSE; @@ -653,21 +653,27 @@ chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain ); if ( chain_id_local != NULL ) { src->live_chain_id = g_strdup( chain_id_local->str ); - GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id ); + GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id ); } + if ( src->uri_name == NULL || strlen( src->uri_name ) <= 0 ) + gmyth_context_initialize(); + src->live_tv_id = src->spawn_livetv->recorder->recorder_num; GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); } - src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, - g_string_new( src->uri_name ), -1, src->mythtv_version ); + //src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, + // g_string_new( src->uri_name ), -1, src->mythtv_version ); + src->file_transfer = gmyth_file_transfer_new( ); if ( src->file_transfer == NULL ) { goto init_failed; } + ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) ); + /* sets the Playback monitor connection */ - ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv ); + //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv ); if ( src->live_tv == TRUE && ret == TRUE ) { /* loop finished, set the max tries variable to zero again... */ @@ -680,11 +686,11 @@ /* IS_RECORDING again, just like the MythTV backend does... */ gmyth_livetv_is_recording( src->spawn_livetv ); - sleep( 5 ); + sleep( 4 ); } /* sets the FileTransfer instance connection (video/audio download) */ - ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); + //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); if ( ret == FALSE ) { #ifndef GST_DISABLE_GST_DEBUG @@ -697,12 +703,13 @@ src->content_size = src->file_transfer->filesize; src->do_start = FALSE; - + + /* this is used for the buffer cache */ src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE ); - //src->th_read_ahead = gst_task_create( (GstTaskFunction)gst_mythtv_src_read_ahead, src ); - //gst_task_set_lock( src->th_read_ahead, &th_mutex ); - //gst_task_start( src->th_read_ahead ); src->buffer_remain = 0; + + //gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)), + // gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) ); done: return TRUE; @@ -787,15 +794,16 @@ GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); } - src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, - g_string_new( src->uri_name ), -1, src->mythtv_version ); + src->file_transfer = gmyth_file_transfer_new(); if ( src->file_transfer == NULL ) { goto init_failed; } + + ret = gmyth_file_transfer_open( src->file_transfer, g_string_new( src->uri_name ) ); /* sets the Playback monitor connection */ - ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv ); + //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv ); if ( src->live_tv == TRUE && ret == TRUE ) { /* loop finished, set the max tries variable to zero again... */ @@ -809,7 +817,7 @@ } /* sets the FileTransfer instance connection (video/audio download) */ - ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); + //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); if ( ret == FALSE ) { #ifndef GST_DISABLE_GST_DEBUG @@ -835,6 +843,9 @@ src->bytes_queue = g_byte_array_sized_new( INTERNAL_BUFFER_SIZE ); + //gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (src)), + // gst_event_new_new_segment ( TRUE, 1.0, GST_FORMAT_TIME, 0, src->content_size, 0 ) ); + done: src->update_prog_chain = FALSE; @@ -874,7 +885,7 @@ } else if ( src->live_tv && src->enable_timing_position && ( abs( src->content_size - src->bytes_read ) < GMYTHTV_TRANSFER_MAX_BUFFER ) ) { - gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); + gint64 new_offset = gmyth_recorder_get_file_position( src->spawn_livetv->recorder ); if ( new_offset > 0 && new_offset > src->content_size ) { src->content_size = new_offset; } else if ( new_offset < src->content_size ) { @@ -935,38 +946,8 @@ gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL ); gst_element_set_locked_state ( GST_ELEMENT (src), FALSE ); } - } else - src->eos = TRUE; - ret = TRUE; + } break; - case GST_EVENT_NEWSEGMENT: - GST_INFO_OBJECT( src, "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ ); - ret = gst_pad_event_default (pad, event); - break; - case GST_EVENT_SEEK: - { - gst_event_ref( event ); - - gdouble rate; - GstFormat format; - GstSeekType cur_type, stop_type; - GstSeekFlags flags; - gint64 cur = 0, stop = 0; - gst_event_parse_seek ( event, &rate, &format, - &flags, &cur_type, &cur, - &stop_type, &stop ); - - GST_INFO_OBJECT( src, "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur ); - if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) { - GST_WARNING_OBJECT( src, "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ ); - } - if ( format == GST_FORMAT_TIME && ( ret = gst_pad_event_default (pad, event) ) == FALSE ) { - gst_event_unref( event ); - break; - } - - break; - } default: ret = gst_pad_event_default (pad, event); } @@ -985,15 +966,22 @@ { gboolean res = FALSE; GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad)); + GstFormat formt; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: - gst_query_set_position (query, GST_FORMAT_BYTES, - myth->read_offset ); + { + gint64 pos = -1; + gst_query_parse_position (query, &formt, &pos ); res = TRUE; - GST_DEBUG_OBJECT (myth, "POS %d", myth->read_offset); + if ( formt == GST_FORMAT_BYTES ) + GST_DEBUG_OBJECT (myth, "POS %lld (BYTES).\n", pos ); + else if ( formt == GST_FORMAT_TIME ) + GST_DEBUG_OBJECT (myth, "POS %lld (TIME).\n", pos ); break; + } case GST_QUERY_DURATION: + { #if 0 if (myth->duration != 0) { gint64 total; @@ -1001,14 +989,23 @@ fps = nuv->h->i_fpsn / nuv->h->i_fpsd; total = gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps); + } #endif + gint64 dur = -1; + gst_query_parse_duration( query, &formt, &dur ); //gst_query_set_duration (query, GST_FORMAT_TIME, myth->content_size); - GST_DEBUG_OBJECT (myth, "DURATION %d", myth->content_size); - res = FALSE; + if ( formt == GST_FORMAT_BYTES ) + GST_DEBUG_OBJECT (myth, "DURATION %lld (BYTES).\n", dur ); + else if ( formt == GST_FORMAT_TIME ) + GST_DEBUG_OBJECT (myth, "DURATION %lld (TIME).\n", dur ); + res = TRUE; break; + } default: + { res = FALSE; break; + } } gst_object_unref (myth);