OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 | 9 |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 23 matching lines...) Expand all Loading... |
34 ObjectPath GenerateTransportPath() { | 34 ObjectPath GenerateTransportPath() { |
35 static unsigned int sequence_number = 0; | 35 static unsigned int sequence_number = 0; |
36 ++sequence_number; | 36 ++sequence_number; |
37 std::stringstream path; | 37 std::stringstream path; |
38 path << bluez::FakeBluetoothAdapterClient::kAdapterPath | 38 path << bluez::FakeBluetoothAdapterClient::kAdapterPath |
39 << bluez::FakeBluetoothMediaTransportClient::kTransportDevicePath | 39 << bluez::FakeBluetoothMediaTransportClient::kTransportDevicePath |
40 << "/fd" << sequence_number; | 40 << "/fd" << sequence_number; |
41 return ObjectPath(path.str()); | 41 return ObjectPath(path.str()); |
42 } | 42 } |
43 | 43 |
| 44 #define UINT8_VECTOR_FROM_ARRAY(array) \ |
| 45 std::vector<uint8_t>(array, array + arraysize(array)) |
| 46 |
44 } // namespace | 47 } // namespace |
45 | 48 |
46 namespace bluez { | 49 namespace bluez { |
47 | 50 |
48 // static | 51 // static |
49 const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] = | 52 const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] = |
50 "/fake_audio_source"; | 53 "/fake_audio_source"; |
51 const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00; | 54 const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00; |
52 const std::vector<uint8_t> | 55 const uint8_t FakeBluetoothMediaTransportClient::kTransportConfiguration[] = { |
53 FakeBluetoothMediaTransportClient::kTransportConfiguration = {0x21, 0x15, | 56 0x21, 0x15, 0x33, 0x2C}; |
54 0x33, 0x2C}; | 57 const uint8_t FakeBluetoothMediaTransportClient::kTransportConfigurationLength = |
| 58 arraysize(FakeBluetoothMediaTransportClient::kTransportConfiguration); |
55 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5; | 59 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5; |
56 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50; | 60 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50; |
57 const uint16_t FakeBluetoothMediaTransportClient::kDefaultReadMtu = 20; | 61 const uint16_t FakeBluetoothMediaTransportClient::kDefaultReadMtu = 20; |
58 const uint16_t FakeBluetoothMediaTransportClient::kDefaultWriteMtu = 25; | 62 const uint16_t FakeBluetoothMediaTransportClient::kDefaultWriteMtu = 25; |
59 | 63 |
60 FakeBluetoothMediaTransportClient::Properties::Properties( | 64 FakeBluetoothMediaTransportClient::Properties::Properties( |
61 const PropertyChangedCallback& callback) | 65 const PropertyChangedCallback& callback) |
62 : BluetoothMediaTransportClient::Properties( | 66 : BluetoothMediaTransportClient::Properties( |
63 nullptr, | 67 nullptr, |
64 kBluetoothMediaTransportInterface, | 68 kBluetoothMediaTransportInterface, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 << " is created for endpoint " << endpoint_path.value(); | 166 << " is created for endpoint " << endpoint_path.value(); |
163 | 167 |
164 // Sets the fake property set with default values. | 168 // Sets the fake property set with default values. |
165 scoped_ptr<Properties> properties(new Properties( | 169 scoped_ptr<Properties> properties(new Properties( |
166 base::Bind(&FakeBluetoothMediaTransportClient::OnPropertyChanged, | 170 base::Bind(&FakeBluetoothMediaTransportClient::OnPropertyChanged, |
167 base::Unretained(this)))); | 171 base::Unretained(this)))); |
168 properties->device.ReplaceValue(ObjectPath(kTransportDevicePath)); | 172 properties->device.ReplaceValue(ObjectPath(kTransportDevicePath)); |
169 properties->uuid.ReplaceValue( | 173 properties->uuid.ReplaceValue( |
170 BluetoothMediaClient::kBluetoothAudioSinkUUID); | 174 BluetoothMediaClient::kBluetoothAudioSinkUUID); |
171 properties->codec.ReplaceValue(kTransportCodec); | 175 properties->codec.ReplaceValue(kTransportCodec); |
172 properties->configuration.ReplaceValue(kTransportConfiguration); | 176 properties->configuration.ReplaceValue( |
| 177 UINT8_VECTOR_FROM_ARRAY(kTransportConfiguration)); |
173 properties->state.ReplaceValue(BluetoothMediaTransportClient::kStateIdle); | 178 properties->state.ReplaceValue(BluetoothMediaTransportClient::kStateIdle); |
174 properties->delay.ReplaceValue(kTransportDelay); | 179 properties->delay.ReplaceValue(kTransportDelay); |
175 properties->volume.ReplaceValue(kTransportVolume); | 180 properties->volume.ReplaceValue(kTransportVolume); |
176 | 181 |
177 endpoint_to_transport_map_[endpoint_path] = | 182 endpoint_to_transport_map_[endpoint_path] = |
178 new Transport(transport_path, properties.release()); | 183 new Transport(transport_path, properties.release()); |
179 transport_to_endpoint_map_[transport_path] = endpoint_path; | 184 transport_to_endpoint_map_[transport_path] = endpoint_path; |
180 return; | 185 return; |
181 } | 186 } |
182 | 187 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 319 } |
315 DCHECK((fds[0] > kInvalidFd) && (fds[1] > kInvalidFd)); | 320 DCHECK((fds[0] > kInvalidFd) && (fds[1] > kInvalidFd)); |
316 transport->input_fd.reset(new base::File(fds[0])); | 321 transport->input_fd.reset(new base::File(fds[0])); |
317 | 322 |
318 dbus::FileDescriptor out_fd(fds[1]); | 323 dbus::FileDescriptor out_fd(fds[1]); |
319 callback.Run(&out_fd, kDefaultReadMtu, kDefaultWriteMtu); | 324 callback.Run(&out_fd, kDefaultReadMtu, kDefaultWriteMtu); |
320 SetState(endpoint_path, "active"); | 325 SetState(endpoint_path, "active"); |
321 } | 326 } |
322 | 327 |
323 } // namespace bluez | 328 } // namespace bluez |
OLD | NEW |