| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 |
| 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ | 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ |
| 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ | 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ |
| 13 | 13 |
| 14 #include <jni.h> | 14 #include <jni.h> |
| 15 | |
| 16 #include <deque> | 15 #include <deque> |
| 17 | 16 |
| 18 #include "webrtc/api/video_codecs/video_decoder.h" | 17 #include "webrtc/api/video_codecs/video_decoder.h" |
| 18 #include "webrtc/common_video/h264/h264_bitstream_parser.h" |
| 19 #include "webrtc/sdk/android/src/jni/jni_helpers.h" | 19 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
| 20 #include "webrtc/sdk/android/src/jni/native_handle_impl.h" | 20 #include "webrtc/sdk/android/src/jni/native_handle_impl.h" |
| 21 | 21 |
| 22 namespace webrtc_jni { | 22 namespace webrtc_jni { |
| 23 | 23 |
| 24 // Wraps a Java decoder and delegates all calls to it. Passes | 24 // Wraps a Java decoder and delegates all calls to it. Passes |
| 25 // VideoDecoderWrapperCallback to the decoder on InitDecode. Wraps the received | 25 // VideoDecoderWrapperCallback to the decoder on InitDecode. Wraps the received |
| 26 // frames to AndroidVideoBuffer. | 26 // frames to AndroidVideoBuffer. |
| 27 class VideoDecoderWrapper : public webrtc::VideoDecoder { | 27 class VideoDecoderWrapper : public webrtc::VideoDecoder { |
| 28 public: | 28 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 53 void OnDecodedFrame(JNIEnv* jni, | 53 void OnDecodedFrame(JNIEnv* jni, |
| 54 jobject jframe, | 54 jobject jframe, |
| 55 jobject jdecode_time_ms, | 55 jobject jdecode_time_ms, |
| 56 jobject jqp); | 56 jobject jqp); |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 struct FrameExtraInfo { | 59 struct FrameExtraInfo { |
| 60 uint32_t capture_time_ms; // Used as an identifier of the frame. | 60 uint32_t capture_time_ms; // Used as an identifier of the frame. |
| 61 | 61 |
| 62 uint32_t timestamp_rtp; | 62 uint32_t timestamp_rtp; |
| 63 rtc::Optional<uint8_t> qp; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 int32_t InitDecodeInternal(JNIEnv* jni); | 66 int32_t InitDecodeInternal(JNIEnv* jni); |
| 66 | 67 |
| 67 // Takes Java VideoCodecStatus, handles it and returns WEBRTC_VIDEO_CODEC_* | 68 // Takes Java VideoCodecStatus, handles it and returns WEBRTC_VIDEO_CODEC_* |
| 68 // status code. | 69 // status code. |
| 69 int32_t HandleReturnCode(JNIEnv* jni, jobject code); | 70 int32_t HandleReturnCode(JNIEnv* jni, jobject code); |
| 70 | 71 |
| 72 rtc::Optional<uint8_t> ParseQP(const webrtc::EncodedImage& input_image); |
| 73 |
| 71 webrtc::VideoCodec codec_settings_; | 74 webrtc::VideoCodec codec_settings_; |
| 72 int32_t number_of_cores_; | 75 int32_t number_of_cores_; |
| 73 | 76 |
| 74 bool initialized_; | 77 bool initialized_; |
| 75 AndroidVideoBufferFactory android_video_buffer_factory_; | 78 AndroidVideoBufferFactory android_video_buffer_factory_; |
| 76 std::deque<FrameExtraInfo> frame_extra_infos_; | 79 std::deque<FrameExtraInfo> frame_extra_infos_; |
| 80 bool qp_parsing_enabled_; |
| 81 webrtc::H264BitstreamParser h264_bitstream_parser_; |
| 77 | 82 |
| 78 webrtc::DecodedImageCallback* callback_; | 83 webrtc::DecodedImageCallback* callback_; |
| 79 | 84 |
| 80 const ScopedGlobalRef<jobject> decoder_; | 85 const ScopedGlobalRef<jobject> decoder_; |
| 81 const ScopedGlobalRef<jclass> encoded_image_class_; | 86 const ScopedGlobalRef<jclass> encoded_image_class_; |
| 82 const ScopedGlobalRef<jclass> frame_type_class_; | 87 const ScopedGlobalRef<jclass> frame_type_class_; |
| 83 const ScopedGlobalRef<jclass> settings_class_; | 88 const ScopedGlobalRef<jclass> settings_class_; |
| 84 const ScopedGlobalRef<jclass> video_frame_class_; | 89 const ScopedGlobalRef<jclass> video_frame_class_; |
| 85 const ScopedGlobalRef<jclass> video_codec_status_class_; | 90 const ScopedGlobalRef<jclass> video_codec_status_class_; |
| 86 const ScopedGlobalRef<jclass> integer_class_; | 91 const ScopedGlobalRef<jclass> integer_class_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 106 jmethodID int_value_method_; | 111 jmethodID int_value_method_; |
| 107 | 112 |
| 108 jobject ConvertEncodedImageToJavaEncodedImage( | 113 jobject ConvertEncodedImageToJavaEncodedImage( |
| 109 JNIEnv* jni, | 114 JNIEnv* jni, |
| 110 const webrtc::EncodedImage& image); | 115 const webrtc::EncodedImage& image); |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 } // namespace webrtc_jni | 118 } // namespace webrtc_jni |
| 114 | 119 |
| 115 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ | 120 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ |
| OLD | NEW |