Diff between 4d3458a1a631bc572b0d689e722ed4c9d08b583b and 15295bc4bc90c594b7eb31974653b0f5907a42b0

Changed Files

File Additions Deletions Status
profiles/audio/a2dp.c +36 -0 modified
profiles/audio/avdtp.c +5 -0 modified
profiles/audio/avdtp.h +3 -0 modified

Full Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 31c5086..d65b7a2 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -447,6 +447,41 @@ static void endpoint_setconf_cb(struct a2dp_setup *setup, gboolean ret)
 	auto_config(setup);
 }
 
+static gboolean endpoint_match_codec_ind(struct avdtp *session,
+				struct avdtp_media_codec_capability *codec,
+				void *user_data)
+{
+	struct a2dp_sep *sep = user_data;
+	a2dp_vendor_codec_t *remote_codec;
+	a2dp_vendor_codec_t *local_codec;
+	uint8_t *capabilities;
+	size_t length;
+
+	if (codec->media_codec_type != A2DP_CODEC_VENDOR)
+		return TRUE;
+
+	if (sep->endpoint == NULL)
+		return FALSE;
+
+	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;
+	remote_codec = (a2dp_vendor_codec_t *) codec->data;
+
+	if (remote_codec->vendor_id != local_codec->vendor_id)
+		return FALSE;
+
+	if (remote_codec->codec_id != local_codec->codec_id)
+		return FALSE;
+
+	DBG("vendor 0x%08x codec 0x%04x", btohl(remote_codec->vendor_id),
+						btohs(remote_codec->codec_id));
+	return TRUE;
+}
+
 static gboolean endpoint_setconf_ind(struct avdtp *session,
 						struct avdtp_local_sep *sep,
 						struct avdtp_stream *stream,
@@ -1114,6 +1149,7 @@ static struct avdtp_sep_cfm cfm = {
 };
 
 static struct avdtp_sep_ind endpoint_ind = {
+	.match_codec		= endpoint_match_codec_ind,
 	.get_capability		= endpoint_getcap_ind,
 	.set_configuration	= endpoint_setconf_ind,
 	.get_configuration	= getconf_ind,
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index f38188f..d2cd1dc 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -1226,6 +1226,11 @@ struct avdtp_remote_sep *avdtp_find_remote_sep(struct avdtp *session,
 		if (codec_data->media_codec_type != lsep->codec)
 			continue;
 
+		if (lsep->ind && lsep->ind->match_codec)
+			if (!lsep->ind->match_codec(session, codec_data,
+							lsep->user_data))
+				continue;
+
 		if (sep->stream == NULL)
 			return sep;
 	}
diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h
index 1b02232..621a6e3 100644
--- a/profiles/audio/avdtp.h
+++ b/profiles/audio/avdtp.h
@@ -172,6 +172,9 @@ struct avdtp_sep_cfm {
 /* Callbacks for indicating when we received a new command. The return value
  * indicates whether the command should be rejected or accepted */
 struct avdtp_sep_ind {
+	gboolean (*match_codec) (struct avdtp *session,
+				struct avdtp_media_codec_capability *codec,
+				void *user_data);
 	gboolean (*get_capability) (struct avdtp *session,
 					struct avdtp_local_sep *sep,
 					gboolean get_all,