Commit f08bc644 authored by Emil Gydesen's avatar Emil Gydesen Committed by Anas Nashif
Browse files

Bluetooth: Audio: Rename stream_lang to lang



Remove the "stream" part of the value and functions to
better fit with the name in the assigned numbers document.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 57af793b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ Commands
                                    [pref_ctx <context>]
                                    [stream_ctx <context>]
                                    [program_info <program info>]
                                    [stream_lang <ISO 639-3 lang>]
                                    [lang <ISO 639-3 lang>]
                                    [ccid_list <ccids>]
                                    [parental_rating <rating>]
                                    [program_info_uri <URI>]
@@ -336,7 +336,7 @@ any stream previously configured.
                  [pref_ctx <context>]
                  [stream_ctx <context>]
                  [program_info <program info>]
                  [stream_lang <ISO 639-3 lang>]
                  [lang <ISO 639-3 lang>]
                  [ccid_list <ccids>]
                  [parental_rating <rating>]
                  [program_info_uri <URI>]
@@ -415,7 +415,7 @@ assigned numbers values.
   00000000: 08 00                                            |..               |
   QoS: interval 10000 framing 0x00 phy 0x02 sdu 80 rtn 2 latency 10 pd 40000

   uart:~$ bap preset sink 32_2_1 config freq 10 meta stream_lang "eng" stream_ctx 4
   uart:~$ bap preset sink 32_2_1 config freq 10 meta lang "eng" stream_ctx 4
   32_2_1
   codec cfg id 0x06 cid 0x0000 vid 0x0000 count 16
   data #0: type 0x01 value_len 1
+10 −0
Original line number Diff line number Diff line
@@ -504,6 +504,16 @@ Bluetooth Audio
  the :c:func:`bt_bap_stream_connect` shall now be called before :c:func:`bt_bap_stream_start`.
  (:github:`73032`)

* Renamed ``stream_lang`` to just ``lang`` to better fit with the assigned numbers document.
  This affects the ``BT_AUDIO_METADATA_TYPE_LANG`` macro and the following functions:

  * :c:func:`bt_audio_codec_cap_meta_set_lang`
  * :c:func:`bt_audio_codec_cap_meta_get_lang`
  * :c:func:`bt_audio_codec_cfg_meta_set_lang`
  * :c:func:`bt_audio_codec_cfg_meta_get_lang`

  (:github:`72584`)

* All occurrences of ``set_sirk`` have been changed to just ``sirk`` as the ``s`` in ``sirk`` stands
  for set. (:github:`73413`)

