2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gstflacenc.h"
22 #include "gstflacdec.h"
24 #include "flac_compat.h"
26 extern GstElementDetails flacenc_details;
27 extern GstElementDetails flacdec_details;
29 static GstCaps* flac_type_find (GstBuffer *buf, gpointer private);
31 GstPadTemplate *gst_flacdec_src_template, *gst_flacdec_sink_template;
32 GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template;
35 flac_caps_factory (void)
45 raw_caps_factory (void)
52 "format", GST_PROPS_STRING ("int"),
53 "law", GST_PROPS_INT (0),
54 "endianness", GST_PROPS_INT (G_BYTE_ORDER),
55 "signed", GST_PROPS_BOOLEAN (TRUE),
56 "width", GST_PROPS_INT (16),
57 "depth", GST_PROPS_INT (16),
58 "rate", GST_PROPS_INT_RANGE (11025, 48000),
59 "channels", GST_PROPS_INT_RANGE (1, 2),
63 static GstTypeDefinition flacdefinition = {
64 "flac_application/x-flac",
71 flac_type_find (GstBuffer *buf, gpointer private)
73 guint32 head = GUINT32_FROM_BE (*((guint32 *)GST_BUFFER_DATA (buf)));
75 if (head != 0x664C6143)
78 return gst_caps_new ("flac_type_find", "application/x-flac", NULL);
83 plugin_init (GModule *module, GstPlugin *plugin)
85 GstElementFactory *enc, *dec;
87 GstCaps *raw_caps, *flac_caps;
89 /* this filter needs the bytestream package */
90 if (!gst_library_load ("gstbytestream"))
93 gst_plugin_set_longname (plugin, "The FLAC Lossless compressor Codec");
95 /* create an elementfactory for the flacenc element */
96 enc = gst_element_factory_new ("flacenc", GST_TYPE_FLACENC,
98 g_return_val_if_fail (enc != NULL, FALSE);
100 raw_caps = raw_caps_factory ();
101 flac_caps = flac_caps_factory ();
103 /* register sink pads */
104 gst_flacenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
107 gst_element_factory_add_pad_template (enc, gst_flacenc_sink_template);
109 /* register src pads */
110 gst_flacenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
113 gst_element_factory_add_pad_template (enc, gst_flacenc_src_template);
115 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc));
117 /* create an elementfactory for the flacdec element */
118 dec = gst_element_factory_new("flacdec",GST_TYPE_FLACDEC,
120 g_return_val_if_fail(dec != NULL, FALSE);
121 gst_element_factory_set_rank (dec, GST_ELEMENT_RANK_PRIMARY);
123 /* register sink pads */
124 gst_flacdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
127 gst_element_factory_add_pad_template (dec, gst_flacdec_sink_template);
129 /* register src pads */
130 gst_flacdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
133 gst_element_factory_add_pad_template (dec, gst_flacdec_src_template);
135 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec));
137 type = gst_type_factory_new (&flacdefinition);
138 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
143 GstPluginDesc plugin_desc = {