forked from External/mediamtx
parent
1d4ea2cd9a
commit
4e581af7a6
2 changed files with 53 additions and 1 deletions
|
|
@ -54,7 +54,6 @@ func (mi *muxerInstance) initialize() error {
|
|||
if mi.directory != "" {
|
||||
muxerDirectory = filepath.Join(mi.directory, mi.pathName)
|
||||
os.MkdirAll(muxerDirectory, 0o755)
|
||||
defer os.Remove(muxerDirectory)
|
||||
}
|
||||
|
||||
mi.hmuxer = &gohlslib.Muxer{
|
||||
|
|
@ -91,6 +90,9 @@ func (mi *muxerInstance) close() {
|
|||
mi.writer.Stop()
|
||||
mi.hmuxer.Close()
|
||||
mi.stream.RemoveReader(mi.writer)
|
||||
if mi.hmuxer.Directory != "" {
|
||||
os.Remove(mi.hmuxer.Directory)
|
||||
}
|
||||
}
|
||||
|
||||
func (mi *muxerInstance) createVideoTrack() *gohlslib.Track {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package hls
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -293,3 +295,51 @@ func TestServerRead(t *testing.T) {
|
|||
<-recv
|
||||
})
|
||||
}
|
||||
|
||||
func TestDirectory(t *testing.T) {
|
||||
dir, err := os.MkdirTemp("", "mediamtx-playback")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
desc := &description.Session{Medias: []*description.Media{test.MediaH264}}
|
||||
|
||||
stream, err := stream.New(
|
||||
1460,
|
||||
desc,
|
||||
true,
|
||||
test.NilLogger{},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
pathManager := &dummyPathManager{stream: stream}
|
||||
|
||||
s := &Server{
|
||||
Address: "127.0.0.1:8888",
|
||||
Encryption: false,
|
||||
ServerKey: "",
|
||||
ServerCert: "",
|
||||
AlwaysRemux: true,
|
||||
Variant: conf.HLSVariant(gohlslib.MuxerVariantMPEGTS),
|
||||
SegmentCount: 7,
|
||||
SegmentDuration: conf.StringDuration(1 * time.Second),
|
||||
PartDuration: conf.StringDuration(200 * time.Millisecond),
|
||||
SegmentMaxSize: 50 * 1024 * 1024,
|
||||
AllowOrigin: "",
|
||||
TrustedProxies: conf.IPNetworks{},
|
||||
Directory: filepath.Join(dir, "mydir"),
|
||||
ReadTimeout: conf.StringDuration(10 * time.Second),
|
||||
WriteQueueSize: 512,
|
||||
PathManager: pathManager,
|
||||
Parent: &test.NilLogger{},
|
||||
}
|
||||
err = s.Initialize()
|
||||
require.NoError(t, err)
|
||||
defer s.Close()
|
||||
|
||||
s.PathReady(&dummyPath{})
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
_, err = os.Stat(filepath.Join(dir, "mydir", "mystream"))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue