Skip to content

Commit 0846236

Browse files
fix: address review feedback on C ABI codec registry
- codec_name_to_cstring: use expect() instead of unwrap_or_default() to fail fast on programmer errors (matches lib.rs macro pattern) - Add tracing::warn! when EncodedVideo null custom_type_id falls back to Binary (aids debugging of new plugins vs backward compat) - Simplify map_err to forward original from_c_name() error messages - Add doc comments clarifying intentional field loss (bitstream_format, codec_private, profile, level) through C ABI pin-type declarations Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
1 parent 8a4b074 commit 0846236

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sdks/plugin-sdk/native/src/conversions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ pub fn packet_type_from_c(cpt_info: CPacketTypeInfo) -> Result<PacketType, Strin
7474
Ok(PacketType::Binary)
7575
} else {
7676
let name = unsafe { c_str_to_string(cpt_info.custom_type_id) }?;
77-
let codec = VideoCodec::from_c_name(&name)
78-
.map_err(|e| format!("EncodedVideo: {e}"))?;
77+
let codec =
78+
VideoCodec::from_c_name(&name).map_err(|e| format!("EncodedVideo: {e}"))?;
7979
// Note: bitstream_format, codec_private, profile, and level
8080
// are not carried through the C ABI — this conversion is used
8181
// for pin-type declarations only, not runtime packet data.
@@ -96,8 +96,7 @@ pub fn packet_type_from_c(cpt_info: CPacketTypeInfo) -> Result<PacketType, Strin
9696
AudioCodec::Opus
9797
} else {
9898
let name = unsafe { c_str_to_string(cpt_info.custom_type_id) }?;
99-
AudioCodec::from_c_name(&name)
100-
.map_err(|e| format!("EncodedAudio: {e}"))?
99+
AudioCodec::from_c_name(&name).map_err(|e| format!("EncodedAudio: {e}"))?
101100
};
102101
// Note: codec_private is not carried through the C ABI — this
103102
// conversion is used for pin-type declarations only.

0 commit comments

Comments
 (0)