OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_VIDEOENCODERFACTORYWRAPPER_H_ |
| 12 #define WEBRTC_SDK_ANDROID_SRC_JNI_VIDEOENCODERFACTORYWRAPPER_H_ |
| 13 |
| 14 #include <jni.h> |
| 15 #include <vector> |
| 16 |
| 17 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 18 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
| 19 |
| 20 namespace webrtc { |
| 21 namespace jni { |
| 22 |
| 23 // Wrapper for Java VideoEncoderFactory class. Delegates method calls through |
| 24 // JNI and wraps the encoder inside VideoEncoderWrapper. |
| 25 class VideoEncoderFactoryWrapper : public cricket::WebRtcVideoEncoderFactory { |
| 26 public: |
| 27 VideoEncoderFactoryWrapper(JNIEnv* jni, jobject encoder_factory); |
| 28 |
| 29 // Caller takes the ownership of the returned object and it should be released |
| 30 // by calling DestroyVideoEncoder(). |
| 31 VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override; |
| 32 |
| 33 // Returns a list of supported codecs in order of preference. |
| 34 const std::vector<cricket::VideoCodec>& supported_codecs() const override { |
| 35 return supported_codecs_; |
| 36 } |
| 37 |
| 38 void DestroyVideoEncoder(VideoEncoder* encoder) override; |
| 39 |
| 40 private: |
| 41 std::vector<cricket::VideoCodec> GetSupportedCodecs(JNIEnv* jni) const; |
| 42 jobject ToJavaCodecInfo(JNIEnv* jni, const cricket::VideoCodec& codec); |
| 43 |
| 44 const ScopedGlobalRef<jclass> video_codec_info_class_; |
| 45 const ScopedGlobalRef<jclass> hash_map_class_; |
| 46 const ScopedGlobalRef<jobject> encoder_factory_; |
| 47 |
| 48 jmethodID create_encoder_method_; |
| 49 jmethodID get_supported_codecs_method_; |
| 50 |
| 51 jmethodID video_codec_info_constructor_; |
| 52 jfieldID payload_field_; |
| 53 jfieldID name_field_; |
| 54 jfieldID params_field_; |
| 55 |
| 56 jmethodID hash_map_constructor_; |
| 57 jmethodID put_method_; |
| 58 |
| 59 std::vector<cricket::VideoCodec> supported_codecs_; |
| 60 }; |
| 61 |
| 62 } // namespace jni |
| 63 } // namespace webrtc |
| 64 |
| 65 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEOENCODERFACTORYWRAPPER_H_ |
OLD | NEW |