Add API for querying codec support.
Implement - BuiltinVideoEncoderFactory::QueryCodecSupport - QualityAnalyzingVideoEncoderFactory::QueryCodecSupport - FakeWebRtcVideoEncoderFactory::QueryCodecSupport Bug: webrtc:11607 Change-Id: I9a138bbdc809abf5577dd27d84a51d0ed77d62ba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290381 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38994}
This commit is contained in:
parent
07d64b4072
commit
b7f9113b72
@ -145,7 +145,10 @@ rtc_library("builtin_video_encoder_factory") {
|
|||||||
"../../rtc_base:checks",
|
"../../rtc_base:checks",
|
||||||
"../../rtc_base/system:rtc_export",
|
"../../rtc_base/system:rtc_export",
|
||||||
]
|
]
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
absl_deps = [
|
||||||
|
"//third_party/abseil-cpp/absl/strings",
|
||||||
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_source_set("video_encoder_factory_template") {
|
rtc_source_set("video_encoder_factory_template") {
|
||||||
|
|||||||
@ -11,9 +11,11 @@
|
|||||||
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/strings/match.h"
|
#include "absl/strings/match.h"
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "api/video_codecs/sdp_video_format.h"
|
#include "api/video_codecs/sdp_video_format.h"
|
||||||
#include "api/video_codecs/video_encoder.h"
|
#include "api/video_codecs/video_encoder.h"
|
||||||
#include "media/base/codec.h"
|
#include "media/base/codec.h"
|
||||||
@ -49,6 +51,13 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
|
|||||||
return internal_encoder_factory_->GetSupportedFormats();
|
return internal_encoder_factory_->GetSupportedFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodecSupport QueryCodecSupport(
|
||||||
|
const SdpVideoFormat& format,
|
||||||
|
absl::optional<std::string> scalability_mode) const override {
|
||||||
|
return internal_encoder_factory_->QueryCodecSupport(format,
|
||||||
|
scalability_mode);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<VideoEncoderFactory> internal_encoder_factory_;
|
const std::unique_ptr<VideoEncoderFactory> internal_encoder_factory_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -27,6 +27,21 @@ namespace {
|
|||||||
static constexpr webrtc::TimeDelta kEventTimeout =
|
static constexpr webrtc::TimeDelta kEventTimeout =
|
||||||
webrtc::TimeDelta::Seconds(10);
|
webrtc::TimeDelta::Seconds(10);
|
||||||
|
|
||||||
|
bool IsScalabilityModeSupported(
|
||||||
|
const std::vector<webrtc::SdpVideoFormat>& formats,
|
||||||
|
absl::optional<std::string> scalability_mode) {
|
||||||
|
if (!scalability_mode.has_value()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (const auto& format : formats) {
|
||||||
|
for (const auto& mode : format.scalability_modes) {
|
||||||
|
if (ScalabilityModeToString(mode) == scalability_mode)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Decoder.
|
// Decoder.
|
||||||
@ -203,6 +218,22 @@ FakeWebRtcVideoEncoderFactory::GetSupportedFormats() const {
|
|||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
webrtc::VideoEncoderFactory::CodecSupport
|
||||||
|
FakeWebRtcVideoEncoderFactory::QueryCodecSupport(
|
||||||
|
const webrtc::SdpVideoFormat& format,
|
||||||
|
absl::optional<std::string> scalability_mode) const {
|
||||||
|
std::vector<webrtc::SdpVideoFormat> supported_formats;
|
||||||
|
for (const auto& f : formats_) {
|
||||||
|
if (format.IsSameCodec(f))
|
||||||
|
supported_formats.push_back(f);
|
||||||
|
}
|
||||||
|
if (format.IsCodecInList(formats_)) {
|
||||||
|
return {.is_supported = IsScalabilityModeSupported(supported_formats,
|
||||||
|
scalability_mode)};
|
||||||
|
}
|
||||||
|
return {.is_supported = false};
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<webrtc::VideoEncoder>
|
std::unique_ptr<webrtc::VideoEncoder>
|
||||||
FakeWebRtcVideoEncoderFactory::CreateVideoEncoder(
|
FakeWebRtcVideoEncoderFactory::CreateVideoEncoder(
|
||||||
const webrtc::SdpVideoFormat& format) {
|
const webrtc::SdpVideoFormat& format) {
|
||||||
|
|||||||
@ -114,6 +114,9 @@ class FakeWebRtcVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
|||||||
FakeWebRtcVideoEncoderFactory();
|
FakeWebRtcVideoEncoderFactory();
|
||||||
|
|
||||||
std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
|
std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
|
||||||
|
webrtc::VideoEncoderFactory::CodecSupport QueryCodecSupport(
|
||||||
|
const webrtc::SdpVideoFormat& format,
|
||||||
|
absl::optional<std::string> scalability_mode) const override;
|
||||||
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
|
||||||
const webrtc::SdpVideoFormat& format) override;
|
const webrtc::SdpVideoFormat& format) override;
|
||||||
|
|
||||||
|
|||||||
@ -384,6 +384,13 @@ QualityAnalyzingVideoEncoderFactory::GetSupportedFormats() const {
|
|||||||
return delegate_->GetSupportedFormats();
|
return delegate_->GetSupportedFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoEncoderFactory::CodecSupport
|
||||||
|
QualityAnalyzingVideoEncoderFactory::QueryCodecSupport(
|
||||||
|
const SdpVideoFormat& format,
|
||||||
|
absl::optional<std::string> scalability_mode) const {
|
||||||
|
return delegate_->QueryCodecSupport(format, scalability_mode);
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder>
|
std::unique_ptr<VideoEncoder>
|
||||||
QualityAnalyzingVideoEncoderFactory::CreateVideoEncoder(
|
QualityAnalyzingVideoEncoderFactory::CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
|
|||||||
@ -173,6 +173,9 @@ class QualityAnalyzingVideoEncoderFactory : public VideoEncoderFactory {
|
|||||||
|
|
||||||
// Methods of VideoEncoderFactory interface.
|
// Methods of VideoEncoderFactory interface.
|
||||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
||||||
|
VideoEncoderFactory::CodecSupport QueryCodecSupport(
|
||||||
|
const SdpVideoFormat& format,
|
||||||
|
absl::optional<std::string> scalability_mode) const override;
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user