mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
play: Fix object construction
Ideally new() functions should simply call g_object_new() and not much else, so let's do that here and handle all the construction properly in a GObject way. Now a play object created via g_object_new() is actually usable. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2880>
This commit is contained in:
parent
abfbcc0b6f
commit
f060b8b6f3
1 changed files with 13 additions and 9 deletions
|
@ -212,6 +212,8 @@ static void gst_play_constructed (GObject * object);
|
||||||
|
|
||||||
static gpointer gst_play_main (gpointer data);
|
static gpointer gst_play_main (gpointer data);
|
||||||
|
|
||||||
|
static void gst_play_set_playbin_video_sink (GstPlay * self);
|
||||||
|
|
||||||
static void gst_play_seek_internal_locked (GstPlay * self);
|
static void gst_play_seek_internal_locked (GstPlay * self);
|
||||||
static void gst_play_stop_internal (GstPlay * self, gboolean transient);
|
static void gst_play_stop_internal (GstPlay * self, gboolean transient);
|
||||||
static gboolean gst_play_pause_internal (gpointer user_data);
|
static gboolean gst_play_pause_internal (gpointer user_data);
|
||||||
|
@ -509,6 +511,8 @@ gst_play_constructed (GObject * object)
|
||||||
self->thread = g_thread_new ("GstPlay", gst_play_main, self);
|
self->thread = g_thread_new ("GstPlay", gst_play_main, self);
|
||||||
while (!self->loop || !g_main_loop_is_running (self->loop))
|
while (!self->loop || !g_main_loop_is_running (self->loop))
|
||||||
g_cond_wait (&self->cond, &self->lock);
|
g_cond_wait (&self->cond, &self->lock);
|
||||||
|
|
||||||
|
gst_play_set_playbin_video_sink (self);
|
||||||
g_mutex_unlock (&self->lock);
|
g_mutex_unlock (&self->lock);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||||
|
@ -612,7 +616,14 @@ gst_play_set_property (GObject * object, guint prop_id,
|
||||||
g_mutex_lock (&self->lock);
|
g_mutex_lock (&self->lock);
|
||||||
g_clear_object (&self->video_renderer);
|
g_clear_object (&self->video_renderer);
|
||||||
self->video_renderer = g_value_dup_object (value);
|
self->video_renderer = g_value_dup_object (value);
|
||||||
|
|
||||||
|
// When the video_renderer is a GstPlayerWrappedVideoRenderer it cannot be set
|
||||||
|
// at construction time because it requires a valid pipeline which is created
|
||||||
|
// only after GstPlay has been constructed. That is why the video renderer is
|
||||||
|
// set *after* GstPlay has been constructed.
|
||||||
|
if (self->thread) {
|
||||||
gst_play_set_playbin_video_sink (self);
|
gst_play_set_playbin_video_sink (self);
|
||||||
|
}
|
||||||
g_mutex_unlock (&self->lock);
|
g_mutex_unlock (&self->lock);
|
||||||
break;
|
break;
|
||||||
case PROP_URI:{
|
case PROP_URI:{
|
||||||
|
@ -2648,15 +2659,8 @@ gst_play_new (GstPlayVideoRenderer * video_renderer)
|
||||||
|
|
||||||
g_once (&once, gst_play_init_once, NULL);
|
g_once (&once, gst_play_init_once, NULL);
|
||||||
|
|
||||||
self = g_object_new (GST_TYPE_PLAY, NULL);
|
self = g_object_new (GST_TYPE_PLAY, "video-renderer", video_renderer, NULL);
|
||||||
|
|
||||||
// When the video_renderer is a GstPlayerWrappedVideoRenderer it cannot be set
|
|
||||||
// at construction time because it requires a valid pipeline which is created
|
|
||||||
// only after GstPlay has been constructed. That is why the video renderer is
|
|
||||||
// set *after* GstPlay has been constructed.
|
|
||||||
if (video_renderer != NULL) {
|
|
||||||
g_object_set (self, "video-renderer", video_renderer, NULL);
|
|
||||||
}
|
|
||||||
gst_object_ref_sink (self);
|
gst_object_ref_sink (self);
|
||||||
|
|
||||||
if (video_renderer)
|
if (video_renderer)
|
||||||
|
|
Loading…
Reference in a new issue