@casto/sdk

0.0.20 • Public • Published

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 (TBD)

  • react tutorial
  • vue tutorial
  • vanilla javascript tutorial

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

Readme

Keywords

Package Sidebar

Install

npm i @casto/sdk

Weekly Downloads

1

Version

0.0.20

License

MIT

Unpacked Size

17.6 MB

Total Files

11

Last publish

Collaborators

  • calmglow
  • core-digger
  • devninja
  • spectrum