static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* widget)
{
    GtkAllocation allocation;

    if (gst_gtk_handle_need_context (bus, message, NULL))
        return GST_BUS_DROP;

    // ignore anything but 'prepare-window-handle' element messages
    if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
        return GST_BUS_PASS;

    if (!gst_is_video_overlay_prepare_window_handle_message (message))
        return GST_BUS_PASS;

    g_print ("setting window handle %p\n", widget);

    gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), widget);

    gtk_widget_get_allocation (widget, &allocation);
    gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), allocation.x, allocation.y, allocation.width, allocation.height);

    gst_message_unref (message);

    return GST_BUS_DROP;
}
static GstBusSyncReply
create_window (GstBus * bus, GstMessage * message, gpointer data)
{
  GstGLClutterActor **actor = (GstGLClutterActor **) data;
  static gint count = 0;
  static GMutex mutex;
  // ignore anything but 'prepare-window-handle' element messages
  if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
    return GST_BUS_PASS;

  if (!gst_is_video_overlay_prepare_window_handle_message (message))
    return GST_BUS_PASS;

  g_mutex_lock (&mutex);

  if (count < N_ACTORS) {
    g_message ("adding actor %d", count);
    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC
            (message)), actor[count]->win);
    clutter_threads_add_idle ((GSourceFunc) create_actor, actor[count]);
    count++;
  }

  g_mutex_unlock (&mutex);

  gst_message_unref (message);
  return GST_BUS_DROP;
}
Ejemplo n.º 3
0
static GstBusSyncReply
create_window(GstBus *bus, GstMessage *msg, gpointer data)
{
    preview_t *preview = (preview_t*)data;

    switch (GST_MESSAGE_TYPE(msg))
    {
    case GST_MESSAGE_ELEMENT:
    {
#if GST_CHECK_VERSION(1, 0, 0)
        if (!gst_is_video_overlay_prepare_window_handle_message(msg))
            return GST_BUS_PASS;
        gst_video_overlay_set_window_handle(
            GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(msg)), preview->xid);
#else
        if (!gst_structure_has_name(msg->structure, "prepare-xwindow-id"))
            return GST_BUS_PASS;
#if !defined(_WIN32)
        gst_x_overlay_set_xwindow_id(
            GST_X_OVERLAY(GST_MESSAGE_SRC(msg)), preview->xid);
#else
        gst_directdraw_sink_set_window_id(
            GST_X_OVERLAY(GST_MESSAGE_SRC(msg)), preview->xid);
#endif
#endif
        gst_message_unref(msg);
        return GST_BUS_DROP;
    } break;

    default:
    {
    } break;
    }
    return GST_BUS_PASS;
}
Ejemplo n.º 4
0
static gboolean bus_call (GstBus *bus,GstMessage *msg, gpointer data) {

    if (gst_is_video_overlay_prepare_window_handle_message (msg)) {
        if (0 != g_video_xid) {
            GstVideoOverlay *overlay;

            // GST_MESSAGE_SRC (message) will be the video sink element
            overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (msg));
            gst_video_overlay_set_window_handle (overlay, g_video_xid);
        } else {
            g_warning ("Should have obtained video_window_handle by now!");
        }
    }

    switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_EOS:
        g_print ("####################### Stream Ends\n");
        gtk_main_quit();
        break;

    case GST_MESSAGE_ERROR: {
        gchar  *debug;
        GError *error;

        gst_message_parse_error (msg, &error, &debug);
        g_free (debug);

        g_printerr ("####################### Error: %s\n", error->message);
        g_error_free (error);

        gtk_main_quit();
        break;
    }
    case GST_MESSAGE_STATE_CHANGED: {
        GstState oldState;
        GstState newState;
        GstState pendingState;
        gst_message_parse_state_changed(msg, &oldState, &newState, &pendingState);
        g_printf("####################### oldState:%d, newState:%d, pendingState:%d!\n", oldState, newState, pendingState);
        break;
    }
    case GST_MESSAGE_STREAM_STATUS: {
        GstStreamStatusType statusType;
        GstElement* owner = NULL;

        gst_message_parse_stream_status(msg, &statusType, &owner);
        g_printf("####################### statusType:%d, owner:%p!\n", statusType, owner);
        break;
    }
    default:
        break;
    }

    return TRUE;
}
Ejemplo n.º 5
0
static GstBusSyncReply bus_sync_handler(GstBus *bus, GstMessage *msg, gpointer data) {
	if (!gst_is_video_overlay_prepare_window_handle_message(msg))
		return GST_BUS_PASS;
	guintptr video_window_handle = gui_get_video_window_handle();
	g_assert(video_window_handle != 0);
	// GST_MESSAGE_SRC (message) will be the video sink element.
	video_window_overlay = GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(msg));
	gst_video_overlay_set_window_handle(video_window_overlay, video_window_handle);
	int x, y, w, h;
	gui_get_render_rectangle(&x, &y, &w, &h);
	gst_video_overlay_set_render_rectangle(video_window_overlay, x, y, w, h);
	return GST_BUS_DROP;
}
Ejemplo n.º 6
0
static GstBusSyncReply
gst_sync_watch (GstBus *bus, GstMessage *message, gpointer data)
{
	gstPlay *play = (gstPlay *)data;
	if (play == NULL) return FALSE;
	
	if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
		if (gst_is_video_overlay_prepare_window_handle_message(message)) {
			play->overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
			gst_video_overlay_set_window_handle (play->overlay, play->xid);
		}
	}
	return TRUE;
}
gboolean gstGWorldSyncMessageCallback(GstBus*, GstMessage* message, gpointer data)
{
    ASSERT(GST_MESSAGE_TYPE(message) == GST_MESSAGE_ELEMENT);

    GStreamerGWorld* gstGWorld = static_cast<GStreamerGWorld*>(data);
#ifndef GST_API_VERSION_1
    const GstStructure* structure = gst_message_get_structure(message);

    if (gst_structure_has_name(structure, "prepare-xwindow-id")
        || gst_structure_has_name(structure, "have-ns-view"))
        gstGWorld->setWindowOverlay(message);
#else
    if (gst_is_video_overlay_prepare_window_handle_message(message))
        gstGWorld->setWindowOverlay(message);
#endif
    return TRUE;
}
Ejemplo n.º 8
0
GstBusSyncReply Pipeline::create_window (GstBus* bus, GstMessage* message, const Pipeline* p)
{
    // ignore anything but 'prepare-window-handle' element messages
    if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
        return GST_BUS_PASS;

    if (!gst_is_video_overlay_prepare_window_handle_message (message))
        return GST_BUS_PASS;

    qDebug ("setting window handle");

    //Passing 0 as the window_handle will tell the overlay to stop using that window and create an internal one.
    //In the directdrawsink's gst_video_overlay_set_window_handle implementation, window_handle (parameter 2) is casted to HWND before it used.
    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), (guintptr)p->winId());

    gst_message_unref (message);

    return GST_BUS_DROP;
}
Ejemplo n.º 9
0
// static void application_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
//   if (g_strcmp0 (gst_structure_get_name (msg->structure), "tags-changed") == 0) {
//     /* If the message is the "tags-changed" (only one we are currently issuing), update
//      * the stream info GUI */
//     analyze_streams (data);
//   }
// }
static GstBusSyncReply
busSyncHandler (GstBus * bus, GstMessage * message, gpointer user_data)
{
  // ignore anything but 'prepare-window-handle' element messages
  if (!gst_is_video_overlay_prepare_window_handle_message (message))
    return GST_BUS_PASS;

    if (window_handle != 0) {
      GstVideoOverlay *overlay;

      // GST_MESSAGE_SRC (message) will be the video sink element
      overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
      gst_video_overlay_set_window_handle (overlay, window_handle);
    } else {
      g_warning ("Should have obtained video_window_handle by now!");
    }

    gst_message_unref (message);
    return GST_BUS_DROP;
}
Ejemplo n.º 10
0
static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* widget)
{
    // ignore anything but 'prepare-window-handle' element messages
    if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
        return GST_BUS_PASS;

    if (!gst_is_video_overlay_prepare_window_handle_message (message))
        return GST_BUS_PASS;

    g_print ("setting window handle\n");

    //do not call gdk_window_ensure_native for the first time here because
    //we are in a different thread than the main thread
    //(and the main thread the onne)
    gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), widget);

    gst_message_unref (message);

    return GST_BUS_DROP;
}
static GstBusSyncReply
create_window (GstBus * bus, GstMessage * message, GtkWidget * widget)
{
  if (gst_gtk_handle_need_context (bus, message, NULL))
    return GST_BUS_DROP;

  /* ignore anything but 'prepare-window-handle' element messages */
  if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
    return GST_BUS_PASS;

  if (!gst_is_video_overlay_prepare_window_handle_message (message))
    return GST_BUS_PASS;

  /* do not call gdk_window_ensure_native for the first time here because
   * we are in a different thread than the main thread */
  gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC
          (message)), widget);

  gst_message_unref (message);

  return GST_BUS_DROP;
}
Ejemplo n.º 12
0
static GstBusSyncReply
set_playbin_window (GstBus             *bus,
		    GstMessage         *message,
		    GthMediaViewerPage *self)
{
	/* ignore anything but 'prepare-xwindow-id' element messages */
	if (! gst_is_video_overlay_prepare_window_handle_message (message))
		return GST_BUS_PASS;

	if (self->priv->video_window_xid != 0) {
		GstVideoOverlay *video_overlay;

		video_overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
		gst_video_overlay_set_window_handle (video_overlay, self->priv->video_window_xid);
		self->priv->xwin_assigned = TRUE;
	}
	else
		g_warning ("Should have obtained video_window_xid by now!");

	gst_message_unref (message);

	return GST_BUS_DROP;
}