mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Rename stream struct
This commit is contained in:
parent
95b1caeb26
commit
5d47a28ba6
@ -17,7 +17,8 @@ type FileStream struct {
|
||||
Keyframes []float64
|
||||
CanTransmux bool
|
||||
Info *MediaInfo
|
||||
streams map[Quality]*TranscodeStream
|
||||
streams map[Quality]*VideoStream
|
||||
// audios map[uint32]*AudioStream
|
||||
}
|
||||
|
||||
func GetOutPath() string {
|
||||
@ -56,7 +57,7 @@ func NewFileStream(path string) (*FileStream, error) {
|
||||
Keyframes: keyframes,
|
||||
CanTransmux: can_transmux,
|
||||
Info: info.info,
|
||||
streams: make(map[Quality]*TranscodeStream),
|
||||
streams: make(map[Quality]*VideoStream),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -16,13 +16,13 @@ func Min(a int32, b int32) int32 {
|
||||
return b
|
||||
}
|
||||
|
||||
type Stream interface {
|
||||
type TranscodeStream interface {
|
||||
getTranscodeArgs(segments string) []string
|
||||
getOutPath() string
|
||||
}
|
||||
|
||||
type TranscodeStream struct {
|
||||
Stream
|
||||
type Stream struct {
|
||||
TranscodeStream
|
||||
file *FileStream
|
||||
Clients []string
|
||||
// true if the segment at given index is completed/transcoded, false otherwise
|
||||
@ -33,18 +33,7 @@ type TranscodeStream struct {
|
||||
// TODO: add ffmpeg process
|
||||
}
|
||||
|
||||
func NewStream(file *FileStream) (*TranscodeStream, error) {
|
||||
ret := TranscodeStream{
|
||||
file: file,
|
||||
Clients: make([]string, 4),
|
||||
segments: make([]bool, len(file.Keyframes)),
|
||||
}
|
||||
// Start the transcode up to the 100th segment (or less)
|
||||
ret.run(0, Min(100, int32(len(file.Keyframes))))
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (ts *TranscodeStream) run(start int32, end int32) error {
|
||||
func (ts *Stream) run(start int32, end int32) error {
|
||||
log.Printf(
|
||||
"Starting transcode for %s (from %d to %d out of %d segments)",
|
||||
ts.file.Path,
|
||||
@ -90,7 +79,7 @@ func (ts *TranscodeStream) run(start int32, end int32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ts *TranscodeStream) GetIndex(client string) (string, error) {
|
||||
func (ts *Stream) GetIndex(client string) (string, error) {
|
||||
index := `#EXTM3U
|
||||
#EXT-X-VERSION:3
|
||||
#EXT-X-PLAYLIST-TYPE:VOD
|
||||
|
@ -3,10 +3,24 @@ package src
|
||||
import "fmt"
|
||||
|
||||
type VideoStream struct {
|
||||
TranscodeStream
|
||||
Stream
|
||||
quality Quality
|
||||
}
|
||||
|
||||
func NewVideoStream(file *FileStream, quality Quality) (*VideoStream, error) {
|
||||
ret := VideoStream{
|
||||
Stream: Stream{
|
||||
file: file,
|
||||
Clients: make([]string, 4),
|
||||
segments: make([]bool, len(file.Keyframes)),
|
||||
},
|
||||
quality: quality,
|
||||
}
|
||||
// Start the transcode up to the 100th segment (or less)
|
||||
ret.run(0, Min(100, int32(len(file.Keyframes))))
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (vs *VideoStream) getOutPath() string {
|
||||
return fmt.Sprintf("%s/segment-%s-%%03d.ts", vs.file.Out, vs.quality)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user