Skip to content

Commit 6787272

Browse files
Fix H.264 codec matching (#931)
* Fix H.264 codec matching bug * Packetization mode only * Auto generate changeset * Address comment * Changeset --------- Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
1 parent 087f046 commit 6787272

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
webrtc-sys: patch
3+
livekit-ffi: patch
4+
libwebrtc: patch
5+
livekit: patch
6+
---
7+
8+
# Fix H.264 codec matching

webrtc-sys/src/video_decoder_factory.cpp

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

109+
// IsSameCodec treats H.264 packetization-modes as distinct codecs, so when
110+
// the SFU sends mode=0 but the platform factory only advertises mode=1 the
111+
// strict match above fails. Retry with the factory's packetization-mode so
112+
// only that parameter is relaxed while the profile-level-id check is kept.
113+
if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
114+
for (const auto& factory : factories_) {
115+
for (const auto& sf : factory->GetSupportedFormats()) {
116+
if (!absl::EqualsIgnoreCase(sf.name, cricket::kH264CodecName))
117+
continue;
118+
auto adjusted = format;
119+
auto it = sf.parameters.find("packetization-mode");
120+
if (it != sf.parameters.end())
121+
adjusted.parameters["packetization-mode"] = it->second;
122+
else
123+
adjusted.parameters.erase("packetization-mode");
124+
if (sf.IsSameCodec(adjusted))
125+
return factory->Create(env, adjusted);
126+
}
127+
}
128+
}
129+
109130
if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
110131
return webrtc::CreateVp8Decoder(env);
111132
if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName))

0 commit comments

Comments
 (0)