bt_av.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: Apache-2.0 */
  2. /*
  3. * Copyright (C) 2012 The Android Open Source Project
  4. *
  5. */
  6. #ifndef ANDROID_INCLUDE_BT_AV_H
  7. #define ANDROID_INCLUDE_BT_AV_H
  8. __BEGIN_DECLS
  9. /* Bluetooth AV connection states */
  10. typedef enum {
  11. BTAV_CONNECTION_STATE_DISCONNECTED = 0,
  12. BTAV_CONNECTION_STATE_CONNECTING,
  13. BTAV_CONNECTION_STATE_CONNECTED,
  14. BTAV_CONNECTION_STATE_DISCONNECTING
  15. } btav_connection_state_t;
  16. /* Bluetooth AV datapath states */
  17. typedef enum {
  18. BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
  19. BTAV_AUDIO_STATE_STOPPED,
  20. BTAV_AUDIO_STATE_STARTED,
  21. } btav_audio_state_t;
  22. /** Callback for connection state change.
  23. * state will have one of the values from btav_connection_state_t
  24. */
  25. typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
  26. bt_bdaddr_t *bd_addr);
  27. /** Callback for audiopath state change.
  28. * state will have one of the values from btav_audio_state_t
  29. */
  30. typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
  31. bt_bdaddr_t *bd_addr);
  32. /** Callback for audio configuration change.
  33. * Used only for the A2DP sink interface.
  34. * state will have one of the values from btav_audio_state_t
  35. * sample_rate: sample rate in Hz
  36. * channel_count: number of channels (1 for mono, 2 for stereo)
  37. */
  38. typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
  39. uint32_t sample_rate,
  40. uint8_t channel_count);
  41. /** BT-AV callback structure. */
  42. typedef struct {
  43. /** set to sizeof(btav_callbacks_t) */
  44. size_t size;
  45. btav_connection_state_callback connection_state_cb;
  46. btav_audio_state_callback audio_state_cb;
  47. btav_audio_config_callback audio_config_cb;
  48. } btav_callbacks_t;
  49. /**
  50. * NOTE:
  51. *
  52. * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
  53. * shall be handled internally via uinput
  54. *
  55. * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
  56. * android_audio_hw library and the Bluetooth stack.
  57. *
  58. */
  59. /** Represents the standard BT-AV interface.
  60. * Used for both the A2DP source and sink interfaces.
  61. */
  62. typedef struct {
  63. /** set to sizeof(btav_interface_t) */
  64. size_t size;
  65. /**
  66. * Register the BtAv callbacks
  67. */
  68. bt_status_t (*init)( btav_callbacks_t* callbacks );
  69. /** connect to headset */
  70. bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
  71. /** dis-connect from headset */
  72. bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
  73. /** Closes the interface. */
  74. void (*cleanup)( void );
  75. } btav_interface_t;
  76. __END_DECLS
  77. #endif /* ANDROID_INCLUDE_BT_AV_H */