Skip to content

Commit

Permalink
Add H265 Support
Browse files Browse the repository at this point in the history
Resolves #177
  • Loading branch information
Sean-Der committed Jan 5, 2025
1 parent f637a06 commit 000d319
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/webrtc/track_multi_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type trackMultiCodec struct {
ssrc webrtc.SSRC
writeStream webrtc.TrackLocalWriter

payloadTypeH264, payloadTypeVP8, payloadTypeVP9, payloadTypeAV1 uint8
payloadTypeH264, payloadTypeH265, payloadTypeVP8, payloadTypeVP9, payloadTypeAV1 uint8

id, rid, streamID string
}
Expand All @@ -29,6 +29,8 @@ func (t *trackMultiCodec) Bind(ctx webrtc.TrackLocalContext) (webrtc.RTPCodecPar
t.payloadTypeVP9 = uint8(codecs[i].PayloadType)
case videoTrackCodecAV1:
t.payloadTypeAV1 = uint8(codecs[i].PayloadType)
case videoTrackCodecH265:
t.payloadTypeH265 = uint8(codecs[i].PayloadType)
}
}

Expand All @@ -51,6 +53,8 @@ func (t *trackMultiCodec) WriteRTP(p *rtp.Packet, codec videoTrackCodec) error {
p.Header.PayloadType = t.payloadTypeVP9
case videoTrackCodecAV1:
p.Header.PayloadType = t.payloadTypeAV1
case videoTrackCodecH265:
p.Header.PayloadType = t.payloadTypeH265
}

_, err := t.writeStream.WriteRTP(&p.Header, p.Payload)
Expand Down
4 changes: 4 additions & 0 deletions internal/webrtc/webrtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
videoTrackCodecVP8
videoTrackCodecVP9
videoTrackCodecAV1
videoTrackCodecH265
)

type (
Expand Down Expand Up @@ -81,6 +82,8 @@ func getVideoTrackCodec(in string) videoTrackCodec {
return videoTrackCodecVP9
case strings.Contains(downcased, strings.ToLower(webrtc.MimeTypeAV1)):
return videoTrackCodecAV1
case strings.Contains(downcased, strings.ToLower(webrtc.MimeTypeH265)):
return videoTrackCodecH265
}

return 0
Expand Down Expand Up @@ -305,6 +308,7 @@ func PopulateMediaEngine(m *webrtc.MediaEngine) error {
{45, webrtc.MimeTypeAV1, ""},
{98, webrtc.MimeTypeVP9, "profile-id=0"},
{100, webrtc.MimeTypeVP9, "profile-id=2"},
{113, webrtc.MimeTypeH265, "level-id=93;profile-id=1;tier-flag=0;tx-mode=SRST"},
} {
if err := m.RegisterCodec(webrtc.RTPCodecParameters{
RTPCodecCapability: webrtc.RTPCodecCapability{
Expand Down

0 comments on commit 000d319

Please sign in to comment.