1From baea6a2c44f6fc58b20fa9de16fd9858e0d0ea42 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Tue, 11 Jun 2019 10:19:22 +0800 4Subject: [PATCH 03/12] autodetect: Add preferred for 5 autovideosink/autoaudiosink 6 7Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 8--- 9 gst/autodetect/gstautoaudiosink.c | 3 +++ 10 gst/autodetect/gstautodetect.c | 14 ++++++++++++++ 11 gst/autodetect/gstautodetect.h | 1 + 12 gst/autodetect/gstautovideosink.c | 3 +++ 13 4 files changed, 21 insertions(+) 14 15diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c 16index 5c18972..088c83e 100644 17--- a/gst/autodetect/gstautoaudiosink.c 18+++ b/gst/autodetect/gstautoaudiosink.c 19@@ -39,6 +39,8 @@ 20 #include "config.h" 21 #endif 22 23+#include <stdlib.h> 24+ 25 #include "gstautodetectelements.h" 26 #include "gstautodetect.h" 27 #include "gstautoaudiosink.h" 28@@ -99,6 +101,7 @@ gst_auto_audio_sink_init (GstAutoAudioSink * sink) 29 30 autodetect->media_klass = "Audio"; 31 autodetect->flag = GST_ELEMENT_FLAG_SINK; 32+ autodetect->preferred = g_getenv ("AUTOAUDIOSINK_PREFERRED"); 33 34 sink->ts_offset = DEFAULT_TS_OFFSET; 35 } 36diff --git a/gst/autodetect/gstautodetect.c b/gst/autodetect/gstautodetect.c 37index 864d465..56ce69d 100644 38--- a/gst/autodetect/gstautodetect.c 39+++ b/gst/autodetect/gstautodetect.c 40@@ -273,6 +273,20 @@ gst_auto_detect_find_best (GstAutoDetect * self) 41 GST_LOG_OBJECT (self, "Trying to find usable %s elements ...", 42 self->media_klass_lc); 43 44+ if (self->preferred) { 45+ for (item = list; item != NULL; item = item->next) { 46+ GstElementFactory *f = GST_ELEMENT_FACTORY (item->data); 47+ 48+ if (!strcmp (self->preferred, GST_OBJECT_NAME (f))) { 49+ GST_DEBUG_OBJECT (self, "Preferred %s", GST_OBJECT_NAME (f)); 50+ 51+ list = g_list_delete_link (list, item); 52+ list = g_list_prepend (list, f); 53+ break; 54+ } 55+ } 56+ } 57+ 58 for (item = list; item != NULL; item = item->next) { 59 GstElementFactory *f = GST_ELEMENT_FACTORY (item->data); 60 GstElement *el; 61diff --git a/gst/autodetect/gstautodetect.h b/gst/autodetect/gstautodetect.h 62index 3f54c14..85731c0 100644 63--- a/gst/autodetect/gstautodetect.h 64+++ b/gst/autodetect/gstautodetect.h 65@@ -41,6 +41,7 @@ typedef struct _GstAutoDetect { 66 GstBin parent; 67 68 /* configuration for subclasses */ 69+ const gchar *preferred; 70 const gchar *media_klass; /* Audio/Video/... */ 71 GstElementFlags flag; /* GST_ELEMENT_FLAG_{SINK/SOURCE} */ 72 73diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c 74index b3eaf1f..545e21c 100644 75--- a/gst/autodetect/gstautovideosink.c 76+++ b/gst/autodetect/gstautovideosink.c 77@@ -39,6 +39,8 @@ 78 #include "config.h" 79 #endif 80 81+#include <stdlib.h> 82+ 83 #include "gstautodetectelements.h" 84 #include "gstautodetect.h" 85 #include "gstautovideosink.h" 86@@ -99,6 +101,7 @@ gst_auto_video_sink_init (GstAutoVideoSink * sink) 87 88 autodetect->media_klass = "Video"; 89 autodetect->flag = GST_ELEMENT_FLAG_SINK; 90+ autodetect->preferred = g_getenv ("AUTOVIDEOSINK_PREFERRED"); 91 92 sink->ts_offset = DEFAULT_TS_OFFSET; 93 } 94-- 952.20.1 96 97