OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // Factory should guard against other codecs being used with us. | 294 // Factory should guard against other codecs being used with us. |
295 CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " << | 295 CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " << |
296 codec_settings->codecType << " for " << codecType_; | 296 codec_settings->codecType << " for " << codecType_; |
297 | 297 |
298 ALOGD("InitEncode request"); | 298 ALOGD("InitEncode request"); |
299 scale_ = false; | 299 scale_ = false; |
300 if (scale_ && codecType_ == kVideoCodecVP8) { | 300 if (scale_ && codecType_ == kVideoCodecVP8) { |
301 quality_scaler_->Init(kMaxQP / kLowQpThresholdDenominator, true); | 301 quality_scaler_->Init(kMaxQP / kLowQpThresholdDenominator, true); |
302 quality_scaler_->SetMinResolution(kMinWidth, kMinHeight); | 302 quality_scaler_->SetMinResolution(kMinWidth, kMinHeight); |
303 quality_scaler_->ReportFramerate(codec_settings->maxFramerate); | 303 quality_scaler_->ReportFramerate(codec_settings->maxFramerate); |
| 304 updated_framerate_ = codec_settings->maxFramerate; |
| 305 } else { |
| 306 updated_framerate_ = -1; |
304 } | 307 } |
305 updated_framerate_ = codec_settings->maxFramerate; | |
306 return codec_thread_->Invoke<int32_t>( | 308 return codec_thread_->Invoke<int32_t>( |
307 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, | 309 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, |
308 this, | 310 this, |
309 codec_settings->width, | 311 codec_settings->width, |
310 codec_settings->height, | 312 codec_settings->height, |
311 codec_settings->startBitrate, | 313 codec_settings->startBitrate, |
312 codec_settings->maxFramerate)); | 314 codec_settings->maxFramerate)); |
313 } | 315 } |
314 | 316 |
315 int32_t MediaCodecVideoEncoder::Encode( | 317 int32_t MediaCodecVideoEncoder::Encode( |
(...skipping 20 matching lines...) Expand all Loading... |
336 | 338 |
337 int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */, | 339 int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */, |
338 int64_t /* rtt */) { | 340 int64_t /* rtt */) { |
339 return WEBRTC_VIDEO_CODEC_OK; | 341 return WEBRTC_VIDEO_CODEC_OK; |
340 } | 342 } |
341 | 343 |
342 int32_t MediaCodecVideoEncoder::SetRates(uint32_t new_bit_rate, | 344 int32_t MediaCodecVideoEncoder::SetRates(uint32_t new_bit_rate, |
343 uint32_t frame_rate) { | 345 uint32_t frame_rate) { |
344 if (scale_ && codecType_ == kVideoCodecVP8) { | 346 if (scale_ && codecType_ == kVideoCodecVP8) { |
345 quality_scaler_->ReportFramerate(frame_rate); | 347 quality_scaler_->ReportFramerate(frame_rate); |
346 } else { | |
347 updated_framerate_ = frame_rate; | |
348 } | 348 } |
349 return codec_thread_->Invoke<int32_t>( | 349 return codec_thread_->Invoke<int32_t>( |
350 Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread, | 350 Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread, |
351 this, | 351 this, |
352 new_bit_rate, | 352 new_bit_rate, |
353 frame_rate)); | 353 frame_rate)); |
354 } | 354 } |
355 | 355 |
356 void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) { | 356 void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) { |
357 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 357 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 } | 929 } |
930 | 930 |
931 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 931 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
932 webrtc::VideoEncoder* encoder) { | 932 webrtc::VideoEncoder* encoder) { |
933 ALOGD("Destroy video encoder."); | 933 ALOGD("Destroy video encoder."); |
934 delete encoder; | 934 delete encoder; |
935 } | 935 } |
936 | 936 |
937 } // namespace webrtc_jni | 937 } // namespace webrtc_jni |
938 | 938 |
OLD | NEW |