summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormcchou <mcchou@chromium.org>2015-03-26 14:36:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-26 21:37:30 +0000
commitad8553a80203d8be31fc1cd60a4291883bcb3849 (patch)
tree4397778e08c9038c6a32f83463f3ba4d0c049790
parentb53749fec68b4f2f9daacef9cbbe75e2f58f7805 (diff)
downloadchromium_src-ad8553a80203d8be31fc1cd60a4291883bcb3849.zip
chromium_src-ad8553a80203d8be31fc1cd60a4291883bcb3849.tar.gz
chromium_src-ad8553a80203d8be31fc1cd60a4291883bcb3849.tar.bz2
device/bluetooth: Add read_mtu as an argument of BluetoothAudioSinkDataAvailable.
This CL added read_mtu into the signature of BluetoothAudioSink::Observer::BluetoothAudioSinkDataAvailable and modified corresponding tests. BUG=441581 TEST=device_unittests --gtest_filter=*AudioSink* Review URL: https://codereview.chromium.org/1034893002 Cr-Commit-Position: refs/heads/master@{#322476}
-rw-r--r--chromeos/dbus/fake_bluetooth_media_transport_client.cc6
-rw-r--r--chromeos/dbus/fake_bluetooth_media_transport_client.h4
-rw-r--r--device/bluetooth/bluetooth_audio_sink.h10
-rw-r--r--device/bluetooth/bluetooth_audio_sink_chromeos.cc5
-rw-r--r--device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc15
5 files changed, 30 insertions, 10 deletions
diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.cc b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
index 93ee315..441a66b 100644
--- a/chromeos/dbus/fake_bluetooth_media_transport_client.cc
+++ b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
@@ -30,8 +30,6 @@ const char kFailed[] = "org.bluez.Failed";
const char kNotAvailable[] = "org.bluez.NotAvailable";
const int kInvalidFd = -1;
-const uint16_t kReadMtu = 20;
-const uint16_t kWriteMtu = 25;
ObjectPath GenerateTransportPath() {
static unsigned int sequence_number = 0;
@@ -56,6 +54,8 @@ const std::vector<uint8_t>
0x21, 0x15, 0x33, 0x2C};
const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5;
const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50;
+const uint16_t FakeBluetoothMediaTransportClient::kDefaultReadMtu = 20;
+const uint16_t FakeBluetoothMediaTransportClient::kDefaultWriteMtu = 25;
FakeBluetoothMediaTransportClient::Properties::Properties(
const PropertyChangedCallback& callback)
@@ -319,7 +319,7 @@ void FakeBluetoothMediaTransportClient::AcquireInternal(
transport->input_fd.reset(new base::File(fds[0]));
dbus::FileDescriptor out_fd(fds[1]);
- callback.Run(&out_fd, kReadMtu, kWriteMtu);
+ callback.Run(&out_fd, kDefaultReadMtu, kDefaultWriteMtu);
SetState(endpoint_path, "active");
}
diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.h b/chromeos/dbus/fake_bluetooth_media_transport_client.h
index eebbea8..997d28d 100644
--- a/chromeos/dbus/fake_bluetooth_media_transport_client.h
+++ b/chromeos/dbus/fake_bluetooth_media_transport_client.h
@@ -45,6 +45,10 @@ class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient
static const uint16_t kTransportDelay;
static const uint16_t kTransportVolume;
+ // The default MTUs for read and write.
+ static const uint16_t kDefaultReadMtu;
+ static const uint16_t kDefaultWriteMtu;
+
FakeBluetoothMediaTransportClient();
~FakeBluetoothMediaTransportClient() override;
diff --git a/device/bluetooth/bluetooth_audio_sink.h b/device/bluetooth/bluetooth_audio_sink.h
index c7de607..3735925 100644
--- a/device/bluetooth/bluetooth_audio_sink.h
+++ b/device/bluetooth/bluetooth_audio_sink.h
@@ -75,12 +75,14 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSink
// Called when there is audio data available. |audio_sink| indicates the
// object being changed. |data| is the pointer to the audio data and |size|
- // is the number of bytes in |data|. This method provides the raw audio data
- // which hasn't been processed, so RTP assembling and SBC decoding need to
- // be handled in order to get PCM data.
+ // is the number of bytes in |data|. |read_mtu| is the max size of the RTP
+ // packet. This method provides the raw audio data which hasn't been
+ // processed, so RTP assembling and SBC decoding need to be handled in order
+ // to get PCM data.
virtual void BluetoothAudioSinkDataAvailable(BluetoothAudioSink* audio_sink,
char* data,
- size_t size) = 0;
+ size_t size,
+ uint16_t read_mtu) = 0;
};
// The ErrorCallback is used for the methods that can fail in which case it
diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_chromeos.cc
index 0f76be8..dcd751b 100644
--- a/device/bluetooth/bluetooth_audio_sink_chromeos.cc
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc
@@ -400,8 +400,9 @@ void BluetoothAudioSinkChromeOS::ReadFromFile() {
}
VLOG(1) << "ReadFromFile - read " << size << " bytes";
- FOR_EACH_OBSERVER(BluetoothAudioSink::Observer, observers_,
- BluetoothAudioSinkDataAvailable(this, data_.get(), size));
+ FOR_EACH_OBSERVER(
+ BluetoothAudioSink::Observer, observers_,
+ BluetoothAudioSinkDataAvailable(this, data_.get(), size, read_mtu_));
}
void BluetoothAudioSinkChromeOS::StateChanged(
diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
index b415e73..9781dec 100644
--- a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
@@ -58,10 +58,12 @@ class TestAudioSinkObserver : public BluetoothAudioSink::Observer {
void BluetoothAudioSinkDataAvailable(BluetoothAudioSink* audio_sink,
char* data,
- size_t size) override {
+ size_t size,
+ uint16_t read_mtu) override {
total_read_ += size;
data_.clear();
data_.insert(data_.begin(), data, data + size);
+ read_mtu_ = read_mtu;
}
int state_changed_count_;
@@ -69,6 +71,7 @@ class TestAudioSinkObserver : public BluetoothAudioSink::Observer {
int data_available_count_;
size_t total_read_;
std::vector<char> data_;
+ uint16_t read_mtu_;
BluetoothAudioSink::State state_;
private:
@@ -838,6 +841,8 @@ TEST_F(BluetoothAudioSinkChromeOSTest, AcquireFD) {
EXPECT_EQ(observer_->state_changed_count_, 3);
EXPECT_EQ(observer_->total_read_, data_one.size());
EXPECT_EQ(observer_->data_, data_one);
+ EXPECT_EQ(observer_->read_mtu_,
+ FakeBluetoothMediaTransportClient::kDefaultReadMtu);
}
// Tests the case where the remote device pauses and resume audio streaming.
@@ -873,6 +878,8 @@ TEST_F(BluetoothAudioSinkChromeOSTest, PauseAndResume) {
message_loop_.RunUntilIdle();
EXPECT_EQ(observer_->data_, data_one);
+ EXPECT_EQ(observer_->read_mtu_,
+ FakeBluetoothMediaTransportClient::kDefaultReadMtu);
EXPECT_EQ(observer_->state_changed_count_, 3);
EXPECT_EQ(observer_->total_read_, data_one.size());
@@ -891,6 +898,8 @@ TEST_F(BluetoothAudioSinkChromeOSTest, PauseAndResume) {
message_loop_.RunUntilIdle();
EXPECT_EQ(observer_->data_, data_two);
+ EXPECT_EQ(observer_->read_mtu_,
+ FakeBluetoothMediaTransportClient::kDefaultReadMtu);
EXPECT_EQ(observer_->state_changed_count_, 6);
EXPECT_EQ(observer_->total_read_, data_two.size());
}
@@ -927,6 +936,8 @@ TEST_F(BluetoothAudioSinkChromeOSTest, ContinuouslyStreaming) {
message_loop_.RunUntilIdle();
EXPECT_EQ(observer_->data_, data_one);
+ EXPECT_EQ(observer_->read_mtu_,
+ FakeBluetoothMediaTransportClient::kDefaultReadMtu);
EXPECT_EQ(observer_->state_changed_count_, 3);
EXPECT_EQ(observer_->total_read_, data_one.size());
@@ -936,6 +947,8 @@ TEST_F(BluetoothAudioSinkChromeOSTest, ContinuouslyStreaming) {
message_loop_.RunUntilIdle();
EXPECT_EQ(observer_->data_, data_two);
+ EXPECT_EQ(observer_->read_mtu_,
+ FakeBluetoothMediaTransportClient::kDefaultReadMtu);
EXPECT_EQ(observer_->state_changed_count_, 3);
EXPECT_EQ(observer_->total_read_, data_one.size() + data_two.size());
}