Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-16 Thread Sathish Narasimman
Hi,

I had submitted the patch version 2 . please help to review the same

On Thu, Aug 16, 2018 at 12:58 AM Georg Chini  wrote:

> On 15.08.2018 09:24, Pali Rohár wrote:
> > On Wednesday 15 August 2018 09:24:04 Sathish Narasimman wrote:
> >> Hi Pali,
> >>
> >> On Wed, Aug 15, 2018 at 1:31 AM, Pali Rohár 
> wrote:
> >>
> >>> On Tuesday 14 August 2018 22:49:27 Luiz Augusto von Dentz wrote:
>  Hi Pali,
> 
>  On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár 
> >>> wrote:
> > On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> >> mSBC-encoded streams for HFP. The wideband speec encoding and
> >>> decoding
> >> is implemeted with this patch. This patch was refered from original
> >> patch of Joao Paula Rechi Vita and was verified with the supported
> >> bluetooth controller.
> >>
> >> Signed-off-by: Sathish Narasimman 
> >> ---
> >>   src/modules/bluetooth/backend-ofono.c|  20 +-
> >>   src/modules/bluetooth/module-bluez5-device.c | 371
> >>> ++-
> >>   2 files changed, 377 insertions(+), 14 deletions(-)
> > Hi! This looks great. What about support also for other backends, not
> > only ofono?
>  Afaik only oFono supports WBS negotiation.
> >>> IIRC codec negotiation is done via AT commands. Therefore native
> backend
> >>> and its AT parser could be extended to support it.
> >>>
> >> AFAIK i was not able to find Handsfree profile in native backend. I see
> >> only the headset profile in which codec negotiation is not available.
> >> please point me the right place where AT commands are implented in PA
> for
> >> HFP profile in native backend. i can try the best.
> > rfcomm_io_callback function in backend-native.c. There is implemented AT
> > parser. For codec selection is needed to issue some AT command,
> > therefore that code is needed to extend...
> >
> Currently there is no HFP support in the native backend. There have
> been patches by James Bottomley to implement HFP, but they have
> never been merged due to remaining issues. See here:
> https://patchwork.freedesktop.org/series/30716/
>
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-15 Thread Georg Chini

On 15.08.2018 09:24, Pali Rohár wrote:

On Wednesday 15 August 2018 09:24:04 Sathish Narasimman wrote:

Hi Pali,

On Wed, Aug 15, 2018 at 1:31 AM, Pali Rohár  wrote:


On Tuesday 14 August 2018 22:49:27 Luiz Augusto von Dentz wrote:

Hi Pali,

On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár 

wrote:

On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:

mSBC-encoded streams for HFP. The wideband speec encoding and

decoding

is implemeted with this patch. This patch was refered from original
patch of Joao Paula Rechi Vita and was verified with the supported
bluetooth controller.

Signed-off-by: Sathish Narasimman 
---
  src/modules/bluetooth/backend-ofono.c|  20 +-
  src/modules/bluetooth/module-bluez5-device.c | 371

++-

  2 files changed, 377 insertions(+), 14 deletions(-)

Hi! This looks great. What about support also for other backends, not
only ofono?

Afaik only oFono supports WBS negotiation.

IIRC codec negotiation is done via AT commands. Therefore native backend
and its AT parser could be extended to support it.


AFAIK i was not able to find Handsfree profile in native backend. I see
only the headset profile in which codec negotiation is not available.
please point me the right place where AT commands are implented in PA for
HFP profile in native backend. i can try the best.

rfcomm_io_callback function in backend-native.c. There is implemented AT
parser. For codec selection is needed to issue some AT command,
therefore that code is needed to extend...


