player: Add support for selecting a specific video sink

- Add overlay video renderer "video-sink" property, so that can be set
- In create_video_sink, it returns video sink instead of always NULL
- Add new renderer_new_with_sink() API to set video sink

https://bugzilla.gnome.org/show_bug.cgi?id=776490
This commit is contained in:
Lyon Wang 2016-12-27 17:13:58 +08:00 committed by Sebastian Dröge
parent 9bd99d3670
commit b22fec8293
4 changed files with 40 additions and 1 deletions

View file

@ -2058,6 +2058,7 @@ gst_player_g_main_context_signal_dispatcher_get_type
GstPlayerVideoOverlayVideoRenderer GstPlayerVideoOverlayVideoRenderer
gst_player_video_overlay_video_renderer_new gst_player_video_overlay_video_renderer_new
gst_player_video_overlay_video_renderer_new_with_sink
gst_player_video_overlay_video_renderer_get_window_handle gst_player_video_overlay_video_renderer_get_window_handle
gst_player_video_overlay_video_renderer_set_window_handle gst_player_video_overlay_video_renderer_set_window_handle

View file

@ -40,6 +40,8 @@ struct _GstPlayerVideoOverlayVideoRenderer
GstVideoOverlay *video_overlay; GstVideoOverlay *video_overlay;
gpointer window_handle; gpointer window_handle;
gint x, y, width, height; gint x, y, width, height;
GstElement *video_sink; /* configured video sink, or NULL */
}; };
struct _GstPlayerVideoOverlayVideoRendererClass struct _GstPlayerVideoOverlayVideoRendererClass
@ -55,6 +57,7 @@ enum
{ {
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_0, VIDEO_OVERLAY_VIDEO_RENDERER_PROP_0,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE, VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST
}; };
@ -81,6 +84,9 @@ gst_player_video_overlay_video_renderer_set_property (GObject * object,
gst_video_overlay_set_window_handle (self->video_overlay, gst_video_overlay_set_window_handle (self->video_overlay,
(guintptr) self->window_handle); (guintptr) self->window_handle);
break; break;
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK:
self->video_sink = gst_object_ref_sink (g_value_get_object (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -98,6 +104,9 @@ gst_player_video_overlay_video_renderer_get_property (GObject * object,
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE: case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE:
g_value_set_pointer (value, self->window_handle); g_value_set_pointer (value, self->window_handle);
break; break;
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK:
g_value_set_object (value, self->video_sink);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -113,6 +122,9 @@ gst_player_video_overlay_video_renderer_finalize (GObject * object)
if (self->video_overlay) if (self->video_overlay)
gst_object_unref (self->video_overlay); gst_object_unref (self->video_overlay);
if (self->video_sink)
gst_object_unref (self->video_sink);
G_OBJECT_CLASS G_OBJECT_CLASS
(gst_player_video_overlay_video_renderer_parent_class)->finalize (object); (gst_player_video_overlay_video_renderer_parent_class)->finalize (object);
} }
@ -135,6 +147,12 @@ static void
"Window handle to embed the video into", "Window handle to embed the video into",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK] =
g_param_spec_object ("video-sink", "Video Sink",
"the video output element to use (NULL = default sink)",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, g_object_class_install_properties (gobject_class,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST, VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST,
video_overlay_video_renderer_param_specs); video_overlay_video_renderer_param_specs);
@ -145,6 +163,7 @@ static void
(GstPlayerVideoOverlayVideoRenderer * self) (GstPlayerVideoOverlayVideoRenderer * self)
{ {
self->x = self->y = self->width = self->height = -1; self->x = self->y = self->width = self->height = -1;
self->video_sink = NULL;
} }
static GstElement *gst_player_video_overlay_video_renderer_create_video_sink static GstElement *gst_player_video_overlay_video_renderer_create_video_sink
@ -168,7 +187,7 @@ static GstElement *gst_player_video_overlay_video_renderer_create_video_sink
gst_video_overlay_set_render_rectangle (self->video_overlay, self->x, gst_video_overlay_set_render_rectangle (self->video_overlay, self->x,
self->y, self->width, self->height); self->y, self->width, self->height);
return NULL; return self->video_sink;
} }
static void static void
@ -192,6 +211,23 @@ gst_player_video_overlay_video_renderer_new (gpointer window_handle)
"window-handle", window_handle, NULL); "window-handle", window_handle, NULL);
} }
/**
* gst_player_video_overlay_video_renderer_new_with_sink:
* @window_handle: (allow-none): Window handle to use or %NULL
* @video_sink: (transfer floating): the custom video_sink element to be set for the video renderer
*
* Returns: (transfer full):
*
* Since 1.12
*/
GstPlayerVideoRenderer *
gst_player_video_overlay_video_renderer_new_with_sink (gpointer window_handle,
GstElement * video_sink)
{
return g_object_new (GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER,
"window-handle", window_handle, "video-sink", video_sink, NULL);
}
/** /**
* gst_player_video_overlay_video_renderer_set_window_handle: * gst_player_video_overlay_video_renderer_set_window_handle:
* @self: #GstPlayerVideoRenderer instance * @self: #GstPlayerVideoRenderer instance

View file

@ -41,6 +41,7 @@ typedef struct _GstPlayerVideoOverlayVideoRendererClass
GType gst_player_video_overlay_video_renderer_get_type (void); GType gst_player_video_overlay_video_renderer_get_type (void);
GstPlayerVideoRenderer * gst_player_video_overlay_video_renderer_new (gpointer window_handle); GstPlayerVideoRenderer * gst_player_video_overlay_video_renderer_new (gpointer window_handle);
GstPlayerVideoRenderer * gst_player_video_overlay_video_renderer_new_with_sink (gpointer window_handle, GstElement * video_sink);
void gst_player_video_overlay_video_renderer_set_window_handle (GstPlayerVideoOverlayVideoRenderer * self, gpointer window_handle); void gst_player_video_overlay_video_renderer_set_window_handle (GstPlayerVideoOverlayVideoRenderer * self, gpointer window_handle);
gpointer gst_player_video_overlay_video_renderer_get_window_handle (GstPlayerVideoOverlayVideoRenderer * self); gpointer gst_player_video_overlay_video_renderer_get_window_handle (GstPlayerVideoOverlayVideoRenderer * self);

View file

@ -105,6 +105,7 @@ EXPORTS
gst_player_video_overlay_video_renderer_get_type gst_player_video_overlay_video_renderer_get_type
gst_player_video_overlay_video_renderer_get_window_handle gst_player_video_overlay_video_renderer_get_window_handle
gst_player_video_overlay_video_renderer_new gst_player_video_overlay_video_renderer_new
gst_player_video_overlay_video_renderer_new_with_sink
gst_player_video_overlay_video_renderer_set_render_rectangle gst_player_video_overlay_video_renderer_set_render_rectangle
gst_player_video_overlay_video_renderer_set_window_handle gst_player_video_overlay_video_renderer_set_window_handle
gst_player_video_renderer_get_type gst_player_video_renderer_get_type