simplify examples (#493)

This commit is contained in:
Alessandro Ros
2024-01-01 19:56:40 +01:00
committed by GitHub
parent 013a8d8463
commit bcd17a992c
8 changed files with 28 additions and 20 deletions

View File

@@ -52,6 +52,7 @@ func main() {
// setup H264 -> MPEG-TS muxer
mpegtsMuxer := &mpegtsMuxer{
fileName: "mystream.ts",
sps: forma.SPS,
pps: forma.PPS,
}

View File

@@ -15,6 +15,7 @@ func durationGoToMPEGTS(v time.Duration) int64 {
// mpegtsMuxer allows to save a H264 stream into a MPEG-TS file.
type mpegtsMuxer struct {
fileName string
sps []byte
pps []byte
@@ -28,7 +29,7 @@ type mpegtsMuxer struct {
// initialize initializes a mpegtsMuxer.
func (e *mpegtsMuxer) initialize() error {
var err error
e.f, err = os.Create("mystream.ts")
e.f, err = os.Create(e.fileName)
if err != nil {
return err
}

View File

@@ -52,6 +52,7 @@ func main() {
// setup H265 -> MPEG-TS muxer
mpegtsMuxer := &mpegtsMuxer{
fileName: "mystream.ts",
vps: forma.VPS,
sps: forma.SPS,
pps: forma.PPS,

View File

@@ -15,6 +15,7 @@ func durationGoToMPEGTS(v time.Duration) int64 {
// mpegtsMuxer allows to save a H265 stream into a MPEG-TS file.
type mpegtsMuxer struct {
fileName string
vps []byte
sps []byte
pps []byte
@@ -29,7 +30,7 @@ type mpegtsMuxer struct {
// initialize initializes a mpegtsMuxer.
func (e *mpegtsMuxer) initialize() error {
var err error
e.f, err = os.Create("mystream.ts")
e.f, err = os.Create(e.fileName)
if err != nil {
return err
}

View File

@@ -51,6 +51,7 @@ func main() {
// setup MPEG-4 audio -> MPEG-TS muxer
mpegtsMuxer := &mpegtsMuxer{
fileName: "mystream.ts",
config: forma.Config,
}
mpegtsMuxer.initialize()

View File

@@ -15,6 +15,7 @@ func durationGoToMPEGTS(v time.Duration) int64 {
// mpegtsMuxer allows to save a MPEG4-audio stream into a MPEG-TS file.
type mpegtsMuxer struct {
fileName string
config *mpeg4audio.Config
f *os.File
@@ -26,7 +27,7 @@ type mpegtsMuxer struct {
// initialize initializes a mpegtsMuxer.
func (e *mpegtsMuxer) initialize() error {
var err error
e.f, err = os.Create("mystream.ts")
e.f, err = os.Create(e.fileName)
if err != nil {
return err
}

View File

@@ -84,6 +84,7 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
// setup H264 -> MPEGTS muxer
mpegtsMuxer := &mpegtsMuxer{
fileName: "mystream.ts",
sps: forma.SPS,
pps: forma.PPS,
}

View File

@@ -15,6 +15,7 @@ func durationGoToMPEGTS(v time.Duration) int64 {
// mpegtsMuxer allows to save a H264 stream into a MPEG-TS file.
type mpegtsMuxer struct {
fileName string
sps []byte
pps []byte
@@ -28,7 +29,7 @@ type mpegtsMuxer struct {
// initialize initializes a mpegtsMuxer.
func (e *mpegtsMuxer) initialize() error {
var err error
e.f, err = os.Create("mystream.ts")
e.f, err = os.Create(e.fileName)
if err != nil {
return err
}