Currently there is no HFP support in the native backend. There have
been patches by James Bottomley to implement HFP, but they have
never been merged due to remaining issues. See here:
https://patchwork.freedesktop.org/series/30716/

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-15 Thread Pali Rohár
On Wednesday 15 August 2018 09:24:04 Sathish Narasimman wrote:
> Hi Pali,
> 
> On Wed, Aug 15, 2018 at 1:31 AM, Pali Rohár  wrote:
> 
> > On Tuesday 14 August 2018 22:49:27 Luiz Augusto von Dentz wrote:
> > > Hi Pali,
> > >
> > > On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár 
> > wrote:
> > > >
> > > > On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> > > > > mSBC-encoded streams for HFP. The wideband speec encoding and
> > decoding
> > > > > is implemeted with this patch. This patch was refered from original
> > > > > patch of Joao Paula Rechi Vita and was verified with the supported
> > > > > bluetooth controller.
> > > > >
> > > > > Signed-off-by: Sathish Narasimman 
> > > > > ---
> > > > >  src/modules/bluetooth/backend-ofono.c|  20 +-
> > > > >  src/modules/bluetooth/module-bluez5-device.c | 371
> > ++-
> > > > >  2 files changed, 377 insertions(+), 14 deletions(-)
> > > >
> > > > Hi! This looks great. What about support also for other backends, not
> > > > only ofono?
> > >
> > > Afaik only oFono supports WBS negotiation.
> >
> > IIRC codec negotiation is done via AT commands. Therefore native backend
> > and its AT parser could be extended to support it.
> >
> 
> AFAIK i was not able to find Handsfree profile in native backend. I see
> only the headset profile in which codec negotiation is not available.
> please point me the right place where AT commands are implented in PA for
> HFP profile in native backend. i can try the best.

rfcomm_io_callback function in backend-native.c. There is implemented AT
parser. For codec selection is needed to issue some AT command,
therefore that code is needed to extend...

-- 
Pali Rohár
pali.ro...@gmail.com
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Sathish Narasimman
Hi Pali,

On Wed, Aug 15, 2018 at 1:31 AM, Pali Rohár  wrote:

> On Tuesday 14 August 2018 22:49:27 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> >
> > On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár 
> wrote:
> > >
> > > On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> > > > mSBC-encoded streams for HFP. The wideband speec encoding and
> decoding
> > > > is implemeted with this patch. This patch was refered from original
> > > > patch of Joao Paula Rechi Vita and was verified with the supported
> > > > bluetooth controller.
> > > >
> > > > Signed-off-by: Sathish Narasimman 
> > > > ---
> > > >  src/modules/bluetooth/backend-ofono.c|  20 +-
> > > >  src/modules/bluetooth/module-bluez5-device.c | 371
> ++-
> > > >  2 files changed, 377 insertions(+), 14 deletions(-)
> > >
> > > Hi! This looks great. What about support also for other backends, not
> > > only ofono?
> >
> > Afaik only oFono supports WBS negotiation.
>
> IIRC codec negotiation is done via AT commands. Therefore native backend
> and its AT parser could be extended to support it.
>

AFAIK i was not able to find Handsfree profile in native backend. I see
only the headset profile in which codec negotiation is not available.
please point me the right place where AT commands are implented in PA for
HFP profile in native backend. i can try the best.

>
> --
> Pali Rohár
> pali.ro...@gmail.com
>
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Sathish Narasimman
Hi Luiz,

On Wed, Aug 15, 2018 at 1:21 AM, Luiz Augusto von Dentz <
luiz.de...@gmail.com> wrote:

