MCPcopy
hub / github.com/q191201771/lal / remux

Method remux

pkg/remux/rtmp2rtsp.go:239–291  ·  view source on GitHub ↗
(msg base.RtmpMsg)

Source from the content-addressed store, hash-verified

237}
238
239func (r *Rtmp2RtspRemuxer) remux(msg base.RtmpMsg) {
240 var packer *rtprtcp.RtpPacker
241 var rtppkts []rtprtcp.RtpPacket
242 switch msg.Header.MsgTypeId {
243 case base.RtmpTypeIdAudio:
244 packer = r.getAudioPacker()
245 if packer != nil {
246 if msg.AudioCodecId() == base.RtmpSoundFormatG711A || msg.AudioCodecId() == base.RtmpSoundFormatG711U || msg.AudioCodecId() == base.RtmpSoundFormatOpus {
247 rtppkts = packer.Pack(base.AvPacket{
248 Timestamp: int64(msg.Header.TimestampAbs),
249 PayloadType: r.audioPt,
250 Payload: msg.Payload[1:],
251 })
252 } else {
253 rtppkts = packer.Pack(base.AvPacket{
254 Timestamp: int64(msg.Header.TimestampAbs),
255 PayloadType: r.audioPt,
256 Payload: msg.Payload[2:],
257 })
258 }
259 }
260 case base.RtmpTypeIdVideo:
261 packer = r.getVideoPacker()
262 if packer != nil {
263 var payload []byte
264 if msg.VideoCodecId() == base.RtmpCodecIdHevc && msg.IsEnchanedHevcNalu() {
265 index := msg.GetEnchanedHevcNaluIndex()
266 payload = msg.Payload[index:]
267 } else {
268 payload = msg.Payload[5:]
269 }
270
271 if RtspRemuxerAddSpsPps2KeyFrameFlag {
272 if msg.IsAvcKeyNalu() && r.sps != nil && r.pps != nil {
273 payload = h2645.JoinNaluAvcc(r.sps, r.pps, msg.Payload[9:])
274 }
275 if msg.IsHevcKeyNalu() && r.vps != nil && r.sps != nil && r.pps != nil {
276 payload = h2645.JoinNaluAvcc(r.vps, r.sps, r.pps, msg.Payload[9:])
277 }
278 }
279
280 rtppkts = r.getVideoPacker().Pack(base.AvPacket{
281 Timestamp: int64(msg.Header.TimestampAbs),
282 PayloadType: r.videoPt,
283 Payload: payload,
284 })
285 }
286 }
287
288 for i := range rtppkts {
289 r.onRtpPacket(rtppkts[i])
290 }
291}
292
293func (r *Rtmp2RtspRemuxer) getAudioPacker() *rtprtcp.RtpPacker {
294 if r.audioPacker == nil {

Callers 2

FeedRtmpMsgMethod · 0.95
doAnalyzeMethod · 0.95

Calls 11

getAudioPackerMethod · 0.95
PackMethod · 0.95
getVideoPackerMethod · 0.95
JoinNaluAvccFunction · 0.92
AudioCodecIdMethod · 0.80
VideoCodecIdMethod · 0.80
IsEnchanedHevcNaluMethod · 0.80
PackMethod · 0.65
IsAvcKeyNaluMethod · 0.45
IsHevcKeyNaluMethod · 0.45

Tested by

no test coverage detected