diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /ext/ivorbis | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'ext/ivorbis')
-rw-r--r-- | ext/ivorbis/vorbis.c | 24 | ||||
-rw-r--r-- | ext/ivorbis/vorbisenc.h | 82 | ||||
-rw-r--r-- | ext/ivorbis/vorbisfile.c | 694 |
3 files changed, 381 insertions, 419 deletions
diff --git a/ext/ivorbis/vorbis.c b/ext/ivorbis/vorbis.c index 27087002..774687d6 100644 --- a/ext/ivorbis/vorbis.c +++ b/ext/ivorbis/vorbis.c @@ -23,28 +23,24 @@ #include <vorbisenc.h> -extern GType ivorbisfile_get_type(void); +extern GType ivorbisfile_get_type (void); static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { if (!gst_library_load ("gstbytestream")) return FALSE; - if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY, ivorbisfile_get_type ())) + if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY, + ivorbisfile_get_type ())) return FALSE; - + return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "tremor", - "OGG Vorbis Tremor plugins element", - plugin_init, - VERSION, - "LGPL", - GST_PACKAGE, - GST_ORIGIN) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "tremor", + "OGG Vorbis Tremor plugins element", + plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN) diff --git a/ext/ivorbis/vorbisenc.h b/ext/ivorbis/vorbisenc.h index 60fdf670..e33fb1d9 100644 --- a/ext/ivorbis/vorbisenc.h +++ b/ext/ivorbis/vorbisenc.h @@ -27,8 +27,9 @@ #include <tremor/ivorbiscodec.h> #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_VORBISENC \ (vorbisenc_get_type()) @@ -41,60 +42,61 @@ extern "C" { #define GST_IS_VORBISENC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBISENC)) -typedef struct _VorbisEnc VorbisEnc; -typedef struct _VorbisEncClass VorbisEncClass; + typedef struct _VorbisEnc VorbisEnc; + typedef struct _VorbisEncClass VorbisEncClass; -struct _VorbisEnc { - GstElement element; + struct _VorbisEnc + { + GstElement element; - GstPad *sinkpad, - *srcpad; + GstPad *sinkpad, *srcpad; - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ - ogg_packet op; /* one raw packet of data for decode */ + ogg_stream_state os; /* take physical pages, weld into a logical + stream of packets */ + ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ + ogg_packet op; /* one raw packet of data for decode */ - vorbis_info vi; /* struct that stores all the static vorbis bitstream - settings */ - vorbis_comment vc; /* struct that stores all the user comments */ + vorbis_info vi; /* struct that stores all the static vorbis bitstream + settings */ + vorbis_comment vc; /* struct that stores all the user comments */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ - gboolean eos; + gboolean eos; - gboolean managed; - gint bitrate; - gint min_bitrate; - gint max_bitrate; - gfloat quality; - gboolean quality_set; - gint serial; + gboolean managed; + gint bitrate; + gint min_bitrate; + gint max_bitrate; + gfloat quality; + gboolean quality_set; + gint serial; - gint channels; - gint frequency; + gint channels; + gint frequency; - guint64 samples_in; - guint64 bytes_out; + guint64 samples_in; + guint64 bytes_out; - GstCaps *metadata; + GstCaps *metadata; - gboolean setup; - gboolean flush_header; - gchar *last_message; -}; + gboolean setup; + gboolean flush_header; + gchar *last_message; + }; -struct _VorbisEncClass { - GstElementClass parent_class; -}; + struct _VorbisEncClass + { + GstElementClass parent_class; + }; -GType vorbisenc_get_type(void); + GType vorbisenc_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __VORBISENC_H__ */ +#endif /* __VORBISENC_H__ */ diff --git a/ext/ivorbis/vorbisfile.c b/ext/ivorbis/vorbisfile.c index be36e920..2f4f6503 100644 --- a/ext/ivorbis/vorbisfile.c +++ b/ext/ivorbis/vorbisfile.c @@ -43,33 +43,34 @@ GST_DEBUG_CATEGORY_STATIC (ivorbisfile_debug); typedef struct _Ivorbisfile Ivorbisfile; typedef struct _IvorbisfileClass IvorbisfileClass; -struct _Ivorbisfile { - GstElement element; +struct _Ivorbisfile +{ + GstElement element; - GstPad *sinkpad, - *srcpad; + GstPad *sinkpad, *srcpad; GstByteStream *bs; OggVorbis_File vf; - gint current_link; - - gboolean restart; - gboolean need_discont; - gboolean eos; - gboolean seek_pending; - gint64 seek_value; - GstFormat seek_format; - gboolean seek_accurate; - - gboolean may_eos; - guint64 total_bytes; - guint64 offset; - - GstCaps *metadata; - GstCaps *streaminfo; + gint current_link; + + gboolean restart; + gboolean need_discont; + gboolean eos; + gboolean seek_pending; + gint64 seek_value; + GstFormat seek_format; + gboolean seek_accurate; + + gboolean may_eos; + guint64 total_bytes; + guint64 offset; + + GstCaps *metadata; + GstCaps *streaminfo; }; -struct _IvorbisfileClass { +struct _IvorbisfileClass +{ GstElementClass parent_class; }; @@ -79,14 +80,13 @@ GType ivorbisfile_get_type (void); static GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template; /* elementfactory information */ -GstElementDetails ivorbisfile_details = -{ +GstElementDetails ivorbisfile_details = { "Ogg Vorbis decoder", "Codec/Audio/Decoder", "Decodes OGG Vorbis audio using the Tremor vorbisfile API", - "Monty <monty@xiph.org>\n" - "Wim Taymans <wim.taymans@chello.be>\n" - "Amaury Jacquot <sxpert@esitcom.org>", + "Monty <monty@xiph.org>\n" + "Wim Taymans <wim.taymans@chello.be>\n" + "Amaury Jacquot <sxpert@esitcom.org>", }; /* Ivorbisfile signals and args */ @@ -102,49 +102,36 @@ enum ARG_STREAMINFO }; -static void gst_ivorbisfile_base_init (gpointer g_class); -static void - gst_ivorbisfile_class_init (IvorbisfileClass *klass); -static void gst_ivorbisfile_init (Ivorbisfile *ivorbisfile); +static void gst_ivorbisfile_base_init (gpointer g_class); +static void gst_ivorbisfile_class_init (IvorbisfileClass * klass); +static void gst_ivorbisfile_init (Ivorbisfile * ivorbisfile); static GstElementStateReturn - gst_ivorbisfile_change_state (GstElement *element); - -static const -GstFormat* gst_ivorbisfile_get_formats (GstPad *pad); -static gboolean gst_ivorbisfile_src_convert (GstPad *pad, - GstFormat src_format, - gint64 src_value, - GstFormat *dest_format, - gint64 *dest_value); -static gboolean gst_ivorbisfile_sink_convert (GstPad *pad, - GstFormat src_format, - gint64 src_value, - GstFormat *dest_format, - gint64 *dest_value); -static const GstQueryType* - gst_ivorbisfile_get_query_types (GstPad *pad); - -static gboolean gst_ivorbisfile_src_query (GstPad *pad, - GstQueryType type, - GstFormat *format, - gint64 *value); -static const -GstEventMask* gst_ivorbisfile_get_event_masks (GstPad *pad); -static gboolean gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event); - -static void gst_ivorbisfile_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gst_ivorbisfile_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void gst_ivorbisfile_loop (GstElement *element); +gst_ivorbisfile_change_state (GstElement * element); + +static const GstFormat *gst_ivorbisfile_get_formats (GstPad * pad); +static gboolean gst_ivorbisfile_src_convert (GstPad * pad, + GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value); +static gboolean gst_ivorbisfile_sink_convert (GstPad * pad, + GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value); +static const GstQueryType *gst_ivorbisfile_get_query_types (GstPad * pad); + +static gboolean gst_ivorbisfile_src_query (GstPad * pad, + GstQueryType type, GstFormat * format, gint64 * value); +static const GstEventMask *gst_ivorbisfile_get_event_masks (GstPad * pad); +static gboolean gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event); + +static void gst_ivorbisfile_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); +static void gst_ivorbisfile_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); + +static void gst_ivorbisfile_loop (GstElement * element); static GstElementClass *parent_class = NULL; + //static guint gst_ivorbisfile_signals[LAST_SIGNAL] = { 0 }; static GstFormat logical_stream_format; @@ -164,53 +151,47 @@ ivorbisfile_get_type (void) (GInstanceInitFunc) gst_ivorbisfile_init, }; - ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile", - &ivorbisfile_info, 0); + ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile", + &ivorbisfile_info, 0); + + logical_stream_format = + gst_format_register ("logical_stream", "The logical stream"); - logical_stream_format = gst_format_register ("logical_stream", "The logical stream"); - - GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0, - "vorbis in ogg decoding element (integer arithmetic)"); + GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0, + "vorbis in ogg decoding element (integer arithmetic)"); } return ivorbisfile_type; } -static GstCaps* +static GstCaps * vorbis_caps_factory (void) { - return - gst_caps_new_simple ( - "application/ogg", - NULL); + return gst_caps_new_simple ("application/ogg", NULL); } -static GstCaps* +static GstCaps * raw_caps_factory (void) { return - gst_caps_new_simple ( - "audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "rate", GST_TYPE_INT_RANGE, 11025, 48000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, TRUE, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "rate", GST_TYPE_INT_RANGE, 11025, 48000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } -static GstCaps* +static GstCaps * raw_caps2_factory (void) { return - gst_caps_new_simple ( - "audio/x-raw-float", - "depth", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "rate", GST_TYPE_INT_RANGE, 11025, 48000, - "channels", G_TYPE_INT, 2, - NULL); + gst_caps_new_simple ("audio/x-raw-float", + "depth", G_TYPE_INT, 32, + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "rate", GST_TYPE_INT_RANGE, 11025, 48000, + "channels", G_TYPE_INT, 2, NULL); } @@ -225,16 +206,16 @@ gst_ivorbisfile_base_init (gpointer g_class) vorbis_caps = vorbis_caps_factory (); /* register sink pads */ - gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - vorbis_caps); + gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, vorbis_caps); gst_caps_append (raw_caps2, raw_caps); /* register src pads */ - gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - raw_caps2); - gst_element_class_add_pad_template (element_class, gst_vorbisdec_sink_template); - gst_element_class_add_pad_template (element_class, gst_vorbisdec_src_template); + gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, raw_caps2); + gst_element_class_add_pad_template (element_class, + gst_vorbisdec_sink_template); + gst_element_class_add_pad_template (element_class, + gst_vorbisdec_src_template); gst_element_class_set_details (element_class, &ivorbisfile_details); } @@ -244,17 +225,17 @@ gst_ivorbisfile_class_init (IvorbisfileClass * klass) GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property (gobject_class, ARG_METADATA, - g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata", - GST_TYPE_CAPS, G_PARAM_READABLE)); + g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata", + GST_TYPE_CAPS, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_STREAMINFO, - g_param_spec_boxed ("streaminfo", "stream", "(logical) Stream information", - GST_TYPE_CAPS, G_PARAM_READABLE)); + g_param_spec_boxed ("streaminfo", "stream", + "(logical) Stream information", GST_TYPE_CAPS, G_PARAM_READABLE)); gobject_class->get_property = gst_ivorbisfile_get_property; gobject_class->set_property = gst_ivorbisfile_set_property; @@ -266,23 +247,28 @@ static void gst_ivorbisfile_init (Ivorbisfile * ivorbisfile) { ivorbisfile->sinkpad = gst_pad_new_from_template (gst_vorbisdec_sink_template, - "sink"); + "sink"); gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->sinkpad); - gst_pad_set_formats_function (ivorbisfile->sinkpad, gst_ivorbisfile_get_formats); - gst_pad_set_convert_function (ivorbisfile->sinkpad, gst_ivorbisfile_sink_convert); - - gst_element_set_loop_function (GST_ELEMENT (ivorbisfile), gst_ivorbisfile_loop); - ivorbisfile->srcpad = gst_pad_new_from_template (gst_vorbisdec_src_template, - "src"); + gst_pad_set_formats_function (ivorbisfile->sinkpad, + gst_ivorbisfile_get_formats); + gst_pad_set_convert_function (ivorbisfile->sinkpad, + gst_ivorbisfile_sink_convert); + + gst_element_set_loop_function (GST_ELEMENT (ivorbisfile), + gst_ivorbisfile_loop); + ivorbisfile->srcpad = + gst_pad_new_from_template (gst_vorbisdec_src_template, "src"); gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->srcpad); - gst_pad_set_formats_function (ivorbisfile->srcpad, gst_ivorbisfile_get_formats); - gst_pad_set_query_type_function (ivorbisfile->srcpad, - gst_ivorbisfile_get_query_types); + gst_pad_set_formats_function (ivorbisfile->srcpad, + gst_ivorbisfile_get_formats); + gst_pad_set_query_type_function (ivorbisfile->srcpad, + gst_ivorbisfile_get_query_types); gst_pad_set_query_function (ivorbisfile->srcpad, gst_ivorbisfile_src_query); - gst_pad_set_event_mask_function (ivorbisfile->srcpad, - gst_ivorbisfile_get_event_masks); + gst_pad_set_event_mask_function (ivorbisfile->srcpad, + gst_ivorbisfile_get_event_masks); gst_pad_set_event_function (ivorbisfile->srcpad, gst_ivorbisfile_src_event); - gst_pad_set_convert_function (ivorbisfile->srcpad, gst_ivorbisfile_src_convert); + gst_pad_set_convert_function (ivorbisfile->srcpad, + gst_ivorbisfile_src_convert); ivorbisfile->total_bytes = 0; ivorbisfile->offset = 0; @@ -308,41 +294,40 @@ gst_ivorbisfile_read (void *ptr, size_t size, size_t nmemb, void *datasource) GST_DEBUG ("read %d", read_size); /* make sure we don't go to EOS */ - if (!ivorbisfile->may_eos && ivorbisfile->total_bytes && - ivorbisfile->offset + read_size > ivorbisfile->total_bytes) - { + if (!ivorbisfile->may_eos && ivorbisfile->total_bytes && + ivorbisfile->offset + read_size > ivorbisfile->total_bytes) { read_size = ivorbisfile->total_bytes - ivorbisfile->offset; } if (read_size == 0 || ivorbisfile->eos) return 0; - + while (got_bytes == 0) { got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, read_size); if (got_bytes < read_size) { GstEvent *event; guint32 avail; - - gst_bytestream_get_status (ivorbisfile->bs, &avail, &event); + + gst_bytestream_get_status (ivorbisfile->bs, &avail, &event); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: GST_DEBUG ("eos"); - ivorbisfile->eos = TRUE; - if (avail == 0) { - gst_event_unref (event); - return 0; + ivorbisfile->eos = TRUE; + if (avail == 0) { + gst_event_unref (event); + return 0; } break; case GST_EVENT_DISCONTINUOUS: GST_DEBUG ("discont"); ivorbisfile->need_discont = TRUE; default: - break; + break; } gst_event_unref (event); - if (avail > 0) - got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail); + if (avail > 0) + got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail); else got_bytes = 0; } @@ -368,25 +353,22 @@ gst_ivorbisfile_seek (void *datasource, int64_t offset, int whence) if (!ivorbisfile->vf.seekable) { return -1; } - + GST_DEBUG ("seek %lld %d", offset, whence); if (whence == SEEK_SET) { method = GST_SEEK_METHOD_SET; pending_offset = offset; - } - else if (whence == SEEK_CUR) { + } else if (whence == SEEK_CUR) { method = GST_SEEK_METHOD_CUR; pending_offset += offset; - } - else if (whence == SEEK_END) { + } else if (whence == SEEK_END) { method = GST_SEEK_METHOD_END; need_total = TRUE; pending_offset = ivorbisfile->total_bytes - offset; - } - else + } else return -1; - + if (!gst_bytestream_seek (ivorbisfile->bs, offset, method)) return -1; @@ -417,8 +399,7 @@ gst_ivorbisfile_tell (void *datasource) return result; } -ov_callbacks ivorbisfile_ov_callbacks = -{ +ov_callbacks ivorbisfile_ov_callbacks = { gst_ivorbisfile_read, gst_ivorbisfile_seek, gst_ivorbisfile_close, @@ -430,7 +411,7 @@ ov_callbacks ivorbisfile_ov_callbacks = * returns TRUE if caps could be set, * FALSE if they couldn't be read somehow */ static gboolean -gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link) +gst_ivorbisfile_update_metadata (Ivorbisfile * ivorbisfile, gint link) { OggVorbis_File *vf = &ivorbisfile->vf; gchar **ptr; @@ -453,15 +434,14 @@ gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link) while (*ptr) { value = strstr (*ptr, "="); if (value) { - name = g_strndup (*ptr, value-*ptr); - entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value+1); + name = g_strndup (*ptr, value - *ptr); + entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value + 1); gst_props_add_entry (props, (GstPropsEntry *) entry); } ptr++; } ivorbisfile->metadata = gst_caps_new ("ivorbisfile_metadata", - "application/x-gst-metadata", - props); + "application/x-gst-metadata", props); g_object_notify (G_OBJECT (ivorbisfile), "metadata"); @@ -472,7 +452,7 @@ gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link) * returns TRUE if caps could be set, * FALSE if they couldn't be read somehow */ static gboolean -gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link) +gst_ivorbisfile_update_streaminfo (Ivorbisfile * ivorbisfile, gint link) { OggVorbis_File *vf = &ivorbisfile->vf; vorbis_info *vi; @@ -491,25 +471,24 @@ gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link) vi = ov_info (vf, link); entry = gst_props_entry_new ("version", GST_PROPS_INT_TYPE, vi->version); gst_props_add_entry (props, (GstPropsEntry *) entry); - entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE, - vi->bitrate_upper); + entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE, + vi->bitrate_upper); gst_props_add_entry (props, (GstPropsEntry *) entry); - entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE, - vi->bitrate_nominal); + entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE, + vi->bitrate_nominal); gst_props_add_entry (props, (GstPropsEntry *) entry); - entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE, - vi->bitrate_lower); + entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE, + vi->bitrate_lower); gst_props_add_entry (props, (GstPropsEntry *) entry); - entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE, - ov_serialnumber (vf, link)); + entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE, + ov_serialnumber (vf, link)); gst_props_add_entry (props, (GstPropsEntry *) entry); - entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE, - ov_bitrate (vf, link)); + entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE, + ov_bitrate (vf, link)); gst_props_add_entry (props, (GstPropsEntry *) entry); ivorbisfile->streaminfo = gst_caps_new ("ivorbisfile_streaminfo", - "application/x-gst-streaminfo", - props); + "application/x-gst-streaminfo", props); g_object_notify (G_OBJECT (ivorbisfile), "streaminfo"); @@ -518,7 +497,7 @@ gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link) #endif static gboolean -gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link) +gst_ivorbisfile_new_link (Ivorbisfile * ivorbisfile, gint link) { vorbis_info *vi = ov_info (&ivorbisfile->vf, link); GstCaps *caps; @@ -528,25 +507,23 @@ gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link) ivorbisfile->current_link = link; caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "rate", G_TYPE_INT, vi->rate, - "channels", G_TYPE_INT, vi->channels, - NULL); + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, TRUE, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "rate", G_TYPE_INT, vi->rate, "channels", G_TYPE_INT, vi->channels, NULL); if (gst_pad_try_set_caps (ivorbisfile->srcpad, caps) <= 0) { - res = FALSE; + res = FALSE; } gst_caps_free (caps); - + return TRUE; } static void -gst_ivorbisfile_loop (GstElement *element) +gst_ivorbisfile_loop (GstElement * element) { Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element); GstBuffer *outbuf; @@ -562,13 +539,13 @@ gst_ivorbisfile_loop (GstElement *element) ivorbisfile->total_bytes = 0; ivorbisfile->may_eos = FALSE; ivorbisfile->vf.seekable = gst_bytestream_seek (ivorbisfile->bs, 0, - GST_SEEK_METHOD_SET); + GST_SEEK_METHOD_SET); GST_DEBUG ("ivorbisfile: seekable: %s\n", - ivorbisfile->vf.seekable ? "yes" : "no"); + ivorbisfile->vf.seekable ? "yes" : "no"); /* open our custom ivorbisfile data object with the callbacks we provide */ if (ov_open_callbacks (ivorbisfile, &ivorbisfile->vf, NULL, 0, - ivorbisfile_ov_callbacks) < 0) { + ivorbisfile_ov_callbacks) < 0) { GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL), (NULL)); return; } @@ -583,47 +560,43 @@ gst_ivorbisfile_loop (GstElement *element) switch (ivorbisfile->seek_format) { case GST_FORMAT_TIME: { - gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND; + gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND; if (ivorbisfile->seek_accurate) { - if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) { - ivorbisfile->need_discont = TRUE; - } - } - else { - if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) { - ivorbisfile->need_discont = TRUE; - } + if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) { + ivorbisfile->need_discont = TRUE; + } + } else { + if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) { + ivorbisfile->need_discont = TRUE; + } } break; } case GST_FORMAT_DEFAULT: if (ivorbisfile->seek_accurate) { - if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) { - ivorbisfile->need_discont = TRUE; - } - } - else { - if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) { - ivorbisfile->need_discont = TRUE; - } + if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) { + ivorbisfile->need_discont = TRUE; + } + } else { + if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) { + ivorbisfile->need_discont = TRUE; + } } break; default: if (ivorbisfile->seek_format == logical_stream_format) { - gint64 seek_to; - + gint64 seek_to; + seek_to = ivorbisfile->vf.offsets[ivorbisfile->seek_value]; - if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) { - ivorbisfile->need_discont = TRUE; - ivorbisfile->current_link = -1; - } - else { + if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) { + ivorbisfile->need_discont = TRUE; + ivorbisfile->current_link = -1; + } else { g_warning ("raw seek failed"); } - } - else + } else g_warning ("unknown seek method, implement me !"); break; } @@ -645,30 +618,27 @@ gst_ivorbisfile_loop (GstElement *element) /* get current time for discont and buffer timestamp */ time = (GstClockTime) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND); - ret = ov_read (&ivorbisfile->vf, - GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), - &link); + ret = ov_read (&ivorbisfile->vf, + GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), &link); if (ret == 0) { GST_DEBUG ("eos"); /* send EOS event */ - /*ov_clear (&ivorbisfile->vf);*/ + /*ov_clear (&ivorbisfile->vf); */ ivorbisfile->restart = TRUE; gst_buffer_unref (outbuf); /* if the pad is not usable, don't push it out */ if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) { - gst_pad_push (ivorbisfile->srcpad, - GST_DATA (gst_event_new (GST_EVENT_EOS))); + gst_pad_push (ivorbisfile->srcpad, + GST_DATA (gst_event_new (GST_EVENT_EOS))); } gst_element_set_eos (element); return; - } - else if (ret < 0) { + } else if (ret < 0) { g_warning ("ivorbisfile: decoding error"); gst_buffer_unref (outbuf); return; - } - else { + } else { if (ivorbisfile->need_discont) { GstEvent *discont; @@ -676,13 +646,13 @@ gst_ivorbisfile_loop (GstElement *element) /* if the pad is not usable, don't push it out */ if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) { - /* get stream stats */ - samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf)); + /* get stream stats */ + samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf)); - discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, - GST_FORMAT_DEFAULT, samples, NULL); + discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, + GST_FORMAT_DEFAULT, samples, NULL); - gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont)); + gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont)); } } @@ -694,16 +664,16 @@ gst_ivorbisfile_loop (GstElement *element) if (!ivorbisfile->vf.seekable) { ivorbisfile->total_bytes += GST_BUFFER_SIZE (outbuf); } - - if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) + + if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) gst_pad_push (ivorbisfile->srcpad, GST_DATA (outbuf)); else gst_buffer_unref (outbuf); } } -static const GstFormat* -gst_ivorbisfile_get_formats (GstPad *pad) +static const GstFormat * +gst_ivorbisfile_get_formats (GstPad * pad) { static GstFormat src_formats[] = { GST_FORMAT_TIME, @@ -721,21 +691,21 @@ gst_ivorbisfile_get_formats (GstPad *pad) src_formats[3] = logical_stream_format; sink_formats[2] = logical_stream_format; - + return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats); } static gboolean -gst_ivorbisfile_src_convert (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_ivorbisfile_src_convert (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { gboolean res = TRUE; guint scale = 1; gint bytes_per_sample; - Ivorbisfile *ivorbisfile; + Ivorbisfile *ivorbisfile; vorbis_info *vi; - + ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad)); vi = ov_info (&ivorbisfile->vf, -1); @@ -744,44 +714,44 @@ gst_ivorbisfile_src_convert (GstPad *pad, switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { - case GST_FORMAT_DEFAULT: - *dest_value = src_value / (vi->channels * 2); - break; - case GST_FORMAT_TIME: - { - gint byterate = bytes_per_sample * vi->rate; - - if (byterate == 0) - return FALSE; - *dest_value = src_value * GST_SECOND / byterate; - break; - } - default: - res = FALSE; + case GST_FORMAT_DEFAULT: + *dest_value = src_value / (vi->channels * 2); + break; + case GST_FORMAT_TIME: + { + gint byterate = bytes_per_sample * vi->rate; + + if (byterate == 0) + return FALSE; + *dest_value = src_value * GST_SECOND / byterate; + break; + } + default: + res = FALSE; } case GST_FORMAT_DEFAULT: switch (*dest_format) { - case GST_FORMAT_BYTES: + case GST_FORMAT_BYTES: *dest_value = src_value * bytes_per_sample; - break; - case GST_FORMAT_TIME: + break; + case GST_FORMAT_TIME: if (vi->rate == 0) return FALSE; *dest_value = src_value * GST_SECOND / vi->rate; - break; - default: - res = FALSE; + break; + default: + res = FALSE; } break; case GST_FORMAT_TIME: switch (*dest_format) { - case GST_FORMAT_BYTES: + case GST_FORMAT_BYTES: scale = bytes_per_sample; - case GST_FORMAT_DEFAULT: + case GST_FORMAT_DEFAULT: *dest_value = src_value * scale * vi->rate / GST_SECOND; - break; - default: - res = FALSE; + break; + default: + res = FALSE; } break; default: @@ -791,11 +761,11 @@ gst_ivorbisfile_src_convert (GstPad *pad, gint i; gint64 count = 0; - switch (*dest_format) { - case GST_FORMAT_BYTES: - res = FALSE; - break; - case GST_FORMAT_DEFAULT: + switch (*dest_format) { + case GST_FORMAT_BYTES: + res = FALSE; + break; + case GST_FORMAT_DEFAULT: if (src_value > ivorbisfile->vf.links) { src_value = ivorbisfile->vf.links; } @@ -805,86 +775,83 @@ gst_ivorbisfile_src_convert (GstPad *pad, count += ov_pcm_total (&ivorbisfile->vf, i); } *dest_value = count; - break; - case GST_FORMAT_TIME: + break; + case GST_FORMAT_TIME: { if (src_value > ivorbisfile->vf.links) { src_value = ivorbisfile->vf.links; } for (i = 0; i < src_value; i++) { vi = ov_info (&ivorbisfile->vf, i); - if (vi->rate) - count += ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate; + if (vi->rate) + count += + ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate; else - count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND; + count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND; } /* we use the pcm totals to get the total time, it's more accurate */ *dest_value = count; - break; + break; } - default: - res = FALSE; + default: + res = FALSE; } - } - else - res = FALSE; + } else + res = FALSE; break; } return res; } static gboolean -gst_ivorbisfile_sink_convert (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_ivorbisfile_sink_convert (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { gboolean res = TRUE; - Ivorbisfile *ivorbisfile; - + Ivorbisfile *ivorbisfile; + ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad)); switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { - case GST_FORMAT_TIME: - break; - default: - if (*dest_format == logical_stream_format) { - } - else - res = FALSE; + case GST_FORMAT_TIME: + break; + default: + if (*dest_format == logical_stream_format) { + } else + res = FALSE; } case GST_FORMAT_TIME: switch (*dest_format) { - case GST_FORMAT_BYTES: - break; - default: - if (*dest_format == logical_stream_format) { - } - else - res = FALSE; + case GST_FORMAT_BYTES: + break; + default: + if (*dest_format == logical_stream_format) { + } else + res = FALSE; } default: if (src_format == logical_stream_format) { - switch (*dest_format) { - case GST_FORMAT_TIME: - break; - case GST_FORMAT_BYTES: - break; - default: - res = FALSE; - } - } - else - res = FALSE; + switch (*dest_format) { + case GST_FORMAT_TIME: + break; + case GST_FORMAT_BYTES: + break; + default: + res = FALSE; + } + } else + res = FALSE; break; } return res; } -static const GstQueryType* -gst_ivorbisfile_get_query_types (GstPad *pad) +static const GstQueryType * +gst_ivorbisfile_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -896,13 +863,13 @@ gst_ivorbisfile_get_query_types (GstPad *pad) /* handles queries for location in the stream in the requested format */ static gboolean -gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_ivorbisfile_src_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { gboolean res = TRUE; - Ivorbisfile *ivorbisfile; + Ivorbisfile *ivorbisfile; vorbis_info *vi; - + ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad)); vi = ov_info (&ivorbisfile->vf, -1); @@ -911,68 +878,67 @@ gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type, case GST_QUERY_TOTAL: { switch (*format) { - case GST_FORMAT_DEFAULT: - if (ivorbisfile->vf.seekable) + case GST_FORMAT_DEFAULT: + if (ivorbisfile->vf.seekable) *value = ov_pcm_total (&ivorbisfile->vf, -1); else return FALSE; break; - case GST_FORMAT_BYTES: - if (ivorbisfile->vf.seekable) + case GST_FORMAT_BYTES: + if (ivorbisfile->vf.seekable) *value = ov_pcm_total (&ivorbisfile->vf, -1) * vi->channels * 2; else return FALSE; break; - case GST_FORMAT_TIME: - if (ivorbisfile->vf.seekable) - *value = (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND); + case GST_FORMAT_TIME: + if (ivorbisfile->vf.seekable) + *value = + (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND); else return FALSE; break; default: if (*format == logical_stream_format) { - if (ivorbisfile->vf.seekable) + if (ivorbisfile->vf.seekable) *value = ivorbisfile->vf.links; else - return FALSE; - } - else - res = FALSE; - break; + return FALSE; + } else + res = FALSE; + break; } break; } case GST_QUERY_POSITION: switch (*format) { - case GST_FORMAT_TIME: - if (ivorbisfile->vf.seekable) + case GST_FORMAT_TIME: + if (ivorbisfile->vf.seekable) *value = (gint64) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND); else - *value = ivorbisfile->total_bytes * GST_SECOND - / (vi->rate * vi->channels * 2); + *value = ivorbisfile->total_bytes * GST_SECOND + / (vi->rate * vi->channels * 2); break; - case GST_FORMAT_BYTES: - if (ivorbisfile->vf.seekable) + case GST_FORMAT_BYTES: + if (ivorbisfile->vf.seekable) *value = ov_pcm_tell (&ivorbisfile->vf) * vi->channels * 2; else - *value = ivorbisfile->total_bytes; + *value = ivorbisfile->total_bytes; break; - case GST_FORMAT_DEFAULT: - if (ivorbisfile->vf.seekable) + case GST_FORMAT_DEFAULT: + if (ivorbisfile->vf.seekable) *value = ov_pcm_tell (&ivorbisfile->vf); else - *value = ivorbisfile->total_bytes / (vi->channels * 2); + *value = ivorbisfile->total_bytes / (vi->channels * 2); break; - default: + default: if (*format == logical_stream_format) { - if (ivorbisfile->vf.seekable) + if (ivorbisfile->vf.seekable) *value = ivorbisfile->current_link; else - return FALSE; - } - else - res = FALSE; - break; + return FALSE; + } else + res = FALSE; + break; } break; default: @@ -983,23 +949,23 @@ gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type, return res; } -static const GstEventMask* -gst_ivorbisfile_get_event_masks (GstPad *pad) +static const GstEventMask * +gst_ivorbisfile_get_event_masks (GstPad * pad) { static const GstEventMask masks[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE }, - { 0, } + {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE}, + {0,} }; return masks; } /* handle events on src pad */ static gboolean -gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event) +gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event) { gboolean res = TRUE; - Ivorbisfile *ivorbisfile; - + Ivorbisfile *ivorbisfile; + ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad)); switch (GST_EVENT_TYPE (event)) { @@ -1008,13 +974,13 @@ gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event) gint64 offset; vorbis_info *vi; GstFormat format; - + GST_DEBUG ("ivorbisfile: handling seek event on pad %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); if (!ivorbisfile->vf.seekable) { gst_event_unref (event); GST_DEBUG ("vorbis stream is not seekable"); - return FALSE; + return FALSE; } offset = GST_EVENT_SEEK_OFFSET (event); @@ -1025,35 +991,33 @@ gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event) ivorbisfile->seek_pending = TRUE; ivorbisfile->seek_value = offset; ivorbisfile->seek_format = format; - ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) - & GST_SEEK_FLAG_ACCURATE; + ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) + & GST_SEEK_FLAG_ACCURATE; break; case GST_FORMAT_BYTES: - vi = ov_info (&ivorbisfile->vf, -1); + vi = ov_info (&ivorbisfile->vf, -1); if (vi->channels == 0) { GST_DEBUG ("vorbis stream has 0 channels ?"); res = FALSE; - goto done; + goto done; } - offset /= vi->channels * 2; + offset /= vi->channels * 2; /* fallthrough */ case GST_FORMAT_DEFAULT: ivorbisfile->seek_pending = TRUE; ivorbisfile->seek_value = offset; ivorbisfile->seek_format = format; - ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) - & GST_SEEK_FLAG_ACCURATE; + ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) + & GST_SEEK_FLAG_ACCURATE; break; default: if (format == logical_stream_format) { ivorbisfile->seek_pending = TRUE; ivorbisfile->seek_value = offset; ivorbisfile->seek_format = format; - ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) - & GST_SEEK_FLAG_ACCURATE; - } - else - { + ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event) + & GST_SEEK_FLAG_ACCURATE; + } else { GST_DEBUG ("unhandled seek format"); res = FALSE; } @@ -1072,10 +1036,10 @@ done: } static GstElementStateReturn -gst_ivorbisfile_change_state (GstElement *element) +gst_ivorbisfile_change_state (GstElement * element) { Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element); - + switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: case GST_STATE_READY_TO_PAUSED: @@ -1097,16 +1061,16 @@ gst_ivorbisfile_change_state (GstElement *element) if (GST_ELEMENT_CLASS (parent_class)->change_state) return GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return GST_STATE_SUCCESS; } static void -gst_ivorbisfile_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_ivorbisfile_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { Ivorbisfile *ivorbisfile; - + g_return_if_fail (GST_IS_IVORBISFILE (object)); ivorbisfile = GST_IVORBISFILE (object); @@ -1117,12 +1081,12 @@ gst_ivorbisfile_set_property (GObject *object, guint prop_id, } } -static void -gst_ivorbisfile_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +static void +gst_ivorbisfile_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { Ivorbisfile *ivorbisfile; - + g_return_if_fail (GST_IS_IVORBISFILE (object)); ivorbisfile = GST_IVORBISFILE (object); |