Skip to content

Commit 9a6c8ee

Browse files
committed
Fix H.264 codec matching bug
1 parent 087f046 commit 9a6c8ee

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

webrtc-sys/src/video_decoder_factory.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ std::unique_ptr<webrtc::VideoDecoder> VideoDecoderFactory::Create(
106106
}
107107
}
108108

109+
// Platform HW decoders (VideoToolbox, MediaCodec) can decode any H.264
110+
// stream regardless of packetization-mode. IsSameCodec treats different
111+
// packetization-modes as distinct codecs, so when the SFU sends mode=0 but
112+
// the platform factory only advertises mode=1 the strict match above fails.
113+
// Retry with a relaxed name-only check before falling through to software.
114+
if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
115+
for (const auto& factory : factories_) {
116+
for (const auto& sf : factory->GetSupportedFormats()) {
117+
if (absl::EqualsIgnoreCase(sf.name, cricket::kH264CodecName))
118+
return factory->Create(env, format);
119+
}
120+
}
121+
}
122+
109123
if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
110124
return webrtc::CreateVp8Decoder(env);
111125
if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName))

0 commit comments

Comments
 (0)