@@ -17,6 +17,9 @@ defmodule ExWebRTC.RTP.H264 do
17
17
#
18
18
# Janus also does it this way.
19
19
# 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
20
23
21
24
@ doc """
22
25
Returns a boolean telling if the packets contains a beginning of a H264 intra-frame.
@@ -27,14 +30,21 @@ defmodule ExWebRTC.RTP.H264 do
27
30
28
31
def keyframe? ( % Packet { } ) , do: false
29
32
33
+ # Reserved
30
34
defp do_keyframe? ( 0 , _ ) , do: false
35
+
36
+ # Single NAL Unit packets: check if NALU contains SPS (type 7)
31
37
defp do_keyframe? ( nalu_type , _ ) when nalu_type in 1 .. 23 , do: nalu_type == 7
38
+
39
+ # STAP-A
32
40
defp do_keyframe? ( 24 , aus ) , do: check_aggr_units ( 24 , aus )
33
41
42
+ # STAP-B, MTAP16, MTAP24
34
43
defp do_keyframe? ( nalu_type , << _don :: 16 , aus :: binary >> )
35
44
when nalu_type in 25 .. 27 ,
36
45
do: check_aggr_units ( nalu_type , aus )
37
46
47
+ # FU-A, FU-B
38
48
defp do_keyframe? ( nalu_type , << s :: 1 , _e :: 1 , _r :: 1 , type :: 5 , _fu_payload :: binary >> )
39
49
when nalu_type in 28 .. 29 ,
40
50
do: s == 1 and type == 7
0 commit comments