OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1207 } |
1208 | 1208 |
1209 bool is_vp9_hw_supported = jni->CallStaticBooleanMethod( | 1209 bool is_vp9_hw_supported = jni->CallStaticBooleanMethod( |
1210 j_encoder_class, | 1210 j_encoder_class, |
1211 GetStaticMethodID(jni, j_encoder_class, "isVp9HwSupported", "()Z")); | 1211 GetStaticMethodID(jni, j_encoder_class, "isVp9HwSupported", "()Z")); |
1212 CHECK_EXCEPTION(jni); | 1212 CHECK_EXCEPTION(jni); |
1213 if (is_vp9_hw_supported) { | 1213 if (is_vp9_hw_supported) { |
1214 ALOGD << "VP9 HW Encoder supported."; | 1214 ALOGD << "VP9 HW Encoder supported."; |
1215 supported_codecs_.push_back(cricket::VideoCodec("VP9")); | 1215 supported_codecs_.push_back(cricket::VideoCodec("VP9")); |
1216 } | 1216 } |
1217 | 1217 supported_codecs_with_h264_hp_ = supported_codecs_; |
1218 bool is_h264_hw_supported = jni->CallStaticBooleanMethod( | |
1219 j_encoder_class, | |
1220 GetStaticMethodID(jni, j_encoder_class, "isH264HwSupported", "()Z")); | |
1221 CHECK_EXCEPTION(jni); | |
1222 if (is_h264_hw_supported) { | |
1223 ALOGD << "H.264 HW Encoder supported."; | |
1224 // TODO(magjed): Push Constrained High profile as well when negotiation is | |
1225 // ready, http://crbug/webrtc/6337. We can negotiate Constrained High | |
1226 // profile as long as we have decode support for it and still send Baseline | |
1227 // since Baseline is a subset of the High profile. | |
1228 cricket::VideoCodec constrained_baseline(cricket::kH264CodecName); | |
1229 const webrtc::H264::ProfileLevelId constrained_baseline_profile( | |
1230 webrtc::H264::kProfileConstrainedBaseline, webrtc::H264::kLevel3_1); | |
1231 constrained_baseline.SetParam( | |
1232 cricket::kH264FmtpProfileLevelId, | |
1233 *webrtc::H264::ProfileLevelIdToString(constrained_baseline_profile)); | |
1234 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); | |
1235 constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1"); | |
1236 supported_codecs_.push_back(constrained_baseline); | |
1237 } | |
1238 | 1218 |
1239 // Check if high profile is supported by decoder. If yes, encoder can always | 1219 // Check if high profile is supported by decoder. If yes, encoder can always |
1240 // fall back to baseline profile as a subset as high profile. | 1220 // fall back to baseline profile as a subset as high profile. |
1241 supported_codecs_with_h264_hp_ = supported_codecs_; | |
1242 bool is_h264_high_profile_hw_supported = jni->CallStaticBooleanMethod( | 1221 bool is_h264_high_profile_hw_supported = jni->CallStaticBooleanMethod( |
1243 j_decoder_class, | 1222 j_decoder_class, |
1244 GetStaticMethodID(jni, j_decoder_class, "isH264HighProfileHwSupported", | 1223 GetStaticMethodID(jni, j_decoder_class, "isH264HighProfileHwSupported", |
1245 "()Z")); | 1224 "()Z")); |
1246 CHECK_EXCEPTION(jni); | 1225 CHECK_EXCEPTION(jni); |
1247 if (is_h264_high_profile_hw_supported) { | 1226 if (is_h264_high_profile_hw_supported) { |
1248 ALOGD << "H.264 High Profile HW Encoder supported."; | 1227 ALOGD << "H.264 High Profile HW Encoder supported."; |
1249 // TODO(magjed): Enumerate actual level instead of using hardcoded level | 1228 // TODO(magjed): Enumerate actual level instead of using hardcoded level |
1250 // 3.1. Level 3.1 is 1280x720@30fps which is enough for now. | 1229 // 3.1. Level 3.1 is 1280x720@30fps which is enough for now. |
1251 cricket::VideoCodec constrained_high(cricket::kH264CodecName); | 1230 cricket::VideoCodec constrained_high(cricket::kH264CodecName); |
1252 const webrtc::H264::ProfileLevelId constrained_high_profile( | 1231 const webrtc::H264::ProfileLevelId constrained_high_profile( |
1253 webrtc::H264::kProfileConstrainedHigh, webrtc::H264::kLevel3_1); | 1232 webrtc::H264::kProfileConstrainedHigh, webrtc::H264::kLevel3_1); |
1254 constrained_high.SetParam( | 1233 constrained_high.SetParam( |
1255 cricket::kH264FmtpProfileLevelId, | 1234 cricket::kH264FmtpProfileLevelId, |
1256 *webrtc::H264::ProfileLevelIdToString(constrained_high_profile)); | 1235 *webrtc::H264::ProfileLevelIdToString(constrained_high_profile)); |
1257 constrained_high.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); | 1236 constrained_high.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); |
1258 constrained_high.SetParam(cricket::kH264FmtpPacketizationMode, "1"); | 1237 constrained_high.SetParam(cricket::kH264FmtpPacketizationMode, "1"); |
1259 supported_codecs_with_h264_hp_.push_back(constrained_high); | 1238 supported_codecs_with_h264_hp_.push_back(constrained_high); |
1260 } | 1239 } |
| 1240 |
| 1241 bool is_h264_hw_supported = jni->CallStaticBooleanMethod( |
| 1242 j_encoder_class, |
| 1243 GetStaticMethodID(jni, j_encoder_class, "isH264HwSupported", "()Z")); |
| 1244 CHECK_EXCEPTION(jni); |
| 1245 if (is_h264_hw_supported) { |
| 1246 ALOGD << "H.264 HW Encoder supported."; |
| 1247 // TODO(magjed): Push Constrained High profile as well when negotiation is |
| 1248 // ready, http://crbug/webrtc/6337. We can negotiate Constrained High |
| 1249 // profile as long as we have decode support for it and still send Baseline |
| 1250 // since Baseline is a subset of the High profile. |
| 1251 cricket::VideoCodec constrained_baseline(cricket::kH264CodecName); |
| 1252 const webrtc::H264::ProfileLevelId constrained_baseline_profile( |
| 1253 webrtc::H264::kProfileConstrainedBaseline, webrtc::H264::kLevel3_1); |
| 1254 constrained_baseline.SetParam( |
| 1255 cricket::kH264FmtpProfileLevelId, |
| 1256 *webrtc::H264::ProfileLevelIdToString(constrained_baseline_profile)); |
| 1257 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); |
| 1258 constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1"); |
| 1259 supported_codecs_.push_back(constrained_baseline); |
| 1260 supported_codecs_with_h264_hp_.push_back(constrained_baseline); |
| 1261 } |
1261 } | 1262 } |
1262 | 1263 |
1263 MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() { | 1264 MediaCodecVideoEncoderFactory::~MediaCodecVideoEncoderFactory() { |
1264 ALOGD << "MediaCodecVideoEncoderFactory dtor"; | 1265 ALOGD << "MediaCodecVideoEncoderFactory dtor"; |
1265 if (egl_context_) { | 1266 if (egl_context_) { |
1266 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 1267 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
1267 jni->DeleteGlobalRef(egl_context_); | 1268 jni->DeleteGlobalRef(egl_context_); |
1268 } | 1269 } |
1269 } | 1270 } |
1270 | 1271 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 return supported_codecs_; | 1307 return supported_codecs_; |
1307 } | 1308 } |
1308 | 1309 |
1309 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1310 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1310 webrtc::VideoEncoder* encoder) { | 1311 webrtc::VideoEncoder* encoder) { |
1311 ALOGD << "Destroy video encoder."; | 1312 ALOGD << "Destroy video encoder."; |
1312 delete encoder; | 1313 delete encoder; |
1313 } | 1314 } |
1314 | 1315 |
1315 } // namespace webrtc_jni | 1316 } // namespace webrtc_jni |
OLD | NEW |