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

Side by Side Diff: content/public/renderer/media_stream_utils.cc

Issue 2710213005: Revert of Remove |remote| and |readonly| members of MediaStreamTrack (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/renderer/media_stream_utils.h" 5 #include "content/public/renderer/media_stream_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "content/renderer/media/external_media_stream_audio_source.h" 14 #include "content/renderer/media/external_media_stream_audio_source.h"
15 #include "content/renderer/media/media_stream_video_capturer_source.h" 15 #include "content/renderer/media/media_stream_video_capturer_source.h"
16 #include "content/renderer/media/media_stream_video_source.h" 16 #include "content/renderer/media/media_stream_video_source.h"
17 #include "content/renderer/media/media_stream_video_track.h" 17 #include "content/renderer/media/media_stream_video_track.h"
18 #include "media/base/audio_capturer_source.h" 18 #include "media/base/audio_capturer_source.h"
19 #include "media/capture/video_capturer_source.h" 19 #include "media/capture/video_capturer_source.h"
20 #include "third_party/WebKit/public/platform/WebMediaStream.h" 20 #include "third_party/WebKit/public/platform/WebMediaStream.h"
21 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 21 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
22 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" 22 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 bool AddVideoTrackToMediaStream( 26 bool AddVideoTrackToMediaStream(
27 std::unique_ptr<media::VideoCapturerSource> video_source, 27 std::unique_ptr<media::VideoCapturerSource> video_source,
28 bool is_remote,
29 bool is_readonly,
28 blink::WebMediaStream* web_media_stream) { 30 blink::WebMediaStream* web_media_stream) {
29 DCHECK(video_source.get()); 31 DCHECK(video_source.get());
30 if (!web_media_stream || web_media_stream->isNull()) { 32 if (!web_media_stream || web_media_stream->isNull()) {
31 DLOG(ERROR) << "WebMediaStream is null"; 33 DLOG(ERROR) << "WebMediaStream is null";
32 return false; 34 return false;
33 } 35 }
34 36
35 blink::WebMediaStreamSource web_media_stream_source; 37 blink::WebMediaStreamSource web_media_stream_source;
36 MediaStreamVideoSource* const media_stream_source = 38 MediaStreamVideoSource* const media_stream_source =
37 new MediaStreamVideoCapturerSource( 39 new MediaStreamVideoCapturerSource(
38 MediaStreamSource::SourceStoppedCallback(), std::move(video_source)); 40 MediaStreamSource::SourceStoppedCallback(), std::move(video_source));
39 const blink::WebString track_id = 41 const blink::WebString track_id =
40 blink::WebString::fromUTF8(base::GenerateGUID()); 42 blink::WebString::fromUTF8(base::GenerateGUID());
41 web_media_stream_source.initialize( 43 web_media_stream_source.initialize(track_id,
42 track_id, blink::WebMediaStreamSource::TypeVideo, track_id); 44 blink::WebMediaStreamSource::TypeVideo,
45 track_id, is_remote);
43 // Takes ownership of |media_stream_source|. 46 // Takes ownership of |media_stream_source|.
44 web_media_stream_source.setExtraData(media_stream_source); 47 web_media_stream_source.setExtraData(media_stream_source);
45 48
46 blink::WebMediaConstraints constraints; 49 blink::WebMediaConstraints constraints;
47 constraints.initialize(); 50 constraints.initialize();
48 web_media_stream->addTrack(MediaStreamVideoTrack::CreateVideoTrack( 51 web_media_stream->addTrack(MediaStreamVideoTrack::CreateVideoTrack(
49 media_stream_source, constraints, 52 media_stream_source, constraints,
50 MediaStreamVideoSource::ConstraintsCallback(), true)); 53 MediaStreamVideoSource::ConstraintsCallback(), true));
51 return true; 54 return true;
52 } 55 }
53 56
54 bool AddAudioTrackToMediaStream( 57 bool AddAudioTrackToMediaStream(
55 scoped_refptr<media::AudioCapturerSource> audio_source, 58 scoped_refptr<media::AudioCapturerSource> audio_source,
56 int sample_rate, 59 int sample_rate,
57 media::ChannelLayout channel_layout, 60 media::ChannelLayout channel_layout,
58 int frames_per_buffer, 61 int frames_per_buffer,
62 bool is_remote,
63 bool is_readonly,
59 blink::WebMediaStream* web_media_stream) { 64 blink::WebMediaStream* web_media_stream) {
60 DCHECK(audio_source.get()); 65 DCHECK(audio_source.get());
61 if (!web_media_stream || web_media_stream->isNull()) { 66 if (!web_media_stream || web_media_stream->isNull()) {
62 DLOG(ERROR) << "WebMediaStream is null"; 67 DLOG(ERROR) << "WebMediaStream is null";
63 return false; 68 return false;
64 } 69 }
65 70
66 const media::AudioParameters params( 71 const media::AudioParameters params(
67 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 72 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
68 sample_rate, sizeof(int16_t) * 8, frames_per_buffer); 73 sample_rate, sizeof(int16_t) * 8, frames_per_buffer);
69 if (!params.IsValid()) { 74 if (!params.IsValid()) {
70 DLOG(ERROR) << "Invalid audio parameters."; 75 DLOG(ERROR) << "Invalid audio parameters.";
71 return false; 76 return false;
72 } 77 }
73 78
74 blink::WebMediaStreamSource web_media_stream_source; 79 blink::WebMediaStreamSource web_media_stream_source;
75 const blink::WebString track_id = 80 const blink::WebString track_id =
76 blink::WebString::fromUTF8(base::GenerateGUID()); 81 blink::WebString::fromUTF8(base::GenerateGUID());
77 web_media_stream_source.initialize( 82 web_media_stream_source.initialize(track_id,
78 track_id, blink::WebMediaStreamSource::TypeAudio, track_id); 83 blink::WebMediaStreamSource::TypeAudio,
84 track_id, is_remote);
79 MediaStreamAudioSource* const media_stream_source = 85 MediaStreamAudioSource* const media_stream_source =
80 new ExternalMediaStreamAudioSource(std::move(audio_source), sample_rate, 86 new ExternalMediaStreamAudioSource(std::move(audio_source), sample_rate,
81 channel_layout, frames_per_buffer); 87 channel_layout, frames_per_buffer,
88 is_remote);
82 // Takes ownership of |media_stream_source|. 89 // Takes ownership of |media_stream_source|.
83 web_media_stream_source.setExtraData(media_stream_source); 90 web_media_stream_source.setExtraData(media_stream_source);
84 91
85 blink::WebMediaStreamTrack web_media_stream_track; 92 blink::WebMediaStreamTrack web_media_stream_track;
86 web_media_stream_track.initialize(web_media_stream_source); 93 web_media_stream_track.initialize(web_media_stream_source);
87 if (!media_stream_source->ConnectToTrack(web_media_stream_track)) 94 if (!media_stream_source->ConnectToTrack(web_media_stream_track))
88 return false; 95 return false;
89 web_media_stream->addTrack(web_media_stream_track); 96 web_media_stream->addTrack(web_media_stream_track);
90 return true; 97 return true;
91 } 98 }
(...skipping 15 matching lines...) Expand all
107 const blink::WebMediaStreamTrack& video_track) { 114 const blink::WebMediaStreamTrack& video_track) {
108 if (video_track.isNull()) 115 if (video_track.isNull())
109 return; 116 return;
110 MediaStreamVideoSource* const source = 117 MediaStreamVideoSource* const source =
111 MediaStreamVideoSource::GetVideoSource(video_track.source()); 118 MediaStreamVideoSource::GetVideoSource(video_track.source());
112 if (source) 119 if (source)
113 source->RequestRefreshFrame(); 120 source->RequestRefreshFrame();
114 } 121 }
115 122
116 } // namespace content 123 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_utils.h ('k') | content/renderer/media/capturefromelement/canvas_capture_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698