1From 0372b83dc2679de0e1a6ad5ede372ca85e6e1793 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 14 Jun 2019 12:02:05 +0800 4Subject: [PATCH 06/11] playbin2: Add preferred audio/video sink 5 6Using env "PLAYBIN2_PREFERRED_VIDEOSINK" and 7"PLAYBIN2_PREFERRED_AUDIOSINK". 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 gst/playback/gstplaybin2.c | 31 +++++++++++++++++++++++++++++++ 12 1 file changed, 31 insertions(+) 13 14diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c 15index f71b977..b0879db 100644 16--- a/gst/playback/gstplaybin2.c 17+++ b/gst/playback/gstplaybin2.c 18@@ -204,6 +204,7 @@ 19 #include "config.h" 20 #endif 21 22+#include <stdlib.h> 23 #include <string.h> 24 #include <gst/gst.h> 25 26@@ -480,6 +481,9 @@ struct _GstPlayBin 27 GList *contexts; 28 29 gboolean is_live; 30+ 31+ const gchar *apreferred; 32+ const gchar *vpreferred; 33 }; 34 35 struct _GstPlayBinClass 36@@ -1585,6 +1589,9 @@ gst_play_bin_init (GstPlayBin * playbin) 37 38 playbin->multiview_mode = GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE; 39 playbin->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE; 40+ 41+ playbin->apreferred = g_getenv ("PLAYBIN2_PREFERRED_AUDIOSINK"); 42+ playbin->vpreferred = g_getenv ("PLAYBIN2_PREFERRED_VIDEOSINK"); 43 } 44 45 static void 46@@ -4722,6 +4729,7 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad, 47 GSequence *ave_seq = NULL; 48 GSequenceIter *seq_iter; 49 gboolean created_sink = FALSE; 50+ const gchar *preferred = NULL; 51 52 playbin = group->playbin; 53 54@@ -4784,6 +4792,29 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad, 55 ave_list = g_list_prepend (ave_list, NULL); 56 } 57 58+ if (isaudiodec) 59+ preferred = playbin->apreferred; 60+ else if (isvideodec) 61+ preferred = playbin->vpreferred; 62+ 63+ if (preferred) { 64+ for (l = ave_list; l; l = l->next) { 65+ ave = (GstAVElement *) l->data; 66+ 67+ if (ave && ave->sink && 68+ !strcmp (preferred, GST_OBJECT_NAME (ave->sink))) { 69+ GST_DEBUG_OBJECT (playbin, 70+ "Preferred sink '%s' for decoder '%s'", 71+ gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (ave->sink)), 72+ gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); 73+ 74+ ave_list = g_list_delete_link (ave_list, l); 75+ ave_list = g_list_prepend (ave_list, ave); 76+ break; 77+ } 78+ } 79+ } 80+ 81 /* if it is a decoder and we don't have a fixed sink, then find out 82 * the matching audio/video sink from GstAVElements list */ 83 for (l = ave_list; l; l = l->next) { 84-- 852.20.1 86 87