webrtc

package module
v0.0.0-...-624e3d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2017 License: BSD-3-Clause Imports: 5 Imported by: 1

README

webrtc

isomorphic package for WebRTC

  • WebRTC wrapper for native(github.com/keroserene/go-webrtc)
  • WebRTC wrapper for GopherJS

dependencies for native

  • brew install pkg-config
  • go get -u github.com/keroserene/go-webrtc

dependencies for gopherjs

  • go get -u github.com/gopherjs/gopherjs

install

go get -u github.com/arsasm/webrtc

usage

getUserMedia sample(gopherjs only)

package main

import "github.com/arsasm/webrtc"

func main() {
	stream, err := webrtc.GetUserMedia(webrtc.NewConstraints(true, true))
	if err != nil {
		log.Println(err)
		return
	}
    ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioConstraints

type AudioConstraints struct {
	Mandatory AudioMandatory `js:"mandatory"`
}

AudioConstraints ...

type AudioMandatory

type AudioMandatory struct {
	EchoCancellation bool    `js:"echoCancellation"`
	MaxChannelCount  int     `js:"maxChannelCount"`
	MinChannelCount  int     `js:"minChannelCount"`
	MaxSampleRate    int     `js:"maxSampleRate"`
	MinSampleRate    int     `js:"minSampleRate"`
	MaxLatency       float64 `js:"maxLatency"`
	MinLatency       float64 `js:"minLatency"`
	MaxVolume        float64 `js:"maxVolume"`
	MinVolume        float64 `js:"minVolume"`
}

AudioMandatory ...

type Configuration

type Configuration struct {
	IceServers         []*IceServer `js:"iceServers"`
	IceTransportPolicy string       `js:"iceTransportPolicy"`
	BundlePolicy       string       `js:"bundlePolicy"`
	RTCPMuxPolicy      string       `js:"rtcpMuxPolicy"`
	PeerIdentity       string       `js:"peerIdentity"`
}

Configuration ...

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration ...

func (*Configuration) AddIceServer

func (config *Configuration) AddIceServer(params ...string) error

AddIceServer ...

type Constraints

type Constraints struct {
	Video interface{} `js:"video"` // bool or *VideoConstraints
	Audio interface{} `js:"audio"` // bool or *AudioConstraints
}

Constraints ...

func NewConstraints

func NewConstraints(video, audio interface{}) *Constraints

NewConstraints ...

type DataChannel

type DataChannel struct {
	// contains filtered or unexported fields
}

DataChannel ...

func (*DataChannel) Close

func (c *DataChannel) Close() error

Close ...

func (*DataChannel) ID

func (c *DataChannel) ID() int

ID ...

func (*DataChannel) Label

func (c *DataChannel) Label() string

Label ...

func (*DataChannel) OnClose

func (c *DataChannel) OnClose(cb func())

OnClose ...

func (*DataChannel) OnMessage

func (c *DataChannel) OnMessage(cb func([]byte))

OnMessage ...

func (*DataChannel) OnOpen

func (c *DataChannel) OnOpen(cb func())

OnOpen ...

func (*DataChannel) ReadyState

func (c *DataChannel) ReadyState() string

ReadyState ...

func (*DataChannel) Send

func (c *DataChannel) Send(data []byte)

Send ...

type IceCandidate

type IceCandidate struct {
	Candidate     string `json:"candidate",js:"candidate"`
	SdpMid        string `json:"sdpMid",js:"sdpMid"`
	SdpMLineIndex int    `json:"sdpMLineIndex",js:"sdpMLineIndex"`
}

IceCandidate ...

func NewIceCandidate

func NewIceCandidate(candidate, sdpmid string, sdpMLineIndex int) *IceCandidate

NewIceCandidate ...

type IceServer

type IceServer struct {
	Urls           []string `js:"urls"`
	Username       string   `js:"username"`
	Credential     string   `js:"credential"`
	CredentialType string   `js:"credentialType"`
}

IceServer ...

func NewIceServer

func NewIceServer(urls []string, params ...string) *IceServer

NewIceServer ...

type MediaStream

type MediaStream struct{}

MediaStream ...

func GetUserMedia

func GetUserMedia(constraints *Constraints) (stream *MediaStream, err error)

GetUserMedia ...

type PeerConnection

type PeerConnection struct {
	// contains filtered or unexported fields
}

PeerConnection ...

func NewPeerConnection

func NewPeerConnection(config *Configuration) (*PeerConnection, error)

NewPeerConnection ...

func (*PeerConnection) AddIceCandidate

func (pc *PeerConnection) AddIceCandidate(ic *IceCandidate) error

AddIceCandidate ...

func (*PeerConnection) AddStream

func (pc *PeerConnection) AddStream(stream *MediaStream) (err error)

AddStream ...

func (*PeerConnection) Close

func (pc *PeerConnection) Close() error

Close ...

func (*PeerConnection) ConnectionState

func (pc *PeerConnection) ConnectionState() string

ConnectionState ...

func (*PeerConnection) CreateAnswer

func (pc *PeerConnection) CreateAnswer() (*SessionDescription, error)

CreateAnswer ...

func (*PeerConnection) CreateDataChannel

func (pc *PeerConnection) CreateDataChannel(label string) (*DataChannel, error)

CreateDataChannel ...

func (*PeerConnection) CreateOffer

func (pc *PeerConnection) CreateOffer() (*SessionDescription, error)

CreateOffer ...

func (*PeerConnection) IceGatheringState

func (pc *PeerConnection) IceGatheringState() string

IceGatheringState ...

func (*PeerConnection) LocalDescription

func (pc *PeerConnection) LocalDescription() (sdp *SessionDescription)

LocalDescription ...

func (*PeerConnection) OnAddStream

func (pc *PeerConnection) OnAddStream(cb func(*MediaStream))

OnAddStream ...

func (*PeerConnection) OnConnectionStateChange

func (pc *PeerConnection) OnConnectionStateChange(cb func(PeerConnectionState string))

OnConnectionStateChange ...

func (*PeerConnection) OnDataChannel

func (pc *PeerConnection) OnDataChannel(cb func(*DataChannel))

OnDataChannel ...

func (*PeerConnection) OnIceCandidate

func (pc *PeerConnection) OnIceCandidate(cb func(*IceCandidate))

OnIceCandidate ...

func (*PeerConnection) OnIceCandidateError

func (pc *PeerConnection) OnIceCandidateError(cb func())

OnIceCandidateError ...

func (*PeerConnection) OnIceConnectionStateChange

func (pc *PeerConnection) OnIceConnectionStateChange(cb func(IceConnectionState string))

OnIceConnectionStateChange ...

func (*PeerConnection) OnIceGatheringStateChange

func (pc *PeerConnection) OnIceGatheringStateChange(cb func(IceGatheringState string))

OnIceGatheringStateChange ...

func (*PeerConnection) OnNegotiationNeeded

func (pc *PeerConnection) OnNegotiationNeeded(cb func())

OnNegotiationNeeded ...

func (*PeerConnection) OnRemoveStream

func (pc *PeerConnection) OnRemoveStream(cb func(*MediaStream))

OnRemoveStream ...

func (*PeerConnection) OnSignalingStateChange

func (pc *PeerConnection) OnSignalingStateChange(cb func(SignalingState string))

OnSignalingStateChange ...

func (*PeerConnection) RemoteDescription

func (pc *PeerConnection) RemoteDescription() (sdp *SessionDescription)

RemoteDescription ...

func (*PeerConnection) SetLocalDescription

func (pc *PeerConnection) SetLocalDescription(sdp *SessionDescription) error

SetLocalDescription ...

func (*PeerConnection) SetRemoteDescription

func (pc *PeerConnection) SetRemoteDescription(sdp *SessionDescription) error

SetRemoteDescription ...

func (*PeerConnection) SignalingState

func (pc *PeerConnection) SignalingState() string

SignalingState ...

type SessionDescription

type SessionDescription struct {
	Type string `json:"type",js:"type"`
	Sdp  string `json:"sdp",js:"sdp"`
}

SessionDescription ...

func NewSessionDescription

func NewSessionDescription(tp, sdp string) *SessionDescription

NewSessionDescription ...

type VideoConstraints

type VideoConstraints struct {
	Mandatory VideoMandatory `js:"mandatory"`
}

VideoConstraints ...

type VideoMandatory

type VideoMandatory struct {
	MaxWidth      int     `js:"maxWidth"`
	MinWidth      int     `js:"minWidth"`
	MaxHeight     int     `js:"maxHeight"`
	MinHeight     int     `js:"minHeight"`
	MaxFrameRate  float64 `js:"maxFrameRate"`
	MinFrameRate  float64 `js:"minFrameRate"`
	AspectRate    float64 `js:"aspectRate"`
	MaxAspectRate float64 `js:"maxAspectRate"`
	MinAspectRate float64 `js:"minAspectRate"`
}

VideoMandatory ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL