Select the preferred codec 96/140996/2
authorHyuk Lee <hyuk0512.lee@samsung.com>
Thu, 27 Jul 2017 11:27:21 +0000 (20:27 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Thu, 27 Jul 2017 11:28:48 +0000 (20:28 +0900)
Change-Id: Ic7e99cfcd0ecd19e996341ae793c7c66cd71dd54
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
profiles/audio/a2dp.c

index 5877219..c09ddf9 100755 (executable)
 
 #define AVDTP_PSM 25
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#ifdef TIZEN_FEATURE_SSC_ENCODER
+/* Vendor and Codec ID for Samsung Scalable codec */
+#define PREFRED_VENDOR_ID      0x00000075
+#define PREFRED_CODEC_ID       0x0103
+#endif
+#endif
+
 struct a2dp_sep {
        struct a2dp_server *server;
        struct a2dp_endpoint *endpoint;
@@ -512,6 +520,35 @@ static void endpoint_setconf_cb(struct a2dp_setup *setup, gboolean ret)
        auto_config(setup);
 }
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#ifdef TIZEN_FEATURE_SSC_ENCODER
+static gboolean endpoint_match_codec_preference(struct avdtp *session,
+               struct avdtp_media_codec_capability *codec,
+               void *user_data)
+{
+       struct a2dp_sep *sep = user_data;
+       uint8_t *capabilities;
+       a2dp_vendor_codec_t *local_codec;
+       size_t length;
+
+       length = sep->endpoint->get_capabilities(sep, &capabilities,
+                       sep->user_data);
+       if (length < sizeof(a2dp_vendor_codec_t))
+               return FALSE;
+
+       local_codec = (a2dp_vendor_codec_t *) capabilities;
+       DBG("vendor 0x%08x codec 0x%04x", btohl(local_codec->vendor_id),
+                       btohs(local_codec->codec_id));
+       if (btohl(local_codec->vendor_id) == PREFRED_VENDOR_ID &&
+                       btohs(local_codec->codec_id) == PREFRED_CODEC_ID) {
+               DBG("Samsung Scalable Codec Selected");
+               return TRUE;
+       }
+       return FALSE;
+}
+#endif
+#endif
+
 static gboolean endpoint_match_codec_ind(struct avdtp *session,
                                struct avdtp_media_codec_capability *codec,
                                void *user_data)
@@ -1934,6 +1971,14 @@ static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
                if (cap->media_codec_type != A2DP_CODEC_VENDOR) {
                        selected_sep = sep;
                        continue;
+#ifdef TIZEN_FEATURE_SSC_ENCODER
+               } else {
+                       /* This is vendor codec */
+                       selected_sep = sep;
+                       if (endpoint_match_codec_preference(session, cap, sep))
+                               return selected_sep;
+                       continue;
+#endif
                }
 #else
                if (avdtp_find_remote_sep(session, sep->lsep) == NULL)