Skip to content

Commit

Permalink
Use errors.Join to simplify codec registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamlinman committed Sep 5, 2024
1 parent cc04771 commit 3eb419d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions internal/api/webrtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"encoding/json"
"errors"
"log"
"net/http"
"sync"
Expand All @@ -27,20 +28,15 @@ func init() {
)

var me webrtc.MediaEngine

videoParameters := webrtc.RTPCodecParameters{
PayloadType: videoPayloadType,
RTPCodecCapability: tuner.VideoCodecCapability,
}
if err := me.RegisterCodec(videoParameters, webrtc.RTPCodecTypeVideo); err != nil {
panic(err)
}

audioParameters := webrtc.RTPCodecParameters{
PayloadType: audioPayloadType,
RTPCodecCapability: tuner.AudioCodecCapability,
}
if err := me.RegisterCodec(audioParameters, webrtc.RTPCodecTypeAudio); err != nil {
err := errors.Join(
me.RegisterCodec(
webrtc.RTPCodecParameters{PayloadType: videoPayloadType, RTPCodecCapability: tuner.VideoCodecCapability},
webrtc.RTPCodecTypeVideo),
me.RegisterCodec(
webrtc.RTPCodecParameters{PayloadType: audioPayloadType, RTPCodecCapability: tuner.AudioCodecCapability},
webrtc.RTPCodecTypeAudio),
)
if err != nil {
panic(err)
}

Expand Down

0 comments on commit 3eb419d

Please sign in to comment.