• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2016 The Android Open Source Project
4  *  Copyright 2009-2012 Broadcom Corporation
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at:
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  ******************************************************************************/
19 
20 #ifndef BTIF_A2DP_SOURCE_H
21 #define BTIF_A2DP_SOURCE_H
22 
23 #include <stdbool.h>
24 
25 #include "bta_av_api.h"
26 
27 // Initialize the A2DP Source module.
28 // This function should be called by the BTIF state machine prior to using the
29 // module.
30 bool btif_a2dp_source_init(void);
31 
32 // Startup the A2DP Source module.
33 // This function should be called by the BTIF state machine after
34 // btif_a2dp_source_init() to prepare to start streaming.
35 bool btif_a2dp_source_startup(void);
36 
37 // Start the A2DP Source session.
38 // This function should be called by the BTIF state machine after
39 // btif_a2dp_source_startup() to start the streaming session for |peer_address|.
40 bool btif_a2dp_source_start_session(const RawAddress& peer_address);
41 
42 // Restart the A2DP Source session.
43 // This function should be called by the BTIF state machine after
44 // btif_a2dp_source_startup() to restart the streaming session.
45 // |old_peer_address| is the peer address of the old session. This address
46 // can be empty.
47 // |new_peer_address| is the peer address of the new session. This address
48 // cannot be empty.
49 bool btif_a2dp_source_restart_session(const RawAddress& old_peer_address,
50                                       const RawAddress& new_peer_address);
51 
52 // End the A2DP Source session.
53 // This function should be called by the BTIF state machine to end the
54 // streaming session for |peer_address|.
55 bool btif_a2dp_source_end_session(const RawAddress& peer_address);
56 
57 // Shutdown the A2DP Source module.
58 // This function should be called by the BTIF state machine to stop streaming.
59 void btif_a2dp_source_shutdown(void);
60 
61 // Cleanup the A2DP Source module.
62 // This function should be called by the BTIF state machine during graceful
63 // cleanup.
64 void btif_a2dp_source_cleanup(void);
65 
66 // Check whether the A2DP Source media task is running.
67 // Returns true if the A2DP Source media task is running, otherwise false.
68 bool btif_a2dp_source_media_task_is_running(void);
69 
70 // Check whether the A2DP Source media task is shutting down.
71 // Returns true if the A2DP Source media task is shutting down.
72 bool btif_a2dp_source_media_task_is_shutting_down(void);
73 
74 // Return true if the A2DP Source module is streaming.
75 bool btif_a2dp_source_is_streaming(void);
76 
77 // Process a request to start the A2DP audio encoding task.
78 void btif_a2dp_source_start_audio_req(void);
79 
80 // Process a request to stop the A2DP audio encoding task.
81 void btif_a2dp_source_stop_audio_req(void);
82 
83 // Process a request to update the A2DP audio encoder with user preferred
84 // codec configuration.
85 // The peer address is |peer_addr|.
86 // |codec_user_config| contains the preferred codec user configuration.
87 void btif_a2dp_source_encoder_user_config_update_req(
88     const RawAddress& peer_addr,
89     const btav_a2dp_codec_config_t& codec_user_config);
90 
91 // Process a request to update the A2DP audio encoding with new audio
92 // configuration feeding parameters stored in |codec_audio_config|.
93 // The fields that are used are: |codec_audio_config.sample_rate|,
94 // |codec_audio_config.bits_per_sample| and |codec_audio_config.channel_mode|.
95 void btif_a2dp_source_feeding_update_req(
96     const btav_a2dp_codec_config_t& codec_audio_config);
97 
98 // Process 'idle' request from the BTIF state machine during initialization.
99 void btif_a2dp_source_on_idle(void);
100 
101 // Process 'stop' request from the BTIF state machine to stop A2DP streaming.
102 // |p_av_suspend| is the data associated with the request - see
103 // |tBTA_AV_SUSPEND|.
104 void btif_a2dp_source_on_stopped(tBTA_AV_SUSPEND* p_av_suspend);
105 
106 // Process 'suspend' request from the BTIF state machine to suspend A2DP
107 // streaming.
108 // |p_av_suspend| is the data associated with the request - see
109 // |tBTA_AV_SUSPEND|.
110 void btif_a2dp_source_on_suspended(tBTA_AV_SUSPEND* p_av_suspend);
111 
112 // Enable/disable discarding of transmitted frames.
113 // If |enable| is true, the discarding is enabled, otherwise is disabled.
114 void btif_a2dp_source_set_tx_flush(bool enable);
115 
116 // Get the next A2DP buffer to send.
117 // Returns the next A2DP buffer to send if available, otherwise NULL.
118 BT_HDR* btif_a2dp_source_audio_readbuf(void);
119 
120 // Dump debug-related information for the A2DP Source module.
121 // |fd| is the file descriptor to use for writing the ASCII formatted
122 // information.
123 void btif_a2dp_source_debug_dump(int fd);
124 
125 #endif /* BTIF_A2DP_SOURCE_H */
126