This repository was archived by the owner on Aug 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream_specifier.go
95 lines (81 loc) · 1.61 KB
/
stream_specifier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package ffmpeg
import "fmt"
type StreamType int
const (
StreamTypeAll StreamType = iota - 1
StreamTypeVideo StreamType = iota
StreamTypeAudio
StreamTypeSubtitle
StreamTypeData
StreamTypeAttachment
)
func (st StreamType) String() string {
switch st {
case StreamTypeVideo:
return "v"
case StreamTypeAudio:
return "a"
case StreamTypeSubtitle:
return "s"
case StreamTypeData:
return "d"
case StreamTypeAttachment:
return "t"
default:
return ""
}
}
type StreamSpecifier struct {
Stream StreamType
Idx int
}
func (s StreamSpecifier) String() string {
if s.Idx == -1 {
return ":" + s.Stream.String()
} else if s.Stream == StreamTypeAll {
return fmt.Sprintf(":%d", s.Idx)
}
return fmt.Sprintf(":%s:%d", s.Stream, s.Idx)
}
func AllStreamSpecifier() StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeAll,
Idx: -1,
}
}
func StreamIndexSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeAll,
Idx: idx,
}
}
func VideoStreamSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeVideo,
Idx: idx,
}
}
func AudioStreamSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeAudio,
Idx: idx,
}
}
func SubtitleStreamSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeSubtitle,
Idx: idx,
}
}
func DataStreamSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeData,
Idx: idx,
}
}
func AttachmentStreamSpecifier(idx int) StreamSpecifier {
return StreamSpecifier{
Stream: StreamTypeAttachment,
Idx: idx,
}
}