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 SDK_ANDROID_SRC_JNI_VIDEO_ENCODER_FACTORY_WRAPPER_H_ 12 #define SDK_ANDROID_SRC_JNI_VIDEO_ENCODER_FACTORY_WRAPPER_H_ 13 14 #include <jni.h> 15 #include <vector> 16 17 #include "api/video_codecs/sdp_video_format.h" 18 #include "api/video_codecs/video_encoder_factory.h" 19 #include "sdk/android/src/jni/jni_helpers.h" 20 21 namespace webrtc { 22 namespace jni { 23 24 // Wrapper for Java VideoEncoderFactory class. Delegates method calls through 25 // JNI and wraps the encoder inside VideoEncoderWrapper. 26 class VideoEncoderFactoryWrapper : public VideoEncoderFactory { 27 public: 28 VideoEncoderFactoryWrapper(JNIEnv* jni, 29 const JavaRef<jobject>& encoder_factory); 30 ~VideoEncoderFactoryWrapper() override; 31 32 std::unique_ptr<VideoEncoder> CreateVideoEncoder( 33 const SdpVideoFormat& format) override; 34 35 // Returns a list of supported codecs in order of preference. 36 std::vector<SdpVideoFormat> GetSupportedFormats() const override; 37 38 std::vector<SdpVideoFormat> GetImplementations() const override; 39 40 CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override; 41 42 std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override; 43 44 private: 45 const ScopedJavaGlobalRef<jobject> encoder_factory_; 46 std::vector<SdpVideoFormat> supported_formats_; 47 std::vector<SdpVideoFormat> implementations_; 48 }; 49 50 } // namespace jni 51 } // namespace webrtc 52 53 #endif // SDK_ANDROID_SRC_JNI_VIDEO_ENCODER_FACTORY_WRAPPER_H_ 54