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 23 matching lines...) Expand all Loading... |
34 #include "talk/app/webrtc/java/jni/classreferenceholder.h" | 34 #include "talk/app/webrtc/java/jni/classreferenceholder.h" |
35 #include "talk/app/webrtc/java/jni/native_handle_impl.h" | 35 #include "talk/app/webrtc/java/jni/native_handle_impl.h" |
36 #include "talk/app/webrtc/java/jni/surfacetexturehelper_jni.h" | 36 #include "talk/app/webrtc/java/jni/surfacetexturehelper_jni.h" |
37 #include "webrtc/base/bind.h" | 37 #include "webrtc/base/bind.h" |
38 #include "webrtc/base/checks.h" | 38 #include "webrtc/base/checks.h" |
39 #include "webrtc/base/logging.h" | 39 #include "webrtc/base/logging.h" |
40 #include "webrtc/base/scoped_ref_ptr.h" | 40 #include "webrtc/base/scoped_ref_ptr.h" |
41 #include "webrtc/base/thread.h" | 41 #include "webrtc/base/thread.h" |
42 #include "webrtc/base/timeutils.h" | 42 #include "webrtc/base/timeutils.h" |
43 #include "webrtc/common_video/include/i420_buffer_pool.h" | 43 #include "webrtc/common_video/include/i420_buffer_pool.h" |
44 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" | 44 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
45 #include "webrtc/system_wrappers/include/logcat_trace_context.h" | 45 #include "webrtc/system_wrappers/include/logcat_trace_context.h" |
46 #include "webrtc/system_wrappers/include/tick_util.h" | 46 #include "webrtc/system_wrappers/include/tick_util.h" |
47 #include "third_party/libyuv/include/libyuv/convert.h" | 47 #include "third_party/libyuv/include/libyuv/convert.h" |
48 #include "third_party/libyuv/include/libyuv/convert_from.h" | 48 #include "third_party/libyuv/include/libyuv/convert_from.h" |
49 #include "third_party/libyuv/include/libyuv/video_common.h" | 49 #include "third_party/libyuv/include/libyuv/video_common.h" |
50 | 50 |
51 using rtc::Bind; | 51 using rtc::Bind; |
52 using rtc::Thread; | 52 using rtc::Thread; |
53 using rtc::ThreadManager; | 53 using rtc::ThreadManager; |
54 using rtc::scoped_ptr; | 54 using rtc::scoped_ptr; |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (CheckException(jni) || buffer_capacity < inputImage._length) { | 536 if (CheckException(jni) || buffer_capacity < inputImage._length) { |
537 ALOGE << "Input frame size "<< inputImage._length << | 537 ALOGE << "Input frame size "<< inputImage._length << |
538 " is bigger than buffer size " << buffer_capacity; | 538 " is bigger than buffer size " << buffer_capacity; |
539 return ProcessHWErrorOnCodecThread(); | 539 return ProcessHWErrorOnCodecThread(); |
540 } | 540 } |
541 jlong presentation_timestamp_us = | 541 jlong presentation_timestamp_us = |
542 (frames_received_ * 1000000) / codec_.maxFramerate; | 542 (frames_received_ * 1000000) / codec_.maxFramerate; |
543 if (frames_decoded_ < kMaxDecodedLogFrames) { | 543 if (frames_decoded_ < kMaxDecodedLogFrames) { |
544 ALOGD << "Decoder frame in # " << frames_received_ << ". Type: " | 544 ALOGD << "Decoder frame in # " << frames_received_ << ". Type: " |
545 << inputImage._frameType << ". Buffer # " << | 545 << inputImage._frameType << ". Buffer # " << |
546 j_input_buffer_index << ". TS: " | 546 j_input_buffer_index << ". pTS: " |
547 << (int)(presentation_timestamp_us / 1000) | 547 << (int)(presentation_timestamp_us / 1000) |
| 548 << ". TS: " << inputImage._timeStamp |
548 << ". Size: " << inputImage._length; | 549 << ". Size: " << inputImage._length; |
549 } | 550 } |
550 memcpy(buffer, inputImage._buffer, inputImage._length); | 551 memcpy(buffer, inputImage._buffer, inputImage._length); |
551 | 552 |
552 // Save input image timestamps for later output. | 553 // Save input image timestamps for later output. |
553 frames_received_++; | 554 frames_received_++; |
554 current_bytes_ += inputImage._length; | 555 current_bytes_ += inputImage._length; |
555 | 556 |
556 // Feed input to decoder. | 557 // Feed input to decoder. |
557 bool success = jni->CallBooleanMethod( | 558 bool success = jni->CallBooleanMethod( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 return false; | 716 return false; |
716 } | 717 } |
717 } | 718 } |
718 VideoFrame decoded_frame(frame_buffer, 0, 0, webrtc::kVideoRotation_0); | 719 VideoFrame decoded_frame(frame_buffer, 0, 0, webrtc::kVideoRotation_0); |
719 decoded_frame.set_timestamp(output_timestamps_ms); | 720 decoded_frame.set_timestamp(output_timestamps_ms); |
720 decoded_frame.set_ntp_time_ms(output_ntp_timestamps_ms); | 721 decoded_frame.set_ntp_time_ms(output_ntp_timestamps_ms); |
721 | 722 |
722 if (frames_decoded_ < kMaxDecodedLogFrames) { | 723 if (frames_decoded_ < kMaxDecodedLogFrames) { |
723 ALOGD << "Decoder frame out # " << frames_decoded_ << ". " << width << | 724 ALOGD << "Decoder frame out # " << frames_decoded_ << ". " << width << |
724 " x " << height << ". " << stride << " x " << slice_height << | 725 " x " << height << ". " << stride << " x " << slice_height << |
725 ". Color: " << color_format << ". TS:" << (int)output_timestamps_ms << | 726 ". Color: " << color_format << ". TS:" << decoded_frame.timestamp() << |
726 ". DecTime: " << (int)decode_time_ms << | 727 ". DecTime: " << (int)decode_time_ms << |
727 ". DelayTime: " << (int)frame_delayed_ms; | 728 ". DelayTime: " << (int)frame_delayed_ms; |
728 } | 729 } |
729 | 730 |
730 // Calculate and print decoding statistics - every 3 seconds. | 731 // Calculate and print decoding statistics - every 3 seconds. |
731 frames_decoded_++; | 732 frames_decoded_++; |
732 current_frames_++; | 733 current_frames_++; |
733 current_decoding_time_ms_ += decode_time_ms; | 734 current_decoding_time_ms_ += decode_time_ms; |
734 int statistic_time_ms = GetCurrentTimeMs() - start_time_ms_; | 735 int statistic_time_ms = GetCurrentTimeMs() - start_time_ms_; |
735 if (statistic_time_ms >= kMediaCodecStatisticsIntervalMs && | 736 if (statistic_time_ms >= kMediaCodecStatisticsIntervalMs && |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 } | 889 } |
889 | 890 |
890 void MediaCodecVideoDecoderFactory::DestroyVideoDecoder( | 891 void MediaCodecVideoDecoderFactory::DestroyVideoDecoder( |
891 webrtc::VideoDecoder* decoder) { | 892 webrtc::VideoDecoder* decoder) { |
892 ALOGD << "Destroy video decoder."; | 893 ALOGD << "Destroy video decoder."; |
893 delete decoder; | 894 delete decoder; |
894 } | 895 } |
895 | 896 |
896 } // namespace webrtc_jni | 897 } // namespace webrtc_jni |
897 | 898 |
OLD | NEW |