Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

CASTO SDK

The javascript implementation of the CASTO platform.

Install

npm install --save @casto/sdk

Tutorial and Examples

Basic

for sender

const Casto = require('@casto/sdk')
streamer = new Casto({type: "sender"})

for viewer

const Casto = require('@casto/sdk')
viewer = new Casto({type: "viewer"})
viewer.onSendChannelsList = ({channels}) => {
  for (const channel in channels) {
    /* Do some stuff for channel list */
    button.addEventListener('click', ()=> {
      /* media should be a mediaElement for streaming */
      media.srcObject = await casto.getChannel(channel.peerId})
    })
  }
}

For other web frameworks

Modules

casto diagram

sender ( {type: "sender"} )

module that send stream to specific serviceId

viewer ( {type: "viewer"} )

module that receive channel list of serviceId and choose stream from the list to view.

relay

service that relays copies of the sender's stream to viewers.

API

Methods

Create a Casto - new Casto(options)

create an instance of the Casto Require keys in the options object:

  • type: type of casto instance. If you want to do a broadcast, set sender or set viewer if you want to watch a broadcast.
  • serviceId: default is TESTO
  • streamerPeerId:

casto.start(): MediaStream

start a broadcast by the Casto. Should return a MediaStream, which is an object for transfer to the remote.

casto.getChannel(peerId): MediaStream

Should return a MediaStream, which is an object that received broadcasting from peerId

Events

Sender

casto.onNodeInitiated:

Casto is initiated. Ready to connect to relay nodes.

casto.onReadyToCast:

Successfully connected to a relay node and is ready to start broadcasting.

casto.onCompleted:

webRTC peerConnection is 'completed'. currently sending stream to a relay.

casto.onClosed:

webRTC peerConnection is 'closed'.

Viewer

casto.onNodeInitiated:

Casto is initiated. Ready to connect to relay nodes.

casto.onReadyToCast:

Successfully connected to a relay node and is ready to view streams.

casto.onClosed:

webRTC peerConnection is 'closed'.

casto.onSendChannelsList:

Retrieved available lists of channels from relay nodes.

casto.onSendChannelRemoved:

Channel is removed.

casto.onSendChannelAdded:

Channel is added.

casto.onWavesUpdated:

Received the updated channel information.

License

MIT © Casto Network

About

The CASTO SDK, including the sending, viewing, and more.

Resources

Releases

No releases published

Packages

No packages published