@@ -70,7 +70,8 @@ func rtpH264ContainsIDR(pkt *rtp.Packet) bool {
70
70
}
71
71
}
72
72
73
- // H264 is a format that uses the H264 codef.
73
+ // H264 is a RTP format that uses the H264 codec, defined in MPEG-4 part 10.
74
+ // Specification: https://datatracker.ietf.org/doc/html/rfc6184
74
75
type H264 struct {
75
76
PayloadTyp uint8
76
77
SPS []byte
@@ -101,14 +102,14 @@ func (f *H264) unmarshal(payloadType uint8, clock string, codec string, rtpmap s
101
102
for key , val := range fmtp {
102
103
switch key {
103
104
case "sprop-parameter-sets" :
104
- tmp2 := strings .Split (val , "," )
105
- if len (tmp2 ) >= 2 {
106
- sps , err := base64 .StdEncoding .DecodeString (tmp2 [0 ])
105
+ tmp := strings .Split (val , "," )
106
+ if len (tmp ) >= 2 {
107
+ sps , err := base64 .StdEncoding .DecodeString (tmp [0 ])
107
108
if err != nil {
108
109
return fmt .Errorf ("invalid sprop-parameter-sets (%v)" , val )
109
110
}
110
111
111
- pps , err := base64 .StdEncoding .DecodeString (tmp2 [1 ])
112
+ pps , err := base64 .StdEncoding .DecodeString (tmp [1 ])
112
113
if err != nil {
113
114
return fmt .Errorf ("invalid sprop-parameter-sets (%v)" , val )
114
115
}
@@ -118,12 +119,12 @@ func (f *H264) unmarshal(payloadType uint8, clock string, codec string, rtpmap s
118
119
}
119
120
120
121
case "packetization-mode" :
121
- tmp2 , err := strconv .ParseInt (val , 10 , 64 )
122
+ tmp , err := strconv .ParseInt (val , 10 , 64 )
122
123
if err != nil {
123
124
return fmt .Errorf ("invalid packetization-mode (%v)" , val )
124
125
}
125
126
126
- f .PacketizationMode = int (tmp2 )
127
+ f .PacketizationMode = int (tmp )
127
128
}
128
129
}
129
130
@@ -141,15 +142,15 @@ func (f *H264) Marshal() (string, map[string]string) {
141
142
fmtp ["packetization-mode" ] = strconv .FormatInt (int64 (f .PacketizationMode ), 10 )
142
143
}
143
144
144
- var tmp2 []string
145
+ var tmp []string
145
146
if f .SPS != nil {
146
- tmp2 = append (tmp2 , base64 .StdEncoding .EncodeToString (f .SPS ))
147
+ tmp = append (tmp , base64 .StdEncoding .EncodeToString (f .SPS ))
147
148
}
148
149
if f .PPS != nil {
149
- tmp2 = append (tmp2 , base64 .StdEncoding .EncodeToString (f .PPS ))
150
+ tmp = append (tmp , base64 .StdEncoding .EncodeToString (f .PPS ))
150
151
}
151
- if tmp2 != nil {
152
- fmtp ["sprop-parameter-sets" ] = strings .Join (tmp2 , "," )
152
+ if tmp != nil {
153
+ fmtp ["sprop-parameter-sets" ] = strings .Join (tmp , "," )
153
154
}
154
155
if len (f .SPS ) >= 4 {
155
156
fmtp ["profile-level-id" ] = strings .ToUpper (hex .EncodeToString (f .SPS [1 :4 ]))
@@ -163,7 +164,7 @@ func (f *H264) PTSEqualsDTS(pkt *rtp.Packet) bool {
163
164
return rtpH264ContainsIDR (pkt )
164
165
}
165
166
166
- // CreateDecoder creates a decoder able to decode the content of the formaf .
167
+ // CreateDecoder creates a decoder able to decode the content of the format .
167
168
func (f * H264 ) CreateDecoder () * rtph264.Decoder {
168
169
d := & rtph264.Decoder {
169
170
PacketizationMode : f .PacketizationMode ,
@@ -172,7 +173,7 @@ func (f *H264) CreateDecoder() *rtph264.Decoder {
172
173
return d
173
174
}
174
175
175
- // CreateEncoder creates an encoder able to encode the content of the formaf .
176
+ // CreateEncoder creates an encoder able to encode the content of the format .
176
177
func (f * H264 ) CreateEncoder () * rtph264.Encoder {
177
178
e := & rtph264.Encoder {
178
179
PayloadType : f .PayloadTyp ,
0 commit comments