* HandsfreeAudioCard registration for HFP AG plugin
@ 2015-10-06 10:48 Simon Fels
2015-10-06 10:48 ` [PATCH 1/3] include: Add ofono_emulator_set_handsfree_card Simon Fels
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Simon Fels @ 2015-10-06 10:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 505 bytes --]
Hey everybody,
after some more detailed discussion with Denis yesterday on IRC I've
reworked the previously sent patches a bit and included two patches
Denis worked on before but never submitted yet. With this the audio
card is only registered if we have a service level connection
successfully established.
What is missing currently is codec negotiation between AG and HF but
I already started to implement this and will send further patches
with support for this soon.
regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] include: Add ofono_emulator_set_handsfree_card
2015-10-06 10:48 HandsfreeAudioCard registration for HFP AG plugin Simon Fels
@ 2015-10-06 10:48 ` Simon Fels
2015-10-06 10:48 ` [PATCH 2/3] emulator: " Simon Fels
2015-10-06 10:48 ` [PATCH 3/3] hfp_ag_bluez5: register audio card Simon Fels
2 siblings, 0 replies; 6+ messages in thread
From: Simon Fels @ 2015-10-06 10:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 745 bytes --]
From: Denis Kenzior <denkenz@gmail.com>
---
include/emulator.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/emulator.h b/include/emulator.h
index 5e8d431..15dc61c 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -50,6 +50,7 @@ extern "C" {
struct ofono_emulator;
struct ofono_emulator_request;
+struct ofono_handsfree_card;
enum ofono_emulator_type {
OFONO_EMULATOR_TYPE_DUN,
@@ -108,6 +109,9 @@ void ofono_emulator_set_hf_indicator_active(struct ofono_emulator *em,
int indicator,
ofono_bool_t active);
+void ofono_emulator_set_handsfree_card(struct ofono_emulator *em,
+ struct ofono_handsfree_card *card);
+
#ifdef __cplusplus
}
#endif
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] emulator: Add ofono_emulator_set_handsfree_card
2015-10-06 10:48 HandsfreeAudioCard registration for HFP AG plugin Simon Fels
2015-10-06 10:48 ` [PATCH 1/3] include: Add ofono_emulator_set_handsfree_card Simon Fels
@ 2015-10-06 10:48 ` Simon Fels
2015-10-06 10:48 ` [PATCH 3/3] hfp_ag_bluez5: register audio card Simon Fels
2 siblings, 0 replies; 6+ messages in thread
From: Simon Fels @ 2015-10-06 10:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]
From: Denis Kenzior <denkenz@gmail.com>
---
src/emulator.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/emulator.c b/src/emulator.c
index 1c43e21..5be7b63 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -48,6 +48,7 @@ struct ofono_emulator {
GSList *indicators;
guint callsetup_source;
int pns_id;
+ struct ofono_handsfree_card *card;
bool slc : 1;
unsigned int events_mode : 2;
bool events_ind : 1;
@@ -990,6 +991,9 @@ static void emulator_unregister(struct ofono_atom *atom)
g_at_server_unref(em->server);
em->server = NULL;
+
+ ofono_handsfree_card_remove(em->card);
+ em->card = NULL;
}
void ofono_emulator_register(struct ofono_emulator *em, int fd)
@@ -1435,6 +1439,8 @@ void __ofono_emulator_slc_condition(struct ofono_emulator *em,
ofono_info("SLC reached");
em->slc = TRUE;
+ ofono_handsfree_card_register(em->card);
+
default:
break;
}
@@ -1460,3 +1466,12 @@ void ofono_emulator_set_hf_indicator_active(struct ofono_emulator *em,
sprintf(buf, "+BIND: %d,%d", HFP_HF_INDICATOR_ENHANCED_SAFETY, active);
g_at_server_send_unsolicited(em->server, buf);
}
+
+void ofono_emulator_set_handsfree_card(struct ofono_emulator *em,
+ struct ofono_handsfree_card *card)
+{
+ if (em == NULL)
+ return;
+
+ em->card = card;
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] hfp_ag_bluez5: register audio card
2015-10-06 10:48 HandsfreeAudioCard registration for HFP AG plugin Simon Fels
2015-10-06 10:48 ` [PATCH 1/3] include: Add ofono_emulator_set_handsfree_card Simon Fels
2015-10-06 10:48 ` [PATCH 2/3] emulator: " Simon Fels
@ 2015-10-06 10:48 ` Simon Fels
2015-10-06 14:07 ` Denis Kenzior
2 siblings, 1 reply; 6+ messages in thread
From: Simon Fels @ 2015-10-06 10:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3702 bytes --]
To let others (PulseAudio) be notified when a handsfree device is
connected with us and can be used for audio routing we need to
expose this by registering a audio card with the correct type.
---
plugins/hfp_ag_bluez5.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
src/emulator.c | 1 +
2 files changed, 50 insertions(+)
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 93de302..ef8a048 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -22,6 +22,7 @@
#include <config.h>
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@@ -35,15 +36,18 @@
#include <ofono/plugin.h>
#include <ofono/log.h>
#include <ofono/modem.h>
+#include <ofono/handsfree-audio.h>
#include "hfp.h"
#include "bluez5.h"
+#include "bluetooth.h"
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
#define HFP_AG_EXT_PROFILE_PATH "/bluetooth/profile/hfp_ag"
+#define BT_ADDR_SIZE 18
static guint modemwatch_id;
static GList *modems;
@@ -77,8 +81,13 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
const char *device;
GIOChannel *io;
int fd, fd_dup;
+ struct sockaddr_rc saddr;
+ socklen_t optlen;
struct ofono_emulator *em;
struct ofono_modem *modem;
+ char local[BT_ADDR_SIZE], remote[BT_ADDR_SIZE];
+ struct ofono_handsfree_card *card;
+ int err;
DBG("Profile handler NewConnection");
@@ -111,8 +120,35 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
}
modem = modems->data;
+
DBG("Picked modem %p for emulator", modem);
+ memset(&saddr, 0, sizeof(saddr));
+ optlen = sizeof(saddr);
+
+ if (getsockname(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+ err = errno;
+ ofono_error("RFCOMM getsockname(): %s (%d)", strerror(err),
+ err);
+ close(fd);
+ goto invalid;
+ }
+
+ bt_ba2str(&saddr.rc_bdaddr, local);
+
+ memset(&saddr, 0, sizeof(saddr));
+ optlen = sizeof(saddr);
+
+ if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+ err = errno;
+ ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
+ err);
+ close(fd);
+ goto invalid;
+ }
+
+ bt_ba2str(&saddr.rc_bdaddr, remote);
+
em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
if (em == NULL) {
close(fd);
@@ -129,6 +165,15 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
g_strdup(device), g_free);
g_io_channel_unref(io);
+ card = ofono_handsfree_card_create(0,
+ OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
+ NULL, NULL);
+
+ ofono_handsfree_card_set_local(card, local);
+ ofono_handsfree_card_set_remote(card, remote);
+
+ ofono_emulator_set_handsfree_card(em, card);
+
g_hash_table_insert(connection_hash, g_strdup(device),
GINT_TO_POINTER(fd_dup));
@@ -346,6 +391,8 @@ static int hfp_ag_init(void)
connection_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, connection_destroy);
+ ofono_handsfree_audio_ref();
+
return 0;
}
@@ -362,6 +409,8 @@ static void hfp_ag_exit(void)
g_list_free(modems);
g_hash_table_foreach_remove(sim_hash, sim_watch_remove, NULL);
g_hash_table_destroy(sim_hash);
+
+ ofono_handsfree_audio_unref();
}
OFONO_PLUGIN_DEFINE(hfp_ag_bluez5, "Hands-Free Audio Gateway Profile Plugins",
diff --git a/src/emulator.c b/src/emulator.c
index 5be7b63..626dec3 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -35,6 +35,7 @@
#include "hfp.h"
#include "gatserver.h"
#include "gatppp.h"
+#include "handsfree-audio.h"
#define RING_TIMEOUT 3
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] hfp_ag_bluez5: register audio card
2015-10-06 10:48 ` [PATCH 3/3] hfp_ag_bluez5: register audio card Simon Fels
@ 2015-10-06 14:07 ` Denis Kenzior
2015-10-06 14:34 ` Simon Fels
0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2015-10-06 14:07 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
Hi Simon,
On 10/06/2015 05:48 AM, Simon Fels wrote:
> To let others (PulseAudio) be notified when a handsfree device is
> connected with us and can be used for audio routing we need to
> expose this by registering a audio card with the correct type.
> ---
> plugins/hfp_ag_bluez5.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> src/emulator.c | 1 +
> 2 files changed, 50 insertions(+)
>
<snip>
> diff --git a/src/emulator.c b/src/emulator.c
> index 5be7b63..626dec3 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -35,6 +35,7 @@
> #include "hfp.h"
> #include "gatserver.h"
> #include "gatppp.h"
> +#include "handsfree-audio.h"
I squished this part into patch #2 and applied all three. Thanks!
Regards,
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] hfp_ag_bluez5: register audio card
2015-10-06 14:07 ` Denis Kenzior
@ 2015-10-06 14:34 ` Simon Fels
0 siblings, 0 replies; 6+ messages in thread
From: Simon Fels @ 2015-10-06 14:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
On 06.10.2015 16:07, Denis Kenzior wrote:
> Hi Simon,
>
> On 10/06/2015 05:48 AM, Simon Fels wrote:
>> To let others (PulseAudio) be notified when a handsfree device is
>> connected with us and can be used for audio routing we need to
>> expose this by registering a audio card with the correct type.
>> ---
>> plugins/hfp_ag_bluez5.c | 49
>> +++++++++++++++++++++++++++++++++++++++++++++++++
>> src/emulator.c | 1 +
>> 2 files changed, 50 insertions(+)
>>
>
> <snip>
>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index 5be7b63..626dec3 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -35,6 +35,7 @@
>> #include "hfp.h"
>> #include "gatserver.h"
>> #include "gatppp.h"
>> +#include "handsfree-audio.h"
>
> I squished this part into patch #2 and applied all three. Thanks!
Thanks a lot!
regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-06 14:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 10:48 HandsfreeAudioCard registration for HFP AG plugin Simon Fels
2015-10-06 10:48 ` [PATCH 1/3] include: Add ofono_emulator_set_handsfree_card Simon Fels
2015-10-06 10:48 ` [PATCH 2/3] emulator: " Simon Fels
2015-10-06 10:48 ` [PATCH 3/3] hfp_ag_bluez5: register audio card Simon Fels
2015-10-06 14:07 ` Denis Kenzior
2015-10-06 14:34 ` Simon Fels
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.