Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 1/8] hfpmodem: Add codec watcher register
Date: Tue, 09 Apr 2013 20:44:30 -0500	[thread overview]
Message-ID: <5164C3FE.9070600@gmail.com> (raw)
In-Reply-To: <1365540343-8394-2-git-send-email-vinicius.gomes@openbossa.org>

[-- Attachment #1: Type: text/plain, Size: 3500 bytes --]

Hi Vinicius,

On 04/09/2013 03:45 PM, Vinicius Costa Gomes wrote:
> This patch adds a function to monitor when the AG sends a new codec
> before establishing the SCO connection.
> ---
>   drivers/hfpmodem/slc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   drivers/hfpmodem/slc.h |  4 ++++
>   2 files changed, 66 insertions(+)
>
> diff --git a/drivers/hfpmodem/slc.c b/drivers/hfpmodem/slc.c
> index 40b22a1..51c1373 100644
> --- a/drivers/hfpmodem/slc.c
> +++ b/drivers/hfpmodem/slc.c
> @@ -54,6 +54,12 @@ struct slc_establish_data {
>   	gpointer userdata;
>   };
>
> +struct codec_watch {
> +	struct hfp_slc_info *slc;
> +	hfp_slc_codec_watch_cb_t cb;
> +	gpointer user_data;
> +};
> +
>   void hfp_slc_info_init(struct hfp_slc_info *info, guint16 version)
>   {
>   	info->ag_features = 0;
> @@ -347,3 +353,59 @@ void hfp_slc_establish(struct hfp_slc_info *info, hfp_slc_cb_t connect_cb,
>   	g_at_chat_send(info->chat, buf, brsf_prefix,
>   				brsf_cb, sed, slc_establish_data_unref);
>   }
> +
> +static void bcs_notify(GAtResult *result, gpointer user_data)
> +{
> +	struct codec_watch *watch = user_data;
> +	struct hfp_slc_info *info = watch->slc;
> +	GAtResultIter iter;
> +	char str[32];
> +	int value;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+BCS:"))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter,&value))
> +		return;
> +
> +	memset(str, 0, sizeof(str));
> +
> +	switch (value) {
> +	case HFP_CODEC_MSBC:
> +		if (!ofono_handsfree_audio_has_wideband()) {
> +			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
> +			break;
> +		}
> +
> +		/* fallthrough */
> +
> +	case HFP_CODEC_CVSD:
> +		sprintf(str, "AT+BCS=%d", value);
> +		watch->cb(value, watch->user_data);
> +		break;
> +
> +	default:
> +		if (ofono_handsfree_audio_has_wideband())
> +			sprintf(str, "AT+BAC=%d,%d", HFP_CODEC_CVSD,
> +							HFP_CODEC_MSBC);
> +		else
> +			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
> +	}
> +
> +	g_at_chat_send(info->chat, str, NULL, NULL, NULL, NULL);
> +}
> +
> +guint hfp_slc_codec_watch_register(struct hfp_slc_info *info,
> +				hfp_slc_codec_watch_cb_t cb, void *user_data)
> +{
> +	struct codec_watch *watch = g_new0(struct codec_watch, 1);
> +
> +	watch->slc = info;
> +	watch->cb = cb;
> +	watch->user_data = user_data;
> +
> +	return g_at_chat_register(info->chat, "+BCS:", bcs_notify, FALSE,
> +								watch, g_free);
> +}

Why would you do this in the SLC ?  The SLC establishment only requires 
HF to send a BAC after the BRSF has been exchanged.  We do this 
successfully in brsf_cb.  I do not see why we can't monitor +BCS inside 
plugins/hfp_hf_bluez5.c?

> diff --git a/drivers/hfpmodem/slc.h b/drivers/hfpmodem/slc.h
> index b71ffe9..95539c8 100644
> --- a/drivers/hfpmodem/slc.h
> +++ b/drivers/hfpmodem/slc.h
> @@ -45,6 +45,7 @@ enum hfp_indicator {
>   };
>
>   typedef void (*hfp_slc_cb_t)(void *userdata);
> +typedef void (*hfp_slc_codec_watch_cb_t)(unsigned char codec, void *userdata);
>
>   struct hfp_slc_info {
>   	GAtChat *chat;
> @@ -60,3 +61,6 @@ void hfp_slc_info_free(struct hfp_slc_info *info);
>
>   void hfp_slc_establish(struct hfp_slc_info *info, hfp_slc_cb_t connect_cb,
>   				hfp_slc_cb_t failed_cb, void *userdata);
> +
> +guint hfp_slc_codec_watch_register(struct hfp_slc_info *info,
> +				hfp_slc_codec_watch_cb_t cb, void *user_data);

Regards,
-Denis

  reply	other threads:[~2013-04-10  1:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09 20:45 [PATCH 0/8] HFP 1.6 codec selection Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 1/8] hfpmodem: Add codec watcher register Vinicius Costa Gomes
2013-04-10  1:44   ` Denis Kenzior [this message]
2013-04-10 19:31     ` Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 2/8] hfp_hf_bluez5: Register codec watcher Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 3/8] include: ofono_handsfree_card_select_codec() Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 4/8] handsfree-audio: Implement ofono_handsfree_card_select_codec() Vinicius Costa Gomes
2013-04-10  1:49   ` Denis Kenzior
2013-04-09 20:45 ` [PATCH 5/8] hfp_hf_bluez5: Set the audio codec in the card Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 6/8] handsfree-audio: Send the selected codec Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 7/8] handsfree-audio: Set CVSD as default in the card Vinicius Costa Gomes
2013-04-09 20:45 ` [PATCH 8/8] handsfree-audio: Enable wideband speech if defer is enabled Vinicius Costa Gomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5164C3FE.9070600@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox