OLD | NEW |
---|---|
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/renderer/media/media_recorder_handler.h" | 5 #include "content/renderer/media/media_recorder_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 // Save histogram data so we can see how much MediaStream Recorder is used. | 86 // Save histogram data so we can see how much MediaStream Recorder is used. |
87 // The histogram counts the number of calls to the JS API. | 87 // The histogram counts the number of calls to the JS API. |
88 UpdateWebRTCMethodCount(WEBKIT_MEDIA_STREAM_RECORDER); | 88 UpdateWebRTCMethodCount(WEBKIT_MEDIA_STREAM_RECORDER); |
89 | 89 |
90 if (!canSupportMimeType(type, codecs)) { | 90 if (!canSupportMimeType(type, codecs)) { |
91 DLOG(ERROR) << "Can't support " << type.utf8() | 91 DLOG(ERROR) << "Can't support " << type.utf8() |
92 << ";codecs=" << codecs.utf8(); | 92 << ";codecs=" << codecs.utf8(); |
93 return false; | 93 return false; |
94 } | 94 } |
95 use_vp9_ = base::ToLowerASCII(codecs.utf8()).find("vp9") != std::string::npos; | 95 use_vp9_ = base::ToLowerASCII(codecs.utf8()).find("vp9") != std::string::npos; |
96 media_stream_ = media_stream; | |
97 DCHECK(client); | 96 DCHECK(client); |
98 client_ = client; | 97 client_ = client; |
99 | 98 |
99 media_stream_ = media_stream; | |
100 DCHECK(MediaStream::GetMediaStream(media_stream)); | |
perkj_chrome
2016/01/07 09:18:00
no need for this check. The same will happen on th
mcasas
2016/01/08 00:14:12
Done.
| |
101 MediaStream::GetMediaStream(media_stream)->AddObserver(this); | |
102 | |
100 return true; | 103 return true; |
101 } | 104 } |
102 | 105 |
103 bool MediaRecorderHandler::start() { | 106 bool MediaRecorderHandler::start() { |
104 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 107 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
105 DCHECK(!recording_); | 108 DCHECK(!recording_); |
106 return start(0); | 109 return start(0); |
107 } | 110 } |
108 | 111 |
109 bool MediaRecorderHandler::start(int timeslice) { | 112 bool MediaRecorderHandler::start(int timeslice) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 } | 198 } |
196 | 199 |
197 void MediaRecorderHandler::resume() { | 200 void MediaRecorderHandler::resume() { |
198 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 201 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
199 DCHECK(!recording_); | 202 DCHECK(!recording_); |
200 recording_ = true; | 203 recording_ = true; |
201 for (const auto& video_recorder : video_recorders_) | 204 for (const auto& video_recorder : video_recorders_) |
202 video_recorder->Resume(); | 205 video_recorder->Resume(); |
203 } | 206 } |
204 | 207 |
208 void MediaRecorderHandler::TrackAdded(const blink::WebMediaStreamTrack& track) { | |
209 WriteData(base::StringPiece("")); | |
perkj_chrome
2016/01/07 09:18:00
Why is WriteData(base::StringPiece necessary here
mcasas
2016/01/08 00:14:12
Actually both writeData() and stop() are not neede
| |
210 stop(); | |
211 client_->failIllegalStreamModification("Track added"); | |
212 } | |
213 | |
214 void MediaRecorderHandler::TrackRemoved( | |
215 const blink::WebMediaStreamTrack& track) { | |
216 WriteData(base::StringPiece("")); | |
217 stop(); | |
218 client_->failIllegalStreamModification("Track removed"); | |
219 } | |
220 | |
205 void MediaRecorderHandler::OnEncodedVideo( | 221 void MediaRecorderHandler::OnEncodedVideo( |
206 const scoped_refptr<media::VideoFrame>& video_frame, | 222 const scoped_refptr<media::VideoFrame>& video_frame, |
207 scoped_ptr<std::string> encoded_data, | 223 scoped_ptr<std::string> encoded_data, |
208 TimeTicks timestamp, | 224 TimeTicks timestamp, |
209 bool is_key_frame) { | 225 bool is_key_frame) { |
210 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 226 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
211 if (!webm_muxer_) | 227 if (!webm_muxer_) |
212 return; | 228 return; |
213 webm_muxer_->OnEncodedVideo(video_frame, encoded_data.Pass(), timestamp, | 229 webm_muxer_->OnEncodedVideo(video_frame, encoded_data.Pass(), timestamp, |
214 is_key_frame); | 230 is_key_frame); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 recorder->OnData(audio_bus, timestamp); | 269 recorder->OnData(audio_bus, timestamp); |
254 } | 270 } |
255 | 271 |
256 void MediaRecorderHandler::SetAudioFormatForTesting( | 272 void MediaRecorderHandler::SetAudioFormatForTesting( |
257 const media::AudioParameters& params) { | 273 const media::AudioParameters& params) { |
258 for (auto* recorder : audio_recorders_) | 274 for (auto* recorder : audio_recorders_) |
259 recorder->OnSetFormat(params); | 275 recorder->OnSetFormat(params); |
260 } | 276 } |
261 | 277 |
262 } // namespace content | 278 } // namespace content |
OLD | NEW |