Giter Site home page Giter Site logo

castosdk's Introduction

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

castosdk's People

Contributors

acidsound avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.