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 int codecs_count = video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs); |
emircan
2016/04/14 22:00:10
const
mcasas
2016/04/14 22:14:56
Done.
| |
72 | 72 |
73 std::vector<std::string> codecs_list; | 73 std::vector<std::string> codecs_list; |
74 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */); | 74 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */); |
75 for (const auto& codec : codecs_list) { | 75 for (const auto& codec : codecs_list) { |
76 const auto found = std::find_if( | 76 const auto found = std::find_if( |
77 &codecs[0], &codecs[codecs_count], [&codec](const char* name) { | 77 &codecs[0], &codecs[codecs_count], [&codec](const char* name) { |
emircan
2016/04/14 22:00:10
std:end(codecs)?
mcasas
2016/04/14 22:14:56
Compiler complained that can't apply std::end
to a
| |
78 return base::EqualsCaseInsensitiveASCII(codec, name); | 78 return base::EqualsCaseInsensitiveASCII(codec, name); |
79 }); | 79 }); |
80 if (found == &codecs[codecs_count]) | 80 if (found == &codecs[codecs_count]) |
81 return false; | 81 return false; |
82 } | 82 } |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 bool MediaRecorderHandler::initialize( | 86 bool MediaRecorderHandler::initialize( |
87 blink::WebMediaRecorderHandlerClient* client, | 87 blink::WebMediaRecorderHandlerClient* client, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 << "Only recording first video track."; | 158 << "Only recording first video track."; |
159 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; | 159 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; |
160 if (video_track.isNull()) | 160 if (video_track.isNull()) |
161 return false; | 161 return false; |
162 | 162 |
163 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = | 163 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = |
164 media::BindToCurrentLoop(base::Bind( | 164 media::BindToCurrentLoop(base::Bind( |
165 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); | 165 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); |
166 | 166 |
167 video_recorders_.push_back(new VideoTrackRecorder( | 167 video_recorders_.push_back(new VideoTrackRecorder( |
168 use_vp9_, video_track, on_encoded_video_cb, video_bits_per_second_)); | 168 use_vp9_ ? VideoTrackRecorder::CodecId::VP9 |
169 : VideoTrackRecorder::CodecId::VP8, | |
170 video_track, on_encoded_video_cb, video_bits_per_second_)); | |
169 } | 171 } |
170 | 172 |
171 if (use_audio_tracks) { | 173 if (use_audio_tracks) { |
172 // TODO(ajose): The muxer API supports only one audio track. Extend it to | 174 // TODO(ajose): The muxer API supports only one audio track. Extend it to |
173 // several tracks. | 175 // several tracks. |
174 LOG_IF(WARNING, audio_tracks.size() > 1u) | 176 LOG_IF(WARNING, audio_tracks.size() > 1u) |
175 << "Recording multiple audio" | 177 << "Recording multiple audio" |
176 << " tracks is not implemented. Only recording first audio track."; | 178 << " tracks is not implemented. Only recording first audio track."; |
177 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; | 179 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; |
178 if (audio_track.isNull()) | 180 if (audio_track.isNull()) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 recorder->OnData(audio_bus, timestamp); | 276 recorder->OnData(audio_bus, timestamp); |
275 } | 277 } |
276 | 278 |
277 void MediaRecorderHandler::SetAudioFormatForTesting( | 279 void MediaRecorderHandler::SetAudioFormatForTesting( |
278 const media::AudioParameters& params) { | 280 const media::AudioParameters& params) { |
279 for (auto* recorder : audio_recorders_) | 281 for (auto* recorder : audio_recorders_) |
280 recorder->OnSetFormat(params); | 282 recorder->OnSetFormat(params); |
281 } | 283 } |
282 | 284 |
283 } // namespace content | 285 } // namespace content |
OLD | NEW |