Skip to content

Commit 5cad3f1

Browse files
authored
Feat/add helper function for av1 and h265 codec (#611)
* bump deps version * Add NewRTPAV1Codec * fix comment * Update SDPFmtpLine for RTPAV1Codec * Add helper function for h265 as well
1 parent 9d5e9cb commit 5cad3f1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

pkg/codec/codec.go

+34
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ func NewRTPH264Codec(clockrate uint32) *RTPCodec {
3737
}
3838
}
3939

40+
// NewRTPH265Codec is a helper to create an H265 codec
41+
func NewRTPH265Codec(clockrate uint32) *RTPCodec {
42+
return &RTPCodec{
43+
RTPCodecParameters: webrtc.RTPCodecParameters{
44+
RTPCodecCapability: webrtc.RTPCodecCapability{
45+
MimeType: webrtc.MimeTypeH265,
46+
ClockRate: 90000,
47+
Channels: 0,
48+
SDPFmtpLine: "",
49+
RTCPFeedback: nil,
50+
},
51+
PayloadType: 125,
52+
},
53+
Payloader: &codecs.H265Payloader{},
54+
}
55+
}
56+
4057
// NewRTPVP8Codec is a helper to create an VP8 codec
4158
func NewRTPVP8Codec(clockrate uint32) *RTPCodec {
4259
return &RTPCodec{
@@ -71,6 +88,23 @@ func NewRTPVP9Codec(clockrate uint32) *RTPCodec {
7188
}
7289
}
7390

91+
// NewRTPAV1Codec is a helper to create an AV1 codec
92+
func NewRTPAV1Codec(clockrate uint32) *RTPCodec {
93+
return &RTPCodec{
94+
RTPCodecParameters: webrtc.RTPCodecParameters{
95+
RTPCodecCapability: webrtc.RTPCodecCapability{
96+
MimeType: webrtc.MimeTypeAV1,
97+
ClockRate: 90000,
98+
Channels: 0,
99+
SDPFmtpLine: "level-idx=5;profile=0;tier=0",
100+
RTCPFeedback: nil,
101+
},
102+
PayloadType: 99,
103+
},
104+
Payloader: &codecs.AV1Payloader{},
105+
}
106+
}
107+
74108
// NewRTPOpusCodec is a helper to create an Opus codec
75109
func NewRTPOpusCodec(clockrate uint32) *RTPCodec {
76110
return &RTPCodec{

0 commit comments

Comments
 (0)