gst-gmyth/mythsrc/gstmythtvsrc.c
branchtrunk
changeset 677 1b7b4d7f714c
parent 608 43ce4ea2f9fb
child 679 c9757033ccc6
     1.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c	Tue May 01 16:04:02 2007 +0100
     1.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c	Wed May 16 23:21:58 2007 +0100
     1.3 @@ -317,8 +317,6 @@
     1.4    this->bytes_queue = NULL;
     1.5  
     1.6    this->wait_to_transfer = 0;
     1.7 -  this->try_number = 0;
     1.8 -  this->max_try = 10;
     1.9  
    1.10    gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES);
    1.11  
    1.12 @@ -333,7 +331,6 @@
    1.13  gst_mythtv_src_clear (GstMythtvSrc *mythtv_src)
    1.14  {
    1.15    mythtv_src->unique_setup = FALSE;
    1.16 -  mythtv_src->try_number = 0;
    1.17  
    1.18    if (mythtv_src->spawn_livetv) {
    1.19      g_object_unref (mythtv_src->spawn_livetv);
    1.20 @@ -454,11 +451,13 @@
    1.21    if (G_UNLIKELY (src->update_prog_chain))
    1.22      goto change_progchain;
    1.23  
    1.24 +  /*
    1.25    GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...",
    1.26        src->read_offset, MAX_READ_SIZE);
    1.27  
    1.28    GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.",
    1.29        (gint) src->buffer_remain, src->bytes_queue->len);
    1.30 +  */	  
    1.31  
    1.32  program_chain_changed:
    1.33    /* just get from the byte array, no network effort... */
    1.34 @@ -523,10 +522,12 @@
    1.35        buffer = NULL;
    1.36      }
    1.37  
    1.38 +	/*
    1.39      GST_DEBUG_OBJECT (src,
    1.40          "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "
    1.41          "OFFSET = %llu, CONTENT SIZE = %llu.", read,
    1.42          src->bytes_read, src->read_offset, src->content_size);
    1.43 +	*/		
    1.44  
    1.45    }
    1.46  
    1.47 @@ -538,10 +539,12 @@
    1.48    /* gets the first buffer_size bytes from the byte array buffer variable */
    1.49    /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */
    1.50  
    1.51 +  /*
    1.52    GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d",
    1.53        (buffer_size_inter ==
    1.54            0) ? "NO, got from buffer" : "YES, go see the backend's log file",
    1.55        src->buffer_remain);
    1.56 +	  */
    1.57  
    1.58    GST_BUFFER_SIZE (*outbuf) = buffer_size;
    1.59    GST_BUFFER_MALLOCDATA (*outbuf) = g_malloc0 (GST_BUFFER_SIZE (*outbuf));
    1.60 @@ -556,20 +559,13 @@
    1.61  
    1.62    src->read_offset += GST_BUFFER_SIZE (*outbuf);
    1.63    src->bytes_read += GST_BUFFER_SIZE (*outbuf);
    1.64 -  GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
    1.65 -      GST_BUFFER_SIZE (*outbuf));
    1.66 +  //GST_DEBUG_OBJECT (src, "Buffer output with size: %d",
    1.67 +  //    GST_BUFFER_SIZE (*outbuf));
    1.68  
    1.69    /* flushs the newly buffer got from byte array */
    1.70    src->bytes_queue =
    1.71        g_byte_array_remove_range (src->bytes_queue, 0, buffer_size);
    1.72  
    1.73 -  GST_DEBUG_OBJECT ( src, "Got buffer: BUFFER --->SIZE = %d, OFFSET = %llu, "
    1.74 -      "OFFSET_END = %llu.", GST_BUFFER_SIZE (*outbuf),
    1.75 -      GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
    1.76 -
    1.77 -  GST_DEBUG_OBJECT (src, "CONTENT_SIZE = %llu, BYTES_READ = %llu.",
    1.78 -      src->content_size, src->bytes_read);
    1.79 -
    1.80    if ( G_UNLIKELY (src->eos) || ( !src->live_tv
    1.81            && ( src->bytes_read >= src->content_size ) ) )
    1.82      goto eos;
    1.83 @@ -577,8 +573,6 @@
    1.84  done:
    1.85    {
    1.86      const gchar *reason = gst_flow_get_name (ret);
    1.87 -
    1.88 -    GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason);
    1.89      return ret;
    1.90    }
    1.91  eos:
    1.92 @@ -702,6 +696,7 @@
    1.93    GString *chain_id_local = NULL;  
    1.94    GMythURI *gmyth_uri = NULL;
    1.95    gboolean ret = TRUE;
    1.96 +  GstMessage *msg;
    1.97  
    1.98    if (src->unique_setup == FALSE) {
    1.99      src->unique_setup = TRUE;
   1.100 @@ -801,6 +796,10 @@
   1.101  
   1.102    src->content_size = gmyth_file_get_filesize (src->file);
   1.103  
   1.104 +  msg = gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_BYTES, src->content_size);
   1.105 +  gst_element_post_message (GST_ELEMENT (src), msg);
   1.106 +
   1.107 +
   1.108    src->do_start = FALSE;
   1.109  
   1.110    /* this is used for the buffer cache */
   1.111 @@ -844,12 +843,7 @@
   1.112              src->uri_name));
   1.113      */            
   1.114  
   1.115 -    if  (++src->try_number <= src->max_try) {
   1.116 -       gst_mythtv_src_clear (src);
   1.117 -       GST_DEBUG_OBJECT (src, "Starting new try for get free recorder on MythTV");
   1.118 -       g_usleep (0.5 * G_USEC_PER_SEC);
   1.119 -       return gst_mythtv_src_start (bsrc);
   1.120 -    }
   1.121 +    gst_mythtv_src_clear (src);
   1.122  
   1.123      return FALSE;
   1.124  begin_req_failed:
   1.125 @@ -956,6 +950,7 @@
   1.126    GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad));
   1.127    GstFormat formt;
   1.128  
   1.129 +
   1.130    switch (GST_QUERY_TYPE (query)) {
   1.131      case GST_QUERY_POSITION:
   1.132      {
   1.133 @@ -971,21 +966,11 @@
   1.134      }
   1.135      case GST_QUERY_DURATION:
   1.136      {
   1.137 -#if 0
   1.138 -      if (myth->duration != 0) {
   1.139 -        gint64 total;
   1.140 -        gint64 fps;
   1.141 -
   1.142 -        fps = nuv->h->i_fpsn / nuv->h->i_fpsd;
   1.143 -        total =
   1.144 -            gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps);
   1.145 -      }
   1.146 -#endif
   1.147 -
   1.148        gst_query_parse_duration (query, &formt, NULL);
   1.149        if (formt == GST_FORMAT_BYTES) {
   1.150 -        gst_query_set_duration (query, formt, myth->content_size);
   1.151 -        GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, myth->content_size);
   1.152 +		gint64 size = myth->content_size;			  
   1.153 +        gst_query_set_duration (query, GST_FORMAT_BYTES, 10);
   1.154 +        GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, size);
   1.155          res = TRUE;
   1.156        } else if (formt == GST_FORMAT_TIME) {
   1.157          res = gst_pad_query_default (pad, query);
   1.158 @@ -1034,6 +1019,7 @@
   1.159  
   1.160    switch (transition) {
   1.161      case GST_STATE_CHANGE_READY_TO_NULL:
   1.162 +	  gst_mythtv_src_clear (src);			
   1.163        break;
   1.164      case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
   1.165      case GST_STATE_CHANGE_PAUSED_TO_READY: