opentok

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TOKEN_SENTINEL = "T1=="

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonS3Config added in v1.5.0

type AmazonS3Config struct {
	AccessKey string `json:"accessKey"`          // The Amazon Web Services access key.
	SecretKey string `json:"secretKey"`          // The Amazon Web Services secret key.
	Bucket    string `json:"bucket"`             // The S3 bucket name.
	Endpoint  string `json:"endpoint,omitempty"` // The S3 or S3-compatible storage endpoint.
}

type Archive added in v1.4.0

type Archive struct {
	CreatedAt  int               `json:"createdAt"`  // The time at which the archive was created, in milliseconds since the UNIX epoch.
	Duration   int               `json:"duration"`   // The duration of the archive, in milliseconds.
	HasAudio   bool              `json:"hasAudio"`   // Whether the archive has an audio track or not.
	HasVideo   bool              `json:"hasVideo"`   // Whether the archive has an video track or not.
	Id         string            `json:"id"`         // The unique archive ID.
	Name       *string           `json:"name"`       // The name of the archive.
	OutputMode ArchiveOutputMode `json:"outputMode"` // The output mode to be generated for this archive.
	ProjectId  int               `json:"projectId"`  // The API key associated with the archive.
	Reason     string            `json:"reason"`     // This string describes the reason the archive stopped or failed.
	Resolution Resolution        `json:"resolution"` // The resolution of the archive.
	SessionId  string            `json:"sessionId"`  // The session ID of the OpenTok session associated with this archive.
	Size       int               `json:"size"`       // The size of the MP4 file.
	Status     string            `json:"status"`     // The status of the archive.
	Url        *string           `json:"url"`        // The download URL of the available MP4 file.
	OpenTok    *OpenTok          `json:"-"`
}

func (*Archive) Delete added in v1.4.0

func (archive *Archive) Delete() error

func (*Archive) Stop added in v1.4.0

func (archive *Archive) Stop() (*Archive, error)

type ArchiveList added in v1.4.0

type ArchiveList struct {
	Count int        `json:"count"`
	Items []*Archive `json:"items"`
}

type ArchiveListOptions added in v1.4.0

type ArchiveListOptions struct {
	Offset    int
	Count     int
	SessionId string
}

type ArchiveMode

type ArchiveMode string
const (
	/**
	 * Set to always to have the session archived automatically.
	 */
	AutoArchived ArchiveMode = "always"
	/**
	 * Set to manual (the default), you can archive the session by calling the REST /archive POST method
	 */
	ManualArchived ArchiveMode = "manual"
)

type ArchiveOptions added in v1.4.0

type ArchiveOptions struct {
	SessionId  string            `json:"sessionId"`
	HasAudio   bool              `json:"hasAudio,omitempty"`
	HasVideo   bool              `json:"hasVideo,omitempty"`
	Layout     *Layout           `json:"layout,omitempty"`
	Name       string            `json:"name,omitempty"`
	OutputMode ArchiveOutputMode `json:"outputMode,omitempty"`
	Resolution Resolution        `json:"resolution,omitempty"`
}

type ArchiveOutputMode added in v1.4.0

