0.0.20 • Published 5 years ago

@casto/sdk v0.0.20

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago