Chromium Code Reviews| Index: content/renderer/media_recorder/media_recorder_handler.cc |
| diff --git a/content/renderer/media_recorder/media_recorder_handler.cc b/content/renderer/media_recorder/media_recorder_handler.cc |
| index 544665f530f4367af01c1fe71b13795221baed12..18c39eb07b305ec8b7709e2d1760be3ab7e7aff4 100644 |
| --- a/content/renderer/media_recorder/media_recorder_handler.cc |
| +++ b/content/renderer/media_recorder/media_recorder_handler.cc |
| @@ -55,6 +55,23 @@ media::VideoCodec CodecIdToMediaVideoCodec(VideoTrackRecorder::CodecId id) { |
| return media::kUnknownVideoCodec; |
| } |
| +// Extracts the first recognised CodecId of |codecs| or CodecId::LAST if none |
| +// of them is known. |
| +VideoTrackRecorder::CodecId StringToCodecId(const blink::WebString& codecs) { |
| + const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); |
| + |
| + if (codecs_str.find("vp8") != std::string::npos) |
| + return VideoTrackRecorder::CodecId::VP8; |
| + else if (codecs_str.find("vp9") != std::string::npos) |
| + return VideoTrackRecorder::CodecId::VP9; |
| +#if BUILDFLAG(RTC_USE_H264) |
|
emircan
2017/04/25 02:04:30
We should use IS_H264_SUPPORTED as the android cl
|
| + else if (codecs_str.find("h264") != std::string::npos || |
| + codecs_str.find("avc1") != std::string::npos) |
| + return VideoTrackRecorder::CodecId::H264; |
| +#endif |
| + return VideoTrackRecorder::CodecId::LAST; |
| +} |
| + |
| void OnEncodingInfoError( |
| std::unique_ptr<WebMediaCapabilitiesQueryCallbacks> callbacks) { |
| callbacks->OnError(); |
| @@ -137,22 +154,13 @@ bool MediaRecorderHandler::Initialize( |
| } |
| // Once established that we support the codec(s), hunt then individually. |
| - const std::string& codecs_str = ToLowerASCII(codecs.Utf8()); |
| - if (codecs_str.find("vp8") != std::string::npos) |
| - codec_id_ = VideoTrackRecorder::CodecId::VP8; |
| - else if (codecs_str.find("vp9") != std::string::npos) |
| - codec_id_ = VideoTrackRecorder::CodecId::VP9; |
| -#if defined(IS_H264_SUPPORTED) |
| - else if (codecs_str.find("h264") != std::string::npos) |
| - codec_id_ = VideoTrackRecorder::CodecId::H264; |
| - else if (codecs_str.find("avc1") != std::string::npos) |
| - codec_id_ = VideoTrackRecorder::CodecId::H264; |
| -#endif |
| - else |
| - codec_id_ = VideoTrackRecorder::GetPreferredCodecId(); |
| + const VideoTrackRecorder::CodecId codec_id = StringToCodecId(codecs); |
| + codec_id_ = (codec_id != VideoTrackRecorder::CodecId::LAST) |
| + ? codec_id |
| + : VideoTrackRecorder::GetPreferredCodecId(); |
| - DVLOG_IF(1, codecs_str.empty()) << "Falling back to preferred codec id " |
| - << static_cast<int>(codec_id_); |
| + DVLOG_IF(1, codec_id == VideoTrackRecorder::CodecId::LAST) |
| + << "Falling back to preferred codec id " << static_cast<int>(codec_id_); |
| media_stream_ = media_stream; |
| DCHECK(client); |
| @@ -318,8 +326,16 @@ void MediaRecorderHandler::EncodingInfo( |
| } |
| info->supported = CanSupportMimeType(web_type, web_codecs); |
| + |
| + if (configuration.video_configuration && info->supported) { |
| + info->smooth = VideoTrackRecorder::IsEncodingLikelyAccelerated( |
|
chcunningham
2017/04/24 20:58:17
Please build this out more to consider system spec
emircan
2017/04/25 02:04:30
We do not have power metrics currently, so we can
mcasas
2017/04/25 18:16:07
Please note that IsEncodingLikelyAccelerated() inc
chcunningham
2017/04/25 18:52:52
Totally fine for the initial implementation to be
|
| + StringToCodecId(web_codecs), configuration.video_configuration->width, |
| + configuration.video_configuration->height); |
| + info->power_efficient = info->smooth; |
| + } |
| DVLOG(1) << "type: " << web_type.Ascii() << ", params:" << web_codecs.Ascii() |
| - << " is" << (info->supported ? " supported" : " NOT supported"); |
| + << " is" << (info->supported ? " supported" : " NOT supported") |
| + << " and" << (info->smooth ? " smooth" : " NOT smooth"); |
| scoped_callbacks.PassCallbacks()->OnSuccess(std::move(info)); |
| } |