type ArchiveOutputMode string
const (
	/**
	 * The archive is a single MP4 file composed of all streams.
	 */
	Composed ArchiveOutputMode = "composed"
	/**
	 * 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 added in v1.5.0

type AzureConfig struct {
	AccountName string `json:"accountName"`      // The Microsoft Azure account name.
	AccountKey  string `json:"accountKey"`       // The Microsoft Azure account key.
	Container   string `json:"container"`        // The Microsoft Azure container name.
	Domain      string `json:"domain,omitempty"` // The Microsoft Azure domain in which the container resides.
}

type Broadcast added in v1.7.0

type Broadcast struct {
	Id            string        `json:"id"`            // The unique ID for the broadcast.
	SessionId     string        `json:"sessionId"`     // The OpenTok session ID.
	ProjectId     int           `json:"projectId"`     // The API key associated with the broadcast..
	CreatedAt     int           `json:"createdAt"`     // The time at which the broadcast was created, in milliseconds since the UNIX epoch.
	UpdatedAt     int           `json:"updatedAt"`     // The time at which the broadcast was updated, in milliseconds since the UNIX epoch.
	Resolution    Resolution    `json:"resolution"`    // The resolution of the broadcast.
	Status        string        `json:"status"`        // The status of the broadcast.
	BroadcastUrls BroadcastUrls `json:"broadcastUrls"` // An object containing details about the HLS and RTMP broadcasts.
	OpenTok       *OpenTok      `json:"-"`
}

func (*Broadcast) Stop added in v1.7.0

func (broadcast *Broadcast) Stop() (*Broadcast, error)

type BroadcastList added in v1.7.0

type BroadcastList struct {
	Count int          `json:"count"`
	Items []*Broadcast `json:"items"`
}

type BroadcastListOptions added in v1.7.0

type BroadcastListOptions struct {
	Offset    int
	Count     int
	SessionId string
}

type BroadcastOptions added in v1.7.0

type BroadcastOptions struct {
	SessionId   string                 `json:"sessionId"`
	Layout      *Layout                `json:"layout,omitempty"`
	MaxDuration int                    `json:"maxDuration,omitempty"`
	Outputs     BroadcastOutputOptions `json:"outputs"`
	Resolution  Resolution             `json:"resolution,omitempty"`
}

type BroadcastOutputOptions added in v1.7.0

type BroadcastOutputOptions struct {
	HLS  *HLSConfig    `json:"hls,omitempty"`
	RTMP []*RTMPConfig `json:"rtmp,omitempty"`
}

type BroadcastUrls added in v1.7.0

type BroadcastUrls struct {
	HLS  string        `json:"hls"`
	RTMP []*RTMPConfig `json:rtmp`
}

type DialOptions added in v1.8.0

type DialOptions struct {
	SessionId string `json:"sessionId"`
	Token     string `json:"token"`
	SIP       SIP    `json:"sip"`
	TokenData string `json:"-"`
}

type HLSConfig added in v1.7.0

type HLSConfig struct{}

type Layout added in v1.7.0

type Layout struct {
	Type       LayoutType `json:"type,omitempty"`
	StyleSheet string     `json:"stylesheet,omitempty"`
}

type LayoutType added in v1.7.0

type LayoutType string
const (
	/**
	 * This is a tiled layout, which scales according to the number of videos.
	 */
	BestFit LayoutType = "bestFit"
	/**
	 * This is a picture-in-picture layout, where a small stream is visible over
	 * a full-size stream.
	 */
	PIP LayoutType = "pip"
	/**
	 * This 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"
	/**
	 * This 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"
	/**
	 * To use a custom layout, set the type property for the layout to "custom"
	 * and set an additional property, stylesheet, which is set to the CSS.
	 */
	Custom LayoutType = "custom"
)

type MediaMode

type MediaMode string
const (
	/**
	 * Set to enabled if you prefer clients to attempt to send audio-video streams directly to other clients
	 */
	Relayed MediaMode = "enabled"
	/**
	 * Set to disabled for sessions that use the OpenTok Media Router
	 */
	Routed MediaMode = "disabled"
)

type OpenTok

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

func New

func New(apiKey, apiSecret string) *OpenTok

func (*OpenTok) ChangeProjectStatus

func (ot *OpenTok) ChangeProjectStatus(projectApiKey string, projectStatus ProjectStatus) (*Project, error)

*

  • Account administrators can use this method to change a project's status.

func (*OpenTok) CreateProject

func (ot *OpenTok) CreateProject(projectName string) (*Project, error)

*

  • Use this method to create an OpenTok API key and secret for a project.

func (*OpenTok) CreateSession

func (ot *OpenTok) CreateSession(opts SessionOptions) (*Session, error)

func (*OpenTok) DeleteArchive added in v1.4.0

func (ot *OpenTok) DeleteArchive(archiveId string) error

*

  • Delete the OpenTok archive.

func (*OpenTok) DeleteArchiveStorage added in v1.5.0

func (ot *OpenTok) DeleteArchiveStorage() error

*

  • Delete the configuration of archive storage.

func (*OpenTok) DeleteProject

func (ot *OpenTok) DeleteProject(projectApiKey string) error

*

  • Use this method to delete a project. This prevents the use of the project API key (an any OpenTok sessions created with it).

func (*OpenTok) Dial added in v1.8.0

func (ot *OpenTok) Dial(sessionId string, opts DialOptions) (*SIPCall, error)

*

  • 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.

func (*OpenTok) ForceDisconnect added in v1.6.0

func (ot *OpenTok) ForceDisconnect(sessionId, connectionId string) error

*

  • Disconnect a client from an OpenTok session via server-side

func (*OpenTok) GenerateToken

func (ot *OpenTok) GenerateToken(sessionId string, opts TokenOptions) (*string, error)

func (*OpenTok) GetArchive added in v1.4.0

func (ot *OpenTok) GetArchive(archiveId string) (*Archive, error)

*

  • Get the specific OpenTok archive by ID.

func (*OpenTok) GetBroadcast added in v1.7.0

