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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #define ALOGV(...) | 79 #define ALOGV(...) |
80 #endif | 80 #endif |
81 #define ALOGD LOG_TAG(rtc::LS_INFO, TAG_ENCODER) | 81 #define ALOGD LOG_TAG(rtc::LS_INFO, TAG_ENCODER) |
82 #define ALOGW LOG_TAG(rtc::LS_WARNING, TAG_ENCODER) | 82 #define ALOGW LOG_TAG(rtc::LS_WARNING, TAG_ENCODER) |
83 #define ALOGE LOG_TAG(rtc::LS_ERROR, TAG_ENCODER) | 83 #define ALOGE LOG_TAG(rtc::LS_ERROR, TAG_ENCODER) |
84 | 84 |
85 namespace { | 85 namespace { |
86 // Maximum time limit between incoming frames before requesting a key frame. | 86 // Maximum time limit between incoming frames before requesting a key frame. |
87 const size_t kFrameDiffThresholdMs = 1100; | 87 const size_t kFrameDiffThresholdMs = 1100; |
88 const int kMinKeyFrameInterval = 2; | 88 const int kMinKeyFrameInterval = 2; |
| 89 |
| 90 const int kLowVp8QpThreshold = 29; |
| 91 const int kHighVp8QpThreshold = 95; |
| 92 |
| 93 const int kLowH264QpThreshold = 24; |
| 94 const int kHighH264QpThreshold = 37; |
89 } // namespace | 95 } // namespace |
90 | 96 |
91 // MediaCodecVideoEncoder is a webrtc::VideoEncoder implementation that uses | 97 // MediaCodecVideoEncoder is a webrtc::VideoEncoder implementation that uses |
92 // Android's MediaCodec SDK API behind the scenes to implement (hopefully) | 98 // Android's MediaCodec SDK API behind the scenes to implement (hopefully) |
93 // HW-backed video encode. This C++ class is implemented as a very thin shim, | 99 // HW-backed video encode. This C++ class is implemented as a very thin shim, |
94 // delegating all of the interesting work to org.webrtc.MediaCodecVideoEncoder. | 100 // delegating all of the interesting work to org.webrtc.MediaCodecVideoEncoder. |
95 // MediaCodecVideoEncoder is created, operated, and destroyed on a single | 101 // MediaCodecVideoEncoder is created, operated, and destroyed on a single |
96 // thread, currently the libjingle Worker thread. | 102 // thread, currently the libjingle Worker thread. |
97 class MediaCodecVideoEncoder : public webrtc::VideoEncoder, | 103 class MediaCodecVideoEncoder : public webrtc::VideoEncoder, |
98 public rtc::MessageHandler { | 104 public rtc::MessageHandler { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } else if (codecType_ != kVideoCodecVP9) { | 396 } else if (codecType_ != kVideoCodecVP9) { |
391 scale_ = true; | 397 scale_ = true; |
392 } | 398 } |
393 | 399 |
394 ALOGD << "InitEncode request: " << init_width << " x " << init_height; | 400 ALOGD << "InitEncode request: " << init_width << " x " << init_height; |
395 ALOGD << "Encoder automatic resize " << (scale_ ? "enabled" : "disabled"); | 401 ALOGD << "Encoder automatic resize " << (scale_ ? "enabled" : "disabled"); |
396 | 402 |
397 if (scale_) { | 403 if (scale_) { |
398 if (codecType_ == kVideoCodecVP8) { | 404 if (codecType_ == kVideoCodecVP8) { |
399 quality_scaler_.Init( | 405 quality_scaler_.Init( |
400 QualityScaler::kLowVp8QpThreshold, QualityScaler::kBadVp8QpThreshold, | 406 kLowVp8QpThreshold, kHighVp8QpThreshold, |
401 codec_settings->startBitrate, codec_settings->width, | 407 codec_settings->startBitrate, codec_settings->width, |
402 codec_settings->height, codec_settings->maxFramerate); | 408 codec_settings->height, codec_settings->maxFramerate); |
403 } else if (codecType_ == kVideoCodecH264) { | 409 } else if (codecType_ == kVideoCodecH264) { |
404 quality_scaler_.Init(QualityScaler::kLowH264QpThreshold, | 410 quality_scaler_.Init(kLowH264QpThreshold, |
405 QualityScaler::kBadH264QpThreshold, | 411 kHighH264QpThreshold, |
406 codec_settings->startBitrate, codec_settings->width, | 412 codec_settings->startBitrate, codec_settings->width, |
407 codec_settings->height, | 413 codec_settings->height, |
408 codec_settings->maxFramerate); | 414 codec_settings->maxFramerate); |
409 } else { | 415 } else { |
410 // When adding codec support to additional hardware codecs, also configure | 416 // When adding codec support to additional hardware codecs, also configure |
411 // their QP thresholds for scaling. | 417 // their QP thresholds for scaling. |
412 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; | 418 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; |
413 scale_ = false; | 419 scale_ = false; |
414 } | 420 } |
415 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); | 421 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 return supported_codecs_; | 1303 return supported_codecs_; |
1298 } | 1304 } |
1299 | 1305 |
1300 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1306 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1301 webrtc::VideoEncoder* encoder) { | 1307 webrtc::VideoEncoder* encoder) { |
1302 ALOGD << "Destroy video encoder."; | 1308 ALOGD << "Destroy video encoder."; |
1303 delete encoder; | 1309 delete encoder; |
1304 } | 1310 } |
1305 | 1311 |
1306 } // namespace webrtc_jni | 1312 } // namespace webrtc_jni |
OLD | NEW |