OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
7 | |
8 #include <stdint.h> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/callback.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 | |
16 namespace device { | |
17 | |
18 // TODO(mcchou): Define a BluetoothAudioSink specific IOBuffer abstraction. | |
19 | |
20 // BluetoothAudioSink represents a local A2DP audio sink where a remote device | |
21 // can stream audio data. Once a BluetoothAudioSink is successfully registered, | |
22 // user applications can obtain a pointer to a BluetoothAudioSink object via | |
23 // the interface provided by BluetoothAdapter. The validity of a | |
24 // BluetoothAudioSink depends on whether BluetoothAdapter is present and whether | |
25 // it is powered. | |
26 class BluetoothAudioSink : public base::RefCounted<BluetoothAudioSink> { | |
armansito
2014/12/05 20:04:27
Add the DEVICE_BLUETOOTH_EXPORT macro here.
Miao
2014/12/05 22:39:42
Done.
| |
27 public: | |
28 // Possible values indicating the connection states between the | |
29 // BluetoothAudioSink and the remote device. | |
30 enum State { | |
31 STATE_INVALID, // BluetoothAdapter not presented or not powered. | |
32 STATE_DISCONNECTED, // Not connected. | |
33 STATE_IDLE, // Connected but not streaming. | |
34 STATE_PENDING, // Connected, streaming but not acquired. | |
35 STATE_ACTIVE, // Connected, streaming and acquired. | |
36 }; | |
37 | |
38 // Options to configure an A2DP audio sink. | |
39 struct Options { | |
40 Options(); | |
41 ~Options(); | |
42 | |
43 uint8_t codec; | |
44 std::vector<uint8_t> capabilities; | |
45 }; | |
46 | |
47 // Interface for observing changes from a BluetoothAudioSink. | |
48 class Observer { | |
49 public: | |
50 virtual ~Observer() {} | |
51 | |
52 // Called when the state of the BluetoothAudioSink object is changed. | |
53 // |audio_sink| indicates the object being changed, and |state| indicates | |
54 // the new state of that object. | |
55 virtual void BluetoothAudioSinkStateChanged( | |
56 BluetoothAudioSink* audio_sink, | |
57 BluetoothAudioSink::State state) = 0; | |
58 | |
59 // Called when the volume of the BluetoothAudioSink object is changed. | |
60 // |audio_sink| indicates the object being changed, and |volume| indicates | |
61 // the new volume level of that object. | |
62 virtual void BluetoothAudioSinkVolumeChanged( | |
63 BluetoothAudioSink* audio_sink, | |
64 uint16_t volume) = 0; | |
65 | |
66 // TODO(mcchou): Add method to monitor the availability of audio data during | |
67 // the streaming. This method should associate with BluetoothAudioSink | |
68 // specific IOBuffer wrapping fd, read_mtu and write_mtu. | |
69 }; | |
70 | |
71 // The AudioSinkAcquiredCallback is used to return a BluetoothAudioSink object | |
72 // after it is registered successfully. | |
73 typedef base::Callback<void( | |
74 scoped_refptr<BluetoothAudioSink>)> AudioSinkAcquiredCallback; | |
75 | |
76 // The ErrorCallback is used for the methods that can fail in which case it | |
77 // is called. | |
78 typedef base::Callback<void(const std::string& error_message)> ErrorCallback; | |
79 | |
80 // Adds and removes a observer for events on the BluetoothAudioSink object. If | |
81 // monitoring multiple audio sinks, check the |audio_sink| parameter of | |
82 // observer methods to determine which audio sink is issuing the event. | |
83 virtual void AddObserver(Observer* observer) = 0; | |
84 virtual void RemoveObserver(Observer* observer) = 0; | |
85 | |
86 // Getters for state and volume. | |
87 virtual State GetState() const = 0; | |
88 virtual uint16_t GetVolume() const = 0; | |
89 | |
90 protected: | |
91 BluetoothAudioSink(); | |
92 virtual ~BluetoothAudioSink(); | |
93 | |
94 private: | |
95 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink); | |
96 }; | |
97 | |
98 } // namespace device | |
99 | |
100 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
OLD | NEW |