Chromium Code Reviews

Side by Side Diff: webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 280 matching lines...)
291 291
292 MediaCodecVideoEncoder::~MediaCodecVideoEncoder() { 292 MediaCodecVideoEncoder::~MediaCodecVideoEncoder() {
293 // Call Release() to ensure no more callbacks to us after we are deleted. 293 // Call Release() to ensure no more callbacks to us after we are deleted.
294 Release(); 294 Release();
295 } 295 }
296 296
297 MediaCodecVideoEncoder::MediaCodecVideoEncoder(JNIEnv* jni, 297 MediaCodecVideoEncoder::MediaCodecVideoEncoder(JNIEnv* jni,
298 const cricket::VideoCodec& codec, 298 const cricket::VideoCodec& codec,
299 jobject egl_context) 299 jobject egl_context)
300 : codec_(codec), 300 : codec_(codec),
301 callback_(NULL), 301 callback_(nullptr),
302 codec_thread_(new Thread()), 302 codec_thread_(new Thread()),
303 j_media_codec_video_encoder_class_( 303 j_media_codec_video_encoder_class_(
304 jni, 304 jni,
305 FindClass(jni, "org/webrtc/MediaCodecVideoEncoder")), 305 FindClass(jni, "org/webrtc/MediaCodecVideoEncoder")),
306 j_media_codec_video_encoder_( 306 j_media_codec_video_encoder_(
307 jni, 307 jni,
308 jni->NewObject(*j_media_codec_video_encoder_class_, 308 jni->NewObject(*j_media_codec_video_encoder_class_,
309 GetMethodID(jni, 309 GetMethodID(jni,
310 *j_media_codec_video_encoder_class_, 310 *j_media_codec_video_encoder_class_,
311 "<init>", 311 "<init>",
312 "()V"))), 312 "()V"))),
313 inited_(false), 313 inited_(false),
314 use_surface_(false), 314 use_surface_(false),
315 picture_id_(0), 315 picture_id_(0),
316 egl_context_(egl_context), 316 egl_context_(egl_context),
317 sw_fallback_required_(false) { 317 sw_fallback_required_(false) {
318 // It would be nice to avoid spinning up a new thread per MediaCodec, and 318 // It would be nice to avoid spinning up a new thread per MediaCodec, and
319 // instead re-use e.g. the PeerConnectionFactory's |worker_thread_|, but bug 319 // instead re-use e.g. the PeerConnectionFactory's |worker_thread_|, but bug
320 // 2732 means that deadlocks abound. This class synchronously trampolines 320 // 2732 means that deadlocks abound. This class synchronously trampolines
321 // to |codec_thread_|, so if anything else can be coming to _us_ from 321 // to |codec_thread_|, so if anything else can be coming to _us_ from
322 // |codec_thread_|, or from any thread holding the |_sendCritSect| described 322 // |codec_thread_|, or from any thread holding the |_sendCritSect| described
323 // in the bug, we have a problem. For now work around that with a dedicated 323 // in the bug, we have a problem. For now work around that with a dedicated
324 // thread. 324 // thread.
325 codec_thread_->SetName("MediaCodecVideoEncoder", NULL); 325 codec_thread_->SetName("MediaCodecVideoEncoder", nullptr);
326 RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder"; 326 RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder";
327 codec_thread_checker_.DetachFromThread(); 327 codec_thread_checker_.DetachFromThread();
328 jclass j_output_buffer_info_class = 328 jclass j_output_buffer_info_class =
329 FindClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo"); 329 FindClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo");
330 j_init_encode_method_ = GetMethodID( 330 j_init_encode_method_ = GetMethodID(
331 jni, 331 jni,
332 *j_media_codec_video_encoder_class_, 332 *j_media_codec_video_encoder_class_,
333 "initEncode", 333 "initEncode",
334 "(Lorg/webrtc/MediaCodecVideoEncoder$VideoCodecType;" 334 "(Lorg/webrtc/MediaCodecVideoEncoder$VideoCodecType;"
335 "IIIILorg/webrtc/EglBase14$Context;)Z"); 335 "IIIILorg/webrtc/EglBase14$Context;)Z");
(...skipping 28 matching lines...)
364 j_info_buffer_field_ = GetFieldID( 364 j_info_buffer_field_ = GetFieldID(
365 jni, j_output_buffer_info_class, "buffer", "Ljava/nio/ByteBuffer;"); 365 jni, j_output_buffer_info_class, "buffer", "Ljava/nio/ByteBuffer;");
366 j_info_is_key_frame_field_ = 366 j_info_is_key_frame_field_ =
367 GetFieldID(jni, j_output_buffer_info_class, "isKeyFrame", "Z"); 367 GetFieldID(jni, j_output_buffer_info_class, "isKeyFrame", "Z");
368 j_info_presentation_timestamp_us_field_ = GetFieldID( 368 j_info_presentation_timestamp_us_field_ = GetFieldID(
369 jni, j_output_buffer_info_class, "presentationTimestampUs", "J"); 369 jni, j_output_buffer_info_class, "presentationTimestampUs", "J");
370 if (CheckException(jni)) { 370 if (CheckException(jni)) {
371 ALOGW << "MediaCodecVideoEncoder ctor failed."; 371 ALOGW << "MediaCodecVideoEncoder ctor failed.";
372 ProcessHWErrorOnCodecThread(true /* reset_if_fallback_unavailable */); 372 ProcessHWErrorOnCodecThread(true /* reset_if_fallback_unavailable */);
373 } 373 }
374 srand(time(NULL)); 374 srand(time(nullptr));
375 AllowBlockingCalls(); 375 AllowBlockingCalls();
376 } 376 }
377 377
378 int32_t MediaCodecVideoEncoder::InitEncode( 378 int32_t MediaCodecVideoEncoder::InitEncode(
379 const webrtc::VideoCodec* codec_settings, 379 const webrtc::VideoCodec* codec_settings,
380 int32_t /* number_of_cores */, 380 int32_t /* number_of_cores */,
381 size_t /* max_payload_size */) { 381 size_t /* max_payload_size */) {
382 if (codec_settings == NULL) { 382 if (codec_settings == nullptr) {
383 ALOGE << "NULL VideoCodec instance"; 383 ALOGE << "null VideoCodec instance";
384 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 384 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
385 } 385 }
386 // Factory should guard against other codecs being used with us. 386 // Factory should guard against other codecs being used with us.
387 const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name) 387 const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name)
388 .value_or(webrtc::kVideoCodecUnknown); 388 .value_or(webrtc::kVideoCodecUnknown);
389 RTC_CHECK(codec_settings->codecType == codec_type) 389 RTC_CHECK(codec_settings->codecType == codec_type)
390 << "Unsupported codec " << codec_settings->codecType << " for " 390 << "Unsupported codec " << codec_settings->codecType << " for "
391 << codec_type; 391 << codec_type;
392 if (sw_fallback_required_) { 392 if (sw_fallback_required_) {
393 return WEBRTC_VIDEO_CODEC_OK; 393 return WEBRTC_VIDEO_CODEC_OK;
(...skipping 912 matching lines...)
1306 return supported_codecs_; 1306 return supported_codecs_;
1307 } 1307 }
1308 1308
1309 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( 1309 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(
1310 webrtc::VideoEncoder* encoder) { 1310 webrtc::VideoEncoder* encoder) {
1311 ALOGD << "Destroy video encoder."; 1311 ALOGD << "Destroy video encoder.";
1312 delete encoder; 1312 delete encoder;
1313 } 1313 }
1314 1314
1315 } // namespace webrtc_jni 1315 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine