Loading system/gd/rust/linux/service/src/iface_bluetooth_media.rs +2 −2 Original line number Original line Diff line number Diff line Loading @@ -125,7 +125,7 @@ impl DBusArg for PlayerMetadata { )? )? } } "length" => { "length" => { metadata.length = i64::ref_arg_to_rust( metadata.length_us = i64::ref_arg_to_rust( variant.as_static_inner(0).unwrap(), variant.as_static_inner(0).unwrap(), String::from("PlayerMetadata::Length"), String::from("PlayerMetadata::Length"), )? )? Loading Loading @@ -244,7 +244,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus { } } #[dbus_method("SetPlayerPosition")] #[dbus_method("SetPlayerPosition")] fn set_player_posistion(&mut self, position: i64) { fn set_player_position(&mut self, position_us: i64) { dbus_generated!() dbus_generated!() } } Loading system/gd/rust/linux/stack/src/bluetooth_media.rs +23 −5 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,7 @@ use bt_topshim::profiles::hfp::{ use bt_topshim::{metrics, topstack}; use bt_topshim::{metrics, topstack}; use bt_utils::uinput::UInput; use bt_utils::uinput::UInput; use log::{info, warn}; use log::{debug, info, warn}; use num_traits::cast::ToPrimitive; use num_traits::cast::ToPrimitive; use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::convert::TryFrom; Loading Loading @@ -94,7 +94,7 @@ pub trait IBluetoothMedia { fn set_player_playback_status(&mut self, status: String); fn set_player_playback_status(&mut self, status: String); /// Set the position of the current media in microseconds. The method is a copy of the existing /// Set the position of the current media in microseconds. The method is a copy of the existing /// CRAS API, hence not following Floss API conventions. /// CRAS API, hence not following Floss API conventions. fn set_player_posistion(&mut self, position: i64); fn set_player_position(&mut self, position: i64); /// Set the media metadata, including title, artist, album, and length. The method is a /// Set the media metadata, including title, artist, album, and length. The method is a /// copy of the existing CRAS API, hence not following Floss API conventions. PlayerMetadata is /// copy of the existing CRAS API, hence not following Floss API conventions. PlayerMetadata is /// a custom data type that requires special handlng. /// a custom data type that requires special handlng. Loading Loading @@ -1315,7 +1315,25 @@ impl IBluetoothMedia for BluetoothMedia { } } } } fn set_player_playback_status(&mut self, _status: String) {} fn set_player_playback_status(&mut self, status: String) { fn set_player_posistion(&mut self, _position: i64) {} debug!("AVRCP received player playback status: {}", status); fn set_player_metadata(&mut self, _metadata: PlayerMetadata) {} match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_playback_status(&status), None => warn!("Uninitialized AVRCP to set player playback status"), }; } fn set_player_position(&mut self, position_us: i64) { debug!("AVRCP received player position: {}", position_us); match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_position(position_us), None => warn!("Uninitialized AVRCP to set player position"), }; } fn set_player_metadata(&mut self, metadata: PlayerMetadata) { debug!("AVRCP received player metadata: {:?}", metadata); match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_metadata(&metadata), None => warn!("Uninitialized AVRCP to set player playback status"), }; } } } system/gd/rust/topshim/btav/btav_shim.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace rust { struct A2dpCodecConfig; struct A2dpCodecConfig; struct RustPresentationPosition; struct RustPresentationPosition; struct RustRawAddress; struct RustRawAddress; struct RustPlayStatus; class A2dpIntf { class A2dpIntf { public: public: Loading Loading @@ -71,6 +72,11 @@ class AvrcpIntf { // interface for Audio server // interface for Audio server void set_volume(int8_t volume); void set_volume(int8_t volume); void set_playback_status(const ::rust::String& status) {} void set_position(int64_t position_us) {} void set_metadata( const ::rust::String& title, const ::rust::String& artist, const ::rust::String& album, int64_t length_us) {} private: private: bluetooth::avrcp::ServiceInterface* intf_; bluetooth::avrcp::ServiceInterface* intf_; }; }; Loading system/gd/rust/topshim/src/profiles/avrcp.rs +30 −1 Original line number Original line Diff line number Diff line Loading @@ -11,7 +11,7 @@ pub struct PlayerMetadata { pub title: String, pub title: String, pub artist: String, pub artist: String, pub album: String, pub album: String, pub length: i64, pub length_us: i64, } } #[cxx::bridge(namespace = bluetooth::topshim::rust)] #[cxx::bridge(namespace = bluetooth::topshim::rust)] Loading @@ -33,6 +33,15 @@ pub mod ffi { fn connect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn connect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn disconnect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn disconnect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn set_volume(self: Pin<&mut AvrcpIntf>, volume: i8); fn set_volume(self: Pin<&mut AvrcpIntf>, volume: i8); fn set_playback_status(self: Pin<&mut AvrcpIntf>, status: &String); fn set_position(self: Pin<&mut AvrcpIntf>, position_us: i64); fn set_metadata( self: Pin<&mut AvrcpIntf>, title: &String, artist: &String, album: &String, length_us: i64, ); } } extern "Rust" { extern "Rust" { Loading Loading @@ -184,4 +193,24 @@ impl Avrcp { self.internal.pin_mut().cleanup(); self.internal.pin_mut().cleanup(); true true } } #[profile_enabled_or] pub fn set_playback_status(&mut self, status: &String) { self.internal.pin_mut().set_playback_status(status); } #[profile_enabled_or] pub fn set_position(&mut self, position_us: i64) { self.internal.pin_mut().set_position(position_us); } #[profile_enabled_or] pub fn set_metadata(&mut self, metadata: &PlayerMetadata) { self.internal.pin_mut().set_metadata( &metadata.title, &metadata.artist, &metadata.album, metadata.length_us, ); } } } Loading
system/gd/rust/linux/service/src/iface_bluetooth_media.rs +2 −2 Original line number Original line Diff line number Diff line Loading @@ -125,7 +125,7 @@ impl DBusArg for PlayerMetadata { )? )? } } "length" => { "length" => { metadata.length = i64::ref_arg_to_rust( metadata.length_us = i64::ref_arg_to_rust( variant.as_static_inner(0).unwrap(), variant.as_static_inner(0).unwrap(), String::from("PlayerMetadata::Length"), String::from("PlayerMetadata::Length"), )? )? Loading Loading @@ -244,7 +244,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus { } } #[dbus_method("SetPlayerPosition")] #[dbus_method("SetPlayerPosition")] fn set_player_posistion(&mut self, position: i64) { fn set_player_position(&mut self, position_us: i64) { dbus_generated!() dbus_generated!() } } Loading
system/gd/rust/linux/stack/src/bluetooth_media.rs +23 −5 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,7 @@ use bt_topshim::profiles::hfp::{ use bt_topshim::{metrics, topstack}; use bt_topshim::{metrics, topstack}; use bt_utils::uinput::UInput; use bt_utils::uinput::UInput; use log::{info, warn}; use log::{debug, info, warn}; use num_traits::cast::ToPrimitive; use num_traits::cast::ToPrimitive; use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::convert::TryFrom; Loading Loading @@ -94,7 +94,7 @@ pub trait IBluetoothMedia { fn set_player_playback_status(&mut self, status: String); fn set_player_playback_status(&mut self, status: String); /// Set the position of the current media in microseconds. The method is a copy of the existing /// Set the position of the current media in microseconds. The method is a copy of the existing /// CRAS API, hence not following Floss API conventions. /// CRAS API, hence not following Floss API conventions. fn set_player_posistion(&mut self, position: i64); fn set_player_position(&mut self, position: i64); /// Set the media metadata, including title, artist, album, and length. The method is a /// Set the media metadata, including title, artist, album, and length. The method is a /// copy of the existing CRAS API, hence not following Floss API conventions. PlayerMetadata is /// copy of the existing CRAS API, hence not following Floss API conventions. PlayerMetadata is /// a custom data type that requires special handlng. /// a custom data type that requires special handlng. Loading Loading @@ -1315,7 +1315,25 @@ impl IBluetoothMedia for BluetoothMedia { } } } } fn set_player_playback_status(&mut self, _status: String) {} fn set_player_playback_status(&mut self, status: String) { fn set_player_posistion(&mut self, _position: i64) {} debug!("AVRCP received player playback status: {}", status); fn set_player_metadata(&mut self, _metadata: PlayerMetadata) {} match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_playback_status(&status), None => warn!("Uninitialized AVRCP to set player playback status"), }; } fn set_player_position(&mut self, position_us: i64) { debug!("AVRCP received player position: {}", position_us); match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_position(position_us), None => warn!("Uninitialized AVRCP to set player position"), }; } fn set_player_metadata(&mut self, metadata: PlayerMetadata) { debug!("AVRCP received player metadata: {:?}", metadata); match self.avrcp.as_mut() { Some(avrcp) => avrcp.set_metadata(&metadata), None => warn!("Uninitialized AVRCP to set player playback status"), }; } } }
system/gd/rust/topshim/btav/btav_shim.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace rust { struct A2dpCodecConfig; struct A2dpCodecConfig; struct RustPresentationPosition; struct RustPresentationPosition; struct RustRawAddress; struct RustRawAddress; struct RustPlayStatus; class A2dpIntf { class A2dpIntf { public: public: Loading Loading @@ -71,6 +72,11 @@ class AvrcpIntf { // interface for Audio server // interface for Audio server void set_volume(int8_t volume); void set_volume(int8_t volume); void set_playback_status(const ::rust::String& status) {} void set_position(int64_t position_us) {} void set_metadata( const ::rust::String& title, const ::rust::String& artist, const ::rust::String& album, int64_t length_us) {} private: private: bluetooth::avrcp::ServiceInterface* intf_; bluetooth::avrcp::ServiceInterface* intf_; }; }; Loading
system/gd/rust/topshim/src/profiles/avrcp.rs +30 −1 Original line number Original line Diff line number Diff line Loading @@ -11,7 +11,7 @@ pub struct PlayerMetadata { pub title: String, pub title: String, pub artist: String, pub artist: String, pub album: String, pub album: String, pub length: i64, pub length_us: i64, } } #[cxx::bridge(namespace = bluetooth::topshim::rust)] #[cxx::bridge(namespace = bluetooth::topshim::rust)] Loading @@ -33,6 +33,15 @@ pub mod ffi { fn connect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn connect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn disconnect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn disconnect(self: Pin<&mut AvrcpIntf>, bt_addr: RustRawAddress) -> u32; fn set_volume(self: Pin<&mut AvrcpIntf>, volume: i8); fn set_volume(self: Pin<&mut AvrcpIntf>, volume: i8); fn set_playback_status(self: Pin<&mut AvrcpIntf>, status: &String); fn set_position(self: Pin<&mut AvrcpIntf>, position_us: i64); fn set_metadata( self: Pin<&mut AvrcpIntf>, title: &String, artist: &String, album: &String, length_us: i64, ); } } extern "Rust" { extern "Rust" { Loading Loading @@ -184,4 +193,24 @@ impl Avrcp { self.internal.pin_mut().cleanup(); self.internal.pin_mut().cleanup(); true true } } #[profile_enabled_or] pub fn set_playback_status(&mut self, status: &String) { self.internal.pin_mut().set_playback_status(status); } #[profile_enabled_or] pub fn set_position(&mut self, position_us: i64) { self.internal.pin_mut().set_position(position_us); } #[profile_enabled_or] pub fn set_metadata(&mut self, metadata: &PlayerMetadata) { self.internal.pin_mut().set_metadata( &metadata.title, &metadata.artist, &metadata.album, metadata.length_us, ); } } }