forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack_pcma.go
61 lines (53 loc) · 1.09 KB
/
track_pcma.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
package gortsplib //nolint:dupl
import (
"fmt"
"strings"
psdp "github.com/pion/sdp/v3"
)
// TrackPCMA is a PCMA track.
type TrackPCMA struct {
trackBase
}
func newTrackPCMAFromMediaDescription(
control string,
rtpmapPart1 string) (*TrackPCMA, error,
) {
tmp := strings.Split(rtpmapPart1, "/")
if len(tmp) >= 3 && tmp[2] != "1" {
return nil, fmt.Errorf("PCMA tracks must have only one channel")
}
return &TrackPCMA{
trackBase: trackBase{
control: control,
},
}, nil
}
// ClockRate returns the track clock rate.
func (t *TrackPCMA) ClockRate() int {
return 8000
}
func (t *TrackPCMA) clone() Track {
return &TrackPCMA{
trackBase: t.trackBase,
}
}
// MediaDescription returns the track media description in SDP format.
func (t *TrackPCMA) MediaDescription() *psdp.MediaDescription {
return &psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "audio",
Protos: []string{"RTP", "AVP"},
Formats: []string{"8"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "8 PCMA/8000",
},
{
Key: "control",
Value: t.control,
},
},
}
}