# HG changeset patch # User renatofilho # Date 1179337693 -3600 # Node ID 2af89a257a86a7149a230c18b446b74e5a0f818a # Parent 5ee8c970d982df1097eb1d6c012717a83b6a40f2 [svn r680] fixed query function diff -r 5ee8c970d982 -r 2af89a257a86 gst-gmyth/mythsrc/gstmythtvsrc.c --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Wed May 16 18:47:09 2007 +0100 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Wed May 16 18:48:13 2007 +0100 @@ -317,8 +317,6 @@ this->bytes_queue = NULL; this->wait_to_transfer = 0; - this->try_number = 0; - this->max_try = 10; gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES); @@ -333,7 +331,6 @@ gst_mythtv_src_clear (GstMythtvSrc *mythtv_src) { mythtv_src->unique_setup = FALSE; - mythtv_src->try_number = 0; if (mythtv_src->spawn_livetv) { g_object_unref (mythtv_src->spawn_livetv); @@ -454,11 +451,13 @@ if (G_UNLIKELY (src->update_prog_chain)) goto change_progchain; + /* GST_DEBUG_OBJECT (src, "offset = %" G_GUINT64_FORMAT ", size = %d...", src->read_offset, MAX_READ_SIZE); GST_DEBUG_OBJECT (src, "Create: buffer_remain: %d, buffer_size = %d.", (gint) src->buffer_remain, src->bytes_queue->len); + */ program_chain_changed: /* just get from the byte array, no network effort... */ @@ -523,10 +522,12 @@ buffer = NULL; } + /* GST_DEBUG_OBJECT (src, "BYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, " "OFFSET = %llu, CONTENT SIZE = %llu.", read, src->bytes_read, src->read_offset, src->content_size); + */ } @@ -538,10 +539,12 @@ /* gets the first buffer_size bytes from the byte array buffer variable */ /* guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); */ + /* GST_DEBUG_OBJECT (src, "read from network? %s!, buffer_remain = %d", (buffer_size_inter == 0) ? "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)); @@ -556,20 +559,13 @@ src->read_offset += GST_BUFFER_SIZE (*outbuf); src->bytes_read += GST_BUFFER_SIZE (*outbuf); - GST_DEBUG_OBJECT (src, "Buffer output with size: %d", - GST_BUFFER_SIZE (*outbuf)); + //GST_DEBUG_OBJECT (src, "Buffer output with size: %d", + // GST_BUFFER_SIZE (*outbuf)); /* flushs the newly buffer got from byte array */ src->bytes_queue = g_byte_array_remove_range (src->bytes_queue, 0, buffer_size); - GST_DEBUG_OBJECT ( src, "Got buffer: BUFFER --->SIZE = %d, OFFSET = %llu, " - "OFFSET_END = %llu.", GST_BUFFER_SIZE (*outbuf), - GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) ); - - GST_DEBUG_OBJECT (src, "CONTENT_SIZE = %llu, BYTES_READ = %llu.", - src->content_size, src->bytes_read); - if ( G_UNLIKELY (src->eos) || ( !src->live_tv && ( src->bytes_read >= src->content_size ) ) ) goto eos; @@ -577,8 +573,6 @@ done: { const gchar *reason = gst_flow_get_name (ret); - - GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason); return ret; } eos: @@ -702,6 +696,7 @@ GString *chain_id_local = NULL; GMythURI *gmyth_uri = NULL; gboolean ret = TRUE; + GstMessage *msg; if (src->unique_setup == FALSE) { src->unique_setup = TRUE; @@ -801,6 +796,10 @@ src->content_size = gmyth_file_get_filesize (src->file); + msg = gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_BYTES, src->content_size); + gst_element_post_message (GST_ELEMENT (src), msg); + + src->do_start = FALSE; /* this is used for the buffer cache */ @@ -844,12 +843,7 @@ src->uri_name)); */ - if (++src->try_number <= src->max_try) { - gst_mythtv_src_clear (src); - GST_DEBUG_OBJECT (src, "Starting new try for get free recorder on MythTV"); - g_usleep (0.5 * G_USEC_PER_SEC); - return gst_mythtv_src_start (bsrc); - } + gst_mythtv_src_clear (src); return FALSE; begin_req_failed: @@ -956,6 +950,7 @@ GstMythtvSrc *myth = GST_MYTHTV_SRC (gst_pad_get_parent (pad)); GstFormat formt; + switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { @@ -971,21 +966,11 @@ } case GST_QUERY_DURATION: { -#if 0 - if (myth->duration != 0) { - gint64 total; - gint64 fps; - - fps = nuv->h->i_fpsn / nuv->h->i_fpsd; - total = - gst_util_uint64_scale_int (GST_SECOND, nuv->h->i_video_blocks, fps); - } -#endif - gst_query_parse_duration (query, &formt, NULL); if (formt == GST_FORMAT_BYTES) { - gst_query_set_duration (query, formt, myth->content_size); - GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, myth->content_size); + gint64 size = myth->content_size; + gst_query_set_duration (query, GST_FORMAT_BYTES, 10); + GST_DEBUG_OBJECT (myth, "SIZE %" G_GINT64_FORMAT, size); res = TRUE; } else if (formt == GST_FORMAT_TIME) { res = gst_pad_query_default (pad, query); @@ -1034,6 +1019,7 @@ switch (transition) { case GST_STATE_CHANGE_READY_TO_NULL: + gst_mythtv_src_clear (src); break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PAUSED_TO_READY: diff -r 5ee8c970d982 -r 2af89a257a86 gst-gmyth/nuvdemux/gstnuvdemux.c --- a/gst-gmyth/nuvdemux/gstnuvdemux.c Wed May 16 18:47:09 2007 +0100 +++ b/gst-gmyth/nuvdemux/gstnuvdemux.c Wed May 16 18:48:13 2007 +0100 @@ -610,28 +610,52 @@ gboolean res = FALSE; GstNuvDemux *nuv = GST_NUV_DEMUX (gst_pad_get_parent (pad)); - switch (GST_QUERY_TYPE (query)) { + + switch (GST_QUERY_TYPE (query)) + { case GST_QUERY_POSITION: - if (GST_CLOCK_TIME_IS_VALID (nuv->priv->last_frame_time)) { - gst_query_set_position (query, GST_FORMAT_TIME, nuv->priv->last_frame_time); - res = TRUE; - } - break; + { + GstFormat format; + gst_query_parse_position (query, &format, NULL); + switch (format) + { + case GST_FORMAT_TIME: + if (GST_CLOCK_TIME_IS_VALID (nuv->priv->last_frame_time)) { + gst_query_set_position (query, GST_FORMAT_TIME, nuv->priv->last_frame_time); + res = TRUE; + } + break; + default: + break; + } + break; + } case GST_QUERY_DURATION: - { - if (nuv->priv->duration_time != GST_CLOCK_TIME_NONE) { - gst_query_set_duration (query, GST_FORMAT_TIME, nuv->priv->duration_time); - res = TRUE; - } - } - break; - default: - res = FALSE; - break; + { + GstFormat format; + gst_query_parse_duration (query, &format, NULL); + switch (format) + { + case GST_FORMAT_TIME: + if (nuv->priv->duration_time != GST_CLOCK_TIME_NONE) { + gst_query_set_duration (query, GST_FORMAT_TIME, nuv->priv->duration_time); + res = TRUE; + } + break; + default: + break; + } + break; + } + default: + break; } + if (res==FALSE) { + res = gst_pad_query_default (pad, query); + } + gst_object_unref (nuv); - return res; }