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

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: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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 a3d61d1f372f3ca219785a17c5d31383c87acad0..bad1ae790c6d1241ec9b119b67460b8c80187655 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 */);
- 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);
}
« no previous file with comments | « content/renderer/media/mock_media_stream_dispatcher.cc ('k') | content/renderer/media/remote_media_stream_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698