From 91ab6b0ca98c88bdab74da57626eadcba5f8bc80 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Thu, 19 Dec 2002 07:45:11 +0000 Subject: [PATCH] add user_data src pad Original commit message from CVS: add user_data src pad --- ext/mpeg2dec/gstmpeg2dec.c | 36 ++++++++++++++++++++++++++++++++++-- ext/mpeg2dec/gstmpeg2dec.h | 14 ++++---------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ext/mpeg2dec/gstmpeg2dec.c b/ext/mpeg2dec/gstmpeg2dec.c index c6ab1c8b8d..3c999efc34 100644 --- a/ext/mpeg2dec/gstmpeg2dec.c +++ b/ext/mpeg2dec/gstmpeg2dec.c @@ -30,8 +30,8 @@ static GstElementDetails gst_mpeg2dec_details = { "GPL", "Uses libmpeg2 to decode MPEG video streams", VERSION, - "Wim Taymans , " - "(C) 2002", + "Wim Taymans ", + "(C) 2002" }; /* Mpeg2dec signals and args */ @@ -70,6 +70,17 @@ GST_PAD_TEMPLATE_FACTORY (src_template_factory, ) ); +GST_PAD_TEMPLATE_FACTORY (user_data_template_factory, + "user_data", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_CAPS_NEW ( + "mpeg2dec_user_data", + "application/octet-stream", + NULL + ) +); + GST_PAD_TEMPLATE_FACTORY (sink_template_factory, "sink", GST_PAD_SINK, @@ -186,6 +197,10 @@ gst_mpeg2dec_init (GstMpeg2dec *mpeg2dec) gst_pad_set_query_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_query)); gst_pad_set_convert_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_convert_src)); + mpeg2dec->userdatapad = gst_pad_new_from_template ( + GST_PAD_TEMPLATE_GET (user_data_template_factory), "user_data"); + gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->userdatapad); + /* initialize the mpeg2dec decoder state */ mpeg2dec->decoder = mpeg2_init (); @@ -506,6 +521,22 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf) state); break; } + + /* If there is user data and user data pad is usable, push it. + * + * FIXME: should pass more information such as state the user data is from + */ + if (info->user_data_len > 0) { + if (GST_PAD_IS_USABLE (mpeg2dec->userdatapad)) { + GstBuffer *udbuf = gst_buffer_new_and_alloc (info->user_data_len); + memcpy (GST_BUFFER_DATA (udbuf), info->user_data, info->user_data_len); + GST_BUFFER_SIZE (udbuf) = info->user_data_len; + // FIXME + //GST_BUFFER_TIMESTAMP (udbuf) = mpeg2dec->... + //... + gst_pad_push (mpeg2dec->userdatapad, udbuf); + } + } } gst_buffer_unref(buf); } @@ -915,6 +946,7 @@ plugin_init (GModule *module, GstPlugin *plugin) gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_template_factory)); gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_template_factory)); + gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (user_data_template_factory)); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); diff --git a/ext/mpeg2dec/gstmpeg2dec.h b/ext/mpeg2dec/gstmpeg2dec.h index 7d89e24c31..b18e8970af 100644 --- a/ext/mpeg2dec/gstmpeg2dec.h +++ b/ext/mpeg2dec/gstmpeg2dec.h @@ -26,10 +26,7 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +G_BEGIN_DECLS #define GST_TYPE_MPEG2DEC \ (gst_mpeg2dec_get_type()) @@ -60,7 +57,8 @@ struct _GstMpeg2dec { /* pads */ GstPad *sinkpad, - *srcpad; + *srcpad, + *userdatapad; GstBufferPool *peerpool; mpeg2dec_t *decoder; @@ -93,10 +91,6 @@ struct _GstMpeg2decClass { GType gst_mpeg2dec_get_type(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +G_END_DECLS #endif /* __GST_MPEG2DEC_H__ */