mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 08:08:22 +00:00
ext/ofa/gstofa.c: Improve debugging, clean up a bit and really generate the fingerprint after 135 seconds.
Original commit message from CVS: * ext/ofa/gstofa.c: (create_fingerprint), (gst_ofa_event), (gst_ofa_transform_ip), (plugin_init): Improve debugging, clean up a bit and really generate the fingerprint after 135 seconds.
This commit is contained in:
parent
3999646a0d
commit
2cdcdd43e7
2 changed files with 30 additions and 18 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-03-19 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* ext/ofa/gstofa.c: (create_fingerprint), (gst_ofa_event),
|
||||||
|
(gst_ofa_transform_ip), (plugin_init):
|
||||||
|
Improve debugging, clean up a bit and really generate the fingerprint
|
||||||
|
after 135 seconds.
|
||||||
|
|
||||||
2008-03-19 Sebastian Dröge <slomo@circular-chaos.org>
|
2008-03-19 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
* ext/ofa/gstofa.c:
|
* ext/ofa/gstofa.c:
|
||||||
|
|
|
@ -49,11 +49,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define _do_init(bla) \
|
GST_BOILERPLATE (GstOFA, gst_ofa, GstAudioFilter, GST_TYPE_AUDIO_FILTER);
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_ofa_debug, "ofa", 0, "ofa element");
|
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstOFA, gst_ofa, GstAudioFilter,
|
|
||||||
GST_TYPE_AUDIO_FILTER, _do_init);
|
|
||||||
|
|
||||||
static void gst_ofa_finalize (GObject * object);
|
static void gst_ofa_finalize (GObject * object);
|
||||||
static void gst_ofa_get_property (GObject * object, guint prop_id,
|
static void gst_ofa_get_property (GObject * object, guint prop_id,
|
||||||
|
@ -120,19 +116,22 @@ create_fingerprint (GstOFA * ofa)
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
|
gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
|
||||||
gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
|
gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
|
||||||
gint width = GST_AUDIO_FILTER (ofa)->format.width / 8;
|
|
||||||
gint endianness =
|
gint endianness =
|
||||||
(GST_AUDIO_FILTER (ofa)->format.
|
(GST_AUDIO_FILTER (ofa)->format.
|
||||||
bigend) ? OFA_BIG_ENDIAN : OFA_LITTLE_ENDIAN;
|
bigend) ? OFA_BIG_ENDIAN : OFA_LITTLE_ENDIAN;
|
||||||
GstTagList *tags;
|
GstTagList *tags;
|
||||||
|
|
||||||
|
GST_DEBUG ("Generating fingerprint");
|
||||||
|
|
||||||
buf =
|
buf =
|
||||||
gst_adapter_take_buffer (ofa->adapter,
|
gst_adapter_take_buffer (ofa->adapter,
|
||||||
gst_adapter_available (ofa->adapter));
|
gst_adapter_available (ofa->adapter));
|
||||||
|
|
||||||
ofa->fingerprint = g_strdup (ofa_create_print (GST_BUFFER_DATA (buf),
|
ofa->fingerprint = g_strdup (ofa_create_print (GST_BUFFER_DATA (buf),
|
||||||
endianness,
|
endianness, GST_BUFFER_SIZE (buf) / 2, rate,
|
||||||
GST_BUFFER_SIZE (buf) / width, rate, (channels == 2) ? 1 : 0));
|
(channels == 2) ? 1 : 0));
|
||||||
|
|
||||||
|
GST_DEBUG ("Generated fingerprint");
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
|
@ -152,6 +151,7 @@ gst_ofa_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
case GST_EVENT_NEWSEGMENT:
|
case GST_EVENT_NEWSEGMENT:
|
||||||
|
GST_DEBUG ("Got %s event, clearing buffer", GST_EVENT_TYPE_NAME (event));
|
||||||
gst_adapter_clear (ofa->adapter);
|
gst_adapter_clear (ofa->adapter);
|
||||||
ofa->record = TRUE;
|
ofa->record = TRUE;
|
||||||
g_free (ofa->fingerprint);
|
g_free (ofa->fingerprint);
|
||||||
|
@ -190,19 +190,16 @@ gst_ofa_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
|
gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
|
||||||
gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
|
gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
|
||||||
gint width = GST_AUDIO_FILTER (ofa)->format.width / 8;
|
|
||||||
|
|
||||||
g_return_val_if_fail (rate > 0 && channels > 0
|
g_return_val_if_fail (rate > 0 && channels > 0, GST_FLOW_NOT_NEGOTIATED);
|
||||||
&& width > 0, GST_FLOW_NOT_NEGOTIATED);
|
|
||||||
|
|
||||||
if (ofa->record)
|
if (!ofa->record)
|
||||||
gst_adapter_push (ofa->adapter, gst_buffer_copy (buf));
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
nframes =
|
gst_adapter_push (ofa->adapter, gst_buffer_copy (buf));
|
||||||
gst_util_uint64_scale (gst_adapter_available (ofa->adapter), 1,
|
|
||||||
channels * width);
|
nframes = gst_adapter_available (ofa->adapter) / (channels * 2);
|
||||||
duration =
|
duration = GST_FRAMES_TO_CLOCK_TIME (nframes, rate);
|
||||||
GST_FRAMES_TO_CLOCK_TIME (gst_adapter_available (ofa->adapter), rate);
|
|
||||||
|
|
||||||
if (duration >= 135 * GST_SECOND && ofa->fingerprint == NULL)
|
if (duration >= 135 * GST_SECOND && ofa->fingerprint == NULL)
|
||||||
create_fingerprint (ofa);
|
create_fingerprint (ofa);
|
||||||
|
@ -232,6 +229,14 @@ plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
|
int major, minor, rev;
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_ofa_debug, "ofa", 0, "ofa element");
|
||||||
|
|
||||||
|
ofa_get_version (&major, &minor, &rev);
|
||||||
|
|
||||||
|
GST_DEBUG ("libofa %d.%d.%d", major, minor, rev);
|
||||||
|
|
||||||
ret = gst_element_register (plugin, "ofa", GST_RANK_NONE, GST_TYPE_OFA);
|
ret = gst_element_register (plugin, "ofa", GST_RANK_NONE, GST_TYPE_OFA);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Reference in a new issue