mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
Changing have_xid to have_video_out to match the new GstVideoSink parent object.
Original commit message from CVS: Changing have_xid to have_video_out to match the new GstVideoSink parent object. Adding have_vis_size. Fixing gst_play_connect_visualisation
This commit is contained in:
parent
4535cf586b
commit
e9c878d58d
3 changed files with 93 additions and 62 deletions
|
@ -31,12 +31,13 @@ enum
|
|||
STATE_CHANGE,
|
||||
STREAM_LENGTH,
|
||||
TIME_TICK,
|
||||
HAVE_XID,
|
||||
HAVE_VIS_XID,
|
||||
HAVE_VIDEO_OUT,
|
||||
HAVE_VIS_VIDEO_OUT,
|
||||
HAVE_VIDEO_SIZE,
|
||||
HAVE_VIS_SIZE,
|
||||
PIPELINE_ERROR,
|
||||
/* put additional signals before this comment */
|
||||
LAST_SIGNAL,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
/* this struct is used to decouple signals coming out of threaded pipelines */
|
||||
|
@ -52,33 +53,27 @@ struct _GstPlaySignal
|
|||
{
|
||||
gint width;
|
||||
gint height;
|
||||
}
|
||||
video_size;
|
||||
} video_size;
|
||||
struct
|
||||
{
|
||||
gint xid;
|
||||
}
|
||||
video_xid;
|
||||
gpointer video_out;
|
||||
} video_out;
|
||||
struct
|
||||
{
|
||||
GstElementState old_state;
|
||||
GstElementState new_state;
|
||||
}
|
||||
state;
|
||||
} state;
|
||||
struct
|
||||
{
|
||||
GstObject *object;
|
||||
GParamSpec *param;
|
||||
}
|
||||
info;
|
||||
} info;
|
||||
struct
|
||||
{
|
||||
GstElement *element;
|
||||
char *error;
|
||||
}
|
||||
error;
|
||||
}
|
||||
signal_data;
|
||||
} error;
|
||||
} signal_data;
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -345,19 +340,24 @@ gst_play_idle_signal (GstPlay * play)
|
|||
|
||||
switch (signal->signal_id)
|
||||
{
|
||||
case HAVE_XID:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_XID], 0,
|
||||
signal->signal_data.video_xid.xid);
|
||||
case HAVE_VIDEO_OUT:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIDEO_OUT], 0,
|
||||
signal->signal_data.video_out.video_out);
|
||||
break;
|
||||
case HAVE_VIS_XID:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIS_XID], 0,
|
||||
signal->signal_data.video_xid.xid);
|
||||
case HAVE_VIS_VIDEO_OUT:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIS_VIDEO_OUT], 0,
|
||||
signal->signal_data.video_out.video_out);
|
||||
break;
|
||||
case HAVE_VIDEO_SIZE:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIDEO_SIZE], 0,
|
||||
signal->signal_data.video_size.width,
|
||||
signal->signal_data.video_size.height);
|
||||
break;
|
||||
case HAVE_VIS_SIZE:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIS_SIZE], 0,
|
||||
signal->signal_data.video_size.width,
|
||||
signal->signal_data.video_size.height);
|
||||
break;
|
||||
case STATE_CHANGE:
|
||||
g_signal_emit (G_OBJECT (play), gst_play_signals[STATE_CHANGE], 0,
|
||||
signal->signal_data.state.old_state,
|
||||
|
@ -370,7 +370,6 @@ gst_play_idle_signal (GstPlay * play)
|
|||
gst_object_unref (signal->signal_data.info.object);
|
||||
break;
|
||||
case PIPELINE_ERROR:
|
||||
|
||||
if (gst_element_get_state (play->pipeline) == GST_STATE_PLAYING)
|
||||
if (gst_element_set_state (play->pipeline, GST_STATE_READY) !=
|
||||
GST_STATE_SUCCESS)
|
||||
|
@ -406,13 +405,14 @@ callback_audio_sink_eos (GstElement * element, GstPlay * play)
|
|||
}
|
||||
|
||||
static void
|
||||
callback_video_have_xid (GstElement * element, gint xid, GstPlay * play)
|
||||
callback_video_have_video_out (GstElement * element,
|
||||
gpointer video_out, GstPlay * play)
|
||||
{
|
||||
GstPlaySignal *signal;
|
||||
|
||||
signal = g_new0 (GstPlaySignal, 1);
|
||||
signal->signal_id = HAVE_XID;
|
||||
signal->signal_data.video_xid.xid = xid;
|
||||
signal->signal_id = HAVE_VIDEO_OUT;
|
||||
signal->signal_data.video_out.video_out = video_out;
|
||||
|
||||
g_async_queue_push (play->signal_queue, signal);
|
||||
|
||||
|
@ -420,13 +420,14 @@ callback_video_have_xid (GstElement * element, gint xid, GstPlay * play)
|
|||
}
|
||||
|
||||
static void
|
||||
callback_video_have_vis_xid (GstElement * element, gint xid, GstPlay * play)
|
||||
callback_video_have_vis_video_out (GstElement * element,
|
||||
gpointer video_out, GstPlay * play)
|
||||
{
|
||||
GstPlaySignal *signal;
|
||||
|
||||
signal = g_new0 (GstPlaySignal, 1);
|
||||
signal->signal_id = HAVE_VIS_XID;
|
||||
signal->signal_data.video_xid.xid = xid;
|
||||
signal->signal_id = HAVE_VIS_VIDEO_OUT;
|
||||
signal->signal_data.video_out.video_out = video_out;
|
||||
|
||||
g_async_queue_push (play->signal_queue, signal);
|
||||
|
||||
|
@ -449,6 +450,22 @@ callback_video_have_size (GstElement * element,
|
|||
play->idle_add_func ((GSourceFunc) gst_play_idle_signal, play);
|
||||
}
|
||||
|
||||
static void
|
||||
callback_video_have_vis_size (GstElement * element,
|
||||
gint width, gint height, GstPlay * play)
|
||||
{
|
||||
GstPlaySignal *signal;
|
||||
|
||||
signal = g_new0 (GstPlaySignal, 1);
|
||||
signal->signal_id = HAVE_VIS_SIZE;
|
||||
signal->signal_data.video_size.width = width;
|
||||
signal->signal_data.video_size.height = height;
|
||||
|
||||
g_async_queue_push (play->signal_queue, signal);
|
||||
|
||||
play->idle_add_func ((GSourceFunc) gst_play_idle_signal, play);
|
||||
}
|
||||
|
||||
static void
|
||||
callback_pipeline_error (GstElement * object,
|
||||
GstElement * orig, char *error, GstPlay * play)
|
||||
|
@ -646,21 +663,21 @@ gst_play_class_init (GstPlayClass * klass)
|
|||
NULL, NULL,
|
||||
gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
|
||||
|
||||
gst_play_signals[HAVE_XID] =
|
||||
g_signal_new ("have_xid",
|
||||
gst_play_signals[HAVE_VIDEO_OUT] =
|
||||
g_signal_new ("have_video_out",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GstPlayClass, have_xid),
|
||||
G_STRUCT_OFFSET (GstPlayClass, have_video_out),
|
||||
NULL, NULL,
|
||||
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
|
||||
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_INT);
|
||||
|
||||
gst_play_signals[HAVE_VIS_XID] =
|
||||
g_signal_new ("have_vis_xid",
|
||||
gst_play_signals[HAVE_VIS_VIDEO_OUT] =
|
||||
g_signal_new ("have_vis_video_out",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GstPlayClass, have_vis_xid),
|
||||
G_STRUCT_OFFSET (GstPlayClass, have_vis_video_out),
|
||||
NULL, NULL,
|
||||
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
|
||||
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_INT);
|
||||
|
||||
gst_play_signals[HAVE_VIDEO_SIZE] =
|
||||
g_signal_new ("have_video_size",
|
||||
|
@ -670,6 +687,15 @@ gst_play_class_init (GstPlayClass * klass)
|
|||
NULL, NULL,
|
||||
gst_marshal_VOID__INT_INT,
|
||||
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
|
||||
|
||||
gst_play_signals[HAVE_VIS_SIZE] =
|
||||
g_signal_new ("have_vis_size",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GstPlayClass, have_vis_size),
|
||||
NULL, NULL,
|
||||
gst_marshal_VOID__INT_INT,
|
||||
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
|
||||
|
||||
gst_control_init (NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ typedef enum
|
|||
GST_PLAY_UNKNOWN_MEDIA,
|
||||
GST_PLAY_CANNOT_PLAY,
|
||||
GST_PLAY_ERROR,
|
||||
}
|
||||
GstPlayReturn;
|
||||
} GstPlayReturn;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -56,8 +55,7 @@ typedef enum
|
|||
GST_PLAY_PIPE_AUDIO_HYPER_THREADED,
|
||||
GST_PLAY_PIPE_VIDEO,
|
||||
GST_PLAY_PIPE_VIDEO_VISUALISATION,
|
||||
}
|
||||
GstPlayPipeType;
|
||||
} GstPlayPipeType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -68,16 +66,14 @@ typedef enum
|
|||
GST_PLAY_ERROR_VOLUME,
|
||||
GST_PLAY_ERROR_COLORSPACE,
|
||||
GST_PLAY_ERROR_LAST,
|
||||
}
|
||||
GstPlayError;
|
||||
} GstPlayError;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_PLAY_SINK_TYPE_AUDIO,
|
||||
GST_PLAY_SINK_TYPE_VIDEO,
|
||||
GST_PLAY_SINK_TYPE_ANY,
|
||||
}
|
||||
GstPlaySinkType;
|
||||
} GstPlaySinkType;
|
||||
|
||||
#define GST_PLAY_ERROR gst_play_error_quark ()
|
||||
|
||||
|
@ -152,9 +148,10 @@ struct _GstPlayClass
|
|||
void (*stream_end) (GstPlay * play);
|
||||
void (*time_tick) (GstPlay * play, gint64 time_nanos);
|
||||
void (*stream_length) (GstPlay * play, gint64 length_nanos);
|
||||
void (*have_xid) (GstPlay * play, gint xid);
|
||||
void (*have_vis_xid) (GstPlay * play, gint xid);
|
||||
void (*have_video_out) (GstPlay * play, gpointer video_out);
|
||||
void (*have_vis_video_out) (GstPlay * play, gpointer video_out);
|
||||
void (*have_video_size) (GstPlay * play, gint width, gint height);
|
||||
void (*have_vis_size) (GstPlay * play, gint width, gint height);
|
||||
};
|
||||
|
||||
struct _GstPlayIdleData
|
||||
|
|
|
@ -580,8 +580,8 @@ gst_play_video_set_video (GstPlay * play, GstElement * video_sink)
|
|||
if (play->video_sink_element != NULL)
|
||||
{
|
||||
g_signal_connect (G_OBJECT (play->video_sink_element),
|
||||
"have_xid",
|
||||
G_CALLBACK (callback_video_have_xid), play);
|
||||
"have_video_out",
|
||||
G_CALLBACK (callback_video_have_video_out), play);
|
||||
g_signal_connect (G_OBJECT (play->video_sink_element),
|
||||
"have_size",
|
||||
G_CALLBACK (callback_video_have_size), play);
|
||||
|
@ -917,8 +917,8 @@ gst_play_video_vis_set_video (GstPlay * play, GstElement * video_sink)
|
|||
if (play->video_sink_element != NULL)
|
||||
{
|
||||
g_signal_connect (G_OBJECT (play->video_sink_element),
|
||||
"have_xid",
|
||||
G_CALLBACK (callback_video_have_xid), play);
|
||||
"have_video_out",
|
||||
G_CALLBACK (callback_video_have_video_out), play);
|
||||
g_signal_connect (G_OBJECT (play->video_sink_element),
|
||||
"have_size",
|
||||
G_CALLBACK (callback_video_have_size), play);
|
||||
|
@ -971,12 +971,11 @@ gst_play_set_visualisation_video_sink (GstPlay * play,
|
|||
if (play->visualisation_sink_element != NULL)
|
||||
{
|
||||
g_signal_connect (G_OBJECT (play->visualisation_sink_element),
|
||||
"have_xid",
|
||||
G_CALLBACK (callback_video_have_vis_xid), play);
|
||||
/*g_signal_connect ( G_OBJECT (play->visualisation_sink_element),
|
||||
"have_size",
|
||||
G_CALLBACK (callback_video_have_vis_size),
|
||||
play); */
|
||||
"have_video_out",
|
||||
G_CALLBACK (callback_video_have_vis_video_out), play);
|
||||
g_signal_connect (G_OBJECT (play->visualisation_sink_element),
|
||||
"have_size",
|
||||
G_CALLBACK (callback_video_have_vis_size), play);
|
||||
g_object_set (G_OBJECT (play->visualisation_sink_element),
|
||||
"need_new_window", TRUE, "toplevel", FALSE, NULL);
|
||||
}
|
||||
|
@ -1039,7 +1038,7 @@ gst_play_connect_visualisation (GstPlay * play, gboolean connect)
|
|||
{
|
||||
GstPad *tee_vis_pad, *vis_video_thread_pad;
|
||||
GstElement *vis_video_thread;
|
||||
gboolean connected = FALSE;
|
||||
gboolean connected = FALSE, was_playing = FALSE;
|
||||
|
||||
g_return_val_if_fail (play != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
|
||||
|
@ -1049,6 +1048,13 @@ gst_play_connect_visualisation (GstPlay * play, gboolean connect)
|
|||
"vis_video_thread_pad");
|
||||
vis_video_thread = g_hash_table_lookup (play->other_elements,
|
||||
"vis_video_thread");
|
||||
|
||||
/* If pipeline was playing we pause it and note that */
|
||||
if (gst_element_get_state (play->pipeline) == GST_STATE_PLAYING)
|
||||
{
|
||||
gst_element_set_state (play->pipeline, GST_STATE_PAUSED);
|
||||
was_playing = TRUE;
|
||||
}
|
||||
|
||||
if (gst_pad_get_peer (vis_video_thread_pad) != NULL)
|
||||
connected = TRUE;
|
||||
|
@ -1063,11 +1069,13 @@ gst_play_connect_visualisation (GstPlay * play, gboolean connect)
|
|||
{
|
||||
gst_pad_unlink (tee_vis_pad, vis_video_thread_pad);
|
||||
}
|
||||
|
||||
if (GST_IS_ELEMENT (vis_video_thread) && GST_IS_ELEMENT (play->pipeline))
|
||||
|
||||
/* Restore playing state if needed */
|
||||
if (GST_IS_ELEMENT (vis_video_thread) &&
|
||||
GST_IS_ELEMENT (play->pipeline) &&
|
||||
was_playing)
|
||||
{
|
||||
gst_element_set_state (vis_video_thread,
|
||||
gst_element_get_state (play->pipeline));
|
||||
gst_element_set_state (play->pipeline, GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue