bluetooth_tws_observer.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2018 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file bluetooth tws observer interface
  8. */
  9. #ifndef __BLUETOOTH_TWS_OBSERVER_H__
  10. #define __BLUETOOTH_TWS_OBSERVER_H__
  11. #include <btservice_api.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. typedef struct {
  16. uint16_t pkt_num; /* 包号 */
  17. uint16_t pkt_len; /* 包的数据长度 */
  18. uint16_t samples; /* 当前帧pcm样点数 */
  19. uint64_t pkt_bttime_us; /* 蓝牙时钟 us */
  20. } __attribute__((packed)) tws_pkt_info_t;
  21. typedef int32_t (*media_set_start_pkt_num)(void *handle, uint16_t pkt_num);
  22. typedef int32_t (*media_start_playback)(void *handle);
  23. //level==0xFF: set default aps level
  24. typedef int32_t (*media_set_base_aps_level)(void *handle, uint8_t level);
  25. typedef int32_t (*media_notify_time_diff)(void *handle, int32_t diff_time);
  26. typedef struct {
  27. void *media_handle;
  28. void *tws_observer;
  29. media_set_start_pkt_num set_start_pkt_num;
  30. media_start_playback start_playback;
  31. media_set_base_aps_level set_base_aps_level;
  32. media_notify_time_diff notify_time_diff;
  33. } media_observer_t;
  34. typedef uint64_t (*bt_tws_get_bt_clk_us)(void);
  35. typedef uint8_t (*bt_tws_get_role)(void);
  36. typedef int32_t (*bt_tws_set_stream_info)(uint8_t format, uint16_t first_pktnum, uint16_t sample_rate);
  37. typedef int32_t (*bt_tws_aps_change_request)(uint8_t level);
  38. typedef int32_t (*bt_tws_set_pkt_info)(tws_pkt_info_t *info);
  39. typedef struct {
  40. bt_tws_get_bt_clk_us get_bt_clk_us;
  41. bt_tws_get_role get_role;
  42. bt_tws_set_stream_info set_stream_info;
  43. bt_tws_aps_change_request aps_change_request;
  44. bt_tws_set_pkt_info set_pkt_info;
  45. } bt_tws_observer_t;
  46. bt_tws_observer_t* bluetooth_tws_observer_init(media_observer_t *media_observer);
  47. void bluetooth_tws_observer_deinit(bt_tws_observer_t *tws_observer);
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif //END OF __BLUETOOTH_TWS_OBSERVER_H__