func (ot *OpenTok) GetBroadcast(broadcastId string) (*Broadcast, error)

*

  • Get details on a broadcast that is in-progress.

func (*OpenTok) GetProject added in v1.3.0

func (ot *OpenTok) GetProject(projectApiKey string) (*Project, error)

*

  • Use this method to get a project details record describing the project.

func (*OpenTok) GetStream added in v1.6.0

func (ot *OpenTok) GetStream(sessionId, streamId string) (*Stream, error)

*

  • Get information on an OpenTok stream in a session

func (*OpenTok) ListArchives added in v1.4.0

func (ot *OpenTok) ListArchives(opts ArchiveListOptions) (*ArchiveList, error)

*

  • Get the list of archives for your project, both completed and in-progress.

func (*OpenTok) ListBroadcasts added in v1.7.0

func (ot *OpenTok) ListBroadcasts(opts BroadcastListOptions) (*BroadcastList, error)

*

  • Get details on broadcasts that are in progress and started.
  • Completed broadcasts are not included in the listing.

func (*OpenTok) ListProjects added in v1.3.0

func (ot *OpenTok) ListProjects() ([]*Project, error)

*

  • Use this method to get the records for all projects.

func (*OpenTok) ListStreams added in v1.6.0

func (ot *OpenTok) ListStreams(sessionId string) (*StreamList, error)

*

  • Get information on an OpenTok all stream in a session

func (*OpenTok) RefreshProjectSecret

func (ot *OpenTok) RefreshProjectSecret(projectApiKey string) (*Project, error)

*

  • For security reasons, you may want to generate a new API secret for a project.

func (*OpenTok) SendConnectionSignal added in v1.6.0

func (ot *OpenTok) SendConnectionSignal(sessionId, connectionId string, data SignalData) error

*

  • Send signals to a specific client in an active OpenTok session

func (*OpenTok) SendSessionSignal added in v1.6.0

func (ot *OpenTok) SendSessionSignal(sessionId string, data SignalData) error

*

  • Send signals to all participants in an active OpenTok session

func (*OpenTok) SetArchiveLayout added in v1.5.0

func (ot *OpenTok) SetArchiveLayout(archiveId string, layout Layout) (*Archive, error)

*

  • Dynamically change the layout type of a composed archive.

func (*OpenTok) SetArchiveStorage added in v1.5.0

func (ot *OpenTok) SetArchiveStorage(opts StorageOptions) (*StorageOptions, error)

*

  • For an OpenTok project, you can have OpenTok upload completed archives to an
  • Amazon S3 bucket (or an S3-compliant storage provider) or Microsoft Azure container.

func (*OpenTok) SetBroadcastLayout added in v1.7.0

func (ot *OpenTok) SetBroadcastLayout(broadcastId string, layout Layout) (*Broadcast, error)

*

  • Dynamically change the layout type of a live streaming broadcast.

func (*OpenTok) SetStreamClassLists added in v1.7.0

func (ot *OpenTok) SetStreamClassLists(sessionId string, opts StreamClassOptions) (*StreamList, error)

*

  • Change the composed archive layout classes for an OpenTok stream

func (*OpenTok) StartArchive added in v1.4.0

func (ot *OpenTok) StartArchive(sessionId string, opts ArchiveOptions) (*Archive, error)

*

  • Start 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.

func (*OpenTok) StartBroadcast added in v1.7.0

func (ot *OpenTok) StartBroadcast(sessionId string, opts BroadcastOptions) (*Broadcast, error)

*

  • Use this method to start a live streaming for an OpenTok session.
  • This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.

func (*OpenTok) StopArchive added in v1.4.0

func (ot *OpenTok) StopArchive(archiveId string) (*Archive, error)

*

  • Stop 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.

func (*OpenTok) StopBroadcast added in v1.7.0

func (ot *OpenTok) StopBroadcast(broadcastId string) (*Broadcast, error)

*

  • Use this method to stop a live broadcast of an OpenTok session.
  • Note that broadcasts automatically stop 120 minutes after they are started.

type Project

