10 Star 38 Fork 19

Gitee 极速下载 / Pion-WebRTC

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/pion/webrtc
克隆/下载
rtptransceiverdirection.go 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
Woodrow Douglass 提交于 2023-09-12 11:39 . Remove the "Unknown" constant
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package webrtc
// RTPTransceiverDirection indicates the direction of the RTPTransceiver.
type RTPTransceiverDirection int
const (
// RTPTransceiverDirectionUnknown is the enum's zero-value
RTPTransceiverDirectionUnknown RTPTransceiverDirection = iota
// RTPTransceiverDirectionSendrecv indicates the RTPSender will offer
// to send RTP and the RTPReceiver will offer to receive RTP.
RTPTransceiverDirectionSendrecv
// RTPTransceiverDirectionSendonly indicates the RTPSender will offer
// to send RTP.
RTPTransceiverDirectionSendonly
// RTPTransceiverDirectionRecvonly indicates the RTPReceiver will
// offer to receive RTP.
RTPTransceiverDirectionRecvonly
// RTPTransceiverDirectionInactive indicates the RTPSender won't offer
// to send RTP and the RTPReceiver won't offer to receive RTP.
RTPTransceiverDirectionInactive
)
// This is done this way because of a linter.
const (
rtpTransceiverDirectionSendrecvStr = "sendrecv"
rtpTransceiverDirectionSendonlyStr = "sendonly"
rtpTransceiverDirectionRecvonlyStr = "recvonly"
rtpTransceiverDirectionInactiveStr = "inactive"
)
// NewRTPTransceiverDirection defines a procedure for creating a new
// RTPTransceiverDirection from a raw string naming the transceiver direction.
func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection {
switch raw {
case rtpTransceiverDirectionSendrecvStr:
return RTPTransceiverDirectionSendrecv
case rtpTransceiverDirectionSendonlyStr:
return RTPTransceiverDirectionSendonly
case rtpTransceiverDirectionRecvonlyStr:
return RTPTransceiverDirectionRecvonly
case rtpTransceiverDirectionInactiveStr:
return RTPTransceiverDirectionInactive
default:
return RTPTransceiverDirectionUnknown
}
}
func (t RTPTransceiverDirection) String() string {
switch t {
case RTPTransceiverDirectionSendrecv:
return rtpTransceiverDirectionSendrecvStr
case RTPTransceiverDirectionSendonly:
return rtpTransceiverDirectionSendonlyStr
case RTPTransceiverDirectionRecvonly:
return rtpTransceiverDirectionRecvonlyStr
case RTPTransceiverDirectionInactive:
return rtpTransceiverDirectionInactiveStr
default:
return ErrUnknownType.Error()
}
}
// Revers indicate the opposite direction
func (t RTPTransceiverDirection) Revers() RTPTransceiverDirection {
switch t {
case RTPTransceiverDirectionSendonly:
return RTPTransceiverDirectionRecvonly
case RTPTransceiverDirectionRecvonly:
return RTPTransceiverDirectionSendonly
default:
return t
}
}
func haveRTPTransceiverDirectionIntersection(haystack []RTPTransceiverDirection, needle []RTPTransceiverDirection) bool {
for _, n := range needle {
for _, h := range haystack {
if n == h {
return true
}
}
}
return false
}
1
https://gitee.com/mirrors/Pion-WebRTC.git
git@gitee.com:mirrors/Pion-WebRTC.git
mirrors
Pion-WebRTC
Pion-WebRTC
master

搜索帮助