-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpkt.go
88 lines (71 loc) · 1.48 KB
/
pkt.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
package rtsp
// #include "ffmpeg.h"
import "C"
// Image image meta
type Image struct {
// only image
width int
height int
keyFrame bool
}
// Height if image or 0 if audio
func (image *Image) Height() int {
return image.height
}
// Width if image or 0 if audio
func (image *Image) Width() int {
return image.width
}
// Audio audio meta
type Audio struct {
// only audio
sampleRate int
bitRate int
channels int
}
// SampleRate if audio or 0 if image
func (audio *Audio) SampleRate() int {
return audio.sampleRate
}
// BitRate if audio or 0 if image
func (audio *Audio) BitRate() int {
return audio.bitRate
}
// Channels if audio or 0 if image
func (audio *Audio) Channels() int {
return audio.channels
}
// Packet decoded media packet
type Packet struct {
streamIndex int
codecType int
data []byte
duration int64
position int64
Image
Audio
}
// Data encoded jpeg if image or wav if audio
func (packet *Packet) Data() []byte {
return packet.data
}
// IsAudio is audio packet type
func (packet *Packet) IsAudio() bool {
return packet.codecType == C.AVMEDIA_TYPE_AUDIO
}
// IsVideo is video packet type
func (packet *Packet) IsVideo() bool {
return packet.codecType == C.AVMEDIA_TYPE_VIDEO
}
// Type packet type
func (packet *Packet) Type() int {
return packet.codecType
}
// Position frame position
func (packet *Packet) Position() int64 {
return packet.position
}
// Position frame duration
func (packet *Packet) Duration() int64 {
return packet.duration
}