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 extern GstElementDetails flacenc_details;
25 extern GstElementDetails flacdec_details;
27 static GstCaps* flac_type_find (GstBuffer *buf, gpointer private);
29 GstPadTemplate *gst_flacdec_src_template, *gst_flacdec_sink_template;
30 GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template;
33 flac_caps_factory (void)
43 raw_caps_factory (void)
50 "format", GST_PROPS_STRING ("int"),
51 "law", GST_PROPS_INT (0),
52 "endianness", GST_PROPS_INT (G_BYTE_ORDER),
53 "signed", GST_PROPS_BOOLEAN (TRUE),
54 "width", GST_PROPS_INT (16),
55 "depth", GST_PROPS_INT (16),
56 "rate", GST_PROPS_INT_RANGE (11025, 48000),
57 "channels", GST_PROPS_INT_RANGE (1, 2),
61 static GstTypeDefinition flacdefinition = {
69 flac_type_find (GstBuffer *buf, gpointer private)
71 gulong head = GULONG_FROM_BE (*((gulong *)GST_BUFFER_DATA (buf)));
73 if (head != 0x664C6143)
76 return gst_caps_new ("flac_type_find", "audio/x-flac", NULL);
81 plugin_init (GModule *module, GstPlugin *plugin)
83 GstElementFactory *enc, *dec;
85 GstCaps *raw_caps, *flac_caps;
87 /* this filter needs the bytestream package */
88 if (!gst_library_load ("gstbytestream"))
91 gst_plugin_set_longname (plugin, "The FLAC Lossless compressor Codec");
93 /* create an elementfactory for the flacenc element */
94 enc = gst_element_factory_new ("flacenc", GST_TYPE_FLACENC,
96 g_return_val_if_fail (enc != NULL, FALSE);
98 raw_caps = raw_caps_factory ();
99 flac_caps = flac_caps_factory ();
101 /* register sink pads */
102 gst_flacenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
105 gst_element_factory_add_pad_template (enc, gst_flacenc_sink_template);
107 /* register src pads */
108 gst_flacenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
111 gst_element_factory_add_pad_template (enc, gst_flacenc_src_template);
113 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc));
115 /* create an elementfactory for the flacdec element */
116 dec = gst_element_factory_new("flacdec",GST_TYPE_FLACDEC,
118 g_return_val_if_fail(dec != NULL, FALSE);
119 gst_element_factory_set_rank (dec, GST_ELEMENT_RANK_PRIMARY);
121 /* register sink pads */
122 gst_flacdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
125 gst_element_factory_add_pad_template (dec, gst_flacdec_sink_template);
127 /* register src pads */
128 gst_flacdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
131 gst_element_factory_add_pad_template (dec, gst_flacdec_src_template);
133 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec));
135 type = gst_type_factory_new (&flacdefinition);
136 gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
141 GstPluginDesc plugin_desc = {