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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 jni, j_output_buffer_info_class, "presentationTimestampUs", "J"); | 347 jni, j_output_buffer_info_class, "presentationTimestampUs", "J"); |
348 CHECK_EXCEPTION(jni) << "MediaCodecVideoEncoder ctor failed"; | 348 CHECK_EXCEPTION(jni) << "MediaCodecVideoEncoder ctor failed"; |
349 srand(time(NULL)); | 349 srand(time(NULL)); |
350 AllowBlockingCalls(); | 350 AllowBlockingCalls(); |
351 } | 351 } |
352 | 352 |
353 int32_t MediaCodecVideoEncoder::InitEncode( | 353 int32_t MediaCodecVideoEncoder::InitEncode( |
354 const webrtc::VideoCodec* codec_settings, | 354 const webrtc::VideoCodec* codec_settings, |
355 int32_t /* number_of_cores */, | 355 int32_t /* number_of_cores */, |
356 size_t /* max_payload_size */) { | 356 size_t /* max_payload_size */) { |
357 const int kMinDimension = 180; | |
358 if (codec_settings == NULL) { | 357 if (codec_settings == NULL) { |
359 ALOGE << "NULL VideoCodec instance"; | 358 ALOGE << "NULL VideoCodec instance"; |
360 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 359 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
361 } | 360 } |
362 // Factory should guard against other codecs being used with us. | 361 // Factory should guard against other codecs being used with us. |
363 RTC_CHECK(codec_settings->codecType == codecType_) | 362 RTC_CHECK(codec_settings->codecType == codecType_) |
364 << "Unsupported codec " << codec_settings->codecType << " for " | 363 << "Unsupported codec " << codec_settings->codecType << " for " |
365 << codecType_; | 364 << codecType_; |
366 | 365 |
367 codec_mode_ = codec_settings->mode; | 366 codec_mode_ = codec_settings->mode; |
(...skipping 24 matching lines...) Expand all Loading... |
392 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, | 391 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, |
393 codec_settings->startBitrate, codec_settings->width, | 392 codec_settings->startBitrate, codec_settings->width, |
394 codec_settings->height, | 393 codec_settings->height, |
395 codec_settings->maxFramerate); | 394 codec_settings->maxFramerate); |
396 } else { | 395 } else { |
397 // When adding codec support to additional hardware codecs, also configure | 396 // When adding codec support to additional hardware codecs, also configure |
398 // their QP thresholds for scaling. | 397 // their QP thresholds for scaling. |
399 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; | 398 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; |
400 scale_ = false; | 399 scale_ = false; |
401 } | 400 } |
402 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension); | |
403 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); | 401 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); |
404 init_width = std::max(res.width, kMinDimension); | 402 init_width = res.width; |
405 init_height = std::max(res.height, kMinDimension); | 403 init_height = res.height; |
406 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; | 404 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; |
407 } | 405 } |
408 | 406 |
409 return codec_thread_->Invoke<int32_t>( | 407 return codec_thread_->Invoke<int32_t>( |
410 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, | 408 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, |
411 this, | 409 this, |
412 init_width, | 410 init_width, |
413 init_height, | 411 init_height, |
414 codec_settings->startBitrate, | 412 codec_settings->startBitrate, |
415 codec_settings->maxFramerate, | 413 codec_settings->maxFramerate, |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 } | 1258 } |
1261 | 1259 |
1262 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1260 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1263 webrtc::VideoEncoder* encoder) { | 1261 webrtc::VideoEncoder* encoder) { |
1264 ALOGD << "Destroy video encoder."; | 1262 ALOGD << "Destroy video encoder."; |
1265 delete encoder; | 1263 delete encoder; |
1266 } | 1264 } |
1267 | 1265 |
1268 } // namespace webrtc_jni | 1266 } // namespace webrtc_jni |
1269 | 1267 |
OLD | NEW |