tests for MediaTrack, moving interfaces to new package

This commit is contained in:
David Zhao
2020-12-31 23:24:45 -08:00
parent 313236e3d3
commit 0336e9d92f
23 changed files with 1210 additions and 191 deletions
+13 -2
View File
@@ -7,6 +7,7 @@ import (
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/proto/livekit"
)
@@ -41,7 +42,7 @@ func UnpackDataTrackLabel(packed string) (peerId string, trackId string, label s
return
}
func ToProtoParticipants(participants []Participant) []*livekit.ParticipantInfo {
func ToProtoParticipants(participants []types.Participant) []*livekit.ParticipantInfo {
infos := make([]*livekit.ParticipantInfo, 0, len(participants))
for _, op := range participants {
infos = append(infos, op.ToProto())
@@ -87,7 +88,7 @@ func FromProtoTrickle(trickle *livekit.Trickle) webrtc.ICECandidateInit {
return ci
}
func ToProtoTrack(t PublishedTrack) *livekit.TrackInfo {
func ToProtoTrack(t types.PublishedTrack) *livekit.TrackInfo {
return &livekit.TrackInfo{
Sid: t.ID(),
Type: t.Kind(),
@@ -96,6 +97,16 @@ func ToProtoTrack(t PublishedTrack) *livekit.TrackInfo {
}
}
func ToProtoTrackKind(kind webrtc.RTPCodecType) livekit.TrackInfo_Type {
switch kind {
case webrtc.RTPCodecTypeVideo:
return livekit.TrackInfo_VIDEO
case webrtc.RTPCodecTypeAudio:
return livekit.TrackInfo_AUDIO
}
panic("unsupported track kind")
}
func IsEOF(err error) bool {
return err == io.ErrClosedPipe || err == io.EOF
}