[gst-devel] dynamic change element's parameter
HaroldJRoth
dlafferty at gmail.com
Fri Nov 12 11:28:09 CET 2010
Stefan Kost wrote:
>
> On 14.09.2010 16:37, Chandler Li wrote:
>> Thank you,
>> I paste the key point code to there,
>>
>> the old one caps:
>> caps1 = gst_caps_new_simple ("video/x-raw-yuv",
>> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>> "width", G_TYPE_INT, 123,
>> "height", G_TYPE_INT, 456,
>> "framerate", GST_TYPE_FRACTION, 30, 1,
>> NULL);
>> the new one caps:
>> caps2 = gst_caps_new_simple ("video/x-raw-yuv",
>> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>> "width", G_TYPE_INT, 456,
>> "height", G_TYPE_INT, 789,
>> "framerate", GST_TYPE_FRACTION, 30, 1,
>> NULL);
>> and the folowing code change caps:
>>
>> gst_pad_set_blocked_async(pad,TRUE,my_blocked_callback,NULL);
>> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_NULL);
>> g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);
>> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_PLAYING);
>> gst_pad_set_blocked_async(pad,FALSE,my_blocked_callback,NULL);
>>
> ohh, you can just set the caps. I mean just do:
>
> g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);
>
> Stefan
>
>
The above advice works great.
For absolute beginners, here's a code sample that details how to get the
capsfilter element reference:
// We want to link the inputChain to the video queue using a
// caps filter element. That filter will allow us to adjust the
// height and width used by the videoscaler at the end of the
// the input chain (not shown here).
//
mVideoScaleFilter = gst_element_factory_make("capsfilter", NULL);
g_assert(mVideoScaleFilter);
// Predefined GstCaps makes no assumptions about width/height.
//
GstCaps* videoCaps = gst_caps_new_simple("video/x-raw-yuv",
"format",
GST_TYPE_FOURCC, GST_MAKE_FOURCC('I', '4', '2', '0'), NULL);
g_object_set(G_OBJECT(mVideoScaleFilter), "caps", videoCaps, NULL);
// Now, add filter to pipeline, link it up
//
gst_bin_add_many(GST_BIN(mGstPipeline),
mVideoScaleFilter,
NULL);
linkRes = gst_element_link_many( inputChain, mVideoScaleFilter,
mVideoQueue, NULL);
if (!linkRes){
// Inform logger of error!
}
// Discard caps reference. GstElement references are object members,
// they are unreferenced in the dtor.
//
gst_caps_unref(videoCaps);
AND here's how to set that filter later on. 'width' and 'height' are
function arguments. Notice that this works with the pipeline in a PLAYING
state.
GstCaps* videoCaps = gst_caps_new_simple("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('I', '4', '2', '0'),
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
NULL);
g_assert(videoCaps);
g_assert(mVideoScaleFilter);
g_object_set(G_OBJECT(mVideoScaleFilter), "caps", videoCaps, NULL);
gst_caps_unref(videoCaps);
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/dynamic-change-element-s-parameter-tp2536123p3039377.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list