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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 video ? false : base::EqualsCaseInsensitiveASCII(type, "audio/webm"); | 61 video ? false : base::EqualsCaseInsensitiveASCII(type, "audio/webm"); |
62 if (!video && !audio) | 62 if (!video && !audio) |
63 return false; | 63 return false; |
64 | 64 |
65 // Both |video| and |audio| support empty |codecs|; |type| == "video" supports | 65 // Both |video| and |audio| support empty |codecs|; |type| == "video" supports |
66 // vp8, vp9 or opus; |type| = "audio", supports only opus. | 66 // vp8, vp9 or opus; |type| = "audio", supports only opus. |
67 // http://www.webmproject.org/docs/container Sec:"HTML5 Video Type Parameters" | 67 // http://www.webmproject.org/docs/container Sec:"HTML5 Video Type Parameters" |
68 static const char* const kVideoCodecs[] = { "vp8", "vp9", "opus" }; | 68 static const char* const kVideoCodecs[] = { "vp8", "vp9", "opus" }; |
69 static const char* const kAudioCodecs[] = { "opus" }; | 69 static const char* const kAudioCodecs[] = { "opus" }; |
70 const char* const* codecs = video ? &kVideoCodecs[0] : &kAudioCodecs[0]; | 70 const char* const* codecs = video ? &kVideoCodecs[0] : &kAudioCodecs[0]; |
71 int codecs_count = video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs); | 71 const int codecs_count = |
| 72 video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs); |
72 | 73 |
73 std::vector<std::string> codecs_list; | 74 std::vector<std::string> codecs_list; |
74 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */); | 75 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */); |
75 for (const auto& codec : codecs_list) { | 76 for (const auto& codec : codecs_list) { |
76 const auto found = std::find_if( | 77 const auto found = std::find_if( |
77 &codecs[0], &codecs[codecs_count], [&codec](const char* name) { | 78 &codecs[0], &codecs[codecs_count], [&codec](const char* name) { |
78 return base::EqualsCaseInsensitiveASCII(codec, name); | 79 return base::EqualsCaseInsensitiveASCII(codec, name); |
79 }); | 80 }); |
80 if (found == &codecs[codecs_count]) | 81 if (found == &codecs[codecs_count]) |
81 return false; | 82 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 << "Only recording first video track."; | 159 << "Only recording first video track."; |
159 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; | 160 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; |
160 if (video_track.isNull()) | 161 if (video_track.isNull()) |
161 return false; | 162 return false; |
162 | 163 |
163 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = | 164 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = |
164 media::BindToCurrentLoop(base::Bind( | 165 media::BindToCurrentLoop(base::Bind( |
165 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); | 166 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); |
166 | 167 |
167 video_recorders_.push_back(new VideoTrackRecorder( | 168 video_recorders_.push_back(new VideoTrackRecorder( |
168 use_vp9_, video_track, on_encoded_video_cb, video_bits_per_second_)); | 169 use_vp9_ ? VideoTrackRecorder::CodecId::VP9 |
| 170 : VideoTrackRecorder::CodecId::VP8, |
| 171 video_track, on_encoded_video_cb, video_bits_per_second_)); |
169 } | 172 } |
170 | 173 |
171 if (use_audio_tracks) { | 174 if (use_audio_tracks) { |
172 // TODO(ajose): The muxer API supports only one audio track. Extend it to | 175 // TODO(ajose): The muxer API supports only one audio track. Extend it to |
173 // several tracks. | 176 // several tracks. |
174 LOG_IF(WARNING, audio_tracks.size() > 1u) | 177 LOG_IF(WARNING, audio_tracks.size() > 1u) |
175 << "Recording multiple audio" | 178 << "Recording multiple audio" |
176 << " tracks is not implemented. Only recording first audio track."; | 179 << " tracks is not implemented. Only recording first audio track."; |
177 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; | 180 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; |
178 if (audio_track.isNull()) | 181 if (audio_track.isNull()) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 recorder->OnData(audio_bus, timestamp); | 277 recorder->OnData(audio_bus, timestamp); |
275 } | 278 } |
276 | 279 |
277 void MediaRecorderHandler::SetAudioFormatForTesting( | 280 void MediaRecorderHandler::SetAudioFormatForTesting( |
278 const media::AudioParameters& params) { | 281 const media::AudioParameters& params) { |
279 for (auto* recorder : audio_recorders_) | 282 for (auto* recorder : audio_recorders_) |
280 recorder->OnSetFormat(params); | 283 recorder->OnSetFormat(params); |
281 } | 284 } |
282 | 285 |
283 } // namespace content | 286 } // namespace content |
OLD | NEW |