summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2003-03-03 17:58:07 +0000
committerJulien Moutte <julien@moutte.net>2003-03-03 17:58:07 +0000
commit42aadabc81d991b00582ae9b846f8f0aa4d1b3cd (patch)
treeeef1a47bcd54c5a2509d7c40edb4af9ef9557f41 /gst-libs/gst
parentc62995f2fc0bb404616311c43e9e4177d4c18dc1 (diff)
downloadgst-plugins-bad-42aadabc81d991b00582ae9b846f8f0aa4d1b3cd.tar.gz
gst-plugins-bad-42aadabc81d991b00582ae9b846f8f0aa4d1b3cd.tar.bz2
gst-plugins-bad-42aadabc81d991b00582ae9b846f8f0aa4d1b3cd.zip
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..
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/play/play.old.c86
-rw-r--r--gst-libs/gst/play/play.old.h9
-rw-r--r--gst-libs/gst/play/playpipelines.c20
3 files changed, 94 insertions, 21 deletions
diff --git a/gst-libs/gst/play/play.old.c b/gst-libs/gst/play/play.old.c
index ff6d1b2b..0d17aa67 100644
--- a/gst-libs/gst/play/play.old.c
+++ b/gst-libs/gst/play/play.old.c
@@ -722,19 +722,21 @@ gst_play_set_idle_timeout_funcs ( GstPlay *play,
* gst_play_get_sink_element:
* @play: a #GstPlay.
* @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.
*/
GstElement*
gst_play_get_sink_element ( GstPlay *play,
- GstElement *element)
+ GstElement *element,
+ GstPlaySinkType sink_type)
{
- GstPad *pad = NULL;
GList *elements = 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_ELEMENT (element), NULL);
@@ -744,23 +746,75 @@ gst_play_get_sink_element ( GstPlay *play,
* element is a sink element */
return element;
}
-
+
elements = (GList *) gst_bin_get_list (GST_BIN(element));
+
/* traverse all elements looking for a src pad */
- while (elements && pad == NULL) {
+
+ while (elements) {
+
element = GST_ELEMENT (elements->data);
- pads = gst_element_get_pad_list (element);
- has_src = FALSE;
- while (pads) {
- /* check for src pad */
- if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
- has_src = TRUE;
- break;
+
+ /* Recursivity :) */
+
+ if (GST_IS_BIN(element)) {
+ element = gst_play_get_sink_element(play,element,sink_type);
+ if (GST_IS_ELEMENT (element)) {
+ return element;
}
- pads = g_list_next (pads);
}
- if (!has_src){
- return element;
+ else {
+
+ 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);
}
diff --git a/gst-libs/gst/play/play.old.h b/gst-libs/gst/play/play.old.h
index f9b14116..e38c699d 100644
--- a/gst-libs/gst/play/play.old.h
+++ b/gst-libs/gst/play/play.old.h
@@ -64,6 +64,12 @@ typedef enum {
GST_PLAY_ERROR_LAST,
} 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_TYPE_PLAY (gst_play_get_type())
@@ -169,7 +175,8 @@ gst_play_set_idle_timeout_funcs ( GstPlay *play,
GstPlayIdleAdd idle_add_func);
GstElement*
gst_play_get_sink_element ( GstPlay *play,
- GstElement *element);
+ GstElement *element,
+ GstPlaySinkType sink_type);
/* Set/Get state */
diff --git a/gst-libs/gst/play/playpipelines.c b/gst-libs/gst/play/playpipelines.c
index ace3462a..3b8fb61d 100644
--- a/gst-libs/gst/play/playpipelines.c
+++ b/gst-libs/gst/play/playpipelines.c
@@ -196,7 +196,10 @@ gst_play_audiot_set_audio ( GstPlay *play,
gst_bin_add (GST_BIN (play->pipeline), 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) {
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_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) {
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_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) {
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_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) {
g_signal_connect (G_OBJECT (play->audio_sink_element), "eos",