Chromium Code Reviews| 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/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // VIDEO_CODEC_PROFILE_UNKNOWN otherwise. | 94 // VIDEO_CODEC_PROFILE_UNKNOWN otherwise. |
| 95 media::VideoCodecProfile CodecIdToVEAProfile(CodecId codec); | 95 media::VideoCodecProfile CodecIdToVEAProfile(CodecId codec); |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 // A map of VEA-supported CodecId-and-VEA-profile pairs. | 98 // A map of VEA-supported CodecId-and-VEA-profile pairs. |
| 99 std::map<CodecId, media::VideoCodecProfile> codec_id_to_profile_; | 99 std::map<CodecId, media::VideoCodecProfile> codec_id_to_profile_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(CodecEnumerator); | 101 DISALLOW_COPY_AND_ASSIGN(CodecEnumerator); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 static base::LazyInstance<CodecEnumerator>::Leaky g_codec_enumerator = | 104 static CodecEnumerator* GetCodecEnumerator() { |
|
Mark Mentovai
2017/01/31 21:33:56
No need to write “static” in an unnamed namespace.
DaleCurtis
2017/01/31 22:04:33
Done.
| |
| 105 LAZY_INSTANCE_INITIALIZER; | 105 static CodecEnumerator* enumerator = new CodecEnumerator(); |
| 106 return enumerator; | |
| 107 } | |
| 106 | 108 |
| 107 CodecEnumerator::CodecEnumerator() { | 109 CodecEnumerator::CodecEnumerator() { |
| 108 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| 109 // See https://crbug.com/616659. | 111 // See https://crbug.com/616659. |
| 110 return; | 112 return; |
| 111 #endif | 113 #endif |
| 112 | 114 |
| 113 #if defined(OS_ANDROID) | 115 #if defined(OS_ANDROID) |
| 114 // See https://crbug.com/653864. | 116 // See https://crbug.com/653864. |
| 115 return; | 117 return; |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 | 1113 |
| 1112 int pixel_format = EVideoFormatType::videoFormatI420; | 1114 int pixel_format = EVideoFormatType::videoFormatI420; |
| 1113 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &pixel_format); | 1115 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &pixel_format); |
| 1114 } | 1116 } |
| 1115 #endif //#if BUILDFLAG(RTC_USE_H264) | 1117 #endif //#if BUILDFLAG(RTC_USE_H264) |
| 1116 | 1118 |
| 1117 } // anonymous namespace | 1119 } // anonymous namespace |
| 1118 | 1120 |
| 1119 // static | 1121 // static |
| 1120 VideoTrackRecorder::CodecId VideoTrackRecorder::GetPreferredCodecId() { | 1122 VideoTrackRecorder::CodecId VideoTrackRecorder::GetPreferredCodecId() { |
| 1121 return g_codec_enumerator.Get().GetPreferredCodecId(); | 1123 return GetCodecEnumerator()->GetPreferredCodecId(); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| 1124 VideoTrackRecorder::VideoTrackRecorder( | 1126 VideoTrackRecorder::VideoTrackRecorder( |
| 1125 CodecId codec, | 1127 CodecId codec, |
| 1126 const blink::WebMediaStreamTrack& track, | 1128 const blink::WebMediaStreamTrack& track, |
| 1127 const OnEncodedVideoCB& on_encoded_video_callback, | 1129 const OnEncodedVideoCB& on_encoded_video_callback, |
| 1128 int32_t bits_per_second) | 1130 int32_t bits_per_second) |
| 1129 : track_(track), | 1131 : track_(track), |
| 1130 paused_before_init_(false), | 1132 paused_before_init_(false), |
| 1131 weak_ptr_factory_(this) { | 1133 weak_ptr_factory_(this) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 int32_t bits_per_second, | 1185 int32_t bits_per_second, |
| 1184 const scoped_refptr<media::VideoFrame>& frame, | 1186 const scoped_refptr<media::VideoFrame>& frame, |
| 1185 base::TimeTicks capture_time) { | 1187 base::TimeTicks capture_time) { |
| 1186 DVLOG(3) << __func__ << frame->visible_rect().size().ToString(); | 1188 DVLOG(3) << __func__ << frame->visible_rect().size().ToString(); |
| 1187 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 1189 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 1188 | 1190 |
| 1189 MediaStreamVideoSink::DisconnectFromTrack(); | 1191 MediaStreamVideoSink::DisconnectFromTrack(); |
| 1190 | 1192 |
| 1191 const gfx::Size& input_size = frame->visible_rect().size(); | 1193 const gfx::Size& input_size = frame->visible_rect().size(); |
| 1192 const auto& vea_supported_profile = | 1194 const auto& vea_supported_profile = |
| 1193 g_codec_enumerator.Get().CodecIdToVEAProfile(codec); | 1195 GetCodecEnumerator()->CodecIdToVEAProfile(codec); |
| 1194 if (vea_supported_profile != media::VIDEO_CODEC_PROFILE_UNKNOWN && | 1196 if (vea_supported_profile != media::VIDEO_CODEC_PROFILE_UNKNOWN && |
| 1195 input_size.width() >= kVEAEncoderMinResolutionWidth && | 1197 input_size.width() >= kVEAEncoderMinResolutionWidth && |
| 1196 input_size.height() >= kVEAEncoderMinResolutionHeight) { | 1198 input_size.height() >= kVEAEncoderMinResolutionHeight) { |
| 1197 encoder_ = new VEAEncoder(on_encoded_video_callback, bits_per_second, | 1199 encoder_ = new VEAEncoder(on_encoded_video_callback, bits_per_second, |
| 1198 vea_supported_profile, input_size); | 1200 vea_supported_profile, input_size); |
| 1199 } else { | 1201 } else { |
| 1200 switch (codec) { | 1202 switch (codec) { |
| 1201 #if BUILDFLAG(RTC_USE_H264) | 1203 #if BUILDFLAG(RTC_USE_H264) |
| 1202 case CodecId::H264: | 1204 case CodecId::H264: |
| 1203 encoder_ = | 1205 encoder_ = |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1218 encoder_->SetPaused(paused_before_init_); | 1220 encoder_->SetPaused(paused_before_init_); |
| 1219 | 1221 |
| 1220 // StartFrameEncode() will be called on Render IO thread. | 1222 // StartFrameEncode() will be called on Render IO thread. |
| 1221 MediaStreamVideoSink::ConnectToTrack( | 1223 MediaStreamVideoSink::ConnectToTrack( |
| 1222 track_, | 1224 track_, |
| 1223 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), | 1225 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), |
| 1224 false); | 1226 false); |
| 1225 } | 1227 } |
| 1226 | 1228 |
| 1227 } // namespace content | 1229 } // namespace content |
| OLD | NEW |