GithubHelp home page GithubHelp logo

8xff / atm0s-media-sdk-js Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 2.0 1.15 MB

JS SDK for interacting with Atm0s Media Server

License: MIT License

JavaScript 3.81% TypeScript 96.19%
javascript javascript-library media sdk-js streaming

atm0s-media-sdk-js's Introduction

Atm0s Media JS SDK

Continuous Integrations

JS SDK for interacting with Atm0s Media Server (This SDK is still in Alpha).

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @8xff/atm0s-media-js@alpha --save

# For Yarn, use the command below.
yarn add @8xff/atm0s-media-js@alpha

Installation from CDN

This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/@8xff/atm0s-media-js@alpha"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/@8xff/atm0s-media-js"></script>

<script>
  // UMD module is exposed through the "Atm0s" global variable.
  console.log(Atm0s);
</script>

Documentation

Usage

Connect to a Session

import { createSession } from "@8xff/atm0s-media-js";

const url = "<YOUR SERVER URL>";
const token = "<YOUR SERVER TOKEN IF NEEDED>";

// This can be any MediaStream
const stream = await navigator.mediaDevices.getUserMedia({
  audio: true,
  video: true,
});

const session = createSession(url, {
  roomId: "Echo Room",
  peerId: "echo-client",
  token,
  // You can optionally initialize the session with senders and receivers so we won't have to keep
  // updating SDP every time we create a new senders and receivers
  senders: [
    { stream: stream, name: "audio_main", kind: "audio" },
    {
      stream: stream,
      name: "video_main",
      kind: "video",
      // Optionally, you can add simulcast
      simulcast: true,
    },
  ],
  receivers: {
    audio: 1,
    video: 1,
  },
});

// This will connect to the server and send the initialized MediaStream from above 
session.connect();

Consume the stream

By issued stream name

const consumer = session.createConsumerPair(peerId, "audio_main", "video_main");

Or listen to stream events:

// Note: In this specific case, we only have our own stream, so only `mystream_added` is triggered.
// In the case of listening for an external stream, use `stream_added` instead
session.on("mystream_added", (stream) => {
  // The audio stream and video stream added events will be triggered separately

  if (stream.kind === "video") {
    const consumer = session.createConsumer(stream);
    const stream = consumer.view();
    // Do something with stream ...
  }

  if (stream.kind === "audio") {
    const consumer = session.createConsumer(stream);
    const stream = consumer.view();
    // Do something with stream ...
  }
});

You can find more details about the SDK Documentation here.

License

Released under MIT License.

atm0s-media-sdk-js's People

Contributors

luongngocminh avatar renovate[bot] avatar giangndm avatar

Stargazers

 avatar binhdt avatar

Watchers

 avatar shadowWalker avatar  avatar

atm0s-media-sdk-js's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @rollup/plugin-terser to v0.4.4
  • chore(deps): update dependency @types/jest to v29.5.12
  • chore(deps): update dependency ts-jest to v29.1.2
  • chore(deps): update dependency typedoc to v0.25.13
  • chore(deps): update dependency eslint to v8.57.0
  • chore(deps): update dependency eslint-config-prettier to v9.1.0
  • chore(deps): update dependency eslint-plugin-prettier to v5.1.3
  • chore(deps): update dependency typedoc-plugin-markdown to v3.17.1
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency typedoc-plugin-markdown to v4
  • chore(deps): update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/actions/setup/action.yaml
  • actions/setup-node v4
  • pnpm/action-setup v2
  • actions/cache v3
.github/workflows/continuous-integrations.yaml
  • actions/checkout v4
  • actions/checkout v4
  • codecov/codecov-action v3
  • actions/checkout v4
.github/workflows/publish-alpha.yaml
  • actions/checkout v4
  • actions/upload-release-asset v1
.github/workflows/publish-nightly.yaml
  • actions/checkout v3.0.0
  • actions/checkout v4
.github/workflows/release-drafter.yml
  • release-drafter/release-drafter v5
npm
package.json
  • pako ^2.1.0
  • ts-debounce ^4.0.0
  • tslib ^2.6.2
  • @rollup/plugin-node-resolve ^15.2.3
  • @rollup/plugin-terser ^0.4.3
  • @types/debug ^4.1.12
  • @types/eslint ^8.44.3
  • @types/jest ^29.5.5
  • @types/pako ^2.0.3
  • @types/prettier ^3.0.0
  • @typescript-eslint/eslint-plugin ^6.7.4
  • @typescript-eslint/parser ^6.7.4
  • eslint ^8.50.0
  • eslint-config-prettier ^9.0.0
  • eslint-plugin-prettier ^5.0.0
  • jest ^29.7.0
  • jest-environment-jsdom ^29.7.0
  • prettier ^3.0.3
  • rollup ^3.29.4
  • rollup-plugin-typescript2 ^0.36.0
  • ts-jest ^29.1.1
  • ts-jest-resolver ^2.0.1
  • typedoc ^0.25.1
  • typedoc-plugin-markdown ^3.16.0
  • typescript ^5.2.2

  • Check this box to trigger a request for Renovate to run again on this repository

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.