Chromium Code Reviews| Index: content/public/renderer/media_stream_api.cc |
| diff --git a/content/public/renderer/media_stream_api.cc b/content/public/renderer/media_stream_api.cc |
| index dfe7896d2b4015e9d4e94b1758707f6a918e5db2..e644b5cfc7058d37ff93c95889b631894cef769c 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,28 @@ bool AddAudioTrackToMediaStream( |
| blink::WebMediaStream web_stream = |
| blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor( |
| GURL(media_stream_url)); |
| - if (web_stream.isNull()) { |
| + return AddAudioTrackToMediaStream(source, |
| + // params, |
|
mcasas
2015/11/10 18:18:58
?
|
| + is_remote, is_readonly, &web_stream); |
| +} |
| + |
| +bool AddAudioTrackToMediaStream( |
| + const scoped_refptr<media::AudioCapturerSource>& source, |
| + // const media::AudioParameters& params, |
| + 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, // audio_config.rtp_timebase, // sampling rate |
|
mcasas
2015/11/10 18:18:58
All these comments "confuse and scare me" :)
I th
|
| + 16, |
| + 480); // audio_config.rtp_timebase / audio_config.target_frame_rate); |
| + |
| blink::WebMediaStreamSource webkit_source; |
| const blink::WebString track_id = MakeTrackId(); |
| webkit_source.initialize(track_id, |
| @@ -85,38 +127,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; |
| } |