diff --git a/api/video_codecs/video_encoder_factory.h b/api/video_codecs/video_encoder_factory.h index 7958d16acc..1f80fa74db 100644 --- a/api/video_codecs/video_encoder_factory.h +++ b/api/video_codecs/video_encoder_factory.h @@ -14,10 +14,11 @@ #include #include +#include "api/video_codecs/sdp_video_format.h" + namespace webrtc { class VideoEncoder; -struct SdpVideoFormat; // A factory that creates VideoEncoders. // NOTE: This class is still under development and may change without notice. @@ -40,6 +41,14 @@ class VideoEncoderFactory { // for signaling etc. virtual std::vector GetSupportedFormats() const = 0; + // Returns a list of supported video formats in order of preference, that can + // also be tagged with additional information to allow the VideoEncoderFactory + // to separate between different implementations when CreateVideoEncoder is + // called. + virtual std::vector GetImplementations() const { + return GetSupportedFormats(); + } + // Returns information about how this format will be encoded. The specified // format must be one of the supported formats by this factory. // TODO(magjed): Try to get rid of this method. diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 984d6d9ee4..9658ade62d 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -581,7 +581,7 @@ std::vector WebRtcVideoChannel::SelectSendVideoCodecs( const std::vector& remote_mapped_codecs) const { std::vector sdp_formats = - encoder_factory_->GetSupportedFormats(); + encoder_factory_->GetImplementations(); // The returned vector holds the VideoCodecSettings in term of preference. // They are orderd by receive codec preference first and local implementation diff --git a/sdk/android/api/org/webrtc/VideoEncoderFactory.java b/sdk/android/api/org/webrtc/VideoEncoderFactory.java index 7c00d8d6a4..b318e8ba85 100644 --- a/sdk/android/api/org/webrtc/VideoEncoderFactory.java +++ b/sdk/android/api/org/webrtc/VideoEncoderFactory.java @@ -22,4 +22,14 @@ public interface VideoEncoderFactory { * result will be cached. */ @CalledByNative VideoCodecInfo[] getSupportedCodecs(); + + /** + * Enumerates the list of supported video codecs that can also be tagged with + * implementation information. This method will only be called once and the + * result will be cached. + */ + @CalledByNative + default VideoCodecInfo[] getImplementations() { + return getSupportedCodecs(); + } } diff --git a/sdk/android/src/jni/video_encoder_factory_wrapper.cc b/sdk/android/src/jni/video_encoder_factory_wrapper.cc index 6aace5fea8..538cc5bade 100644 --- a/sdk/android/src/jni/video_encoder_factory_wrapper.cc +++ b/sdk/android/src/jni/video_encoder_factory_wrapper.cc @@ -29,6 +29,10 @@ VideoEncoderFactoryWrapper::VideoEncoderFactoryWrapper( Java_VideoEncoderFactory_getSupportedCodecs(jni, encoder_factory); supported_formats_ = JavaToNativeVector( jni, j_supported_codecs, &VideoCodecInfoToSdpVideoFormat); + const ScopedJavaLocalRef j_implementations = + Java_VideoEncoderFactory_getImplementations(jni, encoder_factory); + implementations_ = JavaToNativeVector( + jni, j_implementations, &VideoCodecInfoToSdpVideoFormat); } VideoEncoderFactoryWrapper::~VideoEncoderFactoryWrapper() = default; @@ -49,6 +53,11 @@ std::vector VideoEncoderFactoryWrapper::GetSupportedFormats() return supported_formats_; } +std::vector VideoEncoderFactoryWrapper::GetImplementations() + const { + return implementations_; +} + VideoEncoderFactory::CodecInfo VideoEncoderFactoryWrapper::QueryVideoEncoder( const SdpVideoFormat& format) const { JNIEnv* jni = AttachCurrentThreadIfNeeded(); diff --git a/sdk/android/src/jni/video_encoder_factory_wrapper.h b/sdk/android/src/jni/video_encoder_factory_wrapper.h index 0650c12d32..7f033aea80 100644 --- a/sdk/android/src/jni/video_encoder_factory_wrapper.h +++ b/sdk/android/src/jni/video_encoder_factory_wrapper.h @@ -35,11 +35,14 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory { // Returns a list of supported codecs in order of preference. std::vector GetSupportedFormats() const override; + std::vector GetImplementations() const override; + CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override; private: const ScopedJavaGlobalRef encoder_factory_; std::vector supported_formats_; + std::vector implementations_; }; } // namespace jni