type Project struct {
	Id                     string `json:"id"`                     // The OpenTok project API key
	UserId                 int    `json:"userId"`                 // The OpenTok account id
	Secret                 string `json:"secret"`                 // The OpenTok project API secret
	Status                 string `json:"status"`                 // Whether the project is active ("VALID", "ACTIVE") or suspended ("SUSPENDED").
	UserStatus             string `json:"userStatus"`             // The OpenTok account status
	Name                   string `json:"name"`                   // The name, if you specified one when creating the project; or an empty string if you did not specify a name
	ContactEmail           string `json:"contactEmail"`           // The OpenTok account email
	CreatedAt              int    `json:"createdAt"`              // The time at which the project was created (a UNIX timestamp, in milliseconds)
	UpdatedAt              int    `json:"updatedAt"`              // The time at which the project was updated (a UNIX timestamp, in milliseconds)
	EnvironmentId          int    `json:"environmentId"`          // The environment id that project is running on
	EnvironmentName        string `json:"environmentName"`        // The environment name that project is running on
	EnvironmentDescription string `json:"environmentDescription"` // The environment description that project is running on
	ApiKey                 string `json:"apiKey"`                 // The OpenTok project API key
}

type ProjectStatus

type ProjectStatus string
const (
	/**
	 * Set to ACTIVE to use the project API key.
	 */
	ProjectActive ProjectStatus = "ACTIVE"
	/**
	 * Set 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 added in v1.7.0

type RTMPConfig struct {
	Id         string `json:"id"`
	Status     string `json:"status,omitempty"`
	ServerUrl  string `json:"serverUrl"`
	StreamName string `json:"streamName"`
}

type Resolution added in v1.7.0

type Resolution string
const (
	// The resolution of the archive.
	SD Resolution = "640x480"
	HD Resolution = "1280x720"
)

type Role added in v1.2.0

type Role string
const (
	/**
	 * A publisher can publish streams, subscribe to streams, and signal.
	 */
	Publisher Role = "publisher"
	/**
	 * A subscriber can only subscribe to streams.
	 */
	Subscriber Role = "subscriber"
	/**
	 * In addition to the privileges granted to a publisher, in clients using
	 * the OpenTok.js library, a moderator can call the forceUnpublish() and
	 * forceDisconnect() method of the Session object.
	 */
	Moderator Role = "moderator"
)

type SIP added in v1.8.0

type SIP struct {
	URI     string      `json:"uri"`
	From    string      `json:"from,omitempty"`
	Headers *SIPHeaders `json:"headers,omitempty"`
	Auth    *SIPAuth    `json:"auth,omitempty"`
	Secure  bool        `json:"secure,omitempty"`
}

type SIPAuth added in v1.8.0

type SIPAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type SIPCall added in v1.8.0

type SIPCall struct {
	Id           string `json:"id"`           // A unique ID for the SIP call.
	ConnectionId string `json:"connectionId"` // The OpenTok connection ID for the SIP call's connection in the OpenTok session.
	StreamId     string `json:"streamId"`     // The OpenTok stream ID for the SIP call's stream in the OpenTok session.
}

type SIPHeaders added in v1.8.0

type SIPHeaders map[string]string

type Session

type Session struct {
	SessionId      string   `json:"session_id"`
	ProjectId      string   `json:"project_id"`
	CreateDt       string   `json:"create_dt"`
	MediaServerURL string   `json:"media_server_url"`
	OpenTok        *OpenTok `json:"-"`
}

func (*Session) GenerateToken

func (s *Session) GenerateToken(opts TokenOptions) (*string, error)

type SessionIdInfo

type SessionIdInfo struct {
	ApiKey     string
	Location   string
	CreateTime time.Time
}

type SessionOptions

type SessionOptions struct {
	ArchiveMode ArchiveMode
	Location    string
	MediaMode   MediaMode
}

type SignalData added in v1.6.0

type SignalData struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type StorageOptions added in v1.5.0

type StorageOptions struct {
	Type     string      `json:"type"`               // Type of storage.
	Config   interface{} `json:"config"`             // Settings for the storage.
	Fallback string      `json:"fallback,omitempty"` // Error handling method if upload fails.
}

type Stream added in v1.6.0

type Stream struct {
	Id              string   `json:"id"`              // The unique stream ID.
	VideoType       string   `json:"videoType"`       // Either "camera" or "screen".
	Name            string   `json:"name"`            // The stream name.
	LayoutClassList []string `json:"layoutClassList"` // An array of the layout classes for the stream.
}

type StreamClass added in v1.7.0

type StreamClass struct {
	Id              string   `json:"id"`
	LayoutClassList []string `json:"layoutClassList"`
}

type StreamClassOptions added in v1.7.0

type StreamClassOptions struct {
	Items []*StreamClass `json:"items"`
}

type StreamList added in v1.6.0

type StreamList struct {
	Count int       `json:"count"`
	Items []*Stream `json:"items"`
}

type TokenOptions

type TokenOptions struct {
	Role                   Role
	Data                   string
	ExpireTime             int
	InitialLayoutClassList []string
}

Jump to

Keyboard shortcuts

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