mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-09-26 19:51:26 +08:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/bluenviron/gohlslib/v2](https://github.com/bluenviron/gohlslib) from 2.2.1 to 2.2.2. - [Commits](https://github.com/bluenviron/gohlslib/compare/v2.2.1...v2.2.2) --- updated-dependencies: - dependency-name: github.com/bluenviron/gohlslib/v2 dependency-version: 2.2.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
77 lines
1.3 KiB
Go
77 lines
1.3 KiB
Go
package playback
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio"
|
|
"github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4"
|
|
"github.com/bluenviron/mediacommon/v2/pkg/formats/mp4"
|
|
"github.com/bluenviron/mediamtx/internal/test"
|
|
)
|
|
|
|
func writeBenchInit(f io.WriteSeeker) {
|
|
init := fmp4.Init{
|
|
Tracks: []*fmp4.InitTrack{
|
|
{
|
|
ID: 1,
|
|
TimeScale: 90000,
|
|
Codec: &mp4.CodecH264{
|
|
SPS: test.FormatH264.SPS,
|
|
PPS: test.FormatH264.PPS,
|
|
},
|
|
},
|
|
{
|
|
ID: 2,
|
|
TimeScale: 90000,
|
|
Codec: &mp4.CodecMPEG4Audio{
|
|
Config: mpeg4audio.AudioSpecificConfig{
|
|
Type: mpeg4audio.ObjectTypeAACLC,
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
err := init.Marshal(f)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
_, err = f.Write([]byte{
|
|
0x00, 0x00, 0x00, 0x10, 'm', 'o', 'o', 'f',
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func BenchmarkFMP4ReadHeader(b *testing.B) {
|
|
f, err := os.CreateTemp(os.TempDir(), "mediamtx-playback-fmp4-")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer os.Remove(f.Name())
|
|
|
|
writeBenchInit(f)
|
|
f.Close()
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
func() {
|
|
f, err = os.Open(f.Name())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer f.Close()
|
|
|
|
_, _, err = segmentFMP4ReadHeader(f)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}()
|
|
}
|
|
}
|