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 "chromeos/dbus/fake_bluetooth_media_transport_client.h" | 5 #include "chromeos/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 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 // TODO(mcchou): Remove this constants once it is in cros_system_api. | 25 // TODO(mcchou): Remove this constants once it is in cros_system_api. |
26 const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1"; | 26 const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1"; |
27 const char kNotImplemented[] = "org.bluez.NotImplemented"; | 27 const char kNotImplemented[] = "org.bluez.NotImplemented"; |
28 const char kNotAuthorized[] = "org.bluez.NotAuthorized"; | 28 const char kNotAuthorized[] = "org.bluez.NotAuthorized"; |
29 const char kFailed[] = "org.bluez.Failed"; | 29 const char kFailed[] = "org.bluez.Failed"; |
30 const char kNotAvailable[] = "org.bluez.NotAvailable"; | 30 const char kNotAvailable[] = "org.bluez.NotAvailable"; |
31 | 31 |
32 const int kInvalidFd = -1; | 32 const int kInvalidFd = -1; |
33 const uint16_t kReadMtu = 20; | |
34 const uint16_t kWriteMtu = 25; | |
35 | 33 |
36 ObjectPath GenerateTransportPath() { | 34 ObjectPath GenerateTransportPath() { |
37 static unsigned int sequence_number = 0; | 35 static unsigned int sequence_number = 0; |
38 ++sequence_number; | 36 ++sequence_number; |
39 std::stringstream path; | 37 std::stringstream path; |
40 path << chromeos::FakeBluetoothAdapterClient::kAdapterPath | 38 path << chromeos::FakeBluetoothAdapterClient::kAdapterPath |
41 << chromeos::FakeBluetoothMediaTransportClient::kTransportDevicePath | 39 << chromeos::FakeBluetoothMediaTransportClient::kTransportDevicePath |
42 << "/fd" << sequence_number; | 40 << "/fd" << sequence_number; |
43 return ObjectPath(path.str()); | 41 return ObjectPath(path.str()); |
44 } | 42 } |
45 | 43 |
46 } // namespace | 44 } // namespace |
47 | 45 |
48 namespace chromeos { | 46 namespace chromeos { |
49 | 47 |
50 // static | 48 // static |
51 const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] = | 49 const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] = |
52 "/fake_audio_source"; | 50 "/fake_audio_source"; |
53 const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00; | 51 const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00; |
54 const std::vector<uint8_t> | 52 const std::vector<uint8_t> |
55 FakeBluetoothMediaTransportClient::kTransportConfiguration = { | 53 FakeBluetoothMediaTransportClient::kTransportConfiguration = { |
56 0x21, 0x15, 0x33, 0x2C}; | 54 0x21, 0x15, 0x33, 0x2C}; |
57 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5; | 55 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5; |
58 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50; | 56 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50; |
| 57 const uint16_t FakeBluetoothMediaTransportClient::kDefaultReadMtu = 20; |
| 58 const uint16_t FakeBluetoothMediaTransportClient::kDefaultWriteMtu = 25; |
59 | 59 |
60 FakeBluetoothMediaTransportClient::Properties::Properties( | 60 FakeBluetoothMediaTransportClient::Properties::Properties( |
61 const PropertyChangedCallback& callback) | 61 const PropertyChangedCallback& callback) |
62 : BluetoothMediaTransportClient::Properties( | 62 : BluetoothMediaTransportClient::Properties( |
63 nullptr, | 63 nullptr, |
64 kBluetoothMediaTransportInterface, | 64 kBluetoothMediaTransportInterface, |
65 callback) { | 65 callback) { |
66 } | 66 } |
67 | 67 |
68 FakeBluetoothMediaTransportClient::Properties::~Properties() { | 68 FakeBluetoothMediaTransportClient::Properties::~Properties() { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 int fds[2]; | 312 int fds[2]; |
313 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { | 313 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { |
314 transport->input_fd.reset(); | 314 transport->input_fd.reset(); |
315 error_callback.Run(kFailed, ""); | 315 error_callback.Run(kFailed, ""); |
316 return; | 316 return; |
317 } | 317 } |
318 DCHECK((fds[0] > kInvalidFd) && (fds[1] > kInvalidFd)); | 318 DCHECK((fds[0] > kInvalidFd) && (fds[1] > kInvalidFd)); |
319 transport->input_fd.reset(new base::File(fds[0])); | 319 transport->input_fd.reset(new base::File(fds[0])); |
320 | 320 |
321 dbus::FileDescriptor out_fd(fds[1]); | 321 dbus::FileDescriptor out_fd(fds[1]); |
322 callback.Run(&out_fd, kReadMtu, kWriteMtu); | 322 callback.Run(&out_fd, kDefaultReadMtu, kDefaultWriteMtu); |
323 SetState(endpoint_path, "active"); | 323 SetState(endpoint_path, "active"); |
324 } | 324 } |
325 | 325 |
326 } // namespace chromeos | 326 } // namespace chromeos |
OLD | NEW |