Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: webrtc/api/android/jni/androidmediaencoder_jni.cc

Issue 2509273002: Unify VideoCodecType to/from string functionality (Closed)
Patch Set: Rebase and update unknown string in WebRtcVideoEncoderFactory Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/common_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 int32_t MediaCodecVideoEncoder::InitEncode( 387 int32_t MediaCodecVideoEncoder::InitEncode(
388 const webrtc::VideoCodec* codec_settings, 388 const webrtc::VideoCodec* codec_settings,
389 int32_t /* number_of_cores */, 389 int32_t /* number_of_cores */,
390 size_t /* max_payload_size */) { 390 size_t /* max_payload_size */) {
391 if (codec_settings == NULL) { 391 if (codec_settings == NULL) {
392 ALOGE << "NULL VideoCodec instance"; 392 ALOGE << "NULL VideoCodec instance";
393 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 393 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
394 } 394 }
395 // Factory should guard against other codecs being used with us. 395 // Factory should guard against other codecs being used with us.
396 const VideoCodecType codec_type = cricket::CodecTypeFromName(codec_.name); 396 const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name)
397 .value_or(webrtc::kVideoCodecUnknown);
397 RTC_CHECK(codec_settings->codecType == codec_type) 398 RTC_CHECK(codec_settings->codecType == codec_type)
398 << "Unsupported codec " << codec_settings->codecType << " for " 399 << "Unsupported codec " << codec_settings->codecType << " for "
399 << codec_type; 400 << codec_type;
400 if (sw_fallback_required_) { 401 if (sw_fallback_required_) {
401 return WEBRTC_VIDEO_CODEC_OK; 402 return WEBRTC_VIDEO_CODEC_OK;
402 } 403 }
403 codec_mode_ = codec_settings->mode; 404 codec_mode_ = codec_settings->mode;
404 int init_width = codec_settings->width; 405 int init_width = codec_settings->width;
405 int init_height = codec_settings->height; 406 int init_height = codec_settings->height;
406 // Scaling is disabled for VP9, but optionally enabled for VP8. 407 // Scaling is disabled for VP9, but optionally enabled for VP8.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread( 546 int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
546 int width, int height, int kbps, int fps, bool use_surface) { 547 int width, int height, int kbps, int fps, bool use_surface) {
547 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread()); 548 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread());
548 if (sw_fallback_required_) { 549 if (sw_fallback_required_) {
549 return WEBRTC_VIDEO_CODEC_OK; 550 return WEBRTC_VIDEO_CODEC_OK;
550 } 551 }
551 RTC_CHECK(!use_surface || egl_context_ != nullptr) << "EGL context not set."; 552 RTC_CHECK(!use_surface || egl_context_ != nullptr) << "EGL context not set.";
552 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 553 JNIEnv* jni = AttachCurrentThreadIfNeeded();
553 ScopedLocalRefFrame local_ref_frame(jni); 554 ScopedLocalRefFrame local_ref_frame(jni);
554 555
555 const VideoCodecType codec_type = cricket::CodecTypeFromName(codec_.name); 556 const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name)
557 .value_or(webrtc::kVideoCodecUnknown);
556 ALOGD << "InitEncodeOnCodecThread Type: " << (int)codec_type << ", " << width 558 ALOGD << "InitEncodeOnCodecThread Type: " << (int)codec_type << ", " << width
557 << " x " << height << ". Bitrate: " << kbps << " kbps. Fps: " << fps; 559 << " x " << height << ". Bitrate: " << kbps << " kbps. Fps: " << fps;
558 if (kbps == 0) { 560 if (kbps == 0) {
559 kbps = last_set_bitrate_kbps_; 561 kbps = last_set_bitrate_kbps_;
560 } 562 }
561 if (fps == 0) { 563 if (fps == 0) {
562 fps = MAX_VIDEO_FPS; 564 fps = MAX_VIDEO_FPS;
563 } 565 }
564 566
565 width_ = width; 567 width_ = width;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 size_t payload_size = jni->GetDirectBufferCapacity(j_output_buffer); 1062 size_t payload_size = jni->GetDirectBufferCapacity(j_output_buffer);
1061 uint8_t* payload = reinterpret_cast<uint8_t*>( 1063 uint8_t* payload = reinterpret_cast<uint8_t*>(
1062 jni->GetDirectBufferAddress(j_output_buffer)); 1064 jni->GetDirectBufferAddress(j_output_buffer));
1063 if (CheckException(jni)) { 1065 if (CheckException(jni)) {
1064 ALOGE << "Exception in get direct buffer address."; 1066 ALOGE << "Exception in get direct buffer address.";
1065 ProcessHWErrorOnCodecThread(true /* reset_if_fallback_unavailable */); 1067 ProcessHWErrorOnCodecThread(true /* reset_if_fallback_unavailable */);
1066 return WEBRTC_VIDEO_CODEC_ERROR; 1068 return WEBRTC_VIDEO_CODEC_ERROR;
1067 } 1069 }
1068 1070
1069 // Callback - return encoded frame. 1071 // Callback - return encoded frame.
1070 const VideoCodecType codec_type = cricket::CodecTypeFromName(codec_.name); 1072 const VideoCodecType codec_type =
1073 webrtc::PayloadNameToCodecType(codec_.name)
1074 .value_or(webrtc::kVideoCodecUnknown);
1071 webrtc::EncodedImageCallback::Result callback_result( 1075 webrtc::EncodedImageCallback::Result callback_result(
1072 webrtc::EncodedImageCallback::Result::OK); 1076 webrtc::EncodedImageCallback::Result::OK);
1073 if (callback_) { 1077 if (callback_) {
1074 std::unique_ptr<webrtc::EncodedImage> image( 1078 std::unique_ptr<webrtc::EncodedImage> image(
1075 new webrtc::EncodedImage(payload, payload_size, payload_size)); 1079 new webrtc::EncodedImage(payload, payload_size, payload_size));
1076 image->_encodedWidth = width_; 1080 image->_encodedWidth = width_;
1077 image->_encodedHeight = height_; 1081 image->_encodedHeight = height_;
1078 image->_timeStamp = output_timestamp_; 1082 image->_timeStamp = output_timestamp_;
1079 image->capture_time_ms_ = output_render_time_ms_; 1083 image->capture_time_ms_ = output_render_time_ms_;
1080 image->rotation_ = output_rotation_; 1084 image->rotation_ = output_rotation_;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 return supported_codecs_; 1378 return supported_codecs_;
1375 } 1379 }
1376 1380
1377 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( 1381 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(
1378 webrtc::VideoEncoder* encoder) { 1382 webrtc::VideoEncoder* encoder) {
1379 ALOGD << "Destroy video encoder."; 1383 ALOGD << "Destroy video encoder.";
1380 delete encoder; 1384 delete encoder;
1381 } 1385 }
1382 1386
1383 } // namespace webrtc_jni 1387 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698