From 7d33cf22a9824590e17f8696b2712c58e5decf7c Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 27 Feb 2009 10:18:14 +0000 Subject: resindvd: First part of the re-plugging audio decoder --- ext/resindvd/Makefile.am | 2 + ext/resindvd/rsnaudiodec.c | 143 +++++++++++++++++++++++++++++++++++++++++++++ ext/resindvd/rsnaudiodec.h | 53 +++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 ext/resindvd/rsnaudiodec.c create mode 100644 ext/resindvd/rsnaudiodec.h (limited to 'ext/resindvd') diff --git a/ext/resindvd/Makefile.am b/ext/resindvd/Makefile.am index dbf34d43..3a00d151 100644 --- a/ext/resindvd/Makefile.am +++ b/ext/resindvd/Makefile.am @@ -6,6 +6,7 @@ libresindvd_la_SOURCES = \ plugin.c \ resindvdbin.c \ rsnaudiomunge.c \ + rsnaudiodec.c \ rsnbasesrc.c \ rsnpushsrc.c \ rsnstreamselector.c \ @@ -23,6 +24,7 @@ libresindvd_la_LIBTOOLFLAGS = --tag=disable-static noinst_HEADERS = resindvdbin.h \ rsnaudiomunge.h \ + rsnaudiodec.h \ rsnbasesrc.h \ rsnpushsrc.h \ rsnstreamselector.h \ diff --git a/ext/resindvd/rsnaudiodec.c b/ext/resindvd/rsnaudiodec.c new file mode 100644 index 00000000..df7fc0c8 --- /dev/null +++ b/ext/resindvd/rsnaudiodec.c @@ -0,0 +1,143 @@ +/* GStreamer + * Copyright (C) <2009> Jan Schmidt + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "rsnaudiodec.h" + +GST_DEBUG_CATEGORY_STATIC (rsn_audiodec_debug); +#define GST_CAT_DEFAULT rsn_audiodec_debug + +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/mpeg,mpegversion=(int)1;" + "audio/x-private1-lpcm;" + "audio/x-private1-ac3;" "audio/x-private1-dts;" "audio/ac3") + ); + +static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-float, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) { 32, 64 }; " + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) 32, " + "depth = (int) 32, " + "signed = (boolean) true; " + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) 24, " + "depth = (int) 24, " + "signed = (boolean) true; " + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) 16, " + "depth = (int) 16, " + "signed = (boolean) true; " + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) 8, " "depth = (int) 8, " "signed = (boolean) true") + ); + +G_DEFINE_TYPE (RsnAudioDec, rsn_audiodec, GST_TYPE_BIN); + +static gboolean rsn_audiodec_set_sink_caps (GstPad * sinkpad, GstCaps * caps); +static GstCaps *rsn_audiodec_get_sink_caps (GstPad * sinkpad); +static GstFlowReturn rsn_audiodec_chain (GstPad * pad, GstBuffer * buf); +static gboolean rsn_audiodec_sink_event (GstPad * pad, GstEvent * event); + +static void +rsn_audiodec_class_init (RsnAudioDecClass * klass) +{ + static GstElementDetails element_details = { + "RsnAudioDec", + "Audio/Decoder", + "Resin DVD audio stream decoder", + "Jan Schmidt " + }; + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + GST_DEBUG_CATEGORY_INIT (rsn_audiodec_debug, "rsn_audiodec", + 0, "Resin DVD audio stream decoder"); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template)); + + gst_element_class_set_details (element_class, &element_details); +} + +static void +rsn_audiodec_init (RsnAudioDec * self) +{ + self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); + gst_pad_set_setcaps_function (self->sinkpad, + GST_DEBUG_FUNCPTR (rsn_audiodec_set_sink_caps)); + gst_pad_set_getcaps_function (self->sinkpad, + GST_DEBUG_FUNCPTR (rsn_audiodec_get_sink_caps)); + gst_pad_set_chain_function (self->sinkpad, + GST_DEBUG_FUNCPTR (rsn_audiodec_chain)); + gst_pad_set_event_function (self->sinkpad, + GST_DEBUG_FUNCPTR (rsn_audiodec_sink_event)); + gst_element_add_pad (GST_ELEMENT (self), self->sinkpad); + + self->srcpad = gst_pad_new_from_static_template (&src_template, "src"); + + gst_element_add_pad (GST_ELEMENT (self), self->srcpad); +} + +static gboolean +rsn_audiodec_set_sink_caps (GstPad * sinkpad, GstCaps * caps) +{ + return FALSE; +} + +static GstCaps * +rsn_audiodec_get_sink_caps (GstPad * sinkpad) +{ + return NULL; +} + +static GstFlowReturn +rsn_audiodec_chain (GstPad * pad, GstBuffer * buf) +{ + return GST_FLOW_ERROR; +} + +static gboolean +rsn_audiodec_sink_event (GstPad * pad, GstEvent * event) +{ + return FALSE; +} diff --git a/ext/resindvd/rsnaudiodec.h b/ext/resindvd/rsnaudiodec.h new file mode 100644 index 00000000..1c08f9f6 --- /dev/null +++ b/ext/resindvd/rsnaudiodec.h @@ -0,0 +1,53 @@ +/* GStreamer + * Copyright (C) <2009> Jan Schmidt + * + * 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. + */ + +#ifndef __RSNAUDIODEC_H__ +#define __RSNAUDIODEC_H__ + +#include + +G_BEGIN_DECLS + +#define RSN_TYPE_AUDIODEC (rsn_audiodec_get_type()) +#define RSN_AUDIODEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),RSN_TYPE_AUDIODEC,RsnAudioMunge)) +#define RSN_AUDIODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),RSN_TYPE_AUDIODEC,RsnAudioMungeClass)) +#define RSN_IS_AUDIODEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),RSN_TYPE_AUDIODEC)) +#define RSN_IS_AUDIODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),RSN_TYPE_AUDIODEC)) + +GType rsn_audiodec_get_type (void) G_GNUC_CONST; + +typedef struct _RsnAudioDec RsnAudioDec; +typedef struct _RsnAudioDecClass RsnAudioDecClass; + +struct _RsnAudioDec { + GstBin element; + + GstPad *sinkpad; + GstPad *srcpad; + + GstElement *cur_dec; +}; + +struct _RsnAudioDecClass { + GstBinClass parent_class; +}; + +G_END_DECLS + +#endif /* __RSNAUDIODEC_H__ */ -- cgit v1.2.1