blob: 2f1763ddbc15da6c2a02927a327f4ceff38ac4a7 [file] [log] [blame]
Pavlin Radoslavov08406e92016-09-23 16:36:47 -07001/******************************************************************************
2 *
3 * Copyright (C) 2016 The Android Open Source Project
4 * Copyright (C) 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
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070027// Initialize and startup the A2DP Source module.
28// This function should be called by the BTIF state machine prior to using the
29// module.
30bool btif_a2dp_source_startup(void);
31
32// Shutdown and cleanup the A2DP Source module.
33// This function should be called by the BTIF state machine during
34// graceful shutdown and cleanup.
35void btif_a2dp_source_shutdown(void);
36
37// Check whether the A2DP Source media task is running.
38// Returns true if the A2DP Source media task is running, otherwise false.
39bool btif_a2dp_source_media_task_is_running(void);
40
41// Check whether the A2DP Source media task is shutting down.
42// Returns true if the A2DP Source media task is shutting down.
43bool btif_a2dp_source_media_task_is_shutting_down(void);
44
45// Return true if the A2DP Source module is streaming.
46bool btif_a2dp_source_is_streaming(void);
47
48// Setup the A2DP Source codec, and prepare the encoder.
49// This function should be called prior to starting A2DP streaming.
50void btif_a2dp_source_setup_codec(void);
51
52// Process a request to start the A2DP audio encoding task.
Pavlin Radoslavov1394c192016-10-02 18:34:46 -070053void btif_a2dp_source_start_audio_req(void);
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070054
55// Process a request to stop the A2DP audio encoding task.
Pavlin Radoslavov1394c192016-10-02 18:34:46 -070056void btif_a2dp_source_stop_audio_req(void);
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070057
Pavlin Radoslavov5ce01162016-12-05 13:02:26 -080058// Process a request to update the A2DP audio encoder with user preferred
59// codec configuration.
60// |codec_user_config| contains the preferred codec user configuration.
61void btif_a2dp_source_encoder_user_config_update_req(
62 const btav_a2dp_codec_config_t& codec_user_config);
63
64// Process a request to update the A2DP audio encoding with new audio
65// configuration feeding parameters stored in |codec_audio_config|.
66// The fields that are used are: |codec_audio_config.sample_rate|,
67// |codec_audio_config.bits_per_sample| and |codec_audio_config.channel_mode|.
68void btif_a2dp_source_feeding_update_req(
69 const btav_a2dp_codec_config_t& codec_audio_config);
70
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070071// Process 'idle' request from the BTIF state machine during initialization.
72void btif_a2dp_source_on_idle(void);
73
74// Process 'stop' request from the BTIF state machine to stop A2DP streaming.
75// |p_av_suspend| is the data associated with the request - see
76// |tBTA_AV_SUSPEND|.
Pavlin Radoslavov397e5a52016-10-14 16:13:54 -070077void btif_a2dp_source_on_stopped(tBTA_AV_SUSPEND* p_av_suspend);
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070078
79// Process 'suspend' request from the BTIF state machine to suspend A2DP
80// streaming.
81// |p_av_suspend| is the data associated with the request - see
82// |tBTA_AV_SUSPEND|.
Pavlin Radoslavov397e5a52016-10-14 16:13:54 -070083void btif_a2dp_source_on_suspended(tBTA_AV_SUSPEND* p_av_suspend);
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070084
85// Enable/disable discarding of transmitted frames.
86// If |enable| is true, the discarding is enabled, otherwise is disabled.
87void btif_a2dp_source_set_tx_flush(bool enable);
88
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070089// Get the next A2DP buffer to send.
90// Returns the next A2DP buffer to send if available, otherwise NULL.
Pavlin Radoslavov397e5a52016-10-14 16:13:54 -070091BT_HDR* btif_a2dp_source_audio_readbuf(void);
Pavlin Radoslavov08406e92016-09-23 16:36:47 -070092
93// Dump debug-related information for the A2DP Source module.
94// |fd| is the file descriptor to use for writing the ASCII formatted
95// information.
96void btif_a2dp_source_debug_dump(int fd);
97
98// Update the A2DP Source related metrics.
99// This function should be called before collecting the metrics.
100void btif_a2dp_source_update_metrics(void);
101
Pavlin Radoslavov08406e92016-09-23 16:36:47 -0700102#endif /* BTIF_A2DP_SOURCE_H */