2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-20 22:30:14 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <vorbisenc.h>
|
|
|
|
#include <vorbisdec.h>
|
|
|
|
|
2002-05-31 23:37:28 +00:00
|
|
|
extern GType vorbisfile_get_type(void);
|
|
|
|
|
|
|
|
extern GstElementDetails vorbisfile_details;
|
2001-12-20 22:30:14 +00:00
|
|
|
extern GstElementDetails vorbisenc_details;
|
|
|
|
extern GstElementDetails vorbisdec_details;
|
|
|
|
|
2002-04-11 20:42:27 +00:00
|
|
|
static GstCaps* vorbis_type_find (GstBuffer *buf, gpointer private);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2002-07-28 19:51:29 +00:00
|
|
|
GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template;
|
|
|
|
GstPadTemplate *gst_vorbisenc_src_template, *gst_vorbisenc_sink_template;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
static GstCaps*
|
|
|
|
vorbis_caps_factory (void)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
gst_caps_new (
|
|
|
|
"vorbis_vorbis",
|
|
|
|
"audio/x-ogg",
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps*
|
|
|
|
raw_caps_factory (void)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
gst_caps_new (
|
|
|
|
"vorbis_raw",
|
|
|
|
"audio/raw",
|
|
|
|
gst_props_new (
|
|
|
|
"format", GST_PROPS_STRING ("int"),
|
|
|
|
"law", GST_PROPS_INT (0),
|
|
|
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
|
|
|
|
"signed", GST_PROPS_BOOLEAN (TRUE),
|
|
|
|
"width", GST_PROPS_INT (16),
|
|
|
|
"depth", GST_PROPS_INT (16),
|
|
|
|
"rate", GST_PROPS_INT_RANGE (11025, 48000),
|
|
|
|
"channels", GST_PROPS_INT_RANGE (1, 2),
|
|
|
|
NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps*
|
|
|
|
raw_caps2_factory (void)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
gst_caps_new (
|
|
|
|
"vorbis_raw_float",
|
|
|
|
"audio/raw",
|
|
|
|
gst_props_new (
|
|
|
|
"format", GST_PROPS_STRING ("float"),
|
|
|
|
"layout", GST_PROPS_STRING ("IEEE"),
|
|
|
|
"rate", GST_PROPS_INT_RANGE (11025, 48000),
|
|
|
|
"channels", GST_PROPS_INT (2),
|
|
|
|
NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstTypeDefinition vorbisdefinition = {
|
|
|
|
"vorbis_audio/x-ogg",
|
|
|
|
"audio/x-ogg",
|
|
|
|
".ogg",
|
2002-04-11 20:42:27 +00:00
|
|
|
vorbis_type_find,
|
2001-12-20 22:30:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GstCaps*
|
2002-04-11 20:42:27 +00:00
|
|
|
vorbis_type_find (GstBuffer *buf, gpointer private)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
|
|
|
gulong head = GULONG_FROM_BE (*((gulong *)GST_BUFFER_DATA (buf)));
|
|
|
|
|
|
|
|
if (head != 0x4F676753)
|
|
|
|
return NULL;
|
|
|
|
|
2002-04-11 20:42:27 +00:00
|
|
|
return gst_caps_new ("vorbis_type_find", "audio/x-ogg", NULL);
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GModule *module, GstPlugin *plugin)
|
|
|
|
{
|
2002-05-31 23:37:28 +00:00
|
|
|
GstElementFactory *enc, *dec, *file;
|
2001-12-20 22:30:14 +00:00
|
|
|
GstTypeFactory *type;
|
|
|
|
GstCaps *raw_caps, *vorbis_caps, *raw_caps2;
|
|
|
|
|
|
|
|
gst_plugin_set_longname (plugin, "The OGG Vorbis Codec");
|
|
|
|
|
|
|
|
/* create an elementfactory for the vorbisenc element */
|
2002-04-11 20:42:27 +00:00
|
|
|
enc = gst_element_factory_new ("vorbisenc", GST_TYPE_VORBISENC,
|
2002-09-09 23:27:38 +00:00
|
|
|
&vorbisenc_details);
|
2001-12-20 22:30:14 +00:00
|
|
|
g_return_val_if_fail (enc != NULL, FALSE);
|
|
|
|
|
|
|
|
raw_caps = raw_caps_factory ();
|
|
|
|
raw_caps2 = raw_caps2_factory ();
|
|
|
|
vorbis_caps = vorbis_caps_factory ();
|
|
|
|
|
|
|
|
/* register sink pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
2002-09-09 23:27:38 +00:00
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
raw_caps, NULL);
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (enc, gst_vorbisenc_sink_template);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
/* register src pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
2002-09-09 23:27:38 +00:00
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
vorbis_caps, NULL);
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (enc, gst_vorbisenc_src_template);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc));
|
|
|
|
|
|
|
|
/* create an elementfactory for the vorbisdec element */
|
2002-09-09 23:27:38 +00:00
|
|
|
dec = gst_element_factory_new ("vorbisdec", GST_TYPE_VORBISDEC,
|
|
|
|
&vorbisdec_details);
|
|
|
|
g_return_val_if_fail (dec != NULL, FALSE);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
/* register sink pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
2002-09-09 23:27:38 +00:00
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
vorbis_caps, NULL);
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (dec, gst_vorbisdec_sink_template);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
raw_caps = gst_caps_prepend (raw_caps, raw_caps2);
|
|
|
|
/* register src pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
2002-09-09 23:27:38 +00:00
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
raw_caps, NULL);
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (dec, gst_vorbisdec_src_template);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec));
|
|
|
|
|
2002-05-31 23:37:28 +00:00
|
|
|
/* create an elementfactory for the vorbisfile element */
|
2002-09-09 23:27:38 +00:00
|
|
|
file = gst_element_factory_new ("vorbisfile", vorbisfile_get_type(),
|
|
|
|
&vorbisfile_details);
|
2002-05-31 23:37:28 +00:00
|
|
|
g_return_val_if_fail(file != NULL, FALSE);
|
2002-06-16 22:03:52 +00:00
|
|
|
gst_element_factory_set_rank (file, GST_ELEMENT_RANK_PRIMARY);
|
2002-05-31 23:37:28 +00:00
|
|
|
|
|
|
|
/* register sink pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (file, gst_vorbisdec_sink_template);
|
2002-05-31 23:37:28 +00:00
|
|
|
/* register src pads */
|
2002-07-28 19:51:29 +00:00
|
|
|
gst_element_factory_add_pad_template (file, gst_vorbisdec_src_template);
|
2002-05-31 23:37:28 +00:00
|
|
|
|
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (file));
|
|
|
|
|
|
|
|
/* this filter needs the bytestream package */
|
2002-09-09 23:27:38 +00:00
|
|
|
if (!gst_library_load ("gstbytestream"))
|
2002-05-31 23:37:28 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2002-04-11 20:42:27 +00:00
|
|
|
type = gst_type_factory_new (&vorbisdefinition);
|
2001-12-20 22:30:14 +00:00
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstPluginDesc plugin_desc = {
|
|
|
|
GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"vorbis",
|
|
|
|
plugin_init
|
|
|
|
};
|