From 0e12bf83a32e1f7ac57b0e6749209da2aba81a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 21 May 2010 12:47:03 +0100 Subject: [PATCH] matroska: move webmmux into own source files Makes things easier for gtk-doc. --- gst/matroska/Makefile.am | 3 +- gst/matroska/matroska-mux.c | 78 ---------------------------- gst/matroska/matroska-mux.h | 2 +- gst/matroska/matroska.c | 13 ++++- gst/matroska/webm-mux.c | 100 ++++++++++++++++++++++++++++++++++++ gst/matroska/webm-mux.h | 49 ++++++++++++++++++ 6 files changed, 163 insertions(+), 82 deletions(-) create mode 100644 gst/matroska/webm-mux.c create mode 100644 gst/matroska/webm-mux.h diff --git a/gst/matroska/Makefile.am b/gst/matroska/Makefile.am index b1e43e213d..8612a2d29e 100644 --- a/gst/matroska/Makefile.am +++ b/gst/matroska/Makefile.am @@ -7,6 +7,7 @@ libgstmatroska_la_SOURCES = \ matroska-demux.c \ matroska-ids.c \ matroska-mux.c \ + webm-mux.c \ lzo.c noinst_HEADERS = \ @@ -16,6 +17,7 @@ noinst_HEADERS = \ matroska-demux.h \ matroska-ids.h \ matroska-mux.h \ + webm-mux.h \ lzo.h libgstmatroska_la_CFLAGS = \ @@ -34,4 +36,3 @@ libgstmatroska_la_LIBADD = \ $(LIBM) libgstmatroska_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmatroska_la_LIBTOOLFLAGS = --tag=disable-static - diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 235d19af47..e21e763c6f 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -204,7 +204,6 @@ G_LOCK_DEFINE_STATIC (used_uids); static void gst_matroska_mux_add_interfaces (GType type); -GType gst_matroska_mux_get_type (void); GST_BOILERPLATE_FULL (GstMatroskaMux, gst_matroska_mux, GstElement, GST_TYPE_ELEMENT, gst_matroska_mux_add_interfaces); @@ -2814,80 +2813,3 @@ gst_matroska_mux_get_property (GObject * object, break; } } - -#define parent_class webm_parent_class - -GType gst_webm_mux_get_type (void); - -typedef GstMatroskaMux GstWebMMux; -typedef GstMatroskaMuxClass GstWebMMuxClass; -#define GST_TYPE_WEBM_MUX \ - (gst_webm_mux_get_type ()) -#define GST_WEBM_MUX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WEBM_MUX, GstWebMMux)) -#define GST_WEBM_MUX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WEBM_MUX, GstWebMMuxClass)) -#define GST_IS_WEBM_MUX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WEBM_MUX)) -#define GST_IS_WEBM_MUX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WEBM_MUX)) - -GST_BOILERPLATE (GstWebMMux, gst_webm_mux, GstMatroskaMux, - GST_TYPE_MATROSKA_MUX); - -static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/webm") - ); - -static GstStaticPadTemplate webm_videosink_templ = -GST_STATIC_PAD_TEMPLATE ("video_%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS ("video/x-vp8, " COMMON_VIDEO_CAPS) - ); - -static GstStaticPadTemplate webm_audiosink_templ = -GST_STATIC_PAD_TEMPLATE ("audio_%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS ("audio/x-vorbis, " COMMON_AUDIO_CAPS) - ); - -static void -gst_webm_mux_base_init (gpointer g_class) -{ -} - -static void -gst_webm_mux_class_init (GstWebMMuxClass * klass) -{ - GstElementClass *gstelement_class = (GstElementClass *) klass; - - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&webm_videosink_templ)); - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&webm_audiosink_templ)); - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&webm_src_templ)); - gst_element_class_set_details_simple (gstelement_class, "WebM muxer", - "Codec/Muxer", - "Muxes video/audio/subtitle streams into a WebM stream", - "GStreamer maintainers "); -} - -static void -gst_webm_mux_init (GstWebMMux * mux, GstWebMMuxClass * g_class) -{ - mux->doctype = GST_MATROSKA_DOCTYPE_WEBM; -} - -gboolean -gst_matroska_mux_plugin_init (GstPlugin * plugin) -{ - return gst_element_register (plugin, "matroskamux", - GST_RANK_PRIMARY, GST_TYPE_MATROSKA_MUX) && - gst_element_register (plugin, "webmmux", - GST_RANK_PRIMARY, GST_TYPE_WEBM_MUX); -} diff --git a/gst/matroska/matroska-mux.h b/gst/matroska/matroska-mux.h index cccd98aed7..f2c7d4f3ed 100644 --- a/gst/matroska/matroska-mux.h +++ b/gst/matroska/matroska-mux.h @@ -128,7 +128,7 @@ typedef struct _GstMatroskaMuxClass { GstElementClass parent; } GstMatroskaMuxClass; -gboolean gst_matroska_mux_plugin_init (GstPlugin *plugin); +GType gst_matroska_mux_get_type (void); G_END_DECLS diff --git a/gst/matroska/matroska.c b/gst/matroska/matroska.c index 5a74c6b521..77634767c6 100644 --- a/gst/matroska/matroska.c +++ b/gst/matroska/matroska.c @@ -26,13 +26,22 @@ #include "matroska-demux.h" #include "matroska-mux.h" #include "matroska-ids.h" +#include "webm-mux.h" static gboolean plugin_init (GstPlugin * plugin) { + gboolean ret; + gst_matroska_register_tags (); - return gst_matroska_demux_plugin_init (plugin) && - gst_matroska_mux_plugin_init (plugin); + + ret = gst_matroska_demux_plugin_init (plugin); + ret &= gst_element_register (plugin, "matroskamux", GST_RANK_PRIMARY, + GST_TYPE_MATROSKA_MUX); + ret &= gst_element_register (plugin, "webmmux", GST_RANK_PRIMARY, + GST_TYPE_WEBM_MUX); + + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/gst/matroska/webm-mux.c b/gst/matroska/webm-mux.c new file mode 100644 index 0000000000..a0a4c4e5e2 --- /dev/null +++ b/gst/matroska/webm-mux.c @@ -0,0 +1,100 @@ +/* GStreamer WebM muxer + * Copyright (c) 2010 Sebastian Dröge + * + * 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. + */ + +/** + * SECTION:element-webmmux + * + * webmmux muxes VP8 video and Vorbis audio streams into a WebM file. + * + * + * Example launch line + * |[ + * FIXME: add example pipeline + * ]| This pipeline muxes this and that into a WebM file. + * |[ + * FIXME: add example pipeline + * ]| This pipeline muxes something else into a WebM file. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "webm-mux.h" + +#define COMMON_VIDEO_CAPS \ + "width = (int) [ 16, 4096 ], " \ + "height = (int) [ 16, 4096 ], " \ + "framerate = (fraction) [ 0, MAX ]" + +#define COMMON_AUDIO_CAPS \ + "channels = (int) [ 1, MAX ], " \ + "rate = (int) [ 1, MAX ]" + +GST_BOILERPLATE (GstWebMMux, gst_webm_mux, GstMatroskaMux, + GST_TYPE_MATROSKA_MUX); + +static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/webm") + ); + +static GstStaticPadTemplate webm_videosink_templ = +GST_STATIC_PAD_TEMPLATE ("video_%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS ("video/x-vp8, " COMMON_VIDEO_CAPS) + ); + +static GstStaticPadTemplate webm_audiosink_templ = +GST_STATIC_PAD_TEMPLATE ("audio_%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS ("audio/x-vorbis, " COMMON_AUDIO_CAPS) + ); + +static void +gst_webm_mux_base_init (gpointer g_class) +{ +} + +static void +gst_webm_mux_class_init (GstWebMMuxClass * klass) +{ + GstElementClass *gstelement_class = (GstElementClass *) klass; + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&webm_videosink_templ)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&webm_audiosink_templ)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&webm_src_templ)); + gst_element_class_set_details_simple (gstelement_class, "WebM muxer", + "Codec/Muxer", + "Muxes video/audio/subtitle streams into a WebM stream", + "GStreamer maintainers "); +} + +static void +gst_webm_mux_init (GstWebMMux * mux, GstWebMMuxClass * g_class) +{ + GST_MATROSKA_MUX (mux)->doctype = GST_MATROSKA_DOCTYPE_WEBM; +} diff --git a/gst/matroska/webm-mux.h b/gst/matroska/webm-mux.h new file mode 100644 index 0000000000..cb007b00cb --- /dev/null +++ b/gst/matroska/webm-mux.h @@ -0,0 +1,49 @@ +/* GStreamer WebM muxer + * Copyright (c) 2010 Sebastian Dröge + * + * 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 __GST_WEBM_MUX_H__ +#define __GST_WEBM_MUX_H__ + +#include "matroska-mux.h" + +#define GST_TYPE_WEBM_MUX \ + (gst_webm_mux_get_type ()) +#define GST_WEBM_MUX(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WEBM_MUX, GstWebMMux)) +#define GST_WEBM_MUX_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WEBM_MUX, GstWebMMuxClass)) +#define GST_IS_WEBM_MUX(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WEBM_MUX)) +#define GST_IS_WEBM_MUX_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WEBM_MUX)) + +typedef struct _GstWebMMux GstWebMMux; +typedef struct _GstWebMMuxClass GstWebMMuxClass; + +struct _GstWebMMux { + GstMatroskaMux matroskamux; +}; + +struct _GstWebMMuxClass { + GstMatroskaMuxClass matroskamuxclass; +}; + +GType gst_webm_mux_get_type (void); + +#endif /* __GST_WEBM_MUX_H__ */