Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Side by Side Diff: device/bluetooth/bluetooth_audio_sink.h

Issue 768493006: device/bluetooth: Add Bluetooth Audio Sink base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "dbus/file_descriptor.h"
armansito 2014/12/02 19:20:20 We can't have dbus includes here. The code wouldn'
15
16 namespace device {
17
18 class BluetoothAdapter;
19
20 // BluetoothAudioSink represents a local audio sink where a remote device can
armansito 2014/12/02 19:20:19 In general you shouldn't refer to any BlueZ concep
Miao 2014/12/03 20:06:38 Done.
21 // stream audio data. BluetoothAudioSink manages the creation/deletion of a BT
22 // Media Endpoint and delivers the file descriptor from the BT Media Transport
23 // which attaches to that endpoint.
armansito 2014/12/02 19:20:19 I wouldn't go into BlueZ API details here. This is
Miao 2014/12/03 20:06:38 Done.
24 // An user applications can obtain a pointer to a BluetoothAudioSink object via
armansito 2014/12/02 19:20:19 "An user applications" -> "User applications" ?
Miao 2014/12/03 20:06:38 Done.
25 // the interface provided by BluetoothAdapter. The validity of
26 // BluetoothAudioSink's endopint object depends on whether BluetoothAdapter is
armansito 2014/12/02 19:20:20 s/endopint/endpoint/ Though I wouldn't mention en
Miao 2014/12/03 20:06:38 Done.
27 // present and whether it is powered. Therefore, BlueotoothAudioSink has to keep
28 // track of the changes on both BluetoothAdapter's state and the connection to
29 // the remote device.
armansito 2014/12/02 19:20:19 Get rid of the last sentence. These are implementa
Miao 2014/12/03 20:06:38 Done.
30 class BluetoothAudioSink : public base::RefCounted<BluetoothAudioSink> {
31 public:
32 // Possible values indicating the connection states between the
33 // BluetoothAudioSink and the remote device. Since a BluetoothAudioSink object
34 // depends on the BluetoothAdapter object's state, the BluetoothAudioSink has
35 // to unregister its endpoint if either present or power of the
36 // BluetoothAdapter object's changes.
armansito 2014/12/02 19:20:19 You don't need the second sentence. Just saying "P
Miao 2014/12/03 20:06:38 Done.
37 enum AudioSinkState {
38 STATE_INVALID, // BluetoothAdapter not presented or not powered.
39 STATE_DISCONNECTED, // Not connected.
40 STATE_IDLE, // Connected but not streaming.
41 STATE_PENDING, // Connected, streaming but not acquired.
42 STATE_ACTIVE, // Connected, streaming and acquired.
43 };
44
45 // Used to configure an BT Media Endpoint.
armansito 2014/12/02 19:20:20 Don't mention anything about BlueZ APIs. Just say
Miao 2014/12/03 20:06:38 Done.
46 struct AudioSinkOptions {
armansito 2014/12/02 19:20:20 I'd just call this "struct Options". BluetoothAudi
Miao 2014/12/03 20:06:38 Done.
47 AudioSinkOptions();
48 ~AudioSinkOptions();
49
50 scoped_ptr<uint8_t> codec;
51 scoped_ptr<std::vector<uint8_t>> capabilities;
armansito 2014/12/02 19:20:20 Aren't codec and capabilities mandatory? I would r
Miao 2014/12/03 20:06:38 Done. Codec and capabilities are mandatory. In the
52 };
53
54 // Interface for observing changes from Bluetooth Audio Sinks.
armansito 2014/12/02 19:20:20 from a BluetoothAudioSink
Miao 2014/12/03 20:06:38 Done.
55 class Observer {
56 public:
57 virtual ~Observer() {}
58
59 // Called when the state of the BluetoothAudioSink object is changed.
60 // |audio_sink| indicates the object being changed, and |audio_sink_state|
61 // indicates the new state of that object.
62 virtual void BluetoothAudioSinkStateChanged(
63 BluetoothAudioSink* audio_sink,
64 const BluetoothAudioSink::AudioSinkState& audio_sink_state) = 0;
armansito 2014/12/02 19:20:20 Pass enum by value. No need for a const reference
Miao 2014/12/03 20:06:38 Done.
65
66 // Called when the volume of the BluetoothAudioSink object is changed.
67 // |audio_sink| indicates the object being changed, and |audio_sink_volume|
68 // indicates the new volume level of that object.
69 virtual void BluetoothAudioSinkVolumeChanged(
70 BluetoothAudioSink* audio_sink,
71 uint16_t audio_sink_volume) = 0;
72
73 // Called when the file descriptor of the BluetoothAudioSink object is
74 // ready to be read. |fd| is the file descriptor, where |read_mtu| and
75 // |write_mtu| are the maximum transport units for reading and writing.
76 virtual void BluetoothAudioSinkFdAvailable(BluetoothAudioSink* audio_sink,
77 const dbus::FileDescriptor& fd,
armansito 2014/12/02 19:20:20 Don't expose dbus objects here since the whole poi
78 uint16_t read_mtu,
79 uint16_t write_mtu) = 0;
80 };
81
82 // The EndpointAcuiredCallback is used to pass the scoped_refptr of
armansito 2014/12/02 19:20:19 Acuired -> Acquired Also you called it EndpointRe
Miao 2014/12/03 20:06:38 Done.
83 // a BluetoothAudioSink object while a BT Media Endpoint is successfully
armansito 2014/12/02 19:20:19 Don't mention BlueZ concepts.
Miao 2014/12/03 20:06:38 Done.
84 // created and registered.
85 typedef base::Callback<void(
86 scoped_refptr<BluetoothAudioSink>)> EndpointRegisteredCallback;
armansito 2014/12/02 19:20:20 I would call this "AudioSinkRegisteredCallback" si
Miao 2014/12/03 20:06:38 Done.
87
88 // The EndpointDeletedCallback is used to handle the clean-up while a BT Media
armansito 2014/12/02 19:20:20 EndpointUnregisteredCallback?
Miao 2014/12/03 20:06:38 Done.
89 // Endpoint is unregistered.
90 typedef base::Callback<void()> EndpointUnregisteredCallback;
armansito 2014/12/02 19:20:20 This typedef is unnecessary since you're method ca
Miao 2014/12/03 20:06:38 Done.
91
92 // The ErrorCallback is used for the methods that can fail in which case it
93 // can fail.
armansito 2014/12/02 19:20:19 "in which case it can fail" -> "in which case it i
Miao 2014/12/03 20:06:38 Done.
Miao 2014/12/03 20:06:38 Done.
94 typedef base::Callback<void(const std::string& error_message)> ErrorCallback;
95
96 virtual ~BluetoothAudioSink();
97
98 // Adds and removes a observer for events on the BluetoothAudioSink object. If
99 // monitoring multiple audio sinks, check the |audio_sink| parameter of
100 // observer methods to determine which audio sink is issuing the event.
101 virtual void AddObserver(Observer* observer) = 0;
102 virtual void RemoveObserver(Observer* observer) = 0;
103
104 // Registers a BT Media Endpoint. User applications can use |options| to
105 // configure a new BT Media Endpoint which will bound to the audio sink.
106 // |callback| will be executed if the endpoint is successfully created,
107 // otherwise |error_callback| will be called.
108 virtual void RegisterEndpoint(const AudioSinkOptions& options,
109 const EndpointRegisteredCallback& callback,
110 const ErrorCallback& error_callback) = 0;
armansito 2014/12/02 19:20:19 I thought we were going to have this method in Blu
Miao 2014/12/03 20:06:38 Sorry about the confusion, there is no doubt that
111
112 // Unregister the BT Media Endpoint if there is one. |callback| should handle
113 // the clean-up after the endpoint is deleted successfully, otherwise
114 // |error_callback| will be called.
115 virtual void UnregisterEndpoint(const EndpointUnregisteredCallback& callback,
armansito 2014/12/02 19:20:19 I think just base::Closure is sufficient.
armansito 2014/12/02 19:20:20 Should we call this method just "Unregister"? I do
Miao 2014/12/03 20:06:38 Done.
116 const ErrorCallback& error_callback) = 0;
117
118 protected:
119 BluetoothAudioSink();
120
121 private:
122 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink);
123 };
124
125 } // namespace device
126
127 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698