Skip to content

Commit

Permalink
VideoToolbox を H265 に対応する
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Jun 13, 2024
1 parent ee0b514 commit c88631c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
- @melpon
- [ADD] NVIDIA Video Codec SDK の H.265 ハードウェアエンコーダ/デコーダに対応する
- @melpon
- [ADD] videoToolbox の H.265 ハードウェアエンコーダ/デコーダに対応する
- @melpon

## 2023.1.0

Expand Down
14 changes: 14 additions & 0 deletions src/rtc/momo_video_decoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ MomoVideoDecoderFactory::GetSupportedFormats() const {
supported_codecs.push_back(webrtc::SdpVideoFormat(cricket::kH265CodecName));
}

if (config_.h265_decoder == VideoCodecInfo::Type::VideoToolbox) {
// VideoToolbox の場合は video_decoder_factory_ から H265 を拾ってくる
for (auto format : video_decoder_factory_->GetSupportedFormats()) {
if (absl::EqualsIgnoreCase(format.name, cricket::kH265CodecName)) {
supported_codecs.push_back(format);
}
}
}

return supported_codecs;
}

Expand Down Expand Up @@ -248,6 +257,11 @@ std::unique_ptr<webrtc::VideoDecoder> MomoVideoDecoderFactory::Create(
}

if (absl::EqualsIgnoreCase(format.name, cricket::kH265CodecName)) {
#if defined(__APPLE__)
if (config_.h265_decoder == VideoCodecInfo::Type::VideoToolbox) {
return video_decoder_factory_->Create(env, format);
}
#endif
#if defined(USE_NVCODEC_ENCODER)
if (config_.h265_decoder == VideoCodecInfo::Type::NVIDIA) {
return std::unique_ptr<webrtc::VideoDecoder>(
Expand Down
17 changes: 17 additions & 0 deletions src/rtc/momo_video_encoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ MomoVideoEncoderFactory::GetSupportedFormats() const {
#endif
}

if (config_.h265_encoder == VideoCodecInfo::Type::VideoToolbox) {
// VideoToolbox の場合は video_encoder_factory_ から H264 を拾ってくる
for (auto format : video_encoder_factory_->GetSupportedFormats()) {
if (absl::EqualsIgnoreCase(format.name, cricket::kH265CodecName)) {
supported_codecs.push_back(format);
}
}
}

return supported_codecs;
}

Expand Down Expand Up @@ -340,6 +349,14 @@ std::unique_ptr<webrtc::VideoEncoder> MomoVideoEncoderFactory::Create(
}

if (absl::EqualsIgnoreCase(format.name, cricket::kH265CodecName)) {
#if defined(__APPLE__)
if (config_.h265_encoder == VideoCodecInfo::Type::VideoToolbox) {
return WithSimulcast(format,
[this5 env](const webrtc::SdpVideoFormat& format) {
return video_encoder_factory_->Create(env, format);
});
}
#endif
#if defined(USE_NVCODEC_ENCODER)
if (config_.h265_encoder == VideoCodecInfo::Type::NVIDIA &&
sora::NvCodecVideoEncoder::IsSupported(config_.cuda_context,
Expand Down
2 changes: 2 additions & 0 deletions src/video_codec_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ struct VideoCodecInfo {

info.h264_encoders.push_back(Type::VideoToolbox);
info.h264_decoders.push_back(Type::VideoToolbox);
info.h265_encoders.push_back(Type::VideoToolbox);
info.h265_decoders.push_back(Type::VideoToolbox);
info.vp8_encoders.push_back(Type::Software);
info.vp9_encoders.push_back(Type::Software);
info.vp8_decoders.push_back(Type::Software);
Expand Down

0 comments on commit c88631c

Please sign in to comment.