Fix MSE in Safari

This commit is contained in:
Alexey Khit
2023-01-27 12:39:51 +03:00
parent a1fec1c6f6
commit e8e43f9d68
2 changed files with 6 additions and 16 deletions
+5 -5
View File
@@ -250,7 +250,7 @@ func (m *Movie) WriteAudioTrack(id uint32, codec string, timescale uint32, chann
m.EndAtom() // TRAK m.EndAtom() // TRAK
} }
func (m *Movie) WriteMovieFragment(seq, tid, duration, size, flags uint32, time uint64) { func (m *Movie) WriteMovieFragment(seq, tid, duration, size uint32, time uint64) {
m.StartAtom(Moof) m.StartAtom(Moof)
m.StartAtom(MoofMfhd) m.StartAtom(MoofMfhd)
@@ -276,10 +276,10 @@ func (m *Movie) WriteMovieFragment(seq, tid, duration, size, flags uint32, time
TfhdDefaultSampleFlags | TfhdDefaultSampleFlags |
TfhdDefaultBaseIsMoof, TfhdDefaultBaseIsMoof,
) )
m.WriteUint32(tid) // track id m.WriteUint32(tid) // track id
m.WriteUint32(duration) // default sample duration m.WriteUint32(duration) // default sample duration
m.WriteUint32(size) // default sample size m.WriteUint32(size) // default sample size
m.WriteUint32(flags) // default sample flags m.WriteUint32(0x2000000) // default sample flags
m.EndAtom() m.EndAtom()
m.StartAtom(MoofTrafTfdt) m.StartAtom(MoofTrafTfdt)
+1 -11
View File
@@ -13,7 +13,6 @@ import (
type Muxer struct { type Muxer struct {
fragIndex uint32 fragIndex uint32
flags []uint32
dts []uint64 dts []uint64
pts []uint32 pts []uint32
} }
@@ -78,8 +77,6 @@ func (m *Muxer) GetInit(codecs []*streamer.Codec) ([]byte, error) {
codecData.AVCDecoderConfRecordBytes(), codecData.AVCDecoderConfRecordBytes(),
) )
m.flags = append(m.flags, 0x1010000)
case streamer.CodecH265: case streamer.CodecH265:
vps, sps, pps := h265.GetParameterSet(codec.FmtpLine) vps, sps, pps := h265.GetParameterSet(codec.FmtpLine)
if sps == nil { if sps == nil {
@@ -100,8 +97,6 @@ func (m *Muxer) GetInit(codecs []*streamer.Codec) ([]byte, error) {
codecData.AVCDecoderConfRecordBytes(), codecData.AVCDecoderConfRecordBytes(),
) )
m.flags = append(m.flags, 0x1010000)
case streamer.CodecAAC: case streamer.CodecAAC:
s := streamer.Between(codec.FmtpLine, "config=", ";") s := streamer.Between(codec.FmtpLine, "config=", ";")
b, err := hex.DecodeString(s) b, err := hex.DecodeString(s)
@@ -113,14 +108,10 @@ func (m *Muxer) GetInit(codecs []*streamer.Codec) ([]byte, error) {
uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, b, uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, b,
) )
m.flags = append(m.flags, 0x2000000)
case streamer.CodecOpus: case streamer.CodecOpus:
mv.WriteAudioTrack( mv.WriteAudioTrack(
uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, nil, uint32(i+1), codec.Name, codec.ClockRate, codec.Channels, nil,
) )
m.flags = append(m.flags, 0x2000000)
} }
m.pts = append(m.pts, 0) m.pts = append(m.pts, 0)
@@ -166,8 +157,7 @@ func (m *Muxer) Marshal(trackID byte, packet *rtp.Packet) []byte {
mv := iso.NewMovie(1024 + len(packet.Payload)) mv := iso.NewMovie(1024 + len(packet.Payload))
mv.WriteMovieFragment( mv.WriteMovieFragment(
m.fragIndex, uint32(trackID+1), duration, m.fragIndex, uint32(trackID+1), duration,
uint32(len(packet.Payload)), uint32(len(packet.Payload)), time,
m.flags[trackID], time,
) )
mv.WriteData(packet.Payload) mv.WriteData(packet.Payload)