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 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 return; | 1068 return; |
1069 } | 1069 } |
1070 | 1070 |
1071 int pixel_format = EVideoFormatType::videoFormatI420; | 1071 int pixel_format = EVideoFormatType::videoFormatI420; |
1072 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &pixel_format); | 1072 openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &pixel_format); |
1073 } | 1073 } |
1074 #endif //#if BUILDFLAG(RTC_USE_H264) | 1074 #endif //#if BUILDFLAG(RTC_USE_H264) |
1075 | 1075 |
1076 } // anonymous namespace | 1076 } // anonymous namespace |
1077 | 1077 |
1078 // static | |
1079 VideoTrackRecorder::CodecId VideoTrackRecorder::GetPreferredCodec() { | |
1080 CodecId codec_id = CodecId::VP8; | |
1081 while (codec_id != VideoTrackRecorder::CodecId::LAST) { | |
1082 if (CodecIdToVEAProfile(codec_id) != media::VIDEO_CODEC_PROFILE_UNKNOWN) | |
emircan
2017/01/11 18:01:58
We end up calling CodecIdToVEAProfile() at least 3
mcasas
2017/01/11 21:40:48
Ok, you convinced me to cut deeper and made a sing
| |
1083 return codec_id; | |
1084 | |
1085 switch (codec_id) { | |
chfremer
2017/01/11 17:34:52
Why not use a for-loop to check a fixed list of ca
mcasas
2017/01/11 21:40:48
I wanted to have a compiler-enforced way to guaran
| |
1086 case CodecId::VP8: | |
1087 codec_id = CodecId::VP9; | |
1088 break; | |
1089 case CodecId::VP9: | |
1090 codec_id = CodecId::H264; | |
1091 break; | |
1092 case CodecId::H264: | |
1093 codec_id = CodecId::LAST; | |
1094 break; | |
1095 case CodecId::LAST: | |
1096 NOTREACHED(); | |
1097 } | |
1098 } | |
1099 return CodecId::VP8; | |
1100 } | |
1101 | |
1078 VideoTrackRecorder::VideoTrackRecorder( | 1102 VideoTrackRecorder::VideoTrackRecorder( |
1079 CodecId codec, | 1103 CodecId codec, |
1080 const blink::WebMediaStreamTrack& track, | 1104 const blink::WebMediaStreamTrack& track, |
1081 const OnEncodedVideoCB& on_encoded_video_callback, | 1105 const OnEncodedVideoCB& on_encoded_video_callback, |
1082 int32_t bits_per_second) | 1106 int32_t bits_per_second) |
1083 : track_(track), | 1107 : track_(track), |
1084 paused_before_init_(false), | 1108 paused_before_init_(false), |
1085 weak_ptr_factory_(this) { | 1109 weak_ptr_factory_(this) { |
1086 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 1110 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
1087 DCHECK(!track_.isNull()); | 1111 DCHECK(!track_.isNull()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 encoder_->SetPaused(paused_before_init_); | 1195 encoder_->SetPaused(paused_before_init_); |
1172 | 1196 |
1173 // StartFrameEncode() will be called on Render IO thread. | 1197 // StartFrameEncode() will be called on Render IO thread. |
1174 MediaStreamVideoSink::ConnectToTrack( | 1198 MediaStreamVideoSink::ConnectToTrack( |
1175 track_, | 1199 track_, |
1176 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), | 1200 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), |
1177 false); | 1201 false); |
1178 } | 1202 } |
1179 | 1203 |
1180 } // namespace content | 1204 } // namespace content |
OLD | NEW |