diff -r 2db0e1da044a -r 58bc1bd585e3 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Nov 30 21:29:54 2006 +0000 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Dec 04 15:10:05 2006 +0000 @@ -424,8 +424,7 @@ (gint) src->buffer_remain, src->bytes_queue->len ); /* just get from the byte array, no network effort... */ - if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE && - abs( src->content_size - src->bytes_read ) > MAX_READ_SIZE ) { + if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) { //( ( INTERNAL_BUFFER_SIZE - src->buffer_remain ) >= REQUEST_MAX_SIZE ) ) { GByteArray *buffer = NULL; guint buffer_size_inter = ( INTERNAL_BUFFER_SIZE - src->buffer_remain ); @@ -441,8 +440,13 @@ goto change_progchain; else goto read_error; - } else if (G_UNLIKELY (read == 0) && !src->live_tv ) - goto done; + } else if (G_UNLIKELY (read == 0)) + { + if (!src->live_tv ) + goto eos; + else + goto done; + } if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; @@ -487,8 +491,8 @@ read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain ); GST_BUFFER_SIZE (*outbuf) = buffer_size; - //GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) ); - //GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf ); + GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) ); + GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf ); g_memmove( GST_BUFFER_DATA( (*outbuf) ), src->bytes_queue->data, GST_BUFFER_SIZE(*outbuf) ); GST_BUFFER_OFFSET (*outbuf) = src->read_offset; GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf); @@ -654,10 +658,9 @@ gst_mythtv_src_start ( GstBaseSrc * bsrc ) { GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc); - GMythURI *gmyth_uri = NULL; - gchar* filename = NULL; GString *chain_id_local = NULL; + gboolean ret = TRUE; if ( G_UNLIKELY (src->update_prog_chain) ) @@ -668,19 +671,15 @@ } else { goto done; } - -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); + src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name ); - -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - if ( src->live_tv ) { + if ( src->live_tv ) { src->spawn_livetv = gmyth_livetv_new( ); if ( gmyth_livetv_setup( src->spawn_livetv, src->backend_info ) == FALSE ) { ret = FALSE; goto init_failed; } -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); /* set up the uri variable */ src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str ); chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain ); @@ -688,30 +687,26 @@ 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 ); } + //if ( src->uri_name == NULL || strlen( src->uri_name ) <= 0 ) + // gmyth_context_initialize(); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); 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 ); } -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - src->file_transfer = gmyth_file_transfer_new( src->backend_info ); + //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->backend_info); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); if ( src->file_transfer == NULL ) { goto init_failed; } GST_INFO_OBJECT( src, "[%s] uri = %s.\n", __FUNCTION__, src->uri_name ); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - gmyth_uri = gmyth_uri_new_with_value (src->uri_name); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - - filename = gmyth_uri_get_path (gmyth_uri); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - ret = gmyth_file_transfer_open( src->file_transfer, filename); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); - g_object_unref (gmyth_uri); -printf ("XXX %s %d\n", __FUNCTION__, __LINE__); + + ret = gmyth_file_transfer_open( src->file_transfer ); + + /* sets the Playback monitor connection */ + //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... */ @@ -814,6 +809,9 @@ if (src->uri_name) { g_free (src->uri_name); } + + if ( src->backend_info == NULL ) + src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name ); if ( src->live_tv ) { if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) { @@ -832,17 +830,16 @@ GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); } - // we do not need to create a new file transfer, just close the previous one and open with the new file name - // src->file_transfer = gmyth_file_transfer_new( src->backend_info); - gmyth_file_transfer_close (src->backend_info); + src->file_transfer = gmyth_file_transfer_new(src->backend_info); if ( src->file_transfer == NULL ) { goto init_failed; } - GMythURI *myth_uri = gmyth_uri_new_with_value (src->uri_name); - ret = gmyth_file_transfer_open( src->file_transfer, gmyth_uri_get_path (myth_uri) ); - g_object_unref (myth_uri); + ret = gmyth_file_transfer_open( src->file_transfer ); + + /* sets the Playback monitor connection */ + //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... */ @@ -855,6 +852,8 @@ g_usleep( 1000 ); } + /* sets the FileTransfer instance connection (video/audio download) */ + //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv ); if ( ret == FALSE ) { #ifndef GST_DISABLE_GST_DEBUG @@ -957,17 +956,6 @@ src->mythtv_caps = NULL; } - if (src->backend_info != NULL) { - g_object_unref (src->backend_info); - src->backend_info = NULL; - } - - if (src->file_transfer != NULL) { - gmyth_file_transfer_close (src->file_transfer); - g_object_unref (src->file_transfer); - src->file_transfer = NULL; - } - src->eos = FALSE; return TRUE;