Merge branch 'master' of ssh://git.freedesktop.org/git/gstreamer/gst-plugins-good into 0.11

This commit is contained in:
Wim Taymans 2010-12-06 17:28:32 +01:00
commit 83ed1deda9
6 changed files with 69 additions and 20 deletions

View file

@ -81,6 +81,7 @@ enum
ARG_0,
ARG_UPDATE_FREQ,
ARG_SILENT,
ARG_DO_QUERY,
ARG_FORMAT
};
@ -98,6 +99,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
#define DEFAULT_UPDATE_FREQ 5
#define DEFAULT_SILENT FALSE
#define DEFAULT_DO_QUERY TRUE
#define DEFAULT_FORMAT "auto"
static void gst_progress_report_set_property (GObject * object, guint prop_id,
@ -166,6 +168,12 @@ gst_progress_report_class_init (GstProgressReportClass * g_class)
"Do not print output to stdout", "Do not print output to stdout",
DEFAULT_SILENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
ARG_DO_QUERY, g_param_spec_boolean ("do-query",
"Use a query instead of buffer metadata to determine stream position",
"Use a query instead of buffer metadata to determine stream position",
DEFAULT_DO_QUERY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
ARG_FORMAT, g_param_spec_string ("format", "format",
"Format to use for the querying", DEFAULT_FORMAT,
@ -186,6 +194,7 @@ gst_progress_report_init (GstProgressReport * report,
report->update_freq = DEFAULT_UPDATE_FREQ;
report->silent = DEFAULT_SILENT;
report->do_query = DEFAULT_DO_QUERY;
report->format = g_strdup (DEFAULT_FORMAT);
}
@ -222,7 +231,7 @@ gst_progress_report_post_progress (GstProgressReport * filter,
static gboolean
gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
gint hh, gint mm, gint ss)
gint hh, gint mm, gint ss, GstBuffer * buf)
{
const gchar *format_name = NULL;
GstPad *sink_pad;
@ -233,9 +242,24 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
GST_LOG_OBJECT (filter, "querying using format %d (%s)", format,
gst_format_get_name (format));
if (!gst_pad_query_peer_position (sink_pad, &format, &cur) ||
!gst_pad_query_peer_duration (sink_pad, &format, &total)) {
return FALSE;
if (filter->do_query || !buf) {
GST_LOG_OBJECT (filter, "using upstream query");
if (!gst_pad_query_peer_position (sink_pad, &format, &cur) ||
!gst_pad_query_peer_duration (sink_pad, &format, &total)) {
return FALSE;
}
} else {
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
GST_LOG_OBJECT (filter, "using buffer metadata");
if (format == GST_FORMAT_TIME && base->have_newsegment &&
base->segment.format == GST_FORMAT_TIME) {
cur = gst_segment_to_stream_time (&base->segment, format,
GST_BUFFER_TIMESTAMP (buf));
total = base->segment.duration;
} else {
return FALSE;
}
}
switch (format) {
@ -300,7 +324,8 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
}
static void
gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time)
gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time,
GstBuffer * buf)
{
GstFormat try_formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES,
GST_FORMAT_PERCENT, GST_FORMAT_BUFFERS,
@ -325,12 +350,13 @@ gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time)
}
if (format != GST_FORMAT_UNDEFINED) {
done = gst_progress_report_do_query (filter, format, hh, mm, ss);
done = gst_progress_report_do_query (filter, format, hh, mm, ss, buf);
} else {
gint i;
for (i = 0; i < G_N_ELEMENTS (try_formats); ++i) {
done = gst_progress_report_do_query (filter, try_formats[i], hh, mm, ss);
done = gst_progress_report_do_query (filter, try_formats[i], hh, mm, ss,
buf);
if (done)
break;
}
@ -361,7 +387,7 @@ gst_progress_report_event (GstBaseTransform * trans, GstEvent * event)
GTimeVal cur_time;
g_get_current_time (&cur_time);
gst_progress_report_report (filter, cur_time);
gst_progress_report_report (filter, cur_time, NULL);
}
return GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
}
@ -384,7 +410,7 @@ gst_progress_report_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
GST_OBJECT_UNLOCK (filter);
if (need_update) {
gst_progress_report_report (filter, cur_time);
gst_progress_report_report (filter, cur_time, buf);
GST_OBJECT_LOCK (filter);
filter->last_report = cur_time;
GST_OBJECT_UNLOCK (filter);
@ -432,6 +458,11 @@ gst_progress_report_set_property (GObject * object, guint prop_id,
filter->silent = g_value_get_boolean (value);
GST_OBJECT_UNLOCK (filter);
break;
case ARG_DO_QUERY:
GST_OBJECT_LOCK (filter);
filter->do_query = g_value_get_boolean (value);
GST_OBJECT_UNLOCK (filter);
break;
case ARG_FORMAT:
GST_OBJECT_LOCK (filter);
g_free (filter->format);
@ -464,6 +495,11 @@ gst_progress_report_get_property (GObject * object, guint prop_id,
g_value_set_boolean (value, filter->silent);
GST_OBJECT_UNLOCK (filter);
break;
case ARG_DO_QUERY:
GST_OBJECT_LOCK (filter);
g_value_set_boolean (value, filter->do_query);
GST_OBJECT_UNLOCK (filter);
break;
case ARG_FORMAT:
GST_OBJECT_LOCK (filter);
g_value_set_string (value, filter->format);

View file

@ -47,6 +47,7 @@ struct _GstProgressReport
gint update_freq;
gboolean silent;
gboolean do_query;
GTimeVal start_time;
GTimeVal last_report;

View file

@ -553,6 +553,13 @@ gst_image_freeze_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
if (!self->buffer) {
/* if we receive EOS before a buffer arrives, then let it pass */
GST_DEBUG_OBJECT (self, "EOS without input buffer, passing on");
ret = gst_pad_push_event (self->srcpad, event);
break;
}
/* fall-through */
case GST_EVENT_NEWSEGMENT:
GST_DEBUG_OBJECT (pad, "Dropping event");
gst_event_unref (event);

View file

@ -223,12 +223,14 @@ gst_ebml_writer_send_new_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
/**
* gst_ebml_write_flush_cache:
* @ebml: a #GstEbmlWrite.
* @ebml: a #GstEbmlWrite.
* @timestamp: timestamp of the buffer.
*
* Flush the cache.
*/
void
gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe)
gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe,
GstClockTime timestamp)
{
GstBuffer *buffer;
@ -239,6 +241,7 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe)
ebml->cache = NULL;
GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
gst_buffer_set_caps (buffer, ebml->caps);
GST_BUFFER_TIMESTAMP (buffer) = timestamp;
GST_BUFFER_OFFSET (buffer) = ebml->pos - GST_BUFFER_SIZE (buffer);
GST_BUFFER_OFFSET_END (buffer) = ebml->pos;
if (ebml->last_write_result == GST_FLOW_OK) {
@ -466,7 +469,7 @@ gst_ebml_write_seek (GstEbmlWrite * ebml, guint64 pos)
return;
} else {
GST_LOG ("Seek outside cache range. Clearing...");
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, GST_CLOCK_TIME_NONE);
}
}
@ -825,5 +828,5 @@ gst_ebml_write_header (GstEbmlWrite * ebml, const gchar * doctype,
gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEVERSION, version);
gst_ebml_write_uint (ebml, GST_EBML_ID_DOCTYPEREADVERSION, version);
gst_ebml_write_master_finish (ebml, pos);
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, 0);
}

