如何将gstreamer videosink嵌入到浏览器中

时间:2011-12-12 10:00:59

标签: browser gtk gstreamer

我正在开发一个webkit-kernel-browser插件。 大多数插件都遵守NPAPI的规则。 调用NP_new函数后,浏览器应调用Npp_setwindows等。 但是Chrome浏览器不能运行它。 它调用Np_destory直接完成实例。 所以我无法让浏览器的xid在其上设置视频链接。 如何解决这个问题?

当我使用firefox浏览器时,我可以获得xid。 不幸的是,当我使用gst_x_overlay_set_xwindow_id嵌入浏览器时。 浏览器崩溃了。 这是一些测试代码。

  gst_init (NULL, NULL);

    player->pipeline = gst_element_factory_make ("playbin2", "playstation");
    LOGMSG("create playbin2");
    player->audio_sink = gst_element_factory_make ("alsasink", "audio-sink");
    if (NULL == player->audio_sink)
    {
        player->audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
        g_warning ("Could not create a GST audio_sink. Audio unavailable.");
    }

    player->video_sink = gst_element_factory_make ("xvimagesink", "video-sink");
    if (NULL == player->video_sink)
    {
        //pvrvideosink is used for some special solution ,but this case never used
        player->video_sink = gst_element_factory_make ("pvrvideosink","video-sink");

        g_warning ("Could not create a GST video_sink. Video unavailable.");
    }
   g_object_set (player->video_sink, "force-aspect-ratio", TRUE, NULL);

    sprintf(buff," \n pipleline:%p\n video:%p\n audio:%p\n uri:%s\n xid:%d",
               player->pipeline,player->video_sink,player->audio_sink,player->uri,player->xid);
    LOGMSG(buff);enter code here
// log shows all the content is ok
    g_object_set (player->pipeline, "video-sink", player->video_sink, NULL);
    g_object_set (player->pipeline, "audio-sink", player->audio_sink, NULL);
    g_object_set (player->pipeline, "uri",player->uri, NULL);

    player->bus = gst_element_get_bus (GST_ELEMENT (player->pipeline));
    gst_bus_add_watch(player->bus,(void *)process_events,player);

    LOGMSG("start set winid");
/*
chrome can not get the browser xid ,so it display the image in fullscreen way with the player 's own window. The firefox can not display the image at all. It crashed here.
*/
    if (player->xid != 0 )
    {
        gst_x_overlay_prepare_xwindow_id(GST_X_OVERLAY(GST_ELEMENT(player->video_sink)));
        gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_ELEMENT(player->video_sink)),player->xid);

        gboolean spt = gst_x_overlay_set_render_rectangle
                       (GST_X_OVERLAY(GST_ELEMENT(player->video_sink)),10,10,480,270);
        if (!spt)
        {
            LOGMSG("not support the rectangle");
        }
        gst_x_overlay_expose(GST_X_OVERLAY(GST_ELEMENT(player->video_sink)));

    }

    LOGMSG("set xwinid finished");
    gst_element_set_state(player->pipeline,GST_STATE_PLAYING);

    loop = g_main_loop_new (NULL, FALSE);
    LOGMSG("start player loop");
    g_main_loop_run (loop); 

有人能给我一些关于这些的信息吗?

祝你好运, 森林

1 个答案:

答案 0 :(得分:2)

尝试使用XEmbed