Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new encoder factory for UWP MF encoder #37

Open
wants to merge 4 commits into
base: releases/m71
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion third_party/winuwp_h264/winuwp_h264_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#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 {

Expand Down Expand Up @@ -61,5 +61,32 @@ namespace webrtc {
delete decoder;
}

std::vector<SdpVideoFormat> WinUWPH264EncoderFactoryNew::GetSupportedFormats()
const {
std::vector<SdpVideoFormat> formats = { SdpVideoFormat("H264") };
return formats;
}

VideoEncoderFactory::CodecInfo WinUWPH264EncoderFactoryNew::QueryVideoEncoder(
const SdpVideoFormat& format) const {
CodecInfo info;
//not sure about this. mf does support hw MFTs but doesn't really tell us
//when using sink writer. it's more of a "silent sw fallback if hw not available" thing
info.is_hardware_accelerated = false;
info.has_internal_source = false;
return info;
}

std::unique_ptr<VideoEncoder> WinUWPH264EncoderFactoryNew::CreateVideoEncoder(
const SdpVideoFormat& format) {
if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) {
return std::make_unique<WinUWPH264EncoderImpl>();
}

RTC_LOG(LS_ERROR) << "Trying to create encoder of unsupported format "
<< format.name;
return nullptr;
}

} // namespace webrtc

11 changes: 11 additions & 0 deletions third_party/winuwp_h264/winuwp_h264_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#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 {

Expand All @@ -34,6 +35,16 @@ class WinUWPH264EncoderFactory : public cricket::WebRtcVideoEncoderFactory {
std::vector<cricket::VideoCodec> codecList_;
};

class WinUWPH264EncoderFactoryNew : public VideoEncoderFactory {
public:
std::vector<SdpVideoFormat> GetSupportedFormats() const override;

CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;

std::unique_ptr<VideoEncoder> CreateVideoEncoder(
const SdpVideoFormat& format) override;
};

class WinUWPH264DecoderFactory : public cricket::WebRtcVideoDecoderFactory {
webrtc::VideoDecoder* CreateVideoDecoder(webrtc::VideoCodecType type)
override;
Expand Down