void AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady(GstPad* pad)
{
    ASSERT(m_wavParserAvailable);

    GRefPtr<GstElement> audioSink = gst_element_factory_make("autoaudiosink", 0);
    m_audioSinkAvailable = audioSink;

    if (!audioSink) {
        LOG_ERROR("Failed to create GStreamer autoaudiosink element");
        return;
    }

    // Autoaudiosink does the real sink detection in the GST_STATE_NULL->READY transition
    // so it's best to roll it to READY as soon as possible to ensure the underlying platform
    // audiosink was loaded correctly.
    GstStateChangeReturn stateChangeReturn = gst_element_set_state(audioSink.get(), GST_STATE_READY);
    if (stateChangeReturn == GST_STATE_CHANGE_FAILURE) {
        LOG_ERROR("Failed to change autoaudiosink element state");
        gst_element_set_state(audioSink.get(), GST_STATE_NULL);
        m_audioSinkAvailable = false;
        return;
    }

    GstElement* audioConvert = gst_element_factory_make("audioconvert", 0);
    gst_bin_add_many(GST_BIN(m_pipeline), audioConvert, audioSink.get(), NULL);

    // Link wavparse's src pad to audioconvert sink pad.
    GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(audioConvert, "sink"));
    gst_pad_link_full(pad, sinkPad.get(), GST_PAD_LINK_CHECK_NOTHING);

    // Link audioconvert to audiosink and roll states.
    gst_element_link_pads_full(audioConvert, "src", audioSink.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_sync_state_with_parent(audioConvert);
    gst_element_sync_state_with_parent(audioSink.leakRef());
}
static GdkPixbuf* getIconPixbufSynchronously(WebKitFaviconDatabase* database, const String& pageURL, const IntSize& iconSize)
{
    ASSERT(isMainThread());

    // The exact size we pass is irrelevant to the iconDatabase code.
    // We must pass something greater than 0x0 to get a pixbuf.
    Image* icon = iconDatabase().synchronousIconForPageURL(pageURL, !iconSize.isZero() ? iconSize : IntSize(1, 1));
    if (!icon)
        return 0;

    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(icon->getGdkPixbuf());
    if (!pixbuf)
        return 0;

    // A size of (0, 0) means the maximum available size.
    if (!iconSize.isZero() && (icon->width() != iconSize.width() || icon->height() != iconSize.height()))
        pixbuf = gdk_pixbuf_scale_simple(pixbuf.get(), iconSize.width(), iconSize.height(), GDK_INTERP_BILINEAR);
    return pixbuf.leakRef();
}
Example #3
0
void webkitContextMenuItemSetSubMenuFromGtkMenu(WebKitContextMenuItem* item, GtkMenu* subMenu)
{
    if (!subMenu)
        return;

    GOwnPtr<GList> children(gtk_container_get_children(GTK_CONTAINER(subMenu)));
    if (!g_list_length(children.get()))
        return;

    webkitContextMenuItemSetSubMenu(item, adoptGRef(webkit_context_menu_new()));
    for (GList* listItem = children.get(); listItem; listItem = g_list_next(listItem)) {
        GRefPtr<GtkWidget> widget = GTK_WIDGET(listItem->data);
        if (!GTK_IS_MENU_ITEM(widget.get()))
            continue;

        gtk_container_remove(GTK_CONTAINER(subMenu), widget.get());
        GtkMenuItem* menuItem = GTK_MENU_ITEM(widget.leakRef());
        g_object_force_floating(G_OBJECT(menuItem));
        webkit_context_menu_append(item->priv->subMenu.get(), webkitContextMenuItemCreateForGtkItem(menuItem));
    }
}
static GdkPixbuf* getIconPixbufSynchronously(WebKitFaviconDatabase* database, const String& pageURL, const IntSize& iconSize)
{
    ASSERT(isMainThread());

    // The exact size we pass is irrelevant to the iconDatabase code.
    // We must pass something greater than 0x0 to get a pixbuf.
    RefPtr<cairo_surface_t> surface = iconDatabase().synchronousNativeIconForPageURL(pageURL, !iconSize.isZero() ? iconSize : IntSize(1, 1));
    if (!surface)
        return 0;

    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(cairoSurfaceToGdkPixbuf(surface.get()));
    if (!pixbuf)
        return 0;

    // A size of (0, 0) means the maximum available size.
    int pixbufWidth = gdk_pixbuf_get_width(pixbuf.get());
    int pixbufHeight = gdk_pixbuf_get_height(pixbuf.get());
    if (!iconSize.isZero() && (pixbufWidth != iconSize.width() || pixbufHeight != iconSize.height()))
        pixbuf = adoptGRef(gdk_pixbuf_scale_simple(pixbuf.get(), iconSize.width(), iconSize.height(), GDK_INTERP_BILINEAR));
    return pixbuf.leakRef();
}