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