Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: content/renderer/media/media_recorder_handler.cc

Issue 2585533002: MediaRecorder (cleanup): support mime type video/x-matroska and codec=avc1 to the list (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool MediaRecorderHandler::canSupportMimeType( 67 bool MediaRecorderHandler::canSupportMimeType(
68 const blink::WebString& web_type, 68 const blink::WebString& web_type,
69 const blink::WebString& web_codecs) { 69 const blink::WebString& web_codecs) {
70 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 70 DCHECK(main_render_thread_checker_.CalledOnValidThread());
71 // An empty |web_type| means MediaRecorderHandler can choose its preferred 71 // An empty |web_type| means MediaRecorderHandler can choose its preferred
72 // codecs. 72 // codecs.
73 if (web_type.isEmpty()) 73 if (web_type.isEmpty())
74 return true; 74 return true;
75 75
76 const std::string type(web_type.utf8()); 76 const std::string type(web_type.utf8());
77 const bool video = base::EqualsCaseInsensitiveASCII(type, "video/webm"); 77 const bool video = base::EqualsCaseInsensitiveASCII(type, "video/webm") ||
78 base::EqualsCaseInsensitiveASCII(type, "video/x-matroska");
78 const bool audio = 79 const bool audio =
79 video ? false : base::EqualsCaseInsensitiveASCII(type, "audio/webm"); 80 video ? false : base::EqualsCaseInsensitiveASCII(type, "audio/webm");
80 if (!video && !audio) 81 if (!video && !audio)
81 return false; 82 return false;
82 83
83 // Both |video| and |audio| support empty |codecs|; |type| == "video" supports 84 // Both |video| and |audio| support empty |codecs|; |type| == "video" supports
84 // vp8, vp9 or opus; |type| = "audio", supports only opus. 85 // vp8, vp9, h264 and avc1 or opus; |type| = "audio", supports only opus.
85 // http://www.webmproject.org/docs/container Sec:"HTML5 Video Type Parameters" 86 // http://www.webmproject.org/docs/container Sec:"HTML5 Video Type Parameters"
86 static const char* const kVideoCodecs[] = { "vp8", "vp9", "h264", "opus" }; 87 static const char* const kVideoCodecs[] = {"vp8", "vp9", "h264", "avc1",
88 "opus"};
87 static const char* const kAudioCodecs[] = { "opus" }; 89 static const char* const kAudioCodecs[] = { "opus" };
88 const char* const* codecs = video ? &kVideoCodecs[0] : &kAudioCodecs[0]; 90 const char* const* codecs = video ? &kVideoCodecs[0] : &kAudioCodecs[0];
89 const int codecs_count = 91 const int codecs_count =
90 video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs); 92 video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs);
91 93
92 std::vector<std::string> codecs_list; 94 std::vector<std::string> codecs_list;
93 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */); 95 media::ParseCodecString(web_codecs.utf8(), &codecs_list, true /* strip */);
94 for (const auto& codec : codecs_list) { 96 for (const auto& codec : codecs_list) {
95 auto* const* found = std::find_if( 97 auto* const* found = std::find_if(
96 &codecs[0], &codecs[codecs_count], [&codec](const char* name) { 98 &codecs[0], &codecs[codecs_count], [&codec](const char* name) {
(...skipping 25 matching lines...) Expand all
122 124
123 // Once established that we support the codec(s), hunt then individually. 125 // Once established that we support the codec(s), hunt then individually.
124 const std::string& codecs_str = ToLowerASCII(codecs.utf8()); 126 const std::string& codecs_str = ToLowerASCII(codecs.utf8());
125 if (codecs_str.find("vp8") != std::string::npos) 127 if (codecs_str.find("vp8") != std::string::npos)
126 codec_id_ = VideoTrackRecorder::CodecId::VP8; 128 codec_id_ = VideoTrackRecorder::CodecId::VP8;
127 else if (codecs_str.find("vp9") != std::string::npos) 129 else if (codecs_str.find("vp9") != std::string::npos)
128 codec_id_ = VideoTrackRecorder::CodecId::VP9; 130 codec_id_ = VideoTrackRecorder::CodecId::VP9;
129 #if BUILDFLAG(RTC_USE_H264) 131 #if BUILDFLAG(RTC_USE_H264)
130 else if (codecs_str.find("h264") != std::string::npos) 132 else if (codecs_str.find("h264") != std::string::npos)
131 codec_id_ = VideoTrackRecorder::CodecId::H264; 133 codec_id_ = VideoTrackRecorder::CodecId::H264;
134 else if (codecs_str.find("avc1") != std::string::npos)
135 codec_id_ = VideoTrackRecorder::CodecId::H264;
132 #endif 136 #endif
133 137
134 media_stream_ = media_stream; 138 media_stream_ = media_stream;
135 DCHECK(client); 139 DCHECK(client);
136 client_ = client; 140 client_ = client;
137 141
138 audio_bits_per_second_ = audio_bits_per_second; 142 audio_bits_per_second_ = audio_bits_per_second;
139 video_bits_per_second_ = video_bits_per_second; 143 video_bits_per_second_ = video_bits_per_second;
140 return true; 144 return true;
141 } 145 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 recorder->OnData(audio_bus, timestamp); 307 recorder->OnData(audio_bus, timestamp);
304 } 308 }
305 309
306 void MediaRecorderHandler::SetAudioFormatForTesting( 310 void MediaRecorderHandler::SetAudioFormatForTesting(
307 const media::AudioParameters& params) { 311 const media::AudioParameters& params) {
308 for (const auto& recorder : audio_recorders_) 312 for (const auto& recorder : audio_recorders_)
309 recorder->OnSetFormat(params); 313 recorder->OnSetFormat(params);
310 } 314 }
311 315
312 } // namespace content 316 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_media_recorder_browsertest.cc ('k') | content/test/data/media/mediarecorder_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698