From 1332cc7d0a618ee88b4d19813340665332d406ca Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Mon, 28 Feb 2022 13:04:45 -0500 Subject: Add Bluetooth media control support Rework to expose Bluetooth AVRCP media control in the Bluetooth class, and use that support to implement a Bluetooth backend in the Mediaplayer class. This replaces the scheme that existed with the agl-service-mediaplayer binding where it abstracted away the Bluetooth support itself. However, care has been take to make sure that the exposed API to users of libqtappfw-mediaplayer has not changed. Bug-AGL: SPEC-4231 Signed-off-by: Scott Murray Change-Id: I76b4f75621ce0121364eea3259b074bf3067ee88 --- bluetooth/bluetootheventhandler.h | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'bluetooth/bluetootheventhandler.h') diff --git a/bluetooth/bluetootheventhandler.h b/bluetooth/bluetootheventhandler.h index ff970f5..c4dd67a 100644 --- a/bluetooth/bluetootheventhandler.h +++ b/bluetooth/bluetootheventhandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Konsulko Group + * Copyright (C) 2021,2022 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ class Bluetooth; class BluetoothEventHandler { public: - explicit BluetoothEventHandler(Bluetooth *parent, bool register_agent); + explicit BluetoothEventHandler(Bluetooth *parent, bool register_agent, bool handle_media = false); virtual ~BluetoothEventHandler(); static void init_cb(gchar *adapter, gboolean status, gpointer user_data) { @@ -40,6 +40,10 @@ class BluetoothEventHandler ((BluetoothEventHandler*) user_data)->handle_pair_event(device, status); } + // Helper function callable by parent (instead of vice versa), since Bluetooth + // object should not expose glib types. + void parse_media_player_properties(GVariant *properties, QVariantMap &metadata); + private: Bluetooth *m_parent; bool m_agent; @@ -59,11 +63,46 @@ class BluetoothEventHandler if (user_data) ((BluetoothEventHandler*) user_data)->handle_agent_event(device, event, properties); } + + static void media_control_event_cb(gchar *adapter, + gchar *device, + bluez_event_t event, + GVariant *properties, + gpointer user_data) { + if (user_data) + ((BluetoothEventHandler*) user_data)->handle_media_control_event(adapter, + device, + event, + properties); + } + + static void media_player_event_cb(gchar *adapter, + gchar *device, + gchar *player, + bluez_event_t event, + GVariant *properties, + gpointer user_data) { + if (user_data) + ((BluetoothEventHandler*) user_data)->handle_media_player_event(adapter, + device, + player, + event, + properties); + } void handle_init_event(gchar *adapter, gboolean status); void handle_adapter_event(gchar *adapter, bluez_event_t event, GVariant *properties); void handle_device_event(gchar *adapter, gchar *device, bluez_event_t event, GVariant *properties); void handle_agent_event(gchar *device, bluez_agent_event_t event, GVariant *properties); + void handle_media_control_event(gchar *adapter, + gchar *device, + bluez_event_t event, + GVariant *properties); + void handle_media_player_event(gchar *adapter, + gchar *device, + gchar *player, + bluez_event_t event, + GVariant *properties); void handle_connect_event(gchar *device, gboolean status); void handle_pair_event(gchar *device, gboolean status); }; -- cgit 1.2.3-korg