forked from bluenviron/gortsplib
/
mjpeg.go
69 lines (53 loc) · 1.29 KB
/
mjpeg.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
package format //nolint:dupl
import (
"github.com/pion/rtp"
"github.com/Ariorhx/gortsplib/pkg/format/rtpmjpeg"
)
// MJPEG is a RTP format for the Motion-JPEG codec.
// Specification: https://datatracker.ietf.org/doc/html/rfc2435
type MJPEG struct{}
func (f *MJPEG) unmarshal(_ *unmarshalContext) error {
return nil
}
// Codec implements Format.
func (f *MJPEG) Codec() string {
return "M-JPEG"
}
// ClockRate implements Format.
func (f *MJPEG) ClockRate() int {
return 90000
}
// PayloadType implements Format.
func (f *MJPEG) PayloadType() uint8 {
return 26
}
// RTPMap implements Format.
func (f *MJPEG) RTPMap() string {
return "JPEG/90000"
}
// FMTP implements Format.
func (f *MJPEG) FMTP() map[string]string {
return nil
}
// PTSEqualsDTS implements Format.
func (f *MJPEG) PTSEqualsDTS(*rtp.Packet) bool {
return true
}
// CreateDecoder creates a decoder able to decode the content of the format.
func (f *MJPEG) CreateDecoder() (*rtpmjpeg.Decoder, error) {
d := &rtpmjpeg.Decoder{}
err := d.Init()
if err != nil {
return nil, err
}
return d, nil
}
// CreateEncoder creates an encoder able to encode the content of the format.
func (f *MJPEG) CreateEncoder() (*rtpmjpeg.Encoder, error) {
e := &rtpmjpeg.Encoder{}
err := e.Init()
if err != nil {
return nil, err
}
return e, nil
}