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

Side by Side Diff: talk/app/webrtc/java/jni/androidmediadecoder_jni.cc

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 5 years, 3 months 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
OLDNEW
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 FindClass(jni, "org/webrtc/MediaCodecVideoDecoder")), 176 FindClass(jni, "org/webrtc/MediaCodecVideoDecoder")),
177 j_media_codec_video_decoder_( 177 j_media_codec_video_decoder_(
178 jni, 178 jni,
179 jni->NewObject(*j_media_codec_video_decoder_class_, 179 jni->NewObject(*j_media_codec_video_decoder_class_,
180 GetMethodID(jni, 180 GetMethodID(jni,
181 *j_media_codec_video_decoder_class_, 181 *j_media_codec_video_decoder_class_,
182 "<init>", 182 "<init>",
183 "()V"))) { 183 "()V"))) {
184 ScopedLocalRefFrame local_ref_frame(jni); 184 ScopedLocalRefFrame local_ref_frame(jni);
185 codec_thread_->SetName("MediaCodecVideoDecoder", NULL); 185 codec_thread_->SetName("MediaCodecVideoDecoder", NULL);
186 CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder"; 186 RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
187 187
188 j_init_decode_method_ = GetMethodID( 188 j_init_decode_method_ = GetMethodID(
189 jni, *j_media_codec_video_decoder_class_, "initDecode", 189 jni, *j_media_codec_video_decoder_class_, "initDecode",
190 "(Lorg/webrtc/MediaCodecVideoDecoder$VideoCodecType;" 190 "(Lorg/webrtc/MediaCodecVideoDecoder$VideoCodecType;"
191 "IILandroid/opengl/EGLContext;)Z"); 191 "IILandroid/opengl/EGLContext;)Z");
192 j_release_method_ = 192 j_release_method_ =
193 GetMethodID(jni, *j_media_codec_video_decoder_class_, "release", "()V"); 193 GetMethodID(jni, *j_media_codec_video_decoder_class_, "release", "()V");
194 j_dequeue_input_buffer_method_ = GetMethodID( 194 j_dequeue_input_buffer_method_ = GetMethodID(
195 jni, *j_media_codec_video_decoder_class_, "dequeueInputBuffer", "()I"); 195 jni, *j_media_codec_video_decoder_class_, "dequeueInputBuffer", "()I");
196 j_queue_input_buffer_method_ = GetMethodID( 196 j_queue_input_buffer_method_ = GetMethodID(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst, 257 int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst,
258 int32_t numberOfCores) { 258 int32_t numberOfCores) {
259 ALOGD("InitDecode."); 259 ALOGD("InitDecode.");
260 if (inst == NULL) { 260 if (inst == NULL) {
261 ALOGE("NULL VideoCodec instance"); 261 ALOGE("NULL VideoCodec instance");
262 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 262 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
263 } 263 }
264 // Factory should guard against other codecs being used with us. 264 // Factory should guard against other codecs being used with us.
265 CHECK(inst->codecType == codecType_) << "Unsupported codec " << 265 RTC_CHECK(inst->codecType == codecType_)
266 inst->codecType << " for " << codecType_; 266 << "Unsupported codec " << inst->codecType << " for " << codecType_;
267 267
268 if (sw_fallback_required_) { 268 if (sw_fallback_required_) {
269 ALOGE("InitDecode() - fallback to SW decoder"); 269 ALOGE("InitDecode() - fallback to SW decoder");
270 return WEBRTC_VIDEO_CODEC_OK; 270 return WEBRTC_VIDEO_CODEC_OK;
271 } 271 }
272 // Save VideoCodec instance for later. 272 // Save VideoCodec instance for later.
273 if (&codec_ != inst) { 273 if (&codec_ != inst) {
274 codec_ = *inst; 274 codec_ = *inst;
275 } 275 }
276 codec_.maxFramerate = (codec_.maxFramerate >= 1) ? codec_.maxFramerate : 1; 276 codec_.maxFramerate = (codec_.maxFramerate >= 1) ? codec_.maxFramerate : 1;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 inited_ = false; 387 inited_ = false;
388 rtc::MessageQueueManager::Clear(this); 388 rtc::MessageQueueManager::Clear(this);
389 if (CheckException(jni)) { 389 if (CheckException(jni)) {
390 ALOGE("Decoder release exception"); 390 ALOGE("Decoder release exception");
391 return WEBRTC_VIDEO_CODEC_ERROR; 391 return WEBRTC_VIDEO_CODEC_ERROR;
392 } 392 }
393 return WEBRTC_VIDEO_CODEC_OK; 393 return WEBRTC_VIDEO_CODEC_OK;
394 } 394 }
395 395
396 void MediaCodecVideoDecoder::CheckOnCodecThread() { 396 void MediaCodecVideoDecoder::CheckOnCodecThread() {
397 CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread()) 397 RTC_CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
398 << "Running on wrong thread!"; 398 << "Running on wrong thread!";
399 } 399 }
400 400
401 int32_t MediaCodecVideoDecoder::ProcessHWErrorOnCodecThread() { 401 int32_t MediaCodecVideoDecoder::ProcessHWErrorOnCodecThread() {
402 CheckOnCodecThread(); 402 CheckOnCodecThread();
403 int ret_val = ReleaseOnCodecThread(); 403 int ret_val = ReleaseOnCodecThread();
404 if (ret_val < 0) { 404 if (ret_val < 0) {
405 ALOGE("ProcessHWError: Release failure"); 405 ALOGE("ProcessHWError: Release failure");
406 } 406 }
407 if (codecType_ == kVideoCodecH264) { 407 if (codecType_ == kVideoCodecH264) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 j_dequeue_input_buffer_method_); 507 j_dequeue_input_buffer_method_);
508 if (CheckException(jni) || j_input_buffer_index < 0) { 508 if (CheckException(jni) || j_input_buffer_index < 0) {
509 ALOGE("dequeueInputBuffer error"); 509 ALOGE("dequeueInputBuffer error");
510 return ProcessHWErrorOnCodecThread(); 510 return ProcessHWErrorOnCodecThread();
511 } 511 }
512 512
513 // Copy encoded data to Java ByteBuffer. 513 // Copy encoded data to Java ByteBuffer.
514 jobject j_input_buffer = input_buffers_[j_input_buffer_index]; 514 jobject j_input_buffer = input_buffers_[j_input_buffer_index];
515 uint8* buffer = 515 uint8* buffer =
516 reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer)); 516 reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
517 CHECK(buffer) << "Indirect buffer??"; 517 RTC_CHECK(buffer) << "Indirect buffer??";
518 int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer); 518 int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer);
519 if (CheckException(jni) || buffer_capacity < inputImage._length) { 519 if (CheckException(jni) || buffer_capacity < inputImage._length) {
520 ALOGE("Input frame size %d is bigger than buffer size %d.", 520 ALOGE("Input frame size %d is bigger than buffer size %d.",
521 inputImage._length, buffer_capacity); 521 inputImage._length, buffer_capacity);
522 return ProcessHWErrorOnCodecThread(); 522 return ProcessHWErrorOnCodecThread();
523 } 523 }
524 jlong timestamp_us = (frames_received_ * 1000000) / codec_.maxFramerate; 524 jlong timestamp_us = (frames_received_ * 1000000) / codec_.maxFramerate;
525 ALOGV("Decoder frame in # %d. Type: %d. Buffer # %d. TS: %lld. Size: %d", 525 ALOGV("Decoder frame in # %d. Type: %d. Buffer # %d. TS: %lld. Size: %d",
526 frames_received_, inputImage._frameType, j_input_buffer_index, 526 frames_received_, inputImage._frameType, j_input_buffer_index,
527 timestamp_us / 1000, inputImage._length); 527 timestamp_us / 1000, inputImage._length);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 724 }
725 725
726 void MediaCodecVideoDecoder::OnMessage(rtc::Message* msg) { 726 void MediaCodecVideoDecoder::OnMessage(rtc::Message* msg) {
727 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 727 JNIEnv* jni = AttachCurrentThreadIfNeeded();
728 ScopedLocalRefFrame local_ref_frame(jni); 728 ScopedLocalRefFrame local_ref_frame(jni);
729 if (!inited_) { 729 if (!inited_) {
730 return; 730 return;
731 } 731 }
732 // We only ever send one message to |this| directly (not through a Bind()'d 732 // We only ever send one message to |this| directly (not through a Bind()'d
733 // functor), so expect no ID/data. 733 // functor), so expect no ID/data.
734 CHECK(!msg->message_id) << "Unexpected message!"; 734 RTC_CHECK(!msg->message_id) << "Unexpected message!";
735 CHECK(!msg->pdata) << "Unexpected message!"; 735 RTC_CHECK(!msg->pdata) << "Unexpected message!";
736 CheckOnCodecThread(); 736 CheckOnCodecThread();
737 737
738 if (!DeliverPendingOutputs(jni, 0)) { 738 if (!DeliverPendingOutputs(jni, 0)) {
739 ALOGE("OnMessage: DeliverPendingOutputs error"); 739 ALOGE("OnMessage: DeliverPendingOutputs error");
740 ProcessHWErrorOnCodecThread(); 740 ProcessHWErrorOnCodecThread();
741 return; 741 return;
742 } 742 }
743 codec_thread_->PostDelayed(kMediaCodecPollMs, this); 743 codec_thread_->PostDelayed(kMediaCodecPollMs, this);
744 } 744 }
745 745
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 return NULL; 826 return NULL;
827 } 827 }
828 828
829 void MediaCodecVideoDecoderFactory::DestroyVideoDecoder( 829 void MediaCodecVideoDecoderFactory::DestroyVideoDecoder(
830 webrtc::VideoDecoder* decoder) { 830 webrtc::VideoDecoder* decoder) {
831 delete decoder; 831 delete decoder;
832 } 832 }
833 833
834 } // namespace webrtc_jni 834 } // namespace webrtc_jni
835 835
OLDNEW
« no previous file with comments | « talk/app/webrtc/fakemetricsobserver.cc ('k') | talk/app/webrtc/java/jni/androidmediaencoder_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698