diff options
author | Stefan Kost <ensonic@users.sourceforge.net> | 2007-03-07 11:24:05 +0000 |
---|---|---|
committer | Stefan Kost <ensonic@users.sourceforge.net> | 2007-03-07 11:24:05 +0000 |
commit | 143708a433a5c919a835703e3f4c0e2ecd73a442 (patch) | |
tree | 12ab661d661bd86f8578442f6ec53051bad40b2d /gst/level | |
parent | 28114d571f198bf9a8f7d7febfd418db9bbd870e (diff) |
gst/level/gstlevel.*: Resolve message timestamps against the playback segment.
Original commit message from CVS:
* gst/level/gstlevel.c: (gst_level_class_init),
(gst_level_set_caps), (gst_level_start), (gst_level_event),
(gst_level_transform_ip):
* gst/level/gstlevel.h:
Resolve message timestamps against the playback segment.
Diffstat (limited to 'gst/level')
-rw-r--r-- | gst/level/gstlevel.c | 52 | ||||
-rw-r--r-- | gst/level/gstlevel.h | 2 |
2 files changed, 49 insertions, 5 deletions
diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c index 6ff849fc..3edef456 100644 --- a/gst/level/gstlevel.c +++ b/gst/level/gstlevel.c @@ -146,6 +146,8 @@ static void gst_level_dispose (GObject * obj); static gboolean gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out); +static gboolean gst_level_start (GstBaseTransform * trans); +static gboolean gst_level_event (GstBaseTransform * trans, GstEvent * event); static GstFlowReturn gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in); @@ -195,6 +197,8 @@ gst_level_class_init (GstLevelClass * klass) GST_DEBUG_CATEGORY_INIT (level_debug, "level", 0, "Level calculation"); trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_level_set_caps); + trans_class->start = GST_DEBUG_FUNCPTR (gst_level_start); + trans_class->event = GST_DEBUG_FUNCPTR (gst_level_event); trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_level_transform_ip); trans_class->passthrough_on_same_caps = TRUE; } @@ -385,8 +389,6 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) GstStructure *structure; int i; - filter->num_frames = 0; - structure = gst_caps_get_structure (in, 0); filter->rate = structure_get_int (structure, "rate"); filter->width = structure_get_int (structure, "width"); @@ -441,6 +443,46 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) return TRUE; } +static gboolean +gst_level_start (GstBaseTransform * trans) +{ + GstLevel *filter = GST_LEVEL (trans); + + filter->num_frames = 0; + gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED); + + return TRUE; +} + +static gboolean +gst_level_event (GstBaseTransform * trans, GstEvent * event) +{ + GstLevel *filter = GST_LEVEL (trans); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_NEWSEGMENT:{ + GstFormat format; + gdouble rate, arate; + gint64 start, stop, time; + gboolean update; + + /* the newsegment values are used to clip the input samples + * and to convert the incomming timestamps to running time */ + gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format, + &start, &stop, &time); + + /* now configure the values */ + gst_segment_set_newsegment_full (&filter->segment, update, + rate, arate, format, start, stop, time); + break; + } + default: + break; + } + + return TRUE; +} + static GstMessage * gst_level_message_new (GstLevel * l, GstClockTime endtime) { @@ -578,9 +620,9 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in) GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate)) { if (filter->message) { GstMessage *m; - GstClockTime endtime; - - endtime = GST_BUFFER_TIMESTAMP (in) + GstClockTime endtime = + gst_segment_to_running_time (&filter->segment, GST_FORMAT_TIME, + GST_BUFFER_TIMESTAMP (in)) + GST_FRAMES_TO_CLOCK_TIME (num_frames, filter->rate); m = gst_level_message_new (filter, endtime); diff --git a/gst/level/gstlevel.h b/gst/level/gstlevel.h index 3cd5d3a8..f91b620c 100644 --- a/gst/level/gstlevel.h +++ b/gst/level/gstlevel.h @@ -78,6 +78,8 @@ struct _GstLevel { gdouble *RMS_dB; /* RMS in dB to emit */ GstClockTime *decay_peak_age; /* age of last peak */ + GstSegment segment; + void (*process)(gpointer, guint, guint, gdouble*, gdouble*); }; |