Documentation ¶
Overview ¶
The OpenTok Go SDK lets you generate sessions and tokens for OpenTok applications.
It also includes methods for working with OpenTok archives, working with OpenTok live streaming broadcasts, working with OpenTok SIP interconnect, and disconnecting clients from sessions.
See Also ¶
Generate sessions: https://tokbox.com/developer/guides/create-session
Generate tokens: https://tokbox.com/developer/guides/create-token
Archives: https://tokbox.com/developer/guides/archiving
Live streaming broadcasts: https://tokbox.com/developer/guides/broadcast/live-streaming
SIP interconnect: https://tokbox.com/developer/guides/sip
Disconnecting clients from sessions: https://tokbox.com/developer/guides/moderation/rest
Index ¶
- Constants
- type AmazonS3Config
- type Archive
- type ArchiveList
- type ArchiveListOptions
- type ArchiveMode
- type ArchiveOptions
- type ArchiveOutputMode
- type AzureConfig
- type Broadcast
- type BroadcastList
- type BroadcastListOptions
- type BroadcastOptions
- type BroadcastOutputOptions
- type BroadcastURLs
- type DialOptions
- type HLSConfig
- type HTTPClient
- type Layout
- type LayoutType
- type MediaMode
- type OpenTok
- func (ot *OpenTok) ChangeProjectStatus(projectAPIKey string, projectStatus ProjectStatus) (*Project, error)
- func (ot *OpenTok) ChangeProjectStatusContext(ctx context.Context, projectAPIKey string, projectStatus ProjectStatus) (*Project, error)
- func (ot *OpenTok) CreateProject(projectName string) (*Project, error)
- func (ot *OpenTok) CreateProjectContext(ctx context.Context, projectName string) (*Project, error)
- func (ot *OpenTok) CreateSession(opts *SessionOptions) (*Session, error)
- func (ot *OpenTok) CreateSessionContext(ctx context.Context, opts *SessionOptions) (*Session, error)
- func (ot *OpenTok) DeleteArchive(archiveID string) error
- func (ot *OpenTok) DeleteArchiveContext(ctx context.Context, archiveID string) error
- func (ot *OpenTok) DeleteArchiveStorage() error
- func (ot *OpenTok) DeleteArchiveStorageContext(ctx context.Context) error
- func (ot *OpenTok) DeleteProject(projectAPIKey string) error
- func (ot *OpenTok) DeleteProjectContext(ctx context.Context, projectAPIKey string) error
- func (ot *OpenTok) Dial(sessionID string, opts *DialOptions) (*SIPCall, error)
- func (ot *OpenTok) DialContext(ctx context.Context, sessionID string, opts *DialOptions) (*SIPCall, error)
- func (ot *OpenTok) ForceDisconnect(sessionID, connectionID string) error
- func (ot *OpenTok) ForceDisconnectContext(ctx context.Context, sessionID, connectionID string) error
- func (ot *OpenTok) GenerateToken(sessionID string, opts *TokenOptions) (string, error)
- func (ot *OpenTok) GetArchive(archiveID string) (*Archive, error)
- func (ot *OpenTok) GetArchiveContext(ctx context.Context, archiveID string) (*Archive, error)
- func (ot *OpenTok) GetBroadcast(broadcastID string) (*Broadcast, error)
- func (ot *OpenTok) GetBroadcastContext(ctx context.Context, broadcastID string) (*Broadcast, error)
- func (ot *OpenTok) GetProject(projectAPIKey string) (*Project, error)
- func (ot *OpenTok) GetProjectContext(ctx context.Context, projectAPIKey string) (*Project, error)
- func (ot *OpenTok) GetStream(sessionID, streamID string) (*Stream, error)
- func (ot *OpenTok) GetStreamContext(ctx context.Context, sessionID, streamID string) (*Stream, error)
- func (ot *OpenTok) ListArchives(opts *ArchiveListOptions) (*ArchiveList, error)
- func (ot *OpenTok) ListArchivesContext(ctx context.Context, opts *ArchiveListOptions) (*ArchiveList, error)
- func (ot *OpenTok) ListBroadcasts(opts *BroadcastListOptions) (*BroadcastList, error)
- func (ot *OpenTok) ListBroadcastsContext(ctx context.Context, opts *BroadcastListOptions) (*BroadcastList, error)
- func (ot *OpenTok) ListProjects() ([]*Project, error)
- func (ot *OpenTok) ListProjectsContext(ctx context.Context) ([]*Project, error)
- func (ot *OpenTok) ListStreams(sessionID string) (*StreamList, error)
- func (ot *OpenTok) ListStreamsContext(ctx context.Context, sessionID string) (*StreamList, error)
- func (ot *OpenTok) RefreshProjectSecret(projectAPIKey string) (*Project, error)
- func (ot *OpenTok) RefreshProjectSecretContext(ctx context.Context, projectAPIKey string) (*Project, error)
- func (ot *OpenTok) SendConnectionSignal(sessionID, connectionID string, data *SignalData) error
- func (ot *OpenTok) SendConnectionSignalContext(ctx context.Context, sessionID, connectionID string, data *SignalData) error
- func (ot *OpenTok) SendSessionSignal(sessionID string, data *SignalData) error
- func (ot *OpenTok) SendSessionSignalContext(ctx context.Context, sessionID string, data *SignalData) error
- func (ot *OpenTok) SetAPIHost(url string) error
- func (ot *OpenTok) SetArchiveLayout(archiveID string, layout *Layout) (*Archive, error)
- func (ot *OpenTok) SetArchiveLayoutContext(ctx context.Context, archiveID string, layout *Layout) (*Archive, error)
- func (ot *OpenTok) SetArchiveStorage(opts *StorageOptions) (*StorageOptions, error)
- func (ot *OpenTok) SetArchiveStorageContext(ctx context.Context, opts *StorageOptions) (*StorageOptions, error)
- func (ot *OpenTok) SetBroadcastLayout(broadcastID string, layout *Layout) (*Broadcast, error)
- func (ot *OpenTok) SetBroadcastLayoutContext(ctx context.Context, broadcastID string, layout *Layout) (*Broadcast, error)
- func (ot *OpenTok) SetStreamClassLists(sessionID string, opts *StreamClassOptions) (*StreamList, error)
- func (ot *OpenTok) SetStreamClassListsContext(ctx context.Context, sessionID string, opts *StreamClassOptions) (*StreamList, error)
- func (ot *OpenTok) StartArchive(sessionID string, opts *ArchiveOptions) (*Archive, error)
- func (ot *OpenTok) StartArchiveContext(ctx context.Context, sessionID string, opts *ArchiveOptions) (*Archive, error)
- func (ot *OpenTok) StartBroadcast(sessionID string, opts *BroadcastOptions) (*Broadcast, error)
- func (ot *OpenTok) StartBroadcastContext(ctx context.Context, sessionID string, opts *BroadcastOptions) (*Broadcast, error)
- func (ot *OpenTok) StopArchive(archiveID string) (*Archive, error)
- func (ot *OpenTok) StopArchiveContext(ctx context.Context, archiveID string) (*Archive, error)
- func (ot *OpenTok) StopBroadcast(broadcastID string) (*Broadcast, error)
- func (ot *OpenTok) StopBroadcastContext(ctx context.Context, broadcastID string) (*Broadcast, error)
- type Project
- type ProjectStatus
- type RTMPConfig
- type Resolution
- type Role
- type SIP
- type SIPAuth
- type SIPCall
- type SIPHeaders
- type Session
- type SessionIDInfo
- type SessionOptions
- type SignalData
- type SignalDataError
- type StorageOptions
- type Stream
- type StreamClass
- type StreamClassOptions
- type StreamList
- type TokenOptions
Examples ¶
- New
- OpenTok.ChangeProjectStatus (Active)
- OpenTok.ChangeProjectStatus (Suspend)
- OpenTok.CreateProject
- OpenTok.CreateSession
- OpenTok.DeleteArchive
- OpenTok.DeleteArchiveStorage
- OpenTok.DeleteProject
- OpenTok.Dial
- OpenTok.ForceDisconnect
- OpenTok.GenerateToken
- OpenTok.GetArchive
- OpenTok.GetBroadcast
- OpenTok.GetProject
- OpenTok.GetStream
- OpenTok.ListArchives
- OpenTok.ListBroadcasts
- OpenTok.ListProjects
- OpenTok.ListStreams
- OpenTok.RefreshProjectSecret
- OpenTok.SendConnectionSignal
- OpenTok.SendSessionSignal
- OpenTok.SetArchiveLayout
- OpenTok.SetArchiveStorage
- OpenTok.SetBroadcastLayout
- OpenTok.SetStreamClassLists
- OpenTok.StartArchive
- OpenTok.StartBroadcast
- OpenTok.StopArchive
- OpenTok.StopBroadcast
Constants ¶
const SDKName = "OpenTok-Go-SDK"
SDKName is the name of this SDK
const SDKVersion = "2.2.0"
SDKVersion is the version of this SDK
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmazonS3Config ¶
type AmazonS3Config struct { // The Amazon Web Services access key. AccessKey string `json:"accessKey"` // The Amazon Web Services secret key. SecretKey string `json:"secretKey"` // The S3 bucket name. Bucket string `json:"bucket"` // The S3 or S3-compatible storage endpoint. Endpoint string `json:"endpoint,omitempty"` }
AmazonS3Config defines the Amazon S3 config for setting archiving upload target.
type Archive ¶
type Archive struct { // The time at which the archive was created, in milliseconds since the // UNIX epoch. CreatedAt int `json:"createdAt"` // The duration of the archive, in milliseconds. Duration int `json:"duration"` // Whether the archive has an audio track or not. HasAudio bool `json:"hasAudio"` // Whether the archive has an video track or not. HasVideo bool `json:"hasVideo"` // The unique archive ID. ID string `json:"id"` // The name of the archive. Name string `json:"name"` // The output mode to be generated for this archive. OutputMode ArchiveOutputMode `json:"outputMode"` // The API key associated with the archive. ProjectID int `json:"projectId"` // This string describes the reason the archive stopped or failed. Reason string `json:"reason"` // The resolution of the archive. Resolution Resolution `json:"resolution"` // The session ID of the OpenTok session associated with this archive. SessionID string `json:"sessionId"` // The size of the MP4 file. Size int `json:"size"` // The status of the archive. Status string `json:"status"` // The download URL of the available MP4 file. URL *string `json:"url"` // The instance of OpenTok. OpenTok *OpenTok `json:"-"` }
Archive defines the response returned from API.
type ArchiveList ¶
type ArchiveList struct { // The total number of archives for the API key. Count int `json:"count"` // An array of objects defining each archive retrieved. // Archives are listed from the newest to the oldest in the return set. Items []*Archive `json:"items"` }
ArchiveList defines the response returned from API.
type ArchiveListOptions ¶
type ArchiveListOptions struct { // Query parameters to specify the index offset of the first archive. Offset int // Query parameter to limit the number of archives to be returned. Count int // Query parameter to list archives for a specific session ID. SessionID string }
ArchiveListOptions defines the query parameters to filter the list of archives.
type ArchiveMode ¶
type ArchiveMode string
ArchiveMode is the alias of string type.
const ( // AutoArchived is used to have the session archived automatically. AutoArchived ArchiveMode = "always" // ManualArchived is used to have the session archived manually, you can // archive the session by calling the REST /archive POST method. ManualArchived ArchiveMode = "manual" )
type ArchiveOptions ¶
type ArchiveOptions struct { // The session ID of the OpenTok session you want to start archiving. SessionID string `json:"sessionId"` // Whether the archive will record audio (true, the default) or not (false). HasAudio bool `json:"hasAudio,omitempty"` // Whether the archive will record video (true, the default) or not (false). HasVideo bool `json:"hasVideo,omitempty"` // Specify this to assign the initial layout type for the archive. Layout *Layout `json:"layout,omitempty"` // The name of the archive (for your own identification). Name string `json:"name,omitempty"` // Whether all streams in the archive are recorded to a single file or to // individual files. OutputMode ArchiveOutputMode `json:"outputMode,omitempty"` // The resolution of the archive. Resolution Resolution `json:"resolution,omitempty"` }
ArchiveOptions defines the options for starting an archive recording.
type ArchiveOutputMode ¶
type ArchiveOutputMode string
ArchiveOutputMode is the alias of string type.
const ( // Composed means the archive is a single MP4 file composed of all streams. Composed ArchiveOutputMode = "composed" // Individual means the archive is a ZIP container file with multiple // individual media files for each stream, and a JSON metadata file for video // synchronization. Individual ArchiveOutputMode = "individual" )
type AzureConfig ¶
type AzureConfig struct { // The Microsoft Azure account name. AccountName string `json:"accountName"` // The Microsoft Azure account key. AccountKey string `json:"accountKey"` // The Microsoft Azure container name. Container string `json:"container"` // The Microsoft Azure domain in which the container resides. Domain string `json:"domain,omitempty"` }
AzureConfig defines the Microsoft Azure config for setting archiving upload target.
type Broadcast ¶
type Broadcast struct { // The unique ID for the broadcast. ID string `json:"id"` // The OpenTok session ID. SessionID string `json:"sessionId"` // The API key associated with the broadcast.. ProjectID int `json:"projectId"` // The time at which the broadcast was created, in milliseconds since the // UNIX epoch. CreatedAt int `json:"createdAt"` // The time at which the broadcast was updated, in milliseconds since the // UNIX epoch. UpdatedAt int `json:"updatedAt"` // The resolution of the broadcast. Resolution Resolution `json:"resolution"` // The status of the broadcast. Status string `json:"status"` // An object containing details about the HLS and RTMP broadcasts. BroadcastURLs *BroadcastURLs `json:"broadcastUrls"` // The instance of OpenTok OpenTok *OpenTok `json:"-"` }
Broadcast defines the response returned from API.
type BroadcastList ¶
type BroadcastList struct { // The total number of broadcasts in the results. Count int `json:"count"` // An array of objects defining each broadcast retrieved. // Broadcasts are listed from the newest to the oldest in the return set. Items []*Broadcast `json:"items"` }
BroadcastList defines the response returned from API.
type BroadcastListOptions ¶
type BroadcastListOptions struct { // The start offset in the list of existing broadcasts. Offset int // The number of broadcasts to retrieve starting at offset. Count int // Retrive only broadcasts for a given session ID. SessionID string }
BroadcastListOptions defines the query parameters to filter the list of broadcasts.
type BroadcastOptions ¶
type BroadcastOptions struct { // The OpenTok session you want to broadcast. SessionID string `json:"sessionId"` // Specify this to assign the initial layout type for the broadcast. Layout *Layout `json:"layout,omitempty"` // The maximum duration for the broadcast, in seconds. MaxDuration int `json:"maxDuration,omitempty"` // This object defines the types of broadcast streams you want to start // (both HLS and RTMP). Outputs *BroadcastOutputOptions `json:"outputs"` // The resolution of the broadcast: either SD(default) or HD. Resolution Resolution `json:"resolution,omitempty"` }
BroadcastOptions defines the options for live streaming broadcast.
type BroadcastOutputOptions ¶
type BroadcastOutputOptions struct { // Set this property to an empty object for HLS. // The HLS URL is returned in the response and in the REST method for getting // information about a live streaming broadcast. HLS *HLSConfig `json:"hls,omitempty"` // The configuration of RTMP RTMP []*RTMPConfig `json:"rtmp,omitempty"` }
BroadcastOutputOptions defines the types of broadcast streams you want to start (both HLS and RTMP).
type BroadcastURLs ¶
type BroadcastURLs struct { // HLS broadcast streams URL. HLS string `json:"hls"` // The configuration of RTMP. RTMP []*RTMPConfig `json:"rtmp"` }
BroadcastURLs defines the details on the HLS and RTMP broadcast streams.
type DialOptions ¶
type DialOptions struct { // The OpenTok session ID for the SIP call to join. SessionID string `json:"sessionId"` // The OpenTok token to be used for the participant being called. Token string `json:"token"` // The SIP information SIP *SIP `json:"sip"` // The data for token generation TokenData string `json:"-"` }
DialOptions defines the options for SIP call
type HTTPClient ¶
HTTPClient is an interface to allow custom clients and timeouts.
type Layout ¶
type Layout struct { Type LayoutType `json:"type,omitempty"` StyleSheet string `json:"stylesheet,omitempty"` }
Layout defines the layout type for the archive.
type LayoutType ¶
type LayoutType string
LayoutType is the alias of string type.
const ( // BestFit is a tiled layout, which scales according to the number of videos. // The number of columns and rows of varies depending on the number of // OpenTok streams in the archive. BestFit LayoutType = "bestFit" // PIP is a picture-in-picture layout, where a small stream is visible over // a full-size stream. PIP LayoutType = "pip" // VerticalPresentation is a layout with one large stream on the right edge of // the output, and several smaller streams along the left edge of the output. VerticalPresentation LayoutType = "verticalPresentation" // HorizontalPresentation is a layout with one large stream on the top edge of // the output, and several smaller streams along the bottom edge of the output. HorizontalPresentation LayoutType = "horizontalPresentation" // Custom let you can use CSS to define your own custom layout for composed // archive videos. Custom LayoutType = "custom" )
type OpenTok ¶
type OpenTok struct {
// contains filtered or unexported fields
}
OpenTok stores the API key and secret for use in making API call
func New ¶
func New(apiKey, apiSecret string, client HTTPClient) *OpenTok
New returns an initialized OpenTok instance with the API key and API secret.
Example ¶
package main import ( "net/http" "time" "github.com/anschwa/opentok-go-sdk/v2/opentok" ) const ( apiKey = "<your api key here>" apiSecret = "<your api secret here>" ) var ( ot = opentok.New(apiKey, apiSecret, http.DefaultClient) client = &http.Client{Timeout: 120 * time.Second} ) func main() { const ( apiKey = "12345678" apiSecret = "ba7816bf8f01cfea414140de5dae2223b00361a3" ) opentok.New(apiKey, apiSecret, client) }
Output:
func (*OpenTok) ChangeProjectStatus ¶
func (ot *OpenTok) ChangeProjectStatus(projectAPIKey string, projectStatus ProjectStatus) (*Project, error)
ChangeProjectStatus changes the status of project. The status is either active or suspended.
Example (Active) ¶
Active a project API key
project, err := ot.ChangeProjectStatus("40000001", opentok.ProjectActive) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", project) } // &opentok.Project{ // ID: "40000001", // Secret: "ba7816bf8f01cfea414140de5dae2223b00361a3", // Status: "ACTIVE", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }
Output:
Example (Suspend) ¶
Suspend a project API key
project, err := ot.ChangeProjectStatus("40000001", opentok.ProjectSuspended) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", project) } // &opentok.Project{ // ID: "40000001", // Secret: "ba7816bf8f01cfea414140de5dae2223b00361a3", // Status: "SUSPENDED", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }
Output:
func (*OpenTok) ChangeProjectStatusContext ¶
func (ot *OpenTok) ChangeProjectStatusContext(ctx context.Context, projectAPIKey string, projectStatus ProjectStatus) (*Project, error)
ChangeProjectStatusContext uses ctx for HTTP requests.
func (*OpenTok) CreateProject ¶
CreateProject creates an OpenTok API key and secret for a project..
Example ¶
project, err := ot.CreateProject("example") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", project) } // &opentok.Project{ // ID: "40000001", // Secret: "ba7816bf8f01cfea414140de5dae2223b00361a3", // Status: "VALID", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }
Output:
func (*OpenTok) CreateProjectContext ¶
CreateProjectContext uses ctx for HTTP requests.
func (*OpenTok) CreateSession ¶
func (ot *OpenTok) CreateSession(opts *SessionOptions) (*Session, error)
CreateSession generates a new session.
Example ¶
session, err := ot.CreateSession(&opentok.SessionOptions{ ArchiveMode: opentok.AutoArchived, MediaMode: opentok.Routed, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", session) } // &opentok.Session{ // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: "40000001", // CreateDt: "Wed Jan 01 00:00:00 PST 2020", // MediaServerURL: "", // }
Output:
func (*OpenTok) CreateSessionContext ¶
func (ot *OpenTok) CreateSessionContext(ctx context.Context, opts *SessionOptions) (*Session, error)
CreateSessionContext uses ctx for HTTP requests.
func (*OpenTok) DeleteArchive ¶
DeleteArchive deletes a specific archive.
Example ¶
err := ot.DeleteArchive("c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea") if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) DeleteArchiveContext ¶
DeleteArchiveContext uses ctx for HTTP requests.
func (*OpenTok) DeleteArchiveStorage ¶
DeleteArchiveStorage deletes the configuration of archive storage.
Example ¶
err := ot.DeleteArchiveStorage() if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) DeleteArchiveStorageContext ¶
DeleteArchiveStorageContext uses ctx for HTTP requests.
func (*OpenTok) DeleteProject ¶
DeleteProjectContext prevents the use of the project API key (and any OpenTok sessions created with it).
Example ¶
err := ot.DeleteProject("40000001") if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) DeleteProjectContext ¶
DeleteProjectContext uses ctx for HTTP requests.
func (*OpenTok) Dial ¶
func (ot *OpenTok) Dial(sessionID string, opts *DialOptions) (*SIPCall, error)
Dial connects your SIP platform to an OpenTok session. The audio from your end of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media Router mixes audio from other streams in the session and sends the mixed audio to your SIP endpoint.
Example ¶
sipCall, err := ot.Dial("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", &opentok.DialOptions{ SIP: &opentok.SIP{ URI: "sip:user@sip.example.comwhen;transport=tls", Headers: &opentok.SIPHeaders{ "X-Foo": "bar", }, Auth: &opentok.SIPAuth{ Username: "username", Password: "password", }, Secure: true, }, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", sipCall) } // &opentok.SIPCall{ // ID: "ab31819a-cd52-4da4-8b3e-fb9803337c17", // ConnectionID: "3a6aa409-bfc5-462c-a9c7-59b72aeebf69", // StreamID: "f1a58131-7b2c-4fa8-b2a7-64fdc6b2c0f6", // }
Output:
func (*OpenTok) DialContext ¶
func (ot *OpenTok) DialContext(ctx context.Context, sessionID string, opts *DialOptions) (*SIPCall, error)
DialContext uses ctx for HTTP requests.
func (*OpenTok) ForceDisconnect ¶
ForceDisconnect disconnects a client from an OpenTok session via server-side
Example ¶
err := ot.ForceDisconnect("40000001", "efdf2fc7-bd6e-4871-9c1d-531f7f6a9486") if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) ForceDisconnectContext ¶
func (ot *OpenTok) ForceDisconnectContext(ctx context.Context, sessionID, connectionID string) error
ForceDisconnectContext uses ctx for HTTP requests.
func (*OpenTok) GenerateToken ¶
func (ot *OpenTok) GenerateToken(sessionID string, opts *TokenOptions) (string, error)
GenerateToken generates a token for each user connecting to an OpenTok session.
Example ¶
token, err := ot.GenerateToken("40000001", &opentok.TokenOptions{ Role: opentok.Publisher, ExpireTime: time.Now().UTC().Add(1 * 24 * time.Hour).Unix(), }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", token) } // T1==cGFydG5lcl9pZD08eW91ciBhcGkga2V5IGhlcmU+JnNpZz0yYjQyMzlkNjU4YTVkYmE0NGRhMGMyMmUzOTA2MWM5ZWI1ODQ1MTE1OmNvbm5lY3Rpb25fZGF0YT1mb28lM0RiYXImY3JlYXRlX3RpbWU9MTU3Nzg2NTYwMCZleHBpcmVfdGltZT0xNTc3ODY1NjAwJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9Jm5vbmNlPTAuNDk4OTMzNzE3NzEyNjgyMjUmcm9sZT1wdWJsaXNoZXImc2Vzc2lvbl9pZD0xX01YNDBNREF3TURBd01YNS1NVFUzTnpnMk5UWXdNREF3TUg1NE4ySTBPRTFSWjBSbUsxbFJSbkZRVVdnNGRsWm1UMHQtUVg0
Output:
func (*OpenTok) GetArchive ¶
GetArchive returns a archive details record describing the archive.
Example ¶
archive, err := ot.GetArchive("c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", archive) } // &opentok.Archive{ // CreatedAt: 1579163008000, // Duration: 34, // HasAudio: true, // HasVideo: true, // ID: "c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", // Name: "example", // OutputMode: "composed", // ProjectID: 40000001, // Reason: "user initiated", // Resolution: "1280x720", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // Size: 355816, // Status: "uploaded", // URL: nil, // }
Output:
func (*OpenTok) GetArchiveContext ¶
GetArchiveContext uses ctx for HTTP requests.
func (*OpenTok) GetBroadcast ¶
GetBroadcast returns a broadcast that is in-progress.
Example ¶
broadcast, err := ot.GetBroadcast("ce872e0d-4997-440a-a0a5-10ce715b54cf") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", broadcast) } // &opentok.Broadcast{ // ID: "ce872e0d-4997-440a-a0a5-10ce715b54cf", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: 40000001, // CreatedAt: 1579163008000, // UpdatedAt: 1579163009000, // Resolution: "1280x720", // Status: "stopped", // BroadcastURLs: nil, // }
Output:
func (*OpenTok) GetBroadcastContext ¶
GetBroadcastContext uses ctx for HTTP requests.
func (*OpenTok) GetProject ¶
GetProject returns a project details record describing the project.
Example ¶
project, err := ot.GetProject("40000001") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", project) } // &opentok.Project{ // ID: "40000001", // Secret: "ba7816bf8f01cfea414140de5dae2223b00361a3", // Status: "VALID", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }
Output:
func (*OpenTok) GetProjectContext ¶
GetProjectContext uses ctx for HTTP requests.
func (*OpenTok) GetStream ¶
GetStream returns a stream details record describing the stream.
Example ¶
stream, err := ot.GetStream("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", "d962b966-964d-4f18-be3f-e0b181a43b0e") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", stream) } // &opentok.Stream{ // ID: "d962b966-964d-4f18-be3f-e0b181a43b0e", // VideoType: "camera", // Name: "", // LayoutClassList: []string{} // }
Output:
func (*OpenTok) GetStreamContext ¶
func (ot *OpenTok) GetStreamContext(ctx context.Context, sessionID, streamID string) (*Stream, error)
GetStreamContext uses ctx for HTTP requests.
func (*OpenTok) ListArchives ¶
func (ot *OpenTok) ListArchives(opts *ArchiveListOptions) (*ArchiveList, error)
ListArchives returns the records of all archives for your project that are in progress.
Example ¶
archiveList, err := ot.ListArchives(&opentok.ArchiveListOptions{}) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", archiveList) } // &opentok.ArchiveList{ // Count: 1, // Items: []*opentok.Archive{ // &opentok.Archive{ // CreatedAt: 1579163008000, // Duration: 34, // HasAudio: true, // HasVideo: true, // ID: "c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", // Name: "example", // OutputMode: "composed", // ProjectID: 40000001, // Reason: "user initiated", // Resolution: "1280x720", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // Size: 355816, // Status: "uploaded", // URL: nil, // }, // }, // }
Output:
func (*OpenTok) ListArchivesContext ¶
func (ot *OpenTok) ListArchivesContext(ctx context.Context, opts *ArchiveListOptions) (*ArchiveList, error)
ListArchivesContext uses ctx for HTTP requests.
func (*OpenTok) ListBroadcasts ¶
func (ot *OpenTok) ListBroadcasts(opts *BroadcastListOptions) (*BroadcastList, error)
ListBroadcasts returns the records of all broadcasts for your project that are in progress and started. Completed broadcasts are not included in the listing.
Example ¶
broadcasts, err := ot.ListBroadcasts(&opentok.BroadcastListOptions{}) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", broadcasts) } // &opentok.BroadcastList{ // Count:1, // Items:[]*opentok.Broadcast{ // &opentok.Broadcast{ // ID: "ce872e0d-4997-440a-a0a5-10ce715b54cf", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: "40000001", // CreatedAt: 1579163008000, // UpdatedAt: 1579163008000, // Resolution: "1280x720", // Status: "started", // BroadcastURLs: &opentok.BroadcastURLs{ // HLS: "", // RTMP:[]*opentok.RTMPConfig{ // &opentok.RTMPConfig{ // ID: "foo", // Status: "connecting", // ServerURL: "rtmps://myfooserver/myfooapp", // StreamName: "myfoostream" // }, // &opentok.RTMPConfig{ // ID: "bar", // Status: "connecting", // ServerURL: "rtmp://mybarserver/mybarapp", // StreamName: "mybarstream" // }, // }, // }, // }, // }, // }
Output:
func (*OpenTok) ListBroadcastsContext ¶
func (ot *OpenTok) ListBroadcastsContext(ctx context.Context, opts *BroadcastListOptions) (*BroadcastList, error)
ListBroadcastsContext uses ctx for HTTP requests.
func (*OpenTok) ListProjects ¶
ListProjectsContext uses ctx for HTTP requests.
Example ¶
projects, err := ot.ListProjects() if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", projects) } // [ // &opentok.Project{ // ID: "40000001", // Secret: "ba7816bf8f01cfea414140de5dae2223b00361a3", // Status: "VALID", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }, // &opentok.Project{ // ID: "40000002", // Secret: "fcde2b2edba56bf408601fb721fe9b5c338d10ee", // Status: "VALID", // Name: "foo", // CreatedAt: 1579163506000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }, // ]
Output:
func (*OpenTok) ListProjectsContext ¶
ListProjectsContext uses ctx for HTTP requests..
func (*OpenTok) ListStreams ¶
func (ot *OpenTok) ListStreams(sessionID string) (*StreamList, error)
ListStreams returns the stream records in a session.
Example ¶
streams, err := ot.ListStreams("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", streams) } // &opentok.StreamList{ // Count:1, // Items:[]*opentok.Stream{ // &opentok.Stream{ // ID: "d962b966-964d-4f18-be3f-e0b181a43b0e", // VideoType: "camera", // Name: "", // LayoutClassList: []string{} // } // } // }
Output:
func (*OpenTok) ListStreamsContext ¶
ListStreamsContext uses ctx for HTTP requests.
func (*OpenTok) RefreshProjectSecret ¶
RefreshProjectSecret generates a new API secret for a project.
Example ¶
project, err := ot.RefreshProjectSecret("40000001") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", project) } // &opentok.Project{ // ID: "40000001", // Secret: "6a1e361fc002c0b2b51a821d7ce11f96e1887aea", // Status: "ACTIVE", // Name: "example", // CreatedAt: 1579163008000, // EnvironmentName: "default", // EnvironmentDescription: "Standard Environment", // }
Output:
func (*OpenTok) RefreshProjectSecretContext ¶
func (ot *OpenTok) RefreshProjectSecretContext(ctx context.Context, projectAPIKey string) (*Project, error)
RefreshProjectSecretContext uses ctx for HTTP requests.
func (*OpenTok) SendConnectionSignal ¶
func (ot *OpenTok) SendConnectionSignal(sessionID, connectionID string, data *SignalData) error
SendConnectionSignal send signals to a specific client in an active OpenTok session.
Example ¶
err := ot.SendConnectionSignal("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", "18145975-97c8-4802-8975-fc8408d56d5c", &opentok.SignalData{ Type: "foo", Data: "bar", }) if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) SendConnectionSignalContext ¶
func (ot *OpenTok) SendConnectionSignalContext(ctx context.Context, sessionID, connectionID string, data *SignalData) error
SendConnectionSignalContext uses ctx for HTTP requests.
func (*OpenTok) SendSessionSignal ¶
func (ot *OpenTok) SendSessionSignal(sessionID string, data *SignalData) error
SendSessionSignal send signals to all participants in an active OpenTok session.
Example ¶
err := ot.SendSessionSignal("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", &opentok.SignalData{ Type: "foo", Data: "bar", }) if err != nil { fmt.Println(err) }
Output:
func (*OpenTok) SendSessionSignalContext ¶
func (ot *OpenTok) SendSessionSignalContext(ctx context.Context, sessionID string, data *SignalData) error
SendSessionSignalContext uses ctx for HTTP requests.
func (*OpenTok) SetAPIHost ¶
SetAPIHost is used to set OpenTok API Host to specific URL
func (*OpenTok) SetArchiveLayout ¶
SetArchiveLayout dynamically change the layout type of a composed archive.
Example ¶
archive, err := ot.SetArchiveLayout("c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", &opentok.Layout{ Type: opentok.BestFit, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", archive) } // &opentok.Archive{ // CreatedAt: 1579163008000, // Duration: 0, // HasAudio: true, // HasVideo: true, // ID: "c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", // Name: "example", // OutputMode: "composed", // ProjectID: 40000001, // Reason: "", // Resolution: "1280x720", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // Size: 0, // Status: "started", // URL: nil, // }
Output:
func (*OpenTok) SetArchiveLayoutContext ¶
func (ot *OpenTok) SetArchiveLayoutContext(ctx context.Context, archiveID string, layout *Layout) (*Archive, error)
SetArchiveLayoutContext uses ctx for HTTP requests.
func (*OpenTok) SetArchiveStorage ¶
func (ot *OpenTok) SetArchiveStorage(opts *StorageOptions) (*StorageOptions, error)
SetArchiveStorage let you can have OpenTok upload completed archives to an Amazon S3 bucket (or an S3-compliant storage provider) or Microsoft Azure container.
Example ¶
storageConfig, err := ot.SetArchiveStorage(&opentok.StorageOptions{ Type: "s3", Config: &opentok.AmazonS3Config{ AccessKey: "myUsername", SecretKey: "myPassword", Bucket: "example", }, Fallback: "none", }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", storageConfig) } // &opentok.StorageOptions{ // Type: "s3", // Config: map[string]interface {}{ // "accessKey": "myUsername", // "bucket": "example", // "secretKey": "myPassword" // }, // Fallback: "none", // }
Output:
func (*OpenTok) SetArchiveStorageContext ¶
func (ot *OpenTok) SetArchiveStorageContext(ctx context.Context, opts *StorageOptions) (*StorageOptions, error)
SetArchiveStorageContext uses ctx for HTTP requests.
func (*OpenTok) SetBroadcastLayout ¶
SetBroadcastLayout dynamically changes the layout type of a live streaming broadcast.
Example ¶
broadcast, err := ot.SetBroadcastLayout("ce872e0d-4997-440a-a0a5-10ce715b54cf", &opentok.Layout{ Type: opentok.BestFit, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", broadcast) } // &opentok.Broadcast{ // ID: "ce872e0d-4997-440a-a0a5-10ce715b54cf", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: "40000001", // CreatedAt: 1579163008000, // UpdatedAt: 1579163008000, // Resolution: "1280x720", // Status: "started", // BroadcastURLs: &opentok.BroadcastURLs{ // HLS: "", // RTMP:[]*opentok.RTMPConfig{ // &opentok.RTMPConfig{ // ID: "foo", // Status: "connecting", // ServerURL: "rtmps://myfooserver/myfooapp", // StreamName: "myfoostream" // }, // &opentok.RTMPConfig{ // ID: "bar", // Status: "connecting", // ServerURL: "rtmp://mybarserver/mybarapp", // StreamName: "mybarstream" // }, // }, // }, // }
Output:
func (*OpenTok) SetBroadcastLayoutContext ¶
func (ot *OpenTok) SetBroadcastLayoutContext(ctx context.Context, broadcastID string, layout *Layout) (*Broadcast, error)
SetBroadcastLayoutContext uses ctx for HTTP requests.
func (*OpenTok) SetStreamClassLists ¶
func (ot *OpenTok) SetStreamClassLists(sessionID string, opts *StreamClassOptions) (*StreamList, error)
SetStreamClassLists changes the composed archive layout classes for an OpenTok stream
Example ¶
streams, err := ot.SetStreamClassLists("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", &opentok.StreamClassOptions{ Items: []*opentok.StreamClass{ &opentok.StreamClass{ ID: "d962b966-964d-4f18-be3f-e0b181a43b0e", LayoutClassList: []string{"full"}, }, }, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", streams) } // &opentok.StreamList{ // Count:1, // Items:[]*opentok.Stream{ // &opentok.Stream{ // ID: "d962b966-964d-4f18-be3f-e0b181a43b0e", // VideoType: "camera", // Name: "", // LayoutClassList: []string{"full"} // } // } // }
Output:
func (*OpenTok) SetStreamClassListsContext ¶
func (ot *OpenTok) SetStreamClassListsContext(ctx context.Context, sessionID string, opts *StreamClassOptions) (*StreamList, error)
SetStreamClassListsContext uses ctx for HTTP requests.
func (*OpenTok) StartArchive ¶
func (ot *OpenTok) StartArchive(sessionID string, opts *ArchiveOptions) (*Archive, error)
StartArchive starts the recording of the archive.
To successfully start recording an archive, at least one client must be connected to the session. You can only record one archive at a time for a given session. You can only record archives of sessions that use the OpenTok Media Router.
Example ¶
archive, err := ot.StartArchive("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", &opentok.ArchiveOptions{ Name: "example", Layout: &opentok.Layout{ Type: opentok.PIP, }, Resolution: opentok.HD, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", archive) } // &opentok.Archive{ // CreatedAt: 1579163008000, // Duration: 0, // HasAudio: true, // HasVideo: true, // ID: "c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", // Name: "example", // OutputMode: "composed", // ProjectID: 40000001, // Reason: "", // Resolution: "1280x720", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // Size: 0, // Status: "started", // URL: nil, // }
Output:
func (*OpenTok) StartArchiveContext ¶
func (ot *OpenTok) StartArchiveContext(ctx context.Context, sessionID string, opts *ArchiveOptions) (*Archive, error)
StartArchiveContext uses ctx for HTTP requests.
func (*OpenTok) StartBroadcast ¶
func (ot *OpenTok) StartBroadcast(sessionID string, opts *BroadcastOptions) (*Broadcast, error)
StartBroadcast starts a live streaming for an OpenTok session. This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.
Example ¶
broadcast, err := ot.StartBroadcast("1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", &opentok.BroadcastOptions{ Layout: &opentok.Layout{ Type: opentok.PIP, }, MaxDuration: 60, Outputs: &opentok.BroadcastOutputOptions{ RTMP: []*opentok.RTMPConfig{ &opentok.RTMPConfig{ ID: "foo", ServerURL: "rtmps://myfooserver/myfooapp", StreamName: "myfoostream", }, &opentok.RTMPConfig{ ID: "bar", ServerURL: "rtmp://mybarserver/mybarapp", StreamName: "mybarstream", }, }, }, Resolution: opentok.HD, }) if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", broadcast) } // &opentok.Broadcast{ // ID: "ce872e0d-4997-440a-a0a5-10ce715b54cf", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: "40000001", // CreatedAt: 1579163008000, // UpdatedAt: 1579163008000, // Resolution: "1280x720", // Status: "started", // BroadcastURLs: &opentok.BroadcastURLs{ // HLS: "", // RTMP:[]*opentok.RTMPConfig{ // &opentok.RTMPConfig{ // ID: "foo", // Status: "connecting", // ServerURL: "rtmps://myfooserver/myfooapp", // StreamName: "myfoostream" // }, // &opentok.RTMPConfig{ // ID: "bar", // Status: "connecting", // ServerURL: "rtmp://mybarserver/mybarapp", // StreamName: "mybarstream" // }, // }, // }, // }
Output:
func (*OpenTok) StartBroadcastContext ¶
func (ot *OpenTok) StartBroadcastContext(ctx context.Context, sessionID string, opts *BroadcastOptions) (*Broadcast, error)
StartBroadcastContext uses ctx for HTTP requests.
func (*OpenTok) StopArchive ¶
StopArchive stops the recording of the archive.
Archives stop recording after 2 hours (120 minutes), or 60 seconds after the last client disconnects from the session, or 60 minutes after the last client stops publishing.
Example ¶
archive, err := ot.StopArchive("c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", archive) } // &opentok.Archive{ // CreatedAt: 1579163008000, // Duration: 0, // HasAudio: true, // HasVideo: true, // ID: "c9c87fbb-f91b-49bf-a6b4-fd0dbe16caea", // Name: "example", // OutputMode: "composed", // ProjectID: 40000001, // Reason: "user initiated", // Resolution: "1280x720", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // Size: 0, // Status: "stopped", // URL: nil, // }
Output:
func (*OpenTok) StopArchiveContext ¶
StopArchiveContext uses ctx for HTTP requests.
func (*OpenTok) StopBroadcast ¶
StopBroadcast stops a live broadcast of an OpenTok session. Note that broadcasts automatically stop 120 minutes after they are started.
Example ¶
broadcast, err := ot.StopBroadcast("ce872e0d-4997-440a-a0a5-10ce715b54cf") if err != nil { fmt.Println(err) } else { fmt.Printf("%#v", broadcast) } // &opentok.Broadcast{ // ID: "ce872e0d-4997-440a-a0a5-10ce715b54cf", // SessionID: "1_QX90NjQ2MCY0Nm6-MTU4QTO4NzE5NTkyOX4yUy2OZndKQExJR0NyalcvNktmTzBpSnp-QX4", // ProjectID: 40000001, // CreatedAt: 1579163008000, // UpdatedAt: 1579163009000, // Resolution: "1280x720", // Status: "stopped", // BroadcastURLs: nil, // }
Output:
type Project ¶
type Project struct { // The OpenTok project API key ID string `json:"id"` // The OpenTok project API secret Secret string `json:"secret"` // Whether the project is active ("VALID", "ACTIVE") or suspended ("SUSPENDED"). Status string `json:"status"` // The name, if you specified one when creating the project; or an empty // string if you did not specify a name Name string `json:"name"` // The time at which the project was created (a UNIX timestamp, in milliseconds) CreatedAt int `json:"createdAt"` // The environment name that project is running on EnvironmentName string `json:"environmentName"` // The environment description that project is running on EnvironmentDescription string `json:"environmentDescription"` }
Project defines the response returned from API
type ProjectStatus ¶
type ProjectStatus string
ProjectStatus is the alias of string type
const ( // ProjectActive is used to set the project API key to ACTIVE. ProjectActive ProjectStatus = "ACTIVE" // ProjectSuspended is used to set the project API key to SUSPENDED, you will // not be able to use the project API key (and any OpenTok sessions created // with it). ProjectSuspended ProjectStatus = "SUSPENDED" )
type RTMPConfig ¶
type RTMPConfig struct { // An unique ID for the stream. ID string `json:"id"` // RTMP stream status returned in the response. Status string `json:"status,omitempty"` // The RTMP server URL. ServerURL string `json:"serverUrl"` // The stream name, such as the YouTube Live stream name or the Facebook // stream key. StreamName string `json:"streamName"` }
RTMPConfig defines the config of RTMP.
type Resolution ¶
type Resolution string
Resolution is the alias of string type.
const ( // SD (640x480-pixel) archives have a 4:3 aspect ratio. SD Resolution = "640x480" // HD (1280x720-pixel) archives have a 16:9 aspect ratio. HD Resolution = "1280x720" )
The resolution of the archive, either SD(default) or HD.
type Role ¶
type Role string
Role is the alias of string type.
const ( // Publisher can publish streams, subscribe to streams, and signal. Publisher Role = "publisher" // Subscriber can only subscribe to streams. Subscriber Role = "subscriber" // Moderator can call the forceUnpublish() and forceDisconnect() method of // the Session object in clients using the OpenTok.js library, and have the // privileges granted to a publisher. Moderator Role = "moderator" )
type SIP ¶
type SIP struct { // The SIP URI to be used as destination of the SIP call initiated from // OpenTok to your SIP platform. URI string `json:"uri"` // The number or string that will be sent to the final SIP number as the // caller. From string `json:"from,omitempty"` // Custom headers to be added to the SIP INVITE request initiated from // OpenTok to your SIP platform. Headers *SIPHeaders `json:"headers,omitempty"` // The username and password to be used in the the SIP INVITE request for // HTTP digest authentication Auth *SIPAuth `json:"auth,omitempty"` // A flag that indicates whether the media must be transmitted encrypted // or not. Secure bool `json:"secure,omitempty"` }
SIP defines the information of SIP call
type SIPAuth ¶
type SIPAuth struct { // The username for HTTP digest authentication Username string `json:"username"` // The password for HTTP digest authentication Password string `json:"password"` }
SIPAuth defines the authentication information for SIP call
type SIPCall ¶
type SIPCall struct { // A unique ID for the SIP call. ID string `json:"id"` // The OpenTok connection ID for the SIP call's connection in the OpenTok // session. ConnectionID string `json:"connectionId"` // The OpenTok stream ID for the SIP call's stream in the OpenTok session. StreamID string `json:"streamId"` }
SIPCall defines the response returned from API
type SIPHeaders ¶
SIPHeaders is the alias of map[string]string type
type Session ¶
type Session struct { // The session ID. SessionID string `json:"session_id"` // The API key associated with the project. ProjectID string `json:"project_id"` // The time at which the session was created. CreateDt string `json:"create_dt"` // The URL of the OpenTok media router used by the session. MediaServerURL string `json:"media_server_url"` // The instance of OpenTok. OpenTok *OpenTok `json:"-"` }
Session defines the response returned from API.
func (*Session) GenerateToken ¶
func (s *Session) GenerateToken(opts *TokenOptions) (string, error)
GenerateToken generates a token for each user connecting to an OpenTok session.
type SessionIDInfo ¶
type SessionIDInfo struct { // The API key associated with the project. APIKey string // The IP address that TokBox use to situate the session in its global // network. Location string // The time at which the session was created. CreateTime time.Time }
SessionIDInfo defines the information decoded from the session ID.
type SessionOptions ¶
type SessionOptions struct { // Set to always to have the session archived automatically. // With the archiveModeset to manual (the default), you can archive the // session by calling the REST /archive POST method. ArchiveMode ArchiveMode // The IP address that TokBox will use to situate the session in its global // network. Location string // Set to enabled if you prefer clients to attempt to send audio-video // streams directly to other clients; set to disabled for sessions that use // the OpenTok Media Router. MediaMode MediaMode }
SessionOptions defines the options for creating a session.
type SignalData ¶
type SignalData struct { // The type of the signal. // This is a string value that clients can filter on when listening for signals Type string `json:"type"` // The data of the signal Data string `json:"data"` }
SignalData defines the type and data of signal
type SignalDataError ¶ added in v2.2.0
func (*SignalDataError) Error ¶ added in v2.2.0
func (e *SignalDataError) Error() string
type StorageOptions ¶
type StorageOptions struct { // Type of upload target. Type string `json:"type"` // Settings for the target. Config interface{} `json:"config"` // Set this to "opentok" to have the archive available at the OpenTok // dashboard if upload fails. // Set this to "none" (or omit the property) to prevents archive files from // being stored in the OpenTok cloud if the upload fails. Fallback string `json:"fallback,omitempty"` }
StorageOptions defines the options for setting archiving upload target.
type Stream ¶
type Stream struct { // The unique stream ID. ID string `json:"id"` // Either "camera" or "screen". VideoType string `json:"videoType"` // The stream name. Name string `json:"name"` // An array of the layout classes for the stream. LayoutClassList []string `json:"layoutClassList"` }
Stream defines the response returned from API
type StreamClass ¶
type StreamClass struct { // The stream ID. ID string `json:"id"` // An array of layout classes (each strings) for the stream. LayoutClassList []string `json:"layoutClassList"` }
StreamClass defines the layout classes to assign to a stream.
type StreamClassOptions ¶
type StreamClassOptions struct { // The layout classes to assign to a stream. Items []*StreamClass `json:"items"` }
StreamClassOptions defines the options for setting the layout classes for the stream
type StreamList ¶
type StreamList struct { // The total number of streams in a session. Count int `json:"count"` // An array of objects defining each stream retrieved. // Streams are listed from the newest to the oldest in the return set. Items []*Stream `json:"items"` }
StreamList defines the response returned from API
type TokenOptions ¶
type TokenOptions struct { // The role to determine the capabilities of the client that connects with // a token. Role Role // The metadata for describing the client. Data string // The expiration period of the token. ExpireTime int64 // Layout classes for the stream. InitialLayoutClassList []string }
TokenOptions defines the options for generating token.