forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream.go
75 lines (58 loc) · 1.5 KB
/
stream.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
package astiav
//#cgo pkg-config: libavformat
//#include <libavformat/avformat.h>
import "C"
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L937
type Stream struct {
c *C.struct_AVStream
}
func newStreamFromC(c *C.struct_AVStream) *Stream {
if c == nil {
return nil
}
return &Stream{c: c}
}
func (s *Stream) AvgFrameRate() Rational {
return newRationalFromC(s.c.avg_frame_rate)
}
func (s *Stream) CodecParameters() *CodecParameters {
return newCodecParametersFromC(s.c.codecpar)
}
func (s *Stream) Duration() int64 {
return int64(s.c.duration)
}
func (s *Stream) EventFlags() StreamEventFlags {
return StreamEventFlags(s.c.event_flags)
}
func (s *Stream) ID() int {
return int(s.c.id)
}
func (s *Stream) Index() int {
return int(s.c.index)
}
func (s *Stream) Metadata() *Dictionary {
return newDictionaryFromC(s.c.metadata)
}
func (s *Stream) NbFrames() int64 {
return int64(s.c.nb_frames)
}
func (s *Stream) RFrameRate() Rational {
return newRationalFromC(s.c.r_frame_rate)
}
func (s *Stream) SampleAspectRatio() Rational {
return newRationalFromC(s.c.sample_aspect_ratio)
}
func (s *Stream) SideData(t PacketSideDataType) []byte {
return bytesFromC(func(size *C.int) *C.uint8_t {
return C.av_stream_get_side_data(s.c, (C.enum_AVPacketSideDataType)(t), size)
})
}
func (s *Stream) StartTime() int64 {
return int64(s.c.start_time)
}
func (s *Stream) TimeBase() Rational {
return newRationalFromC(s.c.time_base)
}
func (s *Stream) SetTimeBase(r Rational) {
s.c.time_base = r.c
}