| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper_; | 138 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper_; |
| 139 DecodedImageCallback* callback_; | 139 DecodedImageCallback* callback_; |
| 140 int frames_received_; // Number of frames received by decoder. | 140 int frames_received_; // Number of frames received by decoder. |
| 141 int frames_decoded_; // Number of frames decoded by decoder. | 141 int frames_decoded_; // Number of frames decoded by decoder. |
| 142 // Number of decoded frames for which log information is displayed. | 142 // Number of decoded frames for which log information is displayed. |
| 143 int frames_decoded_logged_; | 143 int frames_decoded_logged_; |
| 144 int64_t start_time_ms_; // Start time for statistics. | 144 int64_t start_time_ms_; // Start time for statistics. |
| 145 int current_frames_; // Number of frames in the current statistics interval. | 145 int current_frames_; // Number of frames in the current statistics interval. |
| 146 int current_bytes_; // Encoded bytes in the current statistics interval. | 146 int current_bytes_; // Encoded bytes in the current statistics interval. |
| 147 int current_decoding_time_ms_; // Overall decoding time in the current second | 147 int current_decoding_time_ms_; // Overall decoding time in the current second |
| 148 uint32_t max_pending_frames_; // Maximum number of pending input frames | 148 int current_delay_time_ms_; // Overall delay time in the current second. |
| 149 uint32_t max_pending_frames_; // Maximum number of pending input frames. |
| 149 | 150 |
| 150 // State that is constant for the lifetime of this object once the ctor | 151 // State that is constant for the lifetime of this object once the ctor |
| 151 // returns. | 152 // returns. |
| 152 scoped_ptr<Thread> codec_thread_; // Thread on which to operate MediaCodec. | 153 scoped_ptr<Thread> codec_thread_; // Thread on which to operate MediaCodec. |
| 153 ScopedGlobalRef<jclass> j_media_codec_video_decoder_class_; | 154 ScopedGlobalRef<jclass> j_media_codec_video_decoder_class_; |
| 154 ScopedGlobalRef<jobject> j_media_codec_video_decoder_; | 155 ScopedGlobalRef<jobject> j_media_codec_video_decoder_; |
| 155 jmethodID j_init_decode_method_; | 156 jmethodID j_init_decode_method_; |
| 156 jmethodID j_release_method_; | 157 jmethodID j_release_method_; |
| 157 jmethodID j_dequeue_input_buffer_method_; | 158 jmethodID j_dequeue_input_buffer_method_; |
| 158 jmethodID j_queue_input_buffer_method_; | 159 jmethodID j_queue_input_buffer_method_; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 case kVideoCodecH264: | 384 case kVideoCodecH264: |
| 384 max_pending_frames_ = kMaxPendingFramesH264; | 385 max_pending_frames_ = kMaxPendingFramesH264; |
| 385 break; | 386 break; |
| 386 default: | 387 default: |
| 387 max_pending_frames_ = 0; | 388 max_pending_frames_ = 0; |
| 388 } | 389 } |
| 389 start_time_ms_ = GetCurrentTimeMs(); | 390 start_time_ms_ = GetCurrentTimeMs(); |
| 390 current_frames_ = 0; | 391 current_frames_ = 0; |
| 391 current_bytes_ = 0; | 392 current_bytes_ = 0; |
| 392 current_decoding_time_ms_ = 0; | 393 current_decoding_time_ms_ = 0; |
| 394 current_delay_time_ms_ = 0; |
| 393 | 395 |
| 394 jobjectArray input_buffers = (jobjectArray)GetObjectField( | 396 jobjectArray input_buffers = (jobjectArray)GetObjectField( |
| 395 jni, *j_media_codec_video_decoder_, j_input_buffers_field_); | 397 jni, *j_media_codec_video_decoder_, j_input_buffers_field_); |
| 396 size_t num_input_buffers = jni->GetArrayLength(input_buffers); | 398 size_t num_input_buffers = jni->GetArrayLength(input_buffers); |
| 397 ALOGD << "Maximum amount of pending frames: " << max_pending_frames_; | 399 ALOGD << "Maximum amount of pending frames: " << max_pending_frames_; |
| 398 input_buffers_.resize(num_input_buffers); | 400 input_buffers_.resize(num_input_buffers); |
| 399 for (size_t i = 0; i < num_input_buffers; ++i) { | 401 for (size_t i = 0; i < num_input_buffers; ++i) { |
| 400 input_buffers_[i] = | 402 input_buffers_[i] = |
| 401 jni->NewGlobalRef(jni->GetObjectArrayElement(input_buffers, i)); | 403 jni->NewGlobalRef(jni->GetObjectArrayElement(input_buffers, i)); |
| 402 if (CheckException(jni)) { | 404 if (CheckException(jni)) { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 ". Color: " << color_format << | 792 ". Color: " << color_format << |
| 791 ". TS: " << presentation_timestamps_ms << | 793 ". TS: " << presentation_timestamps_ms << |
| 792 ". DecTime: " << (int)decode_time_ms << | 794 ". DecTime: " << (int)decode_time_ms << |
| 793 ". DelayTime: " << (int)frame_delayed_ms; | 795 ". DelayTime: " << (int)frame_delayed_ms; |
| 794 } | 796 } |
| 795 | 797 |
| 796 // Calculate and print decoding statistics - every 3 seconds. | 798 // Calculate and print decoding statistics - every 3 seconds. |
| 797 frames_decoded_++; | 799 frames_decoded_++; |
| 798 current_frames_++; | 800 current_frames_++; |
| 799 current_decoding_time_ms_ += decode_time_ms; | 801 current_decoding_time_ms_ += decode_time_ms; |
| 802 current_delay_time_ms_ += frame_delayed_ms; |
| 800 int statistic_time_ms = GetCurrentTimeMs() - start_time_ms_; | 803 int statistic_time_ms = GetCurrentTimeMs() - start_time_ms_; |
| 801 if (statistic_time_ms >= kMediaCodecStatisticsIntervalMs && | 804 if (statistic_time_ms >= kMediaCodecStatisticsIntervalMs && |
| 802 current_frames_ > 0) { | 805 current_frames_ > 0) { |
| 803 int current_bitrate = current_bytes_ * 8 / statistic_time_ms; | 806 int current_bitrate = current_bytes_ * 8 / statistic_time_ms; |
| 804 int current_fps = | 807 int current_fps = |
| 805 (current_frames_ * 1000 + statistic_time_ms / 2) / statistic_time_ms; | 808 (current_frames_ * 1000 + statistic_time_ms / 2) / statistic_time_ms; |
| 806 ALOGD << "Decoded frames: " << frames_decoded_ << | 809 ALOGD << "Frames decoded: " << frames_decoded_ << |
| 807 ". Received frames: " << frames_received_ << | 810 ". Received: " << frames_received_ << |
| 808 ". Bitrate: " << current_bitrate << " kbps" << | 811 ". Bitrate: " << current_bitrate << " kbps" << |
| 809 ". Fps: " << current_fps << | 812 ". Fps: " << current_fps << |
| 810 ". DecTime: " << (current_decoding_time_ms_ / current_frames_) << | 813 ". DecTime: " << (current_decoding_time_ms_ / current_frames_) << |
| 814 ". DelayTime: " << (current_delay_time_ms_ / current_frames_) << |
| 811 " for last " << statistic_time_ms << " ms."; | 815 " for last " << statistic_time_ms << " ms."; |
| 812 start_time_ms_ = GetCurrentTimeMs(); | 816 start_time_ms_ = GetCurrentTimeMs(); |
| 813 current_frames_ = 0; | 817 current_frames_ = 0; |
| 814 current_bytes_ = 0; | 818 current_bytes_ = 0; |
| 815 current_decoding_time_ms_ = 0; | 819 current_decoding_time_ms_ = 0; |
| 820 current_delay_time_ms_ = 0; |
| 816 } | 821 } |
| 817 | 822 |
| 818 // |.IsZeroSize())| returns true when a frame has been dropped. | 823 // |.IsZeroSize())| returns true when a frame has been dropped. |
| 819 if (!decoded_frame.IsZeroSize()) { | 824 if (!decoded_frame.IsZeroSize()) { |
| 820 // Callback - output decoded frame. | 825 // Callback - output decoded frame. |
| 821 const int32_t callback_status = | 826 const int32_t callback_status = |
| 822 callback_->Decoded(decoded_frame, decode_time_ms); | 827 callback_->Decoded(decoded_frame, decode_time_ms); |
| 823 if (callback_status > 0) { | 828 if (callback_status > 0) { |
| 824 ALOGE << "callback error"; | 829 ALOGE << "callback error"; |
| 825 } | 830 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 ALOGD << "Destroy video decoder."; | 933 ALOGD << "Destroy video decoder."; |
| 929 delete decoder; | 934 delete decoder; |
| 930 } | 935 } |
| 931 | 936 |
| 932 const char* MediaCodecVideoDecoder::ImplementationName() const { | 937 const char* MediaCodecVideoDecoder::ImplementationName() const { |
| 933 return "MediaCodec"; | 938 return "MediaCodec"; |
| 934 } | 939 } |
| 935 | 940 |
| 936 } // namespace webrtc_jni | 941 } // namespace webrtc_jni |
| 937 | 942 |
| OLD | NEW |