mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
add user_data src pad
Original commit message from CVS: add user_data src pad
This commit is contained in:
parent
0a6c2190d5
commit
91ab6b0ca9
2 changed files with 38 additions and 12 deletions
|
@ -30,8 +30,8 @@ static GstElementDetails gst_mpeg2dec_details = {
|
||||||
"GPL",
|
"GPL",
|
||||||
"Uses libmpeg2 to decode MPEG video streams",
|
"Uses libmpeg2 to decode MPEG video streams",
|
||||||
VERSION,
|
VERSION,
|
||||||
"Wim Taymans <wim.taymans@chello.be>, "
|
"Wim Taymans <wim.taymans@chello.be>",
|
||||||
"(C) 2002",
|
"(C) 2002"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Mpeg2dec signals and args */
|
/* 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,
|
GST_PAD_TEMPLATE_FACTORY (sink_template_factory,
|
||||||
"sink",
|
"sink",
|
||||||
GST_PAD_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_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));
|
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 */
|
/* initialize the mpeg2dec decoder state */
|
||||||
mpeg2dec->decoder = mpeg2_init ();
|
mpeg2dec->decoder = mpeg2_init ();
|
||||||
|
|
||||||
|
@ -506,6 +521,22 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf)
|
||||||
state);
|
state);
|
||||||
break;
|
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);
|
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 (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 (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));
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <mpeg2.h>
|
#include <mpeg2.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
G_BEGIN_DECLS
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#define GST_TYPE_MPEG2DEC \
|
#define GST_TYPE_MPEG2DEC \
|
||||||
(gst_mpeg2dec_get_type())
|
(gst_mpeg2dec_get_type())
|
||||||
|
@ -60,7 +57,8 @@ struct _GstMpeg2dec {
|
||||||
|
|
||||||
/* pads */
|
/* pads */
|
||||||
GstPad *sinkpad,
|
GstPad *sinkpad,
|
||||||
*srcpad;
|
*srcpad,
|
||||||
|
*userdatapad;
|
||||||
GstBufferPool *peerpool;
|
GstBufferPool *peerpool;
|
||||||
|
|
||||||
mpeg2dec_t *decoder;
|
mpeg2dec_t *decoder;
|
||||||
|
@ -93,10 +91,6 @@ struct _GstMpeg2decClass {
|
||||||
|
|
||||||
GType gst_mpeg2dec_get_type(void);
|
GType gst_mpeg2dec_get_type(void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_MPEG2DEC_H__ */
|
#endif /* __GST_MPEG2DEC_H__ */
|
||||||
|
|
Loading…
Reference in a new issue