Commit 5e2980d8 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch WebRtcAudioRendererSource away from std::string

Instead it (and its devired class WebRtcAudioDeviceImpl) operate
over WTF::String.

BUG=923394
R=guidou@chromium.org

Change-Id: I13928733af68463d789170ebb7aa7a6836288b55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970138Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#726160}
parent 0d2158b9
......@@ -56,7 +56,7 @@ class MockAudioRendererSource : public blink::WebRtcAudioRendererSource {
base::TimeDelta* current_time));
MOCK_METHOD1(RemoveAudioRenderer, void(blink::WebRtcAudioRenderer* renderer));
MOCK_METHOD0(AudioRendererThreadStopped, void());
MOCK_METHOD1(SetOutputDeviceForAec, void(const std::string&));
MOCK_METHOD1(SetOutputDeviceForAec, void(const String&));
MOCK_CONST_METHOD0(GetAudioProcessingId, base::UnguessableToken());
};
......@@ -128,10 +128,10 @@ class WebRtcAudioRendererTest : public testing::Test {
.WillRepeatedly(Return(*kAudioProcessingId));
}
void SetupRenderer(const std::string& device_id) {
void SetupRenderer(const String& device_id) {
renderer_ = new blink::WebRtcAudioRenderer(
blink::scheduler::GetSingleThreadTaskRunnerForTesting(), stream_,
nullptr, base::UnguessableToken::Create(), device_id);
nullptr, base::UnguessableToken::Create(), device_id.Utf8());
media::AudioSinkParameters params;
EXPECT_CALL(
......@@ -140,7 +140,7 @@ class WebRtcAudioRendererTest : public testing::Test {
nullptr /*blink::WebLocalFrame*/, _))
.Times(testing::AtLeast(1))
.WillRepeatedly(DoAll(SaveArg<2>(&params), InvokeWithoutArgs([&]() {
EXPECT_EQ(params.device_id, device_id);
EXPECT_EQ(params.device_id, device_id.Utf8());
})));
EXPECT_CALL(*source_.get(), SetOutputDeviceForAec(device_id));
......@@ -294,7 +294,8 @@ TEST_F(WebRtcAudioRendererTest, SwitchOutputDevice) {
MockNewAudioRendererSink(blink::WebAudioDeviceSourceType::kWebRtc, _, _))
.WillOnce(SaveArg<2>(&params));
EXPECT_CALL(*source_.get(), AudioRendererThreadStopped());
EXPECT_CALL(*source_.get(), SetOutputDeviceForAec(kOtherOutputDeviceId));
EXPECT_CALL(*source_.get(),
SetOutputDeviceForAec(String::FromUTF8(kOtherOutputDeviceId)));
EXPECT_CALL(*this, MockSwitchDeviceCallback(media::OUTPUT_DEVICE_STATUS_OK));
base::RunLoop loop;
renderer_proxy_->SwitchOutputDevice(
......
......@@ -128,12 +128,12 @@ void WebRtcAudioDeviceImpl::AudioRendererThreadStopped() {
}
void WebRtcAudioDeviceImpl::SetOutputDeviceForAec(
const std::string& output_device_id) {
const String& output_device_id) {
DCHECK_CALLED_ON_VALID_THREAD(main_thread_checker_);
output_device_id_for_aec_ = output_device_id;
base::AutoLock lock(lock_);
for (auto* capturer : capturers_) {
capturer->SetOutputDeviceForAec(output_device_id);
capturer->SetOutputDeviceForAec(output_device_id.Utf8());
}
}
......@@ -386,7 +386,7 @@ void WebRtcAudioDeviceImpl::AddAudioCapturer(
base::AutoLock auto_lock(lock_);
DCHECK(!base::Contains(capturers_, capturer));
capturers_.push_back(capturer);
capturer->SetOutputDeviceForAec(output_device_id_for_aec_);
capturer->SetOutputDeviceForAec(output_device_id_for_aec_.Utf8());
}
void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
......
......@@ -133,7 +133,7 @@ class MODULES_EXPORT WebRtcAudioDeviceImpl
// Called on the main render thread.
void RemoveAudioRenderer(blink::WebRtcAudioRenderer* renderer) override;
void AudioRendererThreadStopped() override;
void SetOutputDeviceForAec(const std::string& output_device_id) override;
void SetOutputDeviceForAec(const String& output_device_id) override;
base::UnguessableToken GetAudioProcessingId() const override;
// blink::WebRtcPlayoutDataSource implementation.
......@@ -190,9 +190,7 @@ class MODULES_EXPORT WebRtcAudioDeviceImpl
Vector<int16_t> render_buffer_;
// The output device used for echo cancellation
//
// TODO(crbug.com/923394): Replace std::string by WTF::String.
std::string output_device_id_for_aec_;
String output_device_id_for_aec_;
DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl);
};
......
......@@ -241,7 +241,7 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
// User must call Play() before any audio can be heard.
state_ = PAUSED;
}
source_->SetOutputDeviceForAec(output_device_id_);
source_->SetOutputDeviceForAec(String::FromUTF8(output_device_id_));
sink_->Start();
sink_->Play(); // Not all the sinks play on start.
......@@ -433,7 +433,7 @@ void WebRtcAudioRenderer::SwitchOutputDevice(
base::AutoLock auto_lock(lock_);
source_->AudioRendererThreadStopped();
}
source_->SetOutputDeviceForAec(output_device_id_);
source_->SetOutputDeviceForAec(String::FromUTF8(output_device_id_));
PrepareSink();
sink_->Start();
sink_->Play(); // Not all the sinks play on start.
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WEBRTC_WEBRTC_SOURCE_H_
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace base {
class UnguessableToken;
......@@ -39,7 +40,7 @@ class PLATFORM_EXPORT WebRtcAudioRendererSource {
virtual void AudioRendererThreadStopped() = 0;
// Callback to notify the client of the output device the renderer is using.
virtual void SetOutputDeviceForAec(const std::string& output_device_id) = 0;
virtual void SetOutputDeviceForAec(const String& output_device_id) = 0;
// Returns the UnguessableToken used to connect this stream to an input stream
// for echo cancellation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment