new plugin writer's issue
ghassen
errouissi.ghassen at gmail.com
Fri Apr 5 06:25:36 PDT 2013
Hi
I' m working on a plugin gstreamer fo demuxing a .ts file using mpegtsdemux
but i have problem with linking pads of my new plugin and mpegtsdemux pads.
if somebady can help me that's will be great
this is my code :
/*
* GStreamer
* Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart.org>
* Copyright (C) 2005 Ronald S. Bultje <rbultje at ronald.bitfreak.net>
* Copyright (C) 2012 Ghassen<<user at hostname.org>>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
"Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Alternatively, the contents of this file may be used under the
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
* which case the following provisions apply instead of the ones
* mentioned above:
*
* 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-pipedemux
*
* FIXME:Describe pipedemux here.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch -v -m fakesrc ! pipedemux ! fakesink silent=TRUE
* ]|
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gst/gst.h>
#include <glib.h>
#include "gstpipedemux.h"
#include "gstpipedemux_core.h"
GST_DEBUG_CATEGORY_STATIC (gst_pipe_demux_debug);
#define GST_CAT_DEFAULT gst_pipe_demux_debug
/* Filter signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_ES_PIDS,
PROP_CHECK_CRC,
PROP_PROGRAM_NUMBER,
PROP_PAT_INFO,
PROP_PMT_INFO,
};
#define VIDEO_CAPS \
GST_STATIC_CAPS (\
"video/mpeg, " \
"mpegversion = (int) { 1, 2, 4 }, " \
"systemstream = (boolean) FALSE; " \
"video/x-h264,stream-format=(string)byte-stream," \
"alignment=(string)nal;" \
"video/x-dirac;" \
"video/x-wmv," \
"wmvversion = (int) 3, " \
"format = (fourcc) WVC1" \
)
#define AUDIO_CAPS \
GST_STATIC_CAPS ( \
"audio/mpeg, " \
"mpegversion = (int) 1;" \
"audio/mpeg, " \
"mpegversion = (int) 4, " \
"stream-format = (string) { adts, loas };" \
"audio/x-lpcm, " \
"width = (int) { 16, 20, 24 }, " \
"rate = (int) { 48000, 96000 }, " \
"channels = (int) [ 1, 8 ], " \
"dynamic_range = (int) [ 0, 255 ], " \
"emphasis = (boolean) { FALSE, TRUE }, " \
"mute = (boolean) { FALSE, TRUE }; " \
"audio/x-ac3; audio/x-eac3;" \
"audio/x-dts;" \
"audio/x-private-ts-lpcm" \
)
#define SUBPICTURE_CAPS \
GST_STATIC_CAPS ("subpicture/x-pgs; video/x-dvd-subpicture")
/* the capabilities of the inputs and outputs.*/
static GstStaticPadTemplate sink_el = GST_STATIC_PAD_TEMPLATE (
"dmxSink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate Video_el =
GST_STATIC_PAD_TEMPLATE (
"dmxVideo",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate Audio_el =
GST_STATIC_PAD_TEMPLATE (
"dmxAudio",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate Subtitle_el =
GST_STATIC_PAD_TEMPLATE (
"dmxSubtitle",
GST_PAD_SRC,
GST_PAD_ALWAYS,
SUBPICTURE_CAPS
);
static GstStaticPadTemplate Reserved_el =
GST_STATIC_PAD_TEMPLATE (
"dmxreserved",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("NULL")
);
static GstStaticPadTemplate gsrc_video_factory =
GST_STATIC_PAD_TEMPLATE("gsrc_video_%d", GST_PAD_SRC, GST_PAD_SOMETIMES,
VIDEO_CAPS);
static GstStaticPadTemplate gsrc_audio_factory =
GST_STATIC_PAD_TEMPLATE("gsrc_audio_%d", GST_PAD_SRC,
GST_PAD_SOMETIMES,AUDIO_CAPS);
static GstStaticPadTemplate gsrc_subtitle_factory =
GST_STATIC_PAD_TEMPLATE("gsrc_subtitle_%d", GST_PAD_SRC, GST_PAD_SOMETIMES,
SUBPICTURE_CAPS);
static GstStaticPadTemplate gsrc_reserved_factory =
GST_STATIC_PAD_TEMPLATE("gsrc_reserved_%d", GST_PAD_SRC, GST_PAD_SOMETIMES,
GST_STATIC_CAPS("NULL"));
GST_BOILERPLATE (GstPipeDemux, gst_pipe_demux, GstBin,GST_TYPE_BIN);
static void gst_pipe_demux_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_pipe_demux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
/* GObject vmethod implementations */
static void gst_pipe_demux_base_init (gpointer gclass) {
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
gst_element_class_set_details_simple(element_class,
"PipeDemux",
"FIXME:Generic",
"FIXME:Generic Template Element",
"ghassen errouissi <<user at hostname.demuxorg>>");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_el));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&Video_el));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&Audio_el));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&Subtitle_el));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&Reserved_el));
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get(&gsrc_video_factory));
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get(&gsrc_audio_factory));
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get(&gsrc_subtitle_factory));
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get(&gsrc_reserved_factory));
}
/* initialize the pipedemux's class */
static void
gst_pipe_demux_class_init (GstPipeDemuxClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_pipe_demux_set_property;
gobject_class->get_property = gst_pipe_demux_get_property;
gobject_class->dispose = gst_pipe_demux_dispose;
gobject_class->finalize = gst_pipe_demux_finalize;
}
/* initialize the new element
* instantiate pads and add them to element
* set pad calback functions
* initialize instance structure
*/
static void gst_pipe_demux_init (GstPipeDemux *module, GstPipeDemuxClass *
gclass) {
char *path;
/*file source location */
path = "/home/g507479/Desktop/ghassen/Nit_with_HD_64qam_final.ts" ;
module->sink_el = gst_element_factory_make ("filesrc","file-source");
module->demux = gst_element_factory_make("mpegtsdemux", "mpegtsdemux");
module->sync_state = GST_PIPE_DEMUX_SYNC_OUT;
module->src_state = GST_PIPE_DEMUX_STATE_SUPPLIED;
module->event_mask = 0;
module->in_buffers = NULL;
module->synchronizers = NULL;
module->is_opal_src = FALSE;
module->need_data = FALSE;
gst_bin_add_many(GST_BIN(module), GST_ELEMENT(module->sink_el),
GST_ELEMENT(module->demux) , NULL);
if(!gst_element_link((module->sink_el), GST_ELEMENT(module->demux)))
{
g_print("failed to link sink_el to the demuxer");
}
g_signal_connect(module->demux,
"pad-added",G_CALLBACK(gst_pipe_demux_on_pad_added),module );
g_signal_connect(module->demux, "pad-removed",
G_CALLBACK(gst_pipe_demux_on_pad_removed), module);
pthread_mutex_init(&module->core_mutex, NULL);
pthread_mutex_init(&module->event_mutex, NULL);
}
static void gst_pipe_demux_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) {
GstPipeDemux *module = GST_PIPEDEMUX (object);
GstCaps *demux_caps = NULL;
pthread_mutex_lock(&module->core_mutex);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
pthread_mutex_unlock(&module->core_mutex);
}
static void gst_pipe_demux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) {
}
/* GstElement vmethod implementations */
/* entry point to initialize the plug-in
* initialize the plug-in itself
* register the element factories and other features
*/
static gboolean pipedemux_init (GstPlugin *pipedemux) {
/* debug category for fltering log messages
*
* exchange the string 'Template pipedemux' with your description
*/
GST_DEBUG_CATEGORY_INIT (gst_pipe_demux_debug, "pipedemux",
0, "Template pipedemux");
return gst_element_register (pipedemux, "pipedemux", GST_RANK_NONE,
GST_TYPE_PIPEDEMUX);
}
/* PACKAGE: this is usually set by autotools depending on some _INIT macro
* in configure.ac and then written into and defined in config.h, but we can
* just set it ourselves here in case someone doesn't use autotools to
* compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
*/
#ifndef PACKAGE
#define PACKAGE "myfirstpipedemux"
#endif
#ifndef VERSION
#define VERSION "0.10.0"
#endif
/* gstreamer looks for this structure to register pipedemuxs
*
* exchange the string 'Template pipedemux' with your pipedemux description
*/
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"pipedemux",
"Template pipedemux",
pipedemux_init,
VERSION,
"LGPL",
"GStreamer",
"http://gstreamer.net/"
)
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/new-plugin-writer-s-issue-tp1559280p4659411.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list