Documentation
¶
Overview ¶
Package sora provides WebRTC signaling feature for WebRTC SFU Sora
Index ¶
- func CreateVideoCodec(codecType VideoCodecType) (*webrtc.RTPCodec, error)
- func SetLogger(l *log.Logger)
- type Connection
- func (c *Connection) ChannelID() string
- func (c *Connection) ClientID() string
- func (c *Connection) Connect() error
- func (c *Connection) ConnectionID() string
- func (c *Connection) Disconnect()
- func (c *Connection) OnConnect(f func())
- func (c *Connection) OnDisconnect(f func(reason string, err error))
- func (c *Connection) OnNetworkNotify(f func(eventType string, message *NetworkNotifyMessage))
- func (c *Connection) OnOpen(f func(pc *webrtc.PeerConnection, m webrtc.MediaEngine))
- func (c *Connection) OnPush(f func(message []byte))
- func (c *Connection) OnSignalingNotify(f func(eventType string, message *SignalingNotifyMessage))
- func (c *Connection) OnSpotlightNotify(f func(eventType string, message *SpotlightNotifyMessage))
- func (c *Connection) OnTrack(f func(track *webrtc.Track))
- func (c *Connection) OnTrackPacket(f func(track *webrtc.Track, packet *rtp.Packet))
- func (c *Connection) PeerConnection() *webrtc.PeerConnection
- type ConnectionOptions
- type Metadata
- type NetworkNotifyMessage
- type Role
- type SignalingNotifyMessage
- type Simulcast
- type SimulcastQuality
- type SpotlightNotifyMessage
- type Video
- type VideoCodecType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateVideoCodec ¶ added in v0.2.0
func CreateVideoCodec(codecType VideoCodecType) (*webrtc.RTPCodec, error)
CreateVideoCodec はコーデックに対応する webrtc.RTPCodec を生成して返します。
Types ¶
type Connection ¶
type Connection struct { Options *ConnectionOptions // contains filtered or unexported fields }
Connection は PeerConnection 接続を管理します。
func NewConnection ¶
func NewConnection(soraURL string, channelID string, options *ConnectionOptions) *Connection
NewConnection は Sora Connection を生成して返します。
func (*Connection) ChannelID ¶ added in v0.3.0
func (c *Connection) ChannelID() string
ChannelID は接続しているチャンネルIDを返します。
func (*Connection) ClientID ¶ added in v0.3.0
func (c *Connection) ClientID() string
ClientID はクライアントIDを返します。
func (*Connection) ConnectionID ¶ added in v0.3.0
func (c *Connection) ConnectionID() string
ConnectionID はコネクションIDを返します。
func (*Connection) OnConnect ¶
func (c *Connection) OnConnect(f func())
OnConnect は connect イベント発生時のコールバック関数を設定します。
func (*Connection) OnDisconnect ¶
func (c *Connection) OnDisconnect(f func(reason string, err error))
OnDisconnect は disconnect イベント発生時のコールバック関数を設定します。
func (*Connection) OnNetworkNotify ¶ added in v0.3.0
func (c *Connection) OnNetworkNotify(f func(eventType string, message *NetworkNotifyMessage))
OnNotify は Sora から notify メッセージを受け取った時に発生するコールバック関数を設定します。
func (*Connection) OnOpen ¶
func (c *Connection) OnOpen(f func(pc *webrtc.PeerConnection, m webrtc.MediaEngine))
OnOpen は open イベント発生時のコールバック関数を設定します。
func (*Connection) OnPush ¶ added in v0.2.0
func (c *Connection) OnPush(f func(message []byte))
OnPush は Sora から push メッセージを受け取った時に発生するコールバック関数を設定します。
func (*Connection) OnSignalingNotify ¶ added in v0.3.0
func (c *Connection) OnSignalingNotify(f func(eventType string, message *SignalingNotifyMessage))
OnNotify は Sora から notify メッセージを受け取った時に発生するコールバック関数を設定します。
func (*Connection) OnSpotlightNotify ¶ added in v0.3.0
func (c *Connection) OnSpotlightNotify(f func(eventType string, message *SpotlightNotifyMessage))
OnNotify は Sora から notify メッセージを受け取った時に発生するコールバック関数を設定します。
func (*Connection) OnTrack ¶ added in v0.3.0
func (c *Connection) OnTrack(f func(track *webrtc.Track))
OnTrack は RTP Packet 受診時に発生するコールバック関数を設定します。
func (*Connection) OnTrackPacket ¶
func (c *Connection) OnTrackPacket(f func(track *webrtc.Track, packet *rtp.Packet))
OnTrackPacket は RTP Packet 受診時に発生するコールバック関数を設定します。
func (*Connection) PeerConnection ¶ added in v0.4.0
func (c *Connection) PeerConnection() *webrtc.PeerConnection
PeerConnection は webrtc.PeerConnection オブジェクトを返します。
type ConnectionOptions ¶
type ConnectionOptions struct { // Sora の URL SoraURL string // Role はクライアントの役割の設定 Role Role // 接続する Channel ID ChannelID string // クライアント ID は、sora.conf で allow_client_id_assignment を true に設定した場合のみ指定することが可能です ClientID string // Video の設定 Video *Video // Audio の設定 Audio bool // Simulcast の設定 Simulcast *Simulcast // Multistream の設定 Multistream bool // Metadata Metadata *Metadata // Debug 出力をするかどうかのフラグ Debug bool }
ConnectionOptions は Sora 接続設定です。
func DefaultOptions ¶
func DefaultOptions() *ConnectionOptions
DefaultOptions は Sora 接続設定のデフォルト値を生成して返します。
type Metadata ¶
type Metadata struct { SignalingKey string `json:"signaling_key"` TurnTCPOnly bool `json:"turn_tcp_only"` TurnTLSOnly bool `json:"turn_tls_only"` }
Metadata は認証 Webhook に渡される認証用のメタデータ
type NetworkNotifyMessage ¶ added in v0.3.0
type NetworkNotifyMessage struct { Type string `json:"type"` EventType string `json:"event_type"` UnstableLevel int `json:"unstable_level"` }
NetworkNotifyMessage はネットワークのシグナリング通知メッセージ https://sora-doc.shiguredo.jp/signaling_notify#id9
type SignalingNotifyMessage ¶ added in v0.3.0
type SignalingNotifyMessage struct { Type string `json:"type"` EventType string `json:"event_type"` Role string `json:"role"` Minutes int `json:"minutes"` ChannelConnections int `json:"channel_connections"` ChannelUpstreamConnections int `json:"channel_upstream_connections"` ChannelDownstreamConnections int `json:"channel_downstream_connections"` ClientID string `json:"client_id"` ConnectionID string `json:"connection_id"` Audio bool `json:"audio"` Video bool `json:"video"` Metadata map[string]interface{} `json:"metadata"` MetadataList []map[string]interface{} `json:"metadata_list"` }
SignalingNotifyMessage はシグナリング通知メッセージ https://sora-doc.shiguredo.jp/signaling_notify
type Simulcast ¶ added in v0.2.0
type Simulcast struct {
Quality SimulcastQuality `json:"quality"`
}
Simulcast はサイマルキャストの設定
func (Simulcast) MarshalJSON ¶ added in v0.2.0
type SimulcastQuality ¶ added in v0.2.0
type SimulcastQuality string
SimulcastQuality はサイマルキャストの画質を指定します
const ( // SimulcastQualityDefault は Sora の `default_simulcast_quality` で指定された画質。指定がない場合は `low` SimulcastQualityDefault SimulcastQuality = "" // SimulcastQualityLow は低画質 SimulcastQualityLow SimulcastQuality = "low" // SimulcastQualityMiddle は中画質 SimulcastQualityMiddle SimulcastQuality = "middle" // SimulcastQualityHigh は最高画質 SimulcastQualityHigh SimulcastQuality = "high" )
type SpotlightNotifyMessage ¶ added in v0.3.0
type SpotlightNotifyMessage struct { Type string `json:"type"` EventType string `json:"event_type"` ChannelID string `json:"channel_id"` ClientID string `json:"client_id"` SpotlightID string `json:"spotlight_id"` Audio bool `json:"audio"` Video bool `json:"video"` Fixed bool `json:"fixed"` }
SpotlightNotifyMessage はスポットライト機能を利用した場合のシグナリング通知メッセージ https://sora-doc.shiguredo.jp/signaling_notify#id9
type Video ¶ added in v0.2.0
type Video struct { // ビデオコーデックの設定 CodecType VideoCodecType `json:"codec_type,omitempty"` // ビデオのビットレート指定。指定できる値は 1 から 50000 です BitRate uint16 `json:"bitrate,omitempty"` }
ビデオの設定
type VideoCodecType ¶ added in v0.2.0
type VideoCodecType string
const ( VideoCodecTypeVP8 VideoCodecType = "VP8" VideoCodecTypeVP9 VideoCodecType = "VP9" VideoCodecTypeAV1 VideoCodecType = "AV1" VideoCodecTypeH264 VideoCodecType = "H264" VideoCodecTypeH265 VideoCodecType = "H265" )