View file

@ -84,7 +84,8 @@ GstBuffer* gst_ebml_stop_streamheader (GstEbmlWrite *ebml);
void gst_ebml_write_set_cache (GstEbmlWrite *ebml,
guint size);
void gst_ebml_write_flush_cache (GstEbmlWrite *ebml,
gboolean is_keyframe);
gboolean is_keyframe,
GstClockTime timestamp);
/*
* Seeking.

View file

@ -2124,7 +2124,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
gst_ebml_write_master_finish (ebml, master);
/* lastly, flush the cache */
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, 0);
}
static void
@ -2233,7 +2233,7 @@ gst_matroska_mux_finish (GstMatroskaMux * mux)
}
gst_ebml_write_master_finish (ebml, master);
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, GST_CLOCK_TIME_NONE);
}
/* tags */
@ -2600,7 +2600,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
GST_LOG_OBJECT (mux, "cluster timestamp %" G_GUINT64_FORMAT,
gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1,
mux->time_scale));
gst_ebml_write_flush_cache (ebml, TRUE);
gst_ebml_write_flush_cache (ebml, TRUE, GST_BUFFER_TIMESTAMP (buf));
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_PREVSIZE,
mux->prev_cluster_size);
@ -2613,7 +2613,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
mux->cluster = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CLUSTER);
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_CLUSTERTIMECODE,
gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (buf), 1, mux->time_scale));
gst_ebml_write_flush_cache (ebml, TRUE);
gst_ebml_write_flush_cache (ebml, TRUE, GST_BUFFER_TIMESTAMP (buf));
mux->cluster_time = GST_BUFFER_TIMESTAMP (buf);
}
@ -2691,7 +2691,7 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
gst_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_SIMPLEBLOCK,
GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
gst_ebml_write_buffer (ebml, hdr);
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf));
gst_ebml_write_buffer (ebml, buf);
return gst_ebml_last_write_result (ebml);
@ -2711,8 +2711,9 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
gst_ebml_write_buffer (ebml, hdr);
gst_ebml_write_master_finish_full (ebml, blockgroup, GST_BUFFER_SIZE (buf));
gst_ebml_write_flush_cache (ebml, FALSE);
gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf));
gst_ebml_write_buffer (ebml, buf);
return gst_ebml_last_write_result (ebml);
}
}