> Hi Sathish,
> On Tue, Aug 14, 2018 at 5:15 PM Sathish Narasimman 
> wrote:
> >
> > mSBC-encoded streams for HFP. The wideband speec encoding and decoding
> > is implemeted with this patch. This patch was refered from original
> > patch of Joao Paula Rechi Vita and was verified with the supported
> > bluetooth controller.
> >
> > Signed-off-by: Sathish Narasimman 
> > ---
> >  src/modules/bluetooth/backend-ofono.c|  20 +-
> >  src/modules/bluetooth/module-bluez5-device.c | 371
> ++-
> >  2 files changed, 377 insertions(+), 14 deletions(-)
> >
> > diff --git a/src/modules/bluetooth/backend-ofono.c
> b/src/modules/bluetooth/backend-ofono.c
> > index 1f0efe9..a836779 100644
> > --- a/src/modules/bluetooth/backend-ofono.c
> > +++ b/src/modules/bluetooth/backend-ofono.c
> > @@ -164,7 +164,7 @@ static int card_acquire(struct hf_audio_card *card) {
> >DBUS_TYPE_BYTE, ,
> >DBUS_TYPE_INVALID) == true)) {
> >  dbus_message_unref(r);
> > -if (codec != HFP_AUDIO_CODEC_CVSD) {
> > +if (codec != HFP_AUDIO_CODEC_CVSD && codec !=
> HFP_AUDIO_CODEC_MSBC) {
> >  pa_log_error("Invalid codec: %u", codec);
> >  /* shutdown to make sure connection is dropped immediately
> */
> >  shutdown(fd, SHUT_RDWR);
> > @@ -250,10 +250,17 @@ static int 
> > hf_audio_agent_transport_acquire(pa_bluetooth_transport
> *t, bool opti
> >   * value from the Isoc USB endpoint in use by btusb and should be
> >   * made available to userspace by the Bluetooth kernel subsystem.
> >   * Meanwhile the empiric value 48 will be used. */
> > -if (imtu)
> > -*imtu = 48;
> > -if (omtu)
> > -*omtu = 48;
> > +if (t->codec == HFP_AUDIO_CODEC_MSBC) {
> > +if (imtu)
> > +*imtu = 60;
> > +if (omtu)
> > +*omtu = 60;
> > +} else {
> > +if (imtu)
> > +*imtu = 48;
> > +if (omtu)
> > +*omtu = 48;
> > +   }
> >
> >  err = socket_accept(card->fd);
> >  if (err < 0) {
> > @@ -464,6 +471,7 @@ static void hf_audio_agent_register(pa_bluetooth_backend
> *hf) {
> >  pa_assert_se(m = dbus_message_new_method_call(OFONO_SERVICE, "/",
> HF_AUDIO_MANAGER_INTERFACE, "Register"));
> >
> >  codecs[ncodecs++] = HFP_AUDIO_CODEC_CVSD;
> > +codecs[ncodecs++] = HFP_AUDIO_CODEC_MSBC;
> >
> >  pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH,
> , DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, , ncodecs,
> >DBUS_TYPE_INVALID));
> > @@ -611,7 +619,7 @@ static DBusMessage 
> > *hf_audio_agent_new_connection(DBusConnection
> *c, DBusMessage
> >
> >  card->connecting = false;
> >
> > -if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) {
> > +if (!card || (codec != HFP_AUDIO_CODEC_CVSD && codec !=
> HFP_AUDIO_CODEC_MSBC) || card->fd >= 0) {
> >  pa_log_warn("New audio connection invalid arguments (path=%s
> fd=%d, codec=%d)", path, fd, codec);
> >  pa_assert_se(r = dbus_message_new_error(m, 
> > "org.ofono.Error.InvalidArguments",
> "Invalid arguments in method call"));
> >  shutdown(fd, SHUT_RDWR);
> > diff --git a/src/modules/bluetooth/module-bluez5-device.c
> b/src/modules/bluetooth/module-bluez5-device.c
> > index 9dbdca3..c9b88bd 100644
> > --- a/src/modules/bluetooth/module-bluez5-device.c
> > +++ b/src/modules/bluetooth/module-bluez5-device.c
> > @@ -57,6 +57,9 @@ PA_MODULE_LOAD_ONCE(false);
> >  PA_MODULE_USAGE("path="
> >  "autodetect_mtu=");
> >
> > +#define HFP_AUDIO_CODEC_CVSD0x01
> > +#define HFP_AUDIO_CODEC_MSBC0x02
> > +
> >  #define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
> >  #define FIXED_LATENCY_PLAYBACK_SCO  (25 * PA_USEC_PER_MSEC)
> >  #define FIXED_LATENCY_RECORD_A2DP   (25 * PA_USEC_PER_MSEC)
> > @@ -106,6 +109,27 @@ typedef struct sbc_info {
> >  size_t buffer_size;  /* Size of the buffer */
> >  } sbc_info_t;
> >
> > +struct msbc_parser {
> > +int len;
> > +uint8_t buffer[60];
> > +};
> > +
> > +typedef struct msbc_info {
> > +bool msbc_initialized;   /* Keep track if the encoder
> is initialized */
> > +sbc_t sbcenc;/* Encoder data */
> > +uint8_t *ebuffer;/* Codec transfer buffer */
> > +size_t ebuffer_size; /* Size of the buffer */
> > +size_t ebuffer_start;/* start of encoding data */
> > +size_t ebuffer_end;  /* end of encoding data */
> > +
> > +struct msbc_parser parser;   /* mSBC parser for
> concatenating frames */
> > +sbc_t sbcdec;/* Decoder data */
> > +
> > +size_t msbc_frame_size;
> > +size_t decoded_frame_size;
> > +
> > 

Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Pali Rohár
On Tuesday 14 August 2018 22:49:27 Luiz Augusto von Dentz wrote:
> Hi Pali,
> 
> On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár  wrote:
> >
> > On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> > > mSBC-encoded streams for HFP. The wideband speec encoding and decoding
> > > is implemeted with this patch. This patch was refered from original
> > > patch of Joao Paula Rechi Vita and was verified with the supported
> > > bluetooth controller.
> > >
> > > Signed-off-by: Sathish Narasimman 
> > > ---
> > >  src/modules/bluetooth/backend-ofono.c|  20 +-
> > >  src/modules/bluetooth/module-bluez5-device.c | 371 
> > > ++-
> > >  2 files changed, 377 insertions(+), 14 deletions(-)
> >
> > Hi! This looks great. What about support also for other backends, not
> > only ofono?
> 
> Afaik only oFono supports WBS negotiation.

IIRC codec negotiation is done via AT commands. Therefore native backend
and its AT parser could be extended to support it.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: PGP signature
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Luiz Augusto von Dentz
Hi Sathish,
On Tue, Aug 14, 2018 at 5:15 PM Sathish Narasimman  wrote:
>
> mSBC-encoded streams for HFP. The wideband speec encoding and decoding
> is implemeted with this patch. This patch was refered from original
> patch of Joao Paula Rechi Vita and was verified with the supported
> bluetooth controller.
>
> Signed-off-by: Sathish Narasimman 
> ---
>  src/modules/bluetooth/backend-ofono.c|  20 +-
>  src/modules/bluetooth/module-bluez5-device.c | 371 
> ++-
>  2 files changed, 377 insertions(+), 14 deletions(-)
>
> diff --git a/src/modules/bluetooth/backend-ofono.c 
> b/src/modules/bluetooth/backend-ofono.c
> index 1f0efe9..a836779 100644
> --- a/src/modules/bluetooth/backend-ofono.c
> +++ b/src/modules/bluetooth/backend-ofono.c
> @@ -164,7 +164,7 @@ static int card_acquire(struct hf_audio_card *card) {
>DBUS_TYPE_BYTE, ,
>DBUS_TYPE_INVALID) == true)) {
>  dbus_message_unref(r);
> -if (codec != HFP_AUDIO_CODEC_CVSD) {
> +if (codec != HFP_AUDIO_CODEC_CVSD && codec != HFP_AUDIO_CODEC_MSBC) {
>  pa_log_error("Invalid codec: %u", codec);
>  /* shutdown to make sure connection is dropped immediately */
>  shutdown(fd, SHUT_RDWR);
> @@ -250,10 +250,17 @@ static int 
> hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti
>   * value from the Isoc USB endpoint in use by btusb and should be
>   * made available to userspace by the Bluetooth kernel subsystem.
>   * Meanwhile the empiric value 48 will be used. */
> -if (imtu)
> -*imtu = 48;
> -if (omtu)
> -*omtu = 48;
> +if (t->codec == HFP_AUDIO_CODEC_MSBC) {
> +if (imtu)
> +*imtu = 60;
> +if (omtu)
> +*omtu = 60;
> +} else {
> +if (imtu)
> +*imtu = 48;
> +if (omtu)
> +*omtu = 48;
> +   }
>
>  err = socket_accept(card->fd);
>  if (err < 0) {
> @@ -464,6 +471,7 @@ static void hf_audio_agent_register(pa_bluetooth_backend 
> *hf) {
>  pa_assert_se(m = dbus_message_new_method_call(OFONO_SERVICE, "/", 
> HF_AUDIO_MANAGER_INTERFACE, "Register"));
>
>  codecs[ncodecs++] = HFP_AUDIO_CODEC_CVSD;
> +codecs[ncodecs++] = HFP_AUDIO_CODEC_MSBC;
>
>  pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, , 
> DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, , ncodecs,
>DBUS_TYPE_INVALID));
> @@ -611,7 +619,7 @@ static DBusMessage 
> *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
>
>  card->connecting = false;
>
> -if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) {
> +if (!card || (codec != HFP_AUDIO_CODEC_CVSD && codec != 
> HFP_AUDIO_CODEC_MSBC) || card->fd >= 0) {
>  pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, 
> codec=%d)", path, fd, codec);
>  pa_assert_se(r = dbus_message_new_error(m, 
> "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
>  shutdown(fd, SHUT_RDWR);
> diff --git a/src/modules/bluetooth/module-bluez5-device.c 
> b/src/modules/bluetooth/module-bluez5-device.c
> index 9dbdca3..c9b88bd 100644
> --- a/src/modules/bluetooth/module-bluez5-device.c
> +++ b/src/modules/bluetooth/module-bluez5-device.c
> @@ -57,6 +57,9 @@ PA_MODULE_LOAD_ONCE(false);
>  PA_MODULE_USAGE("path="
>  "autodetect_mtu=");
>
> +#define HFP_AUDIO_CODEC_CVSD0x01
> +#define HFP_AUDIO_CODEC_MSBC0x02
> +
>  #define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
>  #define FIXED_LATENCY_PLAYBACK_SCO  (25 * PA_USEC_PER_MSEC)
>  #define FIXED_LATENCY_RECORD_A2DP   (25 * PA_USEC_PER_MSEC)
> @@ -106,6 +109,27 @@ typedef struct sbc_info {
>  size_t buffer_size;  /* Size of the buffer */
>  } sbc_info_t;
>
> +struct msbc_parser {
> +int len;
> +uint8_t buffer[60];
> +};
> +
> +typedef struct msbc_info {
> +bool msbc_initialized;   /* Keep track if the encoder is 
> initialized */
> +sbc_t sbcenc;/* Encoder data */
> +uint8_t *ebuffer;/* Codec transfer buffer */
> +size_t ebuffer_size; /* Size of the buffer */
> +size_t ebuffer_start;/* start of encoding data */
> +size_t ebuffer_end;  /* end of encoding data */
> +
> +struct msbc_parser parser;   /* mSBC parser for concatenating 
> frames */
> +sbc_t sbcdec;/* Decoder data */
> +
> +size_t msbc_frame_size;
> +size_t decoded_frame_size;
> +
> +} msbc_info_t;

Have you though about putting this into libsbc?

>  struct userdata {
>  pa_module *module;
>  pa_core *core;
> @@ -147,6 +171,7 @@ struct userdata {
>  pa_memchunk write_memchunk;
>  pa_sample_spec sample_spec;
>  struct sbc_info sbc_info;
> +struct msbc_info msbc_info;
> 

Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Luiz Augusto von Dentz
Hi Pali,

On Tue, Aug 14, 2018 at 10:28 PM Pali Rohár  wrote:
>
> On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> > mSBC-encoded streams for HFP. The wideband speec encoding and decoding
> > is implemeted with this patch. This patch was refered from original
> > patch of Joao Paula Rechi Vita and was verified with the supported
> > bluetooth controller.
> >
> > Signed-off-by: Sathish Narasimman 
> > ---
> >  src/modules/bluetooth/backend-ofono.c|  20 +-
> >  src/modules/bluetooth/module-bluez5-device.c | 371 
> > ++-
> >  2 files changed, 377 insertions(+), 14 deletions(-)
>
> Hi! This looks great. What about support also for other backends, not
> only ofono?

Afaik only oFono supports WBS negotiation.
-- 
Luiz Augusto von Dentz
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Pali Rohár
On Tuesday 14 August 2018 19:44:49 Sathish Narasimman wrote:
> mSBC-encoded streams for HFP. The wideband speec encoding and decoding
> is implemeted with this patch. This patch was refered from original
> patch of Joao Paula Rechi Vita and was verified with the supported
> bluetooth controller.
> 
> Signed-off-by: Sathish Narasimman 
> ---
>  src/modules/bluetooth/backend-ofono.c|  20 +-
>  src/modules/bluetooth/module-bluez5-device.c | 371 
> ++-
>  2 files changed, 377 insertions(+), 14 deletions(-)

Hi! This looks great. What about support also for other backends, not
only ofono?

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: PGP signature
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Sathish Narasimman
mSBC-encoded streams for HFP. The wideband speec encoding and decoding
is implemeted with this patch. This patch was refered from original
patch of Joao Paula Rechi Vita and was verified with the supported
bluetooth controller.

Signed-off-by: Sathish Narasimman 
---
 src/modules/bluetooth/backend-ofono.c|  20 +-
 src/modules/bluetooth/module-bluez5-device.c | 371 ++-
 2 files changed, 377 insertions(+), 14 deletions(-)

diff --git a/src/modules/bluetooth/backend-ofono.c 
b/src/modules/bluetooth/backend-ofono.c
index 1f0efe9..a836779 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -164,7 +164,7 @@ static int card_acquire(struct hf_audio_card *card) {
   DBUS_TYPE_BYTE, ,
   DBUS_TYPE_INVALID) == true)) {
 dbus_message_unref(r);
-if (codec != HFP_AUDIO_CODEC_CVSD) {
+if (codec != HFP_AUDIO_CODEC_CVSD && codec != HFP_AUDIO_CODEC_MSBC) {
 pa_log_error("Invalid codec: %u", codec);
 /* shutdown to make sure connection is dropped immediately */
 shutdown(fd, SHUT_RDWR);
@@ -250,10 +250,17 @@ static int 
hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool opti
  * value from the Isoc USB endpoint in use by btusb and should be
  * made available to userspace by the Bluetooth kernel subsystem.
  * Meanwhile the empiric value 48 will be used. */
-if (imtu)
-*imtu = 48;
-if (omtu)
-*omtu = 48;
+if (t->codec == HFP_AUDIO_CODEC_MSBC) {
+if (imtu)
+*imtu = 60;
+if (omtu)
+*omtu = 60;
+} else {
+if (imtu)
+*imtu = 48;
+if (omtu)
+*omtu = 48;
+   }
 
 err = socket_accept(card->fd);
 if (err < 0) {
@@ -464,6 +471,7 @@ static void hf_audio_agent_register(pa_bluetooth_backend 
*hf) {
 pa_assert_se(m = dbus_message_new_method_call(OFONO_SERVICE, "/", 
HF_AUDIO_MANAGER_INTERFACE, "Register"));
 
 codecs[ncodecs++] = HFP_AUDIO_CODEC_CVSD;
+codecs[ncodecs++] = HFP_AUDIO_CODEC_MSBC;
 
 pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, , 
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, , ncodecs,
   DBUS_TYPE_INVALID));
@@ -611,7 +619,7 @@ static DBusMessage 
*hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
 
 card->connecting = false;
 
-if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) {
+if (!card || (codec != HFP_AUDIO_CODEC_CVSD && codec != 
HFP_AUDIO_CODEC_MSBC) || card->fd >= 0) {
 pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, 
codec=%d)", path, fd, codec);
 pa_assert_se(r = dbus_message_new_error(m, 
"org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
 shutdown(fd, SHUT_RDWR);
diff --git a/src/modules/bluetooth/module-bluez5-device.c 
b/src/modules/bluetooth/module-bluez5-device.c
index 9dbdca3..c9b88bd 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -57,6 +57,9 @@ PA_MODULE_LOAD_ONCE(false);
 PA_MODULE_USAGE("path="
 "autodetect_mtu=");
 
+#define HFP_AUDIO_CODEC_CVSD0x01
+#define HFP_AUDIO_CODEC_MSBC0x02
+
 #define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
 #define FIXED_LATENCY_PLAYBACK_SCO  (25 * PA_USEC_PER_MSEC)
 #define FIXED_LATENCY_RECORD_A2DP   (25 * PA_USEC_PER_MSEC)
@@ -106,6 +109,27 @@ typedef struct sbc_info {
 size_t buffer_size;  /* Size of the buffer */
 } sbc_info_t;
 
+struct msbc_parser {
+int len;
+uint8_t buffer[60];
+};
+
+typedef struct msbc_info {
+bool msbc_initialized;   /* Keep track if the encoder is 
initialized */
+sbc_t sbcenc;/* Encoder data */
+uint8_t *ebuffer;/* Codec transfer buffer */
+size_t ebuffer_size; /* Size of the buffer */
+size_t ebuffer_start;/* start of encoding data */
+size_t ebuffer_end;  /* end of encoding data */
+
+struct msbc_parser parser;   /* mSBC parser for concatenating 
frames */
+sbc_t sbcdec;/* Decoder data */
+
+size_t msbc_frame_size;
+size_t decoded_frame_size;
+
+} msbc_info_t;
+
 struct userdata {
 pa_module *module;
 pa_core *core;
@@ -147,6 +171,7 @@ struct userdata {
 pa_memchunk write_memchunk;
 pa_sample_spec sample_spec;
 struct sbc_info sbc_info;
+struct msbc_info msbc_info;
 };
 
 typedef enum pa_bluetooth_form_factor {
@@ -251,6 +276,215 @@ static void connect_ports(struct userdata *u, void 
*new_data, pa_direction_t dir
 }
 
 /* Run from IO thread */
+static void msbc_parser_reset(struct msbc_parser *p) {
+p->len = 0;
+}
+
+/* Run from IO thread */
+static int msbc_state_machine(struct msbc_parser *p, uint8_t 

[pulseaudio-discuss] [PATCH] bluetooth: Wideband speech implementaion

2018-08-14 Thread Sathish Narasimman
mSBC-encoded streams for HFP. The wideband speec encoding and decoding
is implemeted with this patch. This patch was refered from original
patch of Joao Paula Rechi Vita and was verified with the supported
bluetooth controller.

Sathish Narasimman (1):
  bluetooth: Wideband speech implementaion

 src/modules/bluetooth/backend-ofono.c|  20 +-
 src/modules/bluetooth/module-bluez5-device.c | 371 ++-
 2 files changed, 377 insertions(+), 14 deletions(-)

-- 
2.7.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss