1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Nov 30 21:29:54 2006 +0000
1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Sat Dec 02 03:40:20 2006 +0000
1.3 @@ -424,8 +424,7 @@
1.4 (gint) src->buffer_remain, src->bytes_queue->len );
1.5
1.6 /* just get from the byte array, no network effort... */
1.7 - if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE &&
1.8 - abs( src->content_size - src->bytes_read ) > MAX_READ_SIZE ) {
1.9 + if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) {
1.10 //( ( INTERNAL_BUFFER_SIZE - src->buffer_remain ) >= REQUEST_MAX_SIZE ) ) {
1.11 GByteArray *buffer = NULL;
1.12 guint buffer_size_inter = ( INTERNAL_BUFFER_SIZE - src->buffer_remain );
1.13 @@ -441,8 +440,13 @@
1.14 goto change_progchain;
1.15 else
1.16 goto read_error;
1.17 - } else if (G_UNLIKELY (read == 0) && !src->live_tv )
1.18 - goto done;
1.19 + } else if (G_UNLIKELY (read == 0))
1.20 + {
1.21 + if (!src->live_tv )
1.22 + goto eos;
1.23 + else
1.24 + goto done;
1.25 + }
1.26
1.27 if ( G_UNLIKELY (src->update_prog_chain) )
1.28 goto change_progchain;
1.29 @@ -487,8 +491,8 @@
1.30 read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain );
1.31
1.32 GST_BUFFER_SIZE (*outbuf) = buffer_size;
1.33 - //GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
1.34 - //GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
1.35 + GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
1.36 + GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
1.37 g_memmove( GST_BUFFER_DATA( (*outbuf) ), src->bytes_queue->data, GST_BUFFER_SIZE(*outbuf) );
1.38 GST_BUFFER_OFFSET (*outbuf) = src->read_offset;
1.39 GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf);
1.40 @@ -654,10 +658,9 @@
1.41 gst_mythtv_src_start ( GstBaseSrc * bsrc )
1.42 {
1.43 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
1.44 - GMythURI *gmyth_uri = NULL;
1.45 - gchar* filename = NULL;
1.46
1.47 GString *chain_id_local = NULL;
1.48 +
1.49 gboolean ret = TRUE;
1.50
1.51 if ( G_UNLIKELY (src->update_prog_chain) )
1.52 @@ -668,19 +671,15 @@
1.53 } else {
1.54 goto done;
1.55 }
1.56 -
1.57 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.58 +
1.59 src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
1.60 -
1.61 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.62 - if ( src->live_tv ) {
1.63 + if ( src->live_tv ) {
1.64 src->spawn_livetv = gmyth_livetv_new( );
1.65 if ( gmyth_livetv_setup( src->spawn_livetv, src->backend_info ) == FALSE ) {
1.66 ret = FALSE;
1.67 goto init_failed;
1.68 }
1.69
1.70 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.71 /* set up the uri variable */
1.72 src->uri_name = g_strdup( src->spawn_livetv->proginfo->pathname->str );
1.73 chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
1.74 @@ -688,30 +687,26 @@
1.75 src->live_chain_id = g_strdup( chain_id_local->str );
1.76 GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
1.77 }
1.78 + //if ( src->uri_name == NULL || strlen( src->uri_name ) <= 0 )
1.79 + // gmyth_context_initialize();
1.80
1.81 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.82 src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
1.83 GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
1.84 }
1.85
1.86 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.87 - src->file_transfer = gmyth_file_transfer_new( src->backend_info );
1.88 + //src->file_transfer = gmyth_file_transfer_new( src->live_tv_id,
1.89 + // g_string_new( src->uri_name ), -1, src->mythtv_version );
1.90 + src->file_transfer = gmyth_file_transfer_new(src->backend_info);
1.91
1.92 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.93 if ( src->file_transfer == NULL ) {
1.94 goto init_failed;
1.95 }
1.96 GST_INFO_OBJECT( src, "[%s] uri = %s.\n", __FUNCTION__, src->uri_name );
1.97 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.98 - gmyth_uri = gmyth_uri_new_with_value (src->uri_name);
1.99 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.100 -
1.101 - filename = gmyth_uri_get_path (gmyth_uri);
1.102 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.103 - ret = gmyth_file_transfer_open( src->file_transfer, filename);
1.104 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.105 - g_object_unref (gmyth_uri);
1.106 -printf ("XXX %s %d\n", __FUNCTION__, __LINE__);
1.107 +
1.108 + ret = gmyth_file_transfer_open( src->file_transfer );
1.109 +
1.110 + /* sets the Playback monitor connection */
1.111 + //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
1.112
1.113 if ( src->live_tv == TRUE && ret == TRUE ) {
1.114 /* loop finished, set the max tries variable to zero again... */
1.115 @@ -814,6 +809,9 @@
1.116 if (src->uri_name) {
1.117 g_free (src->uri_name);
1.118 }
1.119 +
1.120 + if ( src->backend_info == NULL )
1.121 + src->backend_info = gmyth_backend_info_new_with_uri( src->uri_name );
1.122
1.123 if ( src->live_tv ) {
1.124 if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) {
1.125 @@ -832,17 +830,16 @@
1.126 GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
1.127 }
1.128
1.129 - // we do not need to create a new file transfer, just close the previous one and open with the new file name
1.130 - // src->file_transfer = gmyth_file_transfer_new( src->backend_info);
1.131 - gmyth_file_transfer_close (src->backend_info);
1.132 + src->file_transfer = gmyth_file_transfer_new(src->backend_info);
1.133
1.134 if ( src->file_transfer == NULL ) {
1.135 goto init_failed;
1.136 }
1.137
1.138 - GMythURI *myth_uri = gmyth_uri_new_with_value (src->uri_name);
1.139 - ret = gmyth_file_transfer_open( src->file_transfer, gmyth_uri_get_path (myth_uri) );
1.140 - g_object_unref (myth_uri);
1.141 + ret = gmyth_file_transfer_open( src->file_transfer );
1.142 +
1.143 + /* sets the Playback monitor connection */
1.144 + //ret = gmyth_file_transfer_playback_setup( &(src->file_transfer), src->live_tv );
1.145
1.146 if ( src->live_tv == TRUE && ret == TRUE ) {
1.147 /* loop finished, set the max tries variable to zero again... */
1.148 @@ -855,6 +852,8 @@
1.149 g_usleep( 1000 );
1.150 }
1.151
1.152 + /* sets the FileTransfer instance connection (video/audio download) */
1.153 + //ret = gmyth_file_transfer_setup( &(src->file_transfer), src->live_tv );
1.154
1.155 if ( ret == FALSE ) {
1.156 #ifndef GST_DISABLE_GST_DEBUG
1.157 @@ -957,17 +956,6 @@
1.158 src->mythtv_caps = NULL;
1.159 }
1.160
1.161 - if (src->backend_info != NULL) {
1.162 - g_object_unref (src->backend_info);
1.163 - src->backend_info = NULL;
1.164 - }
1.165 -
1.166 - if (src->file_transfer != NULL) {
1.167 - gmyth_file_transfer_close (src->file_transfer);
1.168 - g_object_unref (src->file_transfer);
1.169 - src->file_transfer = NULL;
1.170 - }
1.171 -
1.172 src->eos = FALSE;
1.173
1.174 return TRUE;