diff --git a/third_party/winuwp_h264/winuwp_h264_factory.cc b/third_party/winuwp_h264/winuwp_h264_factory.cc index 99714ca21d..c32674c599 100644 --- a/third_party/winuwp_h264/winuwp_h264_factory.cc +++ b/third_party/winuwp_h264/winuwp_h264_factory.cc @@ -14,38 +14,10 @@ #include "third_party/winuwp_h264/H264Decoder/H264Decoder.h" #include "media/engine/webrtcvideoencoderfactory.h" #include "media/engine/webrtcvideodecoderfactory.h" - +#include "rtc_base/logging.h" namespace webrtc { - WinUWPH264EncoderFactory::WinUWPH264EncoderFactory() { - codecList_ = - std::vector { - cricket::VideoCodec("H264") - }; - } - - webrtc::VideoEncoder* WinUWPH264EncoderFactory::CreateVideoEncoder( - const cricket::VideoCodec& codec) { - if (codec.name == "H264") { - return new WinUWPH264EncoderImpl(); - } else { - return nullptr; - } - } - - const std::vector& - WinUWPH264EncoderFactory::supported_codecs() const { - return codecList_; - } - - void WinUWPH264EncoderFactory::DestroyVideoEncoder( - webrtc::VideoEncoder* encoder) { - encoder->Release(); - delete encoder; - } - - webrtc::VideoDecoder* WinUWPH264DecoderFactory::CreateVideoDecoder( webrtc::VideoCodecType type) { if (type == kVideoCodecH264) { @@ -61,5 +33,45 @@ namespace webrtc { delete decoder; } + std::vector WinUWPH264EncoderFactory::GetSupportedFormats() + const { + std::vector formats = { + SdpVideoFormat(cricket::kH264CodecName, + { + //copy-pasted from h264.cc + {cricket::kH264FmtpProfileLevelId, "42100b"}, + {cricket::kH264FmtpLevelAsymmetryAllowed, "1"}, + {cricket::kH264FmtpPacketizationMode, "0"} + }), + SdpVideoFormat(cricket::kH264CodecName, + { + {cricket::kH264FmtpProfileLevelId, "42100b"}, + {cricket::kH264FmtpLevelAsymmetryAllowed, "1"}, + {cricket::kH264FmtpPacketizationMode, "1"} + }) + }; + return formats; + } + + VideoEncoderFactory::CodecInfo WinUWPH264EncoderFactory::QueryVideoEncoder( + const SdpVideoFormat& format) const { + CodecInfo info; + info.is_hardware_accelerated = true; + info.has_internal_source = false; + + return info; + } + + std::unique_ptr WinUWPH264EncoderFactory::CreateVideoEncoder( + const SdpVideoFormat& format) { + if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) { + return std::make_unique(); + } + + RTC_LOG(LS_ERROR) << "Trying to create encoder of unsupported format " + << format.name; + return nullptr; + } + } // namespace webrtc diff --git a/third_party/winuwp_h264/winuwp_h264_factory.h b/third_party/winuwp_h264/winuwp_h264_factory.h index a4e2399c34..c0b07c6101 100644 --- a/third_party/winuwp_h264/winuwp_h264_factory.h +++ b/third_party/winuwp_h264/winuwp_h264_factory.h @@ -15,23 +15,18 @@ #include "media/engine/webrtcvideoencoderfactory.h" #include "media/engine/webrtcvideodecoderfactory.h" #include "media/base/codec.h" +#include "api/video_codecs/video_encoder_factory.h" namespace webrtc { -class WinUWPH264EncoderFactory : public cricket::WebRtcVideoEncoderFactory { +class WinUWPH264EncoderFactory : public VideoEncoderFactory { public: - WinUWPH264EncoderFactory(); + std::vector GetSupportedFormats() const override; - webrtc::VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) - override; - - const std::vector& supported_codecs() - const override; - - void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override; + CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override; - private: - std::vector codecList_; + std::unique_ptr CreateVideoEncoder( + const SdpVideoFormat& format) override; }; class WinUWPH264DecoderFactory : public cricket::WebRtcVideoDecoderFactory {