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 "content/renderer/media/video_track_recorder.h" | 10 #include "content/renderer/media/video_track_recorder.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; | 68 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; |
69 media_stream_.videoTracks(video_tracks); | 69 media_stream_.videoTracks(video_tracks); |
70 | 70 |
71 if (video_tracks.isEmpty()) { | 71 if (video_tracks.isEmpty()) { |
72 // TODO(mcasas): Add audio_tracks and update the code in this function | 72 // TODO(mcasas): Add audio_tracks and update the code in this function |
73 // correspondingly, see http://crbug.com/528519. As of now, only video | 73 // correspondingly, see http://crbug.com/528519. As of now, only video |
74 // tracks are supported. | 74 // tracks are supported. |
75 LOG(WARNING) << "Recording no video tracks is not implemented"; | 75 LOG(WARNING) << "Recording no video tracks is not implemented"; |
76 return false; | 76 return false; |
77 } | 77 } |
78 // TODO(mcasas): The muxer API supports only one video track. Extend it to | |
79 // several video tracks, see http://crbug.com/528523. | |
80 LOG_IF(WARNING, video_tracks.size() > 1u) << "Recording multiple video" | |
81 << " tracks is not implemented. Only recording first video track."; | |
82 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; | |
83 if (video_track.isNull()) | |
84 return false; | |
85 | 78 |
86 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = | 79 for (const blink::WebMediaStreamTrack& video_track : video_tracks) { |
87 base::Bind(&media::WebmMuxer::OnEncodedVideo, | 80 if (video_track.isNull()) { |
88 base::Unretained(webm_muxer_.get())); | 81 LOG(WARNING) << "|video_track| is null"; |
| 82 continue; |
| 83 } |
| 84 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = |
| 85 base::Bind(&media::WebmMuxer::OnEncodedVideo, |
| 86 base::Unretained(webm_muxer_.get()), |
| 87 webm_muxer_->GetNextTrackIndex()); |
| 88 video_recorders_.push_back( |
| 89 new VideoTrackRecorder(video_track, on_encoded_video_cb)); |
| 90 recording_ = true; |
| 91 } |
89 | 92 |
90 video_recorders_.push_back(new VideoTrackRecorder(video_track, | |
91 on_encoded_video_cb)); | |
92 | |
93 recording_ = true; | |
94 return true; | 93 return true; |
95 } | 94 } |
96 | 95 |
97 void MediaRecorderHandler::stop() { | 96 void MediaRecorderHandler::stop() { |
98 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 97 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
99 DCHECK(recording_); | 98 DCHECK(recording_); |
100 | 99 |
101 recording_ = false; | 100 recording_ = false; |
102 video_recorders_.clear(); | 101 video_recorders_.clear(); |
103 webm_muxer_.reset(NULL); | 102 webm_muxer_.reset(NULL); |
(...skipping 19 matching lines...) Expand all Loading... |
123 } | 122 } |
124 | 123 |
125 void MediaRecorderHandler::OnVideoFrameForTesting( | 124 void MediaRecorderHandler::OnVideoFrameForTesting( |
126 const scoped_refptr<media::VideoFrame>& frame, | 125 const scoped_refptr<media::VideoFrame>& frame, |
127 const base::TimeTicks& timestamp) { | 126 const base::TimeTicks& timestamp) { |
128 for (auto* recorder : video_recorders_) | 127 for (auto* recorder : video_recorders_) |
129 recorder->OnVideoFrameForTesting(frame, timestamp); | 128 recorder->OnVideoFrameForTesting(frame, timestamp); |
130 } | 129 } |
131 | 130 |
132 } // namespace content | 131 } // namespace content |
OLD | NEW |