Skip to content

Commit bef1843

Browse files
committed
Add more comments
1 parent ac3c24a commit bef1843

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/ex_webrtc/rtp/h264.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ defmodule ExWebRTC.RTP.H264 do
1717
#
1818
# Janus also does it this way.
1919
# https://github.com/meetecho/janus-gateway/blob/3367f41de9225daed812ca0991c259f1458fe49f/src/utils.h#L352
20+
#
21+
# For more info, refer to the H264 spec and RFC 6184, sections 5.4 and 6
22+
# https://datatracker.ietf.org/doc/html/rfc6184#section-5.4
2023

2124
@doc """
2225
Returns a boolean telling if the packets contains a beginning of a H264 intra-frame.
@@ -27,14 +30,21 @@ defmodule ExWebRTC.RTP.H264 do
2730

2831
def keyframe?(%Packet{}), do: false
2932

33+
# Reserved
3034
defp do_keyframe?(0, _), do: false
35+
36+
# Single NAL Unit packets: check if NALU contains SPS (type 7)
3137
defp do_keyframe?(nalu_type, _) when nalu_type in 1..23, do: nalu_type == 7
38+
39+
# STAP-A
3240
defp do_keyframe?(24, aus), do: check_aggr_units(24, aus)
3341

42+
# STAP-B, MTAP16, MTAP24
3443
defp do_keyframe?(nalu_type, <<_don::16, aus::binary>>)
3544
when nalu_type in 25..27,
3645
do: check_aggr_units(nalu_type, aus)
3746

47+
# FU-A, FU-B
3848
defp do_keyframe?(nalu_type, <<s::1, _e::1, _r::1, type::5, _fu_payload::binary>>)
3949
when nalu_type in 28..29,
4050
do: s == 1 and type == 7

0 commit comments

Comments
 (0)