+16 −18
Original line number Diff line number Diff line
@@ -380,11 +380,11 @@ enum bt_audio_metadata_type {
	/** UTF-8 encoded title or summary of stream content */
	BT_AUDIO_METADATA_TYPE_PROGRAM_INFO        = 0x03,

	/** @brief Stream language
	/** @brief Language
	 *
	 * 3 octet lower case language code defined by ISO 639-3
	 */
	BT_AUDIO_METADATA_TYPE_STREAM_LANG         = 0x04,
	BT_AUDIO_METADATA_TYPE_LANG                = 0x04,

	/** Array of 8-bit CCID values */
	BT_AUDIO_METADATA_TYPE_CCID_LIST           = 0x05,
@@ -1250,31 +1250,30 @@ int bt_audio_codec_cfg_meta_get_program_info(const struct bt_audio_codec_cfg *co
int bt_audio_codec_cfg_meta_set_program_info(struct bt_audio_codec_cfg *codec_cfg,
					     const uint8_t *program_info, size_t program_info_len);

/** @brief Extract stream language
/** @brief Extract language
 *
 *  See @ref BT_AUDIO_METADATA_TYPE_STREAM_LANG for more information about this value.
 *  See @ref BT_AUDIO_METADATA_TYPE_LANG for more information about this value.
 *
 *  @param codec_cfg The codec data to search in.
 *
 *  @retval The stream language if positive or 0
 *  @retval The language if positive or 0
 *  @retval -EINVAL if arguments are invalid
 *  @retval -ENODATA if not found
 *  @retval -EBADMSG if found value has invalid size
 */
int bt_audio_codec_cfg_meta_get_stream_lang(const struct bt_audio_codec_cfg *codec_cfg);
int bt_audio_codec_cfg_meta_get_lang(const struct bt_audio_codec_cfg *codec_cfg);

/**
 * @brief Set the stream language of a codec configuration metadata.
 * @brief Set the language of a codec configuration metadata.
 *
 * @param codec_cfg   The codec configuration to set data for.
 * @param stream_lang The 24-bit stream language to set.
 * @param lang        The 24-bit language to set.
 *
 * @retval The data_len of @p codec_cfg on success
 * @retval -EINVAL if arguments are invalid
 * @retval -ENOMEM if the new value could not set or added due to memory
 */
int bt_audio_codec_cfg_meta_set_stream_lang(struct bt_audio_codec_cfg *codec_cfg,
					    uint32_t stream_lang);
int bt_audio_codec_cfg_meta_set_lang(struct bt_audio_codec_cfg *codec_cfg, uint32_t lang);

/** @brief Extract CCID list
 *
@@ -1773,31 +1772,30 @@ int bt_audio_codec_cap_meta_get_program_info(const struct bt_audio_codec_cap *co
int bt_audio_codec_cap_meta_set_program_info(struct bt_audio_codec_cap *codec_cap,
					     const uint8_t *program_info, size_t program_info_len);

/** @brief Extract stream language
/** @brief Extract language
 *
 *  See @ref BT_AUDIO_METADATA_TYPE_STREAM_LANG for more information about this value.
 *  See @ref BT_AUDIO_METADATA_TYPE_LANG for more information about this value.
 *
 *  @param codec_cap The codec data to search in.
 *
 *  @retval The stream language if positive or 0
 *  @retval The language if positive or 0
 *  @retval -EINVAL if arguments are invalid
 *  @retval -ENODATA if not found
 *  @retval -EBADMSG if found value has invalid size
 */
int bt_audio_codec_cap_meta_get_stream_lang(const struct bt_audio_codec_cap *codec_cap);
int bt_audio_codec_cap_meta_get_lang(const struct bt_audio_codec_cap *codec_cap);

/**
 * @brief Set the stream language of a codec capability metadata.
 * @brief Set the language of a codec capability metadata.
 *
 * @param codec_cap   The codec capability to set data for.
 * @param stream_lang The 24-bit stream language to set.
 * @param lang        The 24-bit language to set.
 *
 * @retval The data_len of @p codec_cap on success
 * @retval -EINVAL if arguments are invalid
 * @retval -ENOMEM if the new value could not set or added due to memory
 */
int bt_audio_codec_cap_meta_set_stream_lang(struct bt_audio_codec_cap *codec_cap,
					    uint32_t stream_lang);
int bt_audio_codec_cap_meta_set_lang(struct bt_audio_codec_cap *codec_cap, uint32_t lang);

/** @brief Extract CCID list
 *
+1 −1
Original line number Diff line number Diff line
@@ -2112,7 +2112,7 @@ static bool ascs_parse_metadata(struct bt_data *data, void *user_data)

		break;
	}
	case BT_AUDIO_METADATA_TYPE_STREAM_LANG:
	case BT_AUDIO_METADATA_TYPE_LANG:
		if (data_len != 3) {
			*result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID,
						       data_type);
+20 −23
Original line number Diff line number Diff line
@@ -804,7 +804,7 @@ static int codec_meta_set_program_info(uint8_t meta[], size_t meta_len, size_t m
				  program_info, program_info_len);
}

static int codec_meta_get_stream_lang(const uint8_t meta[], size_t meta_len)
static int codec_meta_get_lang(const uint8_t meta[], size_t meta_len)
{
	const uint8_t *data;
	int ret;
@@ -814,37 +814,36 @@ static int codec_meta_get_stream_lang(const uint8_t meta[], size_t meta_len)
		return -EINVAL;
	}

	ret = codec_meta_get_val(meta, meta_len, BT_AUDIO_METADATA_TYPE_STREAM_LANG, &data);
	ret = codec_meta_get_val(meta, meta_len, BT_AUDIO_METADATA_TYPE_LANG, &data);
	if (data == NULL) {
		return -ENODATA;
	}

	if (ret != 3) { /* Stream language is 3 octets */
	if (ret != 3) { /* Language is 3 octets */
		return -EBADMSG;
	}

	return sys_get_le24(data);
}

static int codec_meta_set_stream_lang(uint8_t meta[], size_t meta_len, size_t meta_size,
				      uint32_t stream_lang)
static int codec_meta_set_lang(uint8_t meta[], size_t meta_len, size_t meta_size, uint32_t lang)
{
	uint8_t stream_lang_le[3];
	uint8_t lang_le[3];

	CHECKIF(meta == NULL) {
		LOG_DBG("meta is NULL");
		return -EINVAL;
	}

	if ((stream_lang & 0xFFFFFFU) != stream_lang) {
		LOG_DBG("Invalid stream_lang value: %d", stream_lang);
	if ((lang & 0xFFFFFFU) != lang) {
		LOG_DBG("Invalid lang value: %d", lang);
		return -EINVAL;
	}

	sys_put_le24(stream_lang, stream_lang_le);
	sys_put_le24(lang, lang_le);

	return codec_meta_set_val(meta, meta_len, meta_size, BT_AUDIO_METADATA_TYPE_STREAM_LANG,
				  stream_lang_le, sizeof(stream_lang_le));
	return codec_meta_set_val(meta, meta_len, meta_size, BT_AUDIO_METADATA_TYPE_LANG, lang_le,
				  sizeof(lang_le));
}

static int codec_meta_get_ccid_list(const uint8_t meta[], size_t meta_len,
@@ -1256,23 +1255,22 @@ int bt_audio_codec_cfg_meta_set_program_info(struct bt_audio_codec_cfg *codec_cf
	return ret;
}

int bt_audio_codec_cfg_meta_get_stream_lang(const struct bt_audio_codec_cfg *codec_cfg)
int bt_audio_codec_cfg_meta_get_lang(const struct bt_audio_codec_cfg *codec_cfg)
{
	CHECKIF(codec_cfg == NULL) {
		LOG_DBG("codec_cfg is NULL");
		return -EINVAL;
	}

	return codec_meta_get_stream_lang(codec_cfg->meta, codec_cfg->meta_len);
	return codec_meta_get_lang(codec_cfg->meta, codec_cfg->meta_len);
}

int bt_audio_codec_cfg_meta_set_stream_lang(struct bt_audio_codec_cfg *codec_cfg,
					    uint32_t stream_lang)
int bt_audio_codec_cfg_meta_set_lang(struct bt_audio_codec_cfg *codec_cfg, uint32_t lang)
{
	int ret;

	ret = codec_meta_set_stream_lang(codec_cfg->meta, codec_cfg->meta_len,
					 ARRAY_SIZE(codec_cfg->meta), stream_lang);
	ret = codec_meta_set_lang(codec_cfg->meta, codec_cfg->meta_len, ARRAY_SIZE(codec_cfg->meta),
				  lang);
	if (ret >= 0) {
		codec_cfg->meta_len = ret;
	}
@@ -1583,23 +1581,22 @@ int bt_audio_codec_cap_meta_set_program_info(struct bt_audio_codec_cap *codec_ca
	return ret;
}

int bt_audio_codec_cap_meta_get_stream_lang(const struct bt_audio_codec_cap *codec_cap)
int bt_audio_codec_cap_meta_get_lang(const struct bt_audio_codec_cap *codec_cap)
{
	CHECKIF(codec_cap == NULL) {
		LOG_DBG("codec_cap is NULL");
		return -EINVAL;
	}

	return codec_meta_get_stream_lang(codec_cap->meta, codec_cap->meta_len);
	return codec_meta_get_lang(codec_cap->meta, codec_cap->meta_len);
}

int bt_audio_codec_cap_meta_set_stream_lang(struct bt_audio_codec_cap *codec_cap,
					    uint32_t stream_lang)
int bt_audio_codec_cap_meta_set_lang(struct bt_audio_codec_cap *codec_cap, uint32_t lang)
{
	int ret;

	ret = codec_meta_set_stream_lang(codec_cap->meta, codec_cap->meta_len,
					 ARRAY_SIZE(codec_cap->meta), stream_lang);
	ret = codec_meta_set_lang(codec_cap->meta, codec_cap->meta_len, ARRAY_SIZE(codec_cap->meta),
				  lang);
	if (ret >= 0) {
		codec_cap->meta_len = ret;
	}
Loading