English 中文(简体)
GStreamer:如何连接动态垫子
原标题:GStreamer: how to connect dynamic pads

Im试图利用GStreamer从档案中拍摄MP4录像。 我利用玩 play2和迅速从指挥中利用:

gst-launch filesrc location=bbb.mp4 ! decodebin2 ! autovideosink

I am expecting in the future that I will need to create more complicated pipelines and hence why I m attempting to program the pipeline. In my program I am attempting to replicate the pipeline above, however I have an issue which I suspect is related to connecting the dynamic or "sometimes" source pad of decodebin2 to the autovideo sink. I am using these elements only to keep things as simple as possible.

static void on_new_decoded_pad(GstElement* object,
                           GstPad* arg0,
                           gboolean arg1,
                           gpointer user_data)
{
    // dynamically connect decoderbin2 src pad to autovideosink sink pad
}

static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
    // handle bus messages
}

int main(int argc, char *argv[])
{
    GMainLoop *loop;
    GstElement *pipeline, *source, *decodebin, *videosink;
    GstBus *bus;

    gst_init (&argc, &argv);
    loop = g_main_loop_new (NULL, FALSE);

    pipeline  = gst_pipeline_new ("pipeline");
    source    = gst_element_factory_make("filesrc",       "source");
    decodebin = gst_element_factory_make("decodebin2",    "decodebin");
    videosink = gst_element_factory_make("autovideosink", "videosink");

    /* check elements were created successfully */
    if (!pipeline || !source || !decodebin || !videosink) {
        // Failed to create element. Exit Program
        return -1;
    }

    /* apply properties to elements before adding to pipeline */
    gchar * filename = "bbb.mp4";
    g_object_set(G_OBJECT(source), "location", filename, NULL);

    /* add a message handler */
    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);

    /* add elements to pipeline (and bin if necessary) before linking them */
    gst_bin_add_many(GST_BIN (pipeline),
                     source,
                     decodebin,
                     videosink,
                     NULL);

    gst_element_link_pads(source, "src", decodebin, "sink");

    /* decodebins src pad is a sometimes pad - it gets created dynamically */
    g_signal_connect(decodebin, "new-decoded-pad", G_CALLBACK(on_new_decoded_pad),   videosink);

    /* run pipeline */
    gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);

    g_main_loop_run(loop);

    gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
    gst_object_unref (pipeline);

    return 0;
}

在我管理这一方案时,我预计会发生的情况是,由“新代编码”跳板通过“召回功能”接来,这一功能是按行的:

g_signal_connect(decodebin, "new-decoded-pad", G_CALLBACK(on_new_decoded_pad), videosink);

并且允许我适当连接这些垫子。 但是,它从来就没有受到呼吁。 事实上,该方案似乎完全通过,然后才刚刚撤出(主要通道没有任何东西)。

如果有人能够指出我在回击方面做了哪些错误,或者解释为什么还需要做些什么,以便这个例子能够利用所提供的内容来玩.。

Regards.

最佳回答

on_new_decoded_pad is deprecated use "pad-added" instead.

我仍然有与代典二有关的问题,你可以在此找到:。 缩略语

问题回答

见我的栏目:。 [见]。 Rtpbin在那里使用。 希望这一帮助。





相关问题
Calling a service from a callback method in Client

I have a scenario where, upon receiving a command on one of the callback methods in client, the client needs to call another service. For example: In OnNewCommand() callback method client receives a ...

ASP.NET UpdatePanel Javascript Callback

I came across this issue recently and thought it was really helpful. My question was, how would you call a piece of javascript after an updatepanel loads via AJAX in ASP.NET? I needed to reinitialize ...

WCF duplex channel gets closed when using callbacks

My WCF service uses netTcpBinding, and has a callback object. I need to service multiple concurrent clients, and mantain sessions, so the service is decorated with [ServiceBehavior(...

C++: static function wrapper that routes to member function?

I ve tried all sorts of design approaches to solve this problem, but I just can t seem to get it right. I need to expose some static functions to use as callback function to a C lib. However, I want ...

getJSON callback not happening

I have looked at similar queries here, but I can t seem to apply them to my problem. I am pretty new to jquery, so I may be doing something dumb. I have a simple getJSON test: $(document).ready(...

热门标签