mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
gst_play_get_sink_element has been improved :
Original commit message from CVS: gst_play_get_sink_element has been improved : - Recursively searches in bins - Able to find sink_element of a specified GstPlaySinkType (audio,video,any) This now allow us to send very complex bins to GstPlay for audio/video sink without breaking length querying, eos signaling, etc..
This commit is contained in:
parent
33bfd20100
commit
efcf227524
3 changed files with 94 additions and 21 deletions
|
@ -722,19 +722,21 @@ gst_play_set_idle_timeout_funcs ( GstPlay *play,
|
||||||
* gst_play_get_sink_element:
|
* gst_play_get_sink_element:
|
||||||
* @play: a #GstPlay.
|
* @play: a #GstPlay.
|
||||||
* @element: a #GstElement.
|
* @element: a #GstElement.
|
||||||
|
* @sink_type: a #GstPlaySinkType.
|
||||||
*
|
*
|
||||||
* Searches for the sink #GstElement of @element in @play.
|
* Searches recursively for a sink #GstElement with
|
||||||
|
* type @sink_type in @element which is supposed to be a #GstBin.
|
||||||
*
|
*
|
||||||
* Returns: the sink #GstElement of @element.
|
* Returns: the sink #GstElement of @element.
|
||||||
*/
|
*/
|
||||||
GstElement*
|
GstElement*
|
||||||
gst_play_get_sink_element ( GstPlay *play,
|
gst_play_get_sink_element ( GstPlay *play,
|
||||||
GstElement *element)
|
GstElement *element,
|
||||||
|
GstPlaySinkType sink_type)
|
||||||
{
|
{
|
||||||
GstPad *pad = NULL;
|
|
||||||
GList *elements = NULL;
|
GList *elements = NULL;
|
||||||
const GList *pads = NULL;
|
const GList *pads = NULL;
|
||||||
gboolean has_src;
|
gboolean has_src, has_correct_type;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_PLAY (play), NULL);
|
g_return_val_if_fail (GST_IS_PLAY (play), NULL);
|
||||||
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
||||||
|
@ -744,23 +746,75 @@ gst_play_get_sink_element ( GstPlay *play,
|
||||||
* element is a sink element */
|
* element is a sink element */
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = (GList *) gst_bin_get_list (GST_BIN(element));
|
elements = (GList *) gst_bin_get_list (GST_BIN(element));
|
||||||
|
|
||||||
/* traverse all elements looking for a src pad */
|
/* traverse all elements looking for a src pad */
|
||||||
while (elements && pad == NULL) {
|
|
||||||
|
while (elements) {
|
||||||
|
|
||||||
element = GST_ELEMENT (elements->data);
|
element = GST_ELEMENT (elements->data);
|
||||||
pads = gst_element_get_pad_list (element);
|
|
||||||
has_src = FALSE;
|
/* Recursivity :) */
|
||||||
while (pads) {
|
|
||||||
/* check for src pad */
|
if (GST_IS_BIN(element)) {
|
||||||
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
|
element = gst_play_get_sink_element(play,element,sink_type);
|
||||||
has_src = TRUE;
|
if (GST_IS_ELEMENT (element)) {
|
||||||
break;
|
return element;
|
||||||
}
|
}
|
||||||
pads = g_list_next (pads);
|
|
||||||
}
|
}
|
||||||
if (!has_src){
|
else {
|
||||||
return element;
|
|
||||||
|
pads = gst_element_get_pad_list (element);
|
||||||
|
has_src = FALSE;
|
||||||
|
has_correct_type = FALSE;
|
||||||
|
while (pads) {
|
||||||
|
/* check for src pad */
|
||||||
|
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
|
||||||
|
has_src = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* If not a src pad checking caps */
|
||||||
|
GstCaps *caps;
|
||||||
|
caps = gst_pad_get_caps (GST_PAD (pads->data));
|
||||||
|
while (caps) {
|
||||||
|
gboolean has_video_cap = FALSE, has_audio_cap = FALSE;
|
||||||
|
if (g_ascii_strcasecmp( gst_caps_get_mime (caps),
|
||||||
|
"audio/raw") == 0)
|
||||||
|
{
|
||||||
|
has_audio_cap = TRUE;
|
||||||
|
}
|
||||||
|
if (g_ascii_strcasecmp( gst_caps_get_mime (caps),
|
||||||
|
"video/raw") == 0)
|
||||||
|
{
|
||||||
|
has_video_cap = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (sink_type) {
|
||||||
|
case GST_PLAY_SINK_TYPE_AUDIO:
|
||||||
|
if (has_audio_cap)
|
||||||
|
has_correct_type = TRUE;
|
||||||
|
break;;
|
||||||
|
case GST_PLAY_SINK_TYPE_VIDEO:
|
||||||
|
if (has_video_cap)
|
||||||
|
has_correct_type = TRUE;
|
||||||
|
break;;
|
||||||
|
case GST_PLAY_SINK_TYPE_ANY:
|
||||||
|
if ( (has_video_cap) || (has_audio_cap) )
|
||||||
|
has_correct_type = TRUE;
|
||||||
|
break;;
|
||||||
|
default:
|
||||||
|
has_correct_type = FALSE;
|
||||||
|
}
|
||||||
|
caps = caps->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pads = g_list_next (pads);
|
||||||
|
}
|
||||||
|
if ( (!has_src) && (has_correct_type) ){
|
||||||
|
return element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elements = g_list_next (elements);
|
elements = g_list_next (elements);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,12 @@ typedef enum {
|
||||||
GST_PLAY_ERROR_LAST,
|
GST_PLAY_ERROR_LAST,
|
||||||
} GstPlayError;
|
} GstPlayError;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GST_PLAY_SINK_TYPE_AUDIO,
|
||||||
|
GST_PLAY_SINK_TYPE_VIDEO,
|
||||||
|
GST_PLAY_SINK_TYPE_ANY,
|
||||||
|
} GstPlaySinkType;
|
||||||
|
|
||||||
#define GST_PLAY_ERROR gst_play_error_quark ()
|
#define GST_PLAY_ERROR gst_play_error_quark ()
|
||||||
|
|
||||||
#define GST_TYPE_PLAY (gst_play_get_type())
|
#define GST_TYPE_PLAY (gst_play_get_type())
|
||||||
|
@ -169,7 +175,8 @@ gst_play_set_idle_timeout_funcs ( GstPlay *play,
|
||||||
GstPlayIdleAdd idle_add_func);
|
GstPlayIdleAdd idle_add_func);
|
||||||
GstElement*
|
GstElement*
|
||||||
gst_play_get_sink_element ( GstPlay *play,
|
gst_play_get_sink_element ( GstPlay *play,
|
||||||
GstElement *element);
|
GstElement *element,
|
||||||
|
GstPlaySinkType sink_type);
|
||||||
|
|
||||||
/* Set/Get state */
|
/* Set/Get state */
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,10 @@ gst_play_audiot_set_audio ( GstPlay *play,
|
||||||
gst_bin_add (GST_BIN (play->pipeline), play->audio_sink);
|
gst_bin_add (GST_BIN (play->pipeline), play->audio_sink);
|
||||||
gst_element_link (play->volume, play->audio_sink);
|
gst_element_link (play->volume, play->audio_sink);
|
||||||
|
|
||||||
play->audio_sink_element = gst_play_get_sink_element (play, audio_sink);
|
play->audio_sink_element = gst_play_get_sink_element (
|
||||||
|
play,
|
||||||
|
audio_sink,
|
||||||
|
GST_PLAY_SINK_TYPE_AUDIO);
|
||||||
|
|
||||||
if (play->audio_sink_element != NULL) {
|
if (play->audio_sink_element != NULL) {
|
||||||
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
||||||
|
@ -344,7 +347,10 @@ gst_play_audioht_set_audio ( GstPlay *play,
|
||||||
gst_bin_add (GST_BIN (audio_thread), play->audio_sink);
|
gst_bin_add (GST_BIN (audio_thread), play->audio_sink);
|
||||||
gst_element_link (play->volume, play->audio_sink);
|
gst_element_link (play->volume, play->audio_sink);
|
||||||
|
|
||||||
play->audio_sink_element = gst_play_get_sink_element (play, audio_sink);
|
play->audio_sink_element = gst_play_get_sink_element (
|
||||||
|
play,
|
||||||
|
audio_sink,
|
||||||
|
GST_PLAY_SINK_TYPE_AUDIO);
|
||||||
|
|
||||||
if (play->audio_sink_element != NULL) {
|
if (play->audio_sink_element != NULL) {
|
||||||
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
||||||
|
@ -604,7 +610,10 @@ gst_play_video_set_video ( GstPlay *play,
|
||||||
gst_bin_add (GST_BIN (video_bin), play->video_sink);
|
gst_bin_add (GST_BIN (video_bin), play->video_sink);
|
||||||
gst_element_link (video_mate, play->video_sink);
|
gst_element_link (video_mate, play->video_sink);
|
||||||
|
|
||||||
play->video_sink_element = gst_play_get_sink_element (play, video_sink);
|
play->video_sink_element = gst_play_get_sink_element (
|
||||||
|
play,
|
||||||
|
video_sink,
|
||||||
|
GST_PLAY_SINK_TYPE_VIDEO);
|
||||||
|
|
||||||
if (play->video_sink_element != NULL) {
|
if (play->video_sink_element != NULL) {
|
||||||
g_signal_connect ( G_OBJECT (play->video_sink_element),
|
g_signal_connect ( G_OBJECT (play->video_sink_element),
|
||||||
|
@ -646,7 +655,10 @@ gst_play_video_set_audio ( GstPlay *play,
|
||||||
gst_bin_add (GST_BIN (audio_bin), play->audio_sink);
|
gst_bin_add (GST_BIN (audio_bin), play->audio_sink);
|
||||||
gst_element_link (play->volume, play->audio_sink);
|
gst_element_link (play->volume, play->audio_sink);
|
||||||
|
|
||||||
play->audio_sink_element = gst_play_get_sink_element (play, audio_sink);
|
play->audio_sink_element = gst_play_get_sink_element (
|
||||||
|
play,
|
||||||
|
audio_sink,
|
||||||
|
GST_PLAY_SINK_TYPE_AUDIO);
|
||||||
|
|
||||||
if (play->audio_sink_element != NULL) {
|
if (play->audio_sink_element != NULL) {
|
||||||
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",
|
||||||
|
|
Loading…
Reference in a new issue