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

Unified Diff: content/renderer/media/mock_media_stream_registry.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworked unit tests around structural changes, and added exhaustive media_stream_audio_unittest.cc. Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/mock_media_stream_registry.cc
diff --git a/content/renderer/media/mock_media_stream_registry.cc b/content/renderer/media/mock_media_stream_registry.cc
index 9bef2c5f46d0702f639ab3a2f02f908259a749e3..fa2ff1b5f216b33f734b245ffedfea0170df7b1f 100644
--- a/content/renderer/media/mock_media_stream_registry.cc
+++ b/content/renderer/media/mock_media_stream_registry.cc
@@ -11,8 +11,6 @@
#include "content/renderer/media/media_stream_audio_source.h"
#include "content/renderer/media/media_stream_video_track.h"
#include "content/renderer/media/mock_media_stream_video_source.h"
-#include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
-#include "content/renderer/media/webrtc_local_audio_track.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -20,7 +18,31 @@
namespace content {
-static const char kTestStreamLabel[] = "stream_label";
+namespace {
+
+const char kTestStreamLabel[] = "stream_label";
+
+class MockCDQualityAudioSource : public MediaStreamAudioSource {
+ public:
+ MockCDQualityAudioSource() : MediaStreamAudioSource(true) {
+ MediaStreamAudioSource::SetFormat(media::AudioParameters(
+ media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ media::CHANNEL_LAYOUT_STEREO,
+ media::AudioParameters::kAudioCDSampleRate,
+ 16,
+ media::AudioParameters::kAudioCDSampleRate / 100));
+ MediaStreamAudioSource::SetDeviceInfo(StreamDeviceInfo(
+ MEDIA_DEVICE_AUDIO_CAPTURE, "Mock audio device", "mock_audio_device_id",
+ media::AudioParameters::kAudioCDSampleRate,
+ media::CHANNEL_LAYOUT_STEREO,
+ media::AudioParameters::kAudioCDSampleRate / 100));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockCDQualityAudioSource);
+};
+
+} // namespace
MockMediaStreamRegistry::MockMediaStreamRegistry() {}
@@ -55,19 +77,17 @@ void MockMediaStreamRegistry::AddVideoTrack(const std::string& track_id) {
}
void MockMediaStreamRegistry::AddAudioTrack(const std::string& track_id) {
- blink::WebMediaStreamSource audio_source;
- audio_source.initialize(
+ blink::WebMediaStreamSource blink_source;
+ blink_source.initialize(
"mock audio source id", blink::WebMediaStreamSource::TypeAudio,
"mock audio source name", false /* remote */, true /* readonly */);
- audio_source.setExtraData(new MediaStreamAudioSource());
+ MediaStreamAudioSource* const source = new MockCDQualityAudioSource();
+ blink_source.setExtraData(source); // Takes ownership.
+
blink::WebMediaStreamTrack blink_track;
- blink_track.initialize(audio_source);
- const scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
- WebRtcLocalAudioTrackAdapter::Create(track_id,
- nullptr /* track source */));
- std::unique_ptr<WebRtcLocalAudioTrack> native_track(
- new WebRtcLocalAudioTrack(adapter.get()));
- blink_track.setExtraData(native_track.release());
+ blink_track.initialize(blink_source);
+ CHECK(source->ConnectToTrack(blink_track));
+
test_stream_.addTrack(blink_track);
}

Powered by Google App Engine
This is Rietveld 408576698