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 #include <deque> | 15 #include <deque> |
16 | 16 |
17 #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" | 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 { |
| 23 namespace jni { |
23 | 24 |
24 // Wraps a Java decoder and delegates all calls to it. Passes | 25 // Wraps a Java decoder and delegates all calls to it. Passes |
25 // VideoDecoderWrapperCallback to the decoder on InitDecode. Wraps the received | 26 // VideoDecoderWrapperCallback to the decoder on InitDecode. Wraps the received |
26 // frames to AndroidVideoBuffer. | 27 // frames to AndroidVideoBuffer. |
27 class VideoDecoderWrapper : public webrtc::VideoDecoder { | 28 class VideoDecoderWrapper : public VideoDecoder { |
28 public: | 29 public: |
29 VideoDecoderWrapper(JNIEnv* jni, jobject decoder); | 30 VideoDecoderWrapper(JNIEnv* jni, jobject decoder); |
30 | 31 |
31 int32_t InitDecode(const webrtc::VideoCodec* codec_settings, | 32 int32_t InitDecode(const VideoCodec* codec_settings, |
32 int32_t number_of_cores) override; | 33 int32_t number_of_cores) override; |
33 | 34 |
34 int32_t Decode(const webrtc::EncodedImage& input_image, | 35 int32_t Decode(const EncodedImage& input_image, |
35 bool missing_frames, | 36 bool missing_frames, |
36 const webrtc::RTPFragmentationHeader* fragmentation, | 37 const RTPFragmentationHeader* fragmentation, |
37 const webrtc::CodecSpecificInfo* codec_specific_info, | 38 const CodecSpecificInfo* codec_specific_info, |
38 int64_t render_time_ms) override; | 39 int64_t render_time_ms) override; |
39 | 40 |
40 int32_t RegisterDecodeCompleteCallback( | 41 int32_t RegisterDecodeCompleteCallback( |
41 webrtc::DecodedImageCallback* callback) override; | 42 DecodedImageCallback* callback) override; |
42 | 43 |
43 int32_t Release() override; | 44 int32_t Release() override; |
44 | 45 |
45 // Returns true if the decoder prefer to decode frames late. | 46 // Returns true if the decoder prefer to decode frames late. |
46 // That is, it can not decode infinite number of frames before the decoded | 47 // That is, it can not decode infinite number of frames before the decoded |
47 // frame is consumed. | 48 // frame is consumed. |
48 bool PrefersLateDecoding() const override; | 49 bool PrefersLateDecoding() const override; |
49 | 50 |
50 const char* ImplementationName() const override; | 51 const char* ImplementationName() const override; |
51 | 52 |
(...skipping 10 matching lines...) Expand all Loading... |
62 uint32_t timestamp_rtp; | 63 uint32_t timestamp_rtp; |
63 rtc::Optional<uint8_t> qp; | 64 rtc::Optional<uint8_t> qp; |
64 }; | 65 }; |
65 | 66 |
66 int32_t InitDecodeInternal(JNIEnv* jni); | 67 int32_t InitDecodeInternal(JNIEnv* jni); |
67 | 68 |
68 // Takes Java VideoCodecStatus, handles it and returns WEBRTC_VIDEO_CODEC_* | 69 // Takes Java VideoCodecStatus, handles it and returns WEBRTC_VIDEO_CODEC_* |
69 // status code. | 70 // status code. |
70 int32_t HandleReturnCode(JNIEnv* jni, jobject code); | 71 int32_t HandleReturnCode(JNIEnv* jni, jobject code); |
71 | 72 |
72 rtc::Optional<uint8_t> ParseQP(const webrtc::EncodedImage& input_image); | 73 rtc::Optional<uint8_t> ParseQP(const EncodedImage& input_image); |
73 | 74 |
74 webrtc::VideoCodec codec_settings_; | 75 VideoCodec codec_settings_; |
75 int32_t number_of_cores_; | 76 int32_t number_of_cores_; |
76 | 77 |
77 bool initialized_; | 78 bool initialized_; |
78 AndroidVideoBufferFactory android_video_buffer_factory_; | 79 AndroidVideoBufferFactory android_video_buffer_factory_; |
79 std::deque<FrameExtraInfo> frame_extra_infos_; | 80 std::deque<FrameExtraInfo> frame_extra_infos_; |
80 bool qp_parsing_enabled_; | 81 bool qp_parsing_enabled_; |
81 webrtc::H264BitstreamParser h264_bitstream_parser_; | 82 H264BitstreamParser h264_bitstream_parser_; |
82 | 83 |
83 webrtc::DecodedImageCallback* callback_; | 84 DecodedImageCallback* callback_; |
84 | 85 |
85 const ScopedGlobalRef<jobject> decoder_; | 86 const ScopedGlobalRef<jobject> decoder_; |
86 const ScopedGlobalRef<jclass> encoded_image_class_; | 87 const ScopedGlobalRef<jclass> encoded_image_class_; |
87 const ScopedGlobalRef<jclass> frame_type_class_; | 88 const ScopedGlobalRef<jclass> frame_type_class_; |
88 const ScopedGlobalRef<jclass> settings_class_; | 89 const ScopedGlobalRef<jclass> settings_class_; |
89 const ScopedGlobalRef<jclass> video_frame_class_; | 90 const ScopedGlobalRef<jclass> video_frame_class_; |
90 const ScopedGlobalRef<jclass> video_codec_status_class_; | 91 const ScopedGlobalRef<jclass> video_codec_status_class_; |
91 const ScopedGlobalRef<jclass> integer_class_; | 92 const ScopedGlobalRef<jclass> integer_class_; |
92 | 93 |
93 jmethodID encoded_image_constructor_; | 94 jmethodID encoded_image_constructor_; |
94 jmethodID settings_constructor_; | 95 jmethodID settings_constructor_; |
95 | 96 |
96 jfieldID empty_frame_field_; | 97 jfieldID empty_frame_field_; |
97 jfieldID video_frame_key_field_; | 98 jfieldID video_frame_key_field_; |
98 jfieldID video_frame_delta_field_; | 99 jfieldID video_frame_delta_field_; |
99 | 100 |
100 jmethodID video_frame_get_timestamp_ns_method_; | 101 jmethodID video_frame_get_timestamp_ns_method_; |
101 | 102 |
102 jmethodID init_decode_method_; | 103 jmethodID init_decode_method_; |
103 jmethodID release_method_; | 104 jmethodID release_method_; |
104 jmethodID decode_method_; | 105 jmethodID decode_method_; |
105 jmethodID get_prefers_late_decoding_method_; | 106 jmethodID get_prefers_late_decoding_method_; |
106 jmethodID get_implementation_name_method_; | 107 jmethodID get_implementation_name_method_; |
107 | 108 |
108 jmethodID get_number_method_; | 109 jmethodID get_number_method_; |
109 | 110 |
110 jmethodID integer_constructor_; | 111 jmethodID integer_constructor_; |
111 jmethodID int_value_method_; | 112 jmethodID int_value_method_; |
112 | 113 |
113 jobject ConvertEncodedImageToJavaEncodedImage( | 114 jobject ConvertEncodedImageToJavaEncodedImage(JNIEnv* jni, |
114 JNIEnv* jni, | 115 const EncodedImage& image); |
115 const webrtc::EncodedImage& image); | |
116 }; | 116 }; |
117 | 117 |
118 } // namespace webrtc_jni | 118 } // namespace jni |
| 119 } // namespace webrtc |
119 | 120 |
120 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ | 121 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEODECODERWRAPPER_H_ |
OLD | NEW |