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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 const std::string type(web_type.utf8()); | 58 const std::string type(web_type.utf8()); |
59 const bool video = base::EqualsCaseInsensitiveASCII(type, "video/webm"); | 59 const bool video = base::EqualsCaseInsensitiveASCII(type, "video/webm"); |
60 const bool audio = | 60 const bool audio = |
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* kVideoCodecs[] = { "vp8", "vp9", "opus" }; | 68 static const char* const kVideoCodecs[] = { "vp8", "vp9", "opus" }; |
69 static const char* kAudioCodecs[] = { "opus" }; | 69 static const char* const kAudioCodecs[] = { "opus" }; |
70 const char** 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); |
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) { |
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]) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 recorder->OnData(audio_bus, timestamp); | 274 recorder->OnData(audio_bus, timestamp); |
275 } | 275 } |
276 | 276 |
277 void MediaRecorderHandler::SetAudioFormatForTesting( | 277 void MediaRecorderHandler::SetAudioFormatForTesting( |
278 const media::AudioParameters& params) { | 278 const media::AudioParameters& params) { |
279 for (auto* recorder : audio_recorders_) | 279 for (auto* recorder : audio_recorders_) |
280 recorder->OnSetFormat(params); | 280 recorder->OnSetFormat(params); |
281 } | 281 } |
282 | 282 |
283 } // namespace content | 283 } // namespace content |
OLD | NEW |