summaryrefslogtreecommitdiffstats
path: root/content/public/renderer
diff options
context:
space:
mode:
authorajose <ajose@chromium.org>2015-11-20 16:39:20 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-21 00:40:45 +0000
commitdbebd0d23dd4ef4582af0ddbdd55e0727abecb06 (patch)
tree6ca991508fbdcf301379118e2e427118311337ef /content/public/renderer
parent4812ec88bcd1276be41ddd58f1195e4a833f3e30 (diff)
downloadchromium_src-dbebd0d23dd4ef4582af0ddbdd55e0727abecb06.zip
chromium_src-dbebd0d23dd4ef4582af0ddbdd55e0727abecb06.tar.gz
chromium_src-dbebd0d23dd4ef4582af0ddbdd55e0727abecb06.tar.bz2
Add layout tests for the audio component of MediaStream Recording.
Additionally, xtends components/test_runner's generated WebMediaStream to have a ChromeMock AudioTrack and Source components/test_runner is used by Blink LayoutTest to generate a MediaStream. But this MS has only Blink-side objects, whereas some tests (e.g. MediaRecorder) need to have Chrome counterparts of those objects. This CL adds those, for audio. Since components/ has a strict dependency requirement, the added code goes into a subfolder of components/test_runner. BUG=528519,548290 Review URL: https://codereview.chromium.org/1448203002 Cr-Commit-Position: refs/heads/master@{#360965}
Diffstat (limited to 'content/public/renderer')
-rw-r--r--content/public/renderer/media_stream_api.cc85
-rw-r--r--content/public/renderer/media_stream_api.h5
2 files changed, 52 insertions, 38 deletions
diff --git a/content/public/renderer/media_stream_api.cc b/content/public/renderer/media_stream_api.cc
index dfe7896..5908c99 100644
--- a/content/public/renderer/media_stream_api.cc
+++ b/content/public/renderer/media_stream_api.cc
@@ -30,11 +30,10 @@ blink::WebString MakeTrackId() {
} // namespace
-bool AddVideoTrackToMediaStream(
- scoped_ptr<media::VideoCapturerSource> source,
- bool is_remote,
- bool is_readonly,
- const std::string& media_stream_url) {
+bool AddVideoTrackToMediaStream(scoped_ptr<media::VideoCapturerSource> source,
+ bool is_remote,
+ bool is_readonly,
+ const std::string& media_stream_url) {
blink::WebMediaStream web_stream =
blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(
GURL(media_stream_url));
@@ -42,6 +41,31 @@ bool AddVideoTrackToMediaStream(
&web_stream);
}
+bool AddVideoTrackToMediaStream(scoped_ptr<media::VideoCapturerSource> source,
+ bool is_remote,
+ bool is_readonly,
+ blink::WebMediaStream* web_stream) {
+ if (web_stream->isNull()) {
+ DLOG(ERROR) << "Stream not found";
+ return false;
+ }
+ const blink::WebString track_id = MakeTrackId();
+ blink::WebMediaStreamSource webkit_source;
+ scoped_ptr<MediaStreamVideoSource> media_stream_source(
+ new MediaStreamVideoCapturerSource(
+ MediaStreamSource::SourceStoppedCallback(), source.Pass()));
+ webkit_source.initialize(track_id, blink::WebMediaStreamSource::TypeVideo,
+ track_id, is_remote, is_readonly);
+ webkit_source.setExtraData(media_stream_source.get());
+
+ blink::WebMediaConstraints constraints;
+ constraints.initialize();
+ web_stream->addTrack(MediaStreamVideoTrack::CreateVideoTrack(
+ media_stream_source.release(), constraints,
+ MediaStreamVideoSource::ConstraintsCallback(), true));
+ return true;
+}
+
bool AddAudioTrackToMediaStream(
const scoped_refptr<media::AudioCapturerSource>& source,
const media::AudioParameters& params,
@@ -52,10 +76,26 @@ bool AddAudioTrackToMediaStream(
blink::WebMediaStream web_stream =
blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(
GURL(media_stream_url));
- if (web_stream.isNull()) {
+ return AddAudioTrackToMediaStream(source,
+ is_remote, is_readonly, &web_stream);
+}
+
+bool AddAudioTrackToMediaStream(
+ const scoped_refptr<media::AudioCapturerSource>& source,
+ bool is_remote,
+ bool is_readonly,
+ blink::WebMediaStream* web_stream) {
+ if (web_stream->isNull()) {
DLOG(ERROR) << "Stream not found";
return false;
}
+
+ media::AudioParameters params(
+ media::AudioParameters::AUDIO_PCM_LINEAR, media::CHANNEL_LAYOUT_STEREO,
+ 48000, /* sample rate */
+ 16, /* bits per sample */
+ 480); /* frames per buffer */
+
blink::WebMediaStreamSource webkit_source;
const blink::WebString track_id = MakeTrackId();
webkit_source.initialize(track_id,
@@ -85,38 +125,7 @@ bool AddAudioTrackToMediaStream(
RenderThreadImpl::current()->GetPeerConnectionDependencyFactory()->
CreateLocalAudioTrack(web_media_audio_track);
- web_stream.addTrack(web_media_audio_track);
- return true;
-}
-
-bool AddVideoTrackToMediaStream(scoped_ptr<media::VideoCapturerSource> source,
- bool is_remote,
- bool is_readonly,
- blink::WebMediaStream* web_stream) {
- if (web_stream->isNull()) {
- DLOG(ERROR) << "Stream not found";
- return false;
- }
- const blink::WebString track_id = MakeTrackId();
- blink::WebMediaStreamSource webkit_source;
- scoped_ptr<MediaStreamVideoSource> media_stream_source(
- new MediaStreamVideoCapturerSource(
- MediaStreamSource::SourceStoppedCallback(),
- source.Pass()));
- webkit_source.initialize(track_id,
- blink::WebMediaStreamSource::TypeVideo,
- track_id,
- is_remote,
- is_readonly);
- webkit_source.setExtraData(media_stream_source.get());
-
- blink::WebMediaConstraints constraints;
- constraints.initialize();
- web_stream->addTrack(MediaStreamVideoTrack::CreateVideoTrack(
- media_stream_source.release(),
- constraints,
- MediaStreamVideoSource::ConstraintsCallback(),
- true));
+ web_stream->addTrack(web_media_audio_track);
return true;
}
diff --git a/content/public/renderer/media_stream_api.h b/content/public/renderer/media_stream_api.h
index 2e87ff3..dfb2aaf 100644
--- a/content/public/renderer/media_stream_api.h
+++ b/content/public/renderer/media_stream_api.h
@@ -43,6 +43,11 @@ CONTENT_EXPORT bool AddAudioTrackToMediaStream(
bool is_remote,
bool is_readonly,
const std::string& media_stream_url);
+CONTENT_EXPORT bool AddAudioTrackToMediaStream(
+ const scoped_refptr<media::AudioCapturerSource>& source,
+ bool is_remote,
+ bool is_readonly,
+ blink::WebMediaStream* web_stream);
} // namespace content