mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
28114d571f
commit
143708a433
3 changed files with 57 additions and 5 deletions
|
@ -1,3 +1,11 @@
|
|||
2007-03-07 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* 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.
|
||||
|
||||
2007-03-06 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/id3demux/gstid3demux.c: (gst_id3demux_add_srcpad),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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*);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue