Chromium Code Reviews| Index: webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc |
| diff --git a/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc b/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc |
| index c89f902a62a449703c396223a97a78872eeae29e..f09fc735ce3d877203b6bd0f7c1ca8d8e1994bec 100644 |
| --- a/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc |
| +++ b/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc |
| @@ -11,6 +11,7 @@ |
| #include <algorithm> |
| #include <memory> |
| #include <vector> |
| +#include <deque> |
|
magjed_webrtc
2017/02/16 20:22:20
sort the list
sakal
2017/02/17 09:23:43
Done.
|
| // NOTICE: androidmediadecoder_jni.h must be included before |
| // androidmediacodeccommon.h to avoid build errors. |
| @@ -29,7 +30,9 @@ |
| #include "webrtc/base/scoped_ref_ptr.h" |
| #include "webrtc/base/thread.h" |
| #include "webrtc/base/timeutils.h" |
| +#include "webrtc/common_video/h264/h264_bitstream_parser.h" |
| #include "webrtc/common_video/include/i420_buffer_pool.h" |
| +#include "webrtc/modules/video_coding/utility/vp8_header_parser.h" |
|
magjed_webrtc
2017/02/16 20:22:20
sort the list
sakal
2017/02/17 09:23:43
Done.
|
| #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| #include "webrtc/system_wrappers/include/logcat_trace_context.h" |
| @@ -132,6 +135,8 @@ class MediaCodecVideoDecoder : public webrtc::VideoDecoder, |
| int current_decoding_time_ms_; // Overall decoding time in the current second |
| int current_delay_time_ms_; // Overall delay time in the current second. |
| uint32_t max_pending_frames_; // Maximum number of pending input frames. |
| + webrtc::H264BitstreamParser h264_bitstream_parser_; |
| + std::deque<int> pending_frame_qps_; |
|
magjed_webrtc
2017/02/16 20:22:20
Why not a regular queue? You don't need it to be d
sakal
2017/02/17 09:23:43
queue type doesn't have clear method that is requi
|
| // State that is constant for the lifetime of this object once the ctor |
| // returns. |
| @@ -323,6 +328,7 @@ void MediaCodecVideoDecoder::ResetVariables() { |
| current_bytes_ = 0; |
| current_decoding_time_ms_ = 0; |
| current_delay_time_ms_ = 0; |
| + pending_frame_qps_.clear(); |
| } |
| int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() { |
| @@ -653,6 +659,15 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( |
| // Save input image timestamps for later output. |
| frames_received_++; |
| current_bytes_ += inputImage._length; |
| + int qp = -1; |
|
magjed_webrtc
2017/02/16 20:22:20
Use a 'rtc::Optional<uint8_t> qp' directly instead
sakal
2017/02/17 09:23:43
Done.
|
| + if (codecType_ == kVideoCodecVP8) { |
| + webrtc::vp8::GetQp(inputImage._buffer, inputImage._length, &qp); |
| + } else if (codecType_ == kVideoCodecH264) { |
| + h264_bitstream_parser_.ParseBitstream(inputImage._buffer, |
| + inputImage._length); |
| + h264_bitstream_parser_.GetLastSliceQp(&qp); |
| + } |
| + pending_frame_qps_.push_back(qp); |
| // Feed input to decoder. |
| bool success = jni->CallBooleanMethod( |
| @@ -679,6 +694,7 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( |
| bool MediaCodecVideoDecoder::DeliverPendingOutputs( |
| JNIEnv* jni, int dequeue_timeout_ms) { |
| + CheckOnCodecThread(); |
| if (frames_received_ <= frames_decoded_) { |
| // No need to query for output buffers - decoder is drained. |
| return true; |
| @@ -861,11 +877,11 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs( |
| decoded_frame.set_timestamp(output_timestamps_ms); |
| decoded_frame.set_ntp_time_ms(output_ntp_timestamps_ms); |
| - const int32_t callback_status = |
| - callback_->Decoded(decoded_frame, decode_time_ms); |
| - if (callback_status > 0) { |
| - ALOGE << "callback error"; |
| - } |
| + int qp = pending_frame_qps_.front(); |
| + pending_frame_qps_.pop_front(); |
| + callback_->Decoded( |
|
magjed_webrtc
2017/02/16 20:22:20
Why did you remove the return value check?
sakal
2017/02/17 09:23:43
The new callback doesn't include a return value be
|
| + decoded_frame, rtc::Optional<int32_t>(decode_time_ms), |
| + qp != -1 ? rtc::Optional<uint8_t>(qp) : rtc::Optional<uint8_t>()); |
| } |
| return true; |
| } |