Add VideoEncoderFactory::GetImplementations function.

The GetImplementations function is similar to the GetSupportedFormats function, but instead of providing one SdpVideoFormat per codec it provides one per codec implementation. These SdpVideoFormats can then be tagged so that a certain implementation can be instantiated when CreateVideoEncoder is called.

Bug: webrtc:10795
Change-Id: I79f2380aa03d75d5f9f36138625abf3543c2339d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145215
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28553}
This commit is contained in:
philipel
2019-07-11 13:23:16 +02:00
committed by Commit Bot
parent 66147e892d
commit 0bb0881892
5 changed files with 33 additions and 2 deletions

View File

@ -14,10 +14,11 @@
#include <memory>
#include <vector>
#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<SdpVideoFormat> 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<SdpVideoFormat> 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.

View File

@ -581,7 +581,7 @@ std::vector<WebRtcVideoChannel::VideoCodecSettings>
WebRtcVideoChannel::SelectSendVideoCodecs(
const std::vector<VideoCodecSettings>& remote_mapped_codecs) const {
std::vector<webrtc::SdpVideoFormat> 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

View File

@ -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();
}
}

View File

@ -29,6 +29,10 @@ VideoEncoderFactoryWrapper::VideoEncoderFactoryWrapper(
Java_VideoEncoderFactory_getSupportedCodecs(jni, encoder_factory);
supported_formats_ = JavaToNativeVector<SdpVideoFormat>(
jni, j_supported_codecs, &VideoCodecInfoToSdpVideoFormat);
const ScopedJavaLocalRef<jobjectArray> j_implementations =
Java_VideoEncoderFactory_getImplementations(jni, encoder_factory);
implementations_ = JavaToNativeVector<SdpVideoFormat>(
jni, j_implementations, &VideoCodecInfoToSdpVideoFormat);
}
VideoEncoderFactoryWrapper::~VideoEncoderFactoryWrapper() = default;
@ -49,6 +53,11 @@ std::vector<SdpVideoFormat> VideoEncoderFactoryWrapper::GetSupportedFormats()
return supported_formats_;
}
std::vector<SdpVideoFormat> VideoEncoderFactoryWrapper::GetImplementations()
const {
return implementations_;
}
VideoEncoderFactory::CodecInfo VideoEncoderFactoryWrapper::QueryVideoEncoder(
const SdpVideoFormat& format) const {
JNIEnv* jni = AttachCurrentThreadIfNeeded();

View File

@ -35,11 +35,14 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory {
// Returns a list of supported codecs in order of preference.
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
std::vector<SdpVideoFormat> GetImplementations() const override;
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
private:
const ScopedJavaGlobalRef<jobject> encoder_factory_;
std::vector<SdpVideoFormat> supported_formats_;
std::vector<SdpVideoFormat> implementations_;
};
} // namespace jni