# @antmedia/webrtc_adaptor

> WebRTC Adaptor for implementing a front end using Ant Media Server.

Latest version **2.16.2** (published 2025-12-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @antmedia/webrtc_adaptor
pnpm add @antmedia/webrtc_adaptor
yarn add @antmedia/webrtc_adaptor
bun add @antmedia/webrtc_adaptor
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.16.2 |
| Published | 2025-12-08 |
| First published | 2022-02-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 83 |
| Author | Ant Media |
| Maintainers | mekya |

## Links

- npm: https://www.npmjs.com/package/@antmedia/webrtc_adaptor
- Repository: https://github.com/ant-media/StreamApp
- Homepage: https://github.com/ant-media/StreamApp#readme
- Issues: https://github.com/ant-media/Ant-Media-Server/issues
- npm.io page: https://npm.io/package/@antmedia/webrtc_adaptor

## Dependencies (2)

- [url](https://npm.io/package/url.md) ^0.11.1
- [@mediapipe/selfie_segmentation](https://npm.io/package/@mediapipe/selfie_segmentation.md) ^0.1.1675465747

## Recent versions

- 2.16.2 (latest) — 2025-12-08
- 3.0.0-SNAPSHOT-2025-Nov-09-10-23 (SNAPSHOT) — 2025-11-09
- 2.12.0-ALPHA-2024-Dec-03 (ALPHA) — 2024-12-03
- 2.16.1 — 2025-12-04
- 2.16.0 — 2025-11-06
- 3.0.0-SNAPSHOT-2025-Sep-11-05-48 — 2025-09-11
- 3.0.0-SNAPSHOT-2025-Aug-31-12-36 — 2025-08-31
- 3.0.0-SNAPSHOT-2025-Aug-20-03-27 — 2025-08-20
- 3.0.0-SNAPSHOT-2025-Aug-15-11-09 — 2025-08-15
- 3.0.0-SNAPSHOT-2025-Aug-05-02-57 — 2025-08-05
- 3.0.0-SNAPSHOT-2025-Aug-05-05-39 — 2025-08-05
- 2.15.0 — 2025-08-03
- 3.0.0-SNAPSHOT-2025-Jul-10-03-49 — 2025-07-10
- 3.0.0-SNAPSHOT-2025-Jul-04-09-08 — 2025-07-04
- 3.0.0-SNAPSHOT-2025-Jun-28-09-09 — 2025-06-28
- … 202 more at https://npm.io/package/@antmedia/webrtc_adaptor/versions

## README

# [Ant Media Server](https://antmedia.io/) WebRTC JS SDK

WebSocket interface in publishing and playing WebRTC streams on Ant Media Server using Javascript.

For more information, visit [antmedia.io](https://antmedia.io)


[![Build Status](https://api.travis-ci.com/ant-media/StreamApp.svg?branch=master)](https://app.travis-ci.com/github/ant-media/StreamApp)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=io.antmedia%3Aant-media-server&metric=alert_status)](https://sonarcloud.io/dashboard?id=io.antmedia%3Aant-media-server)

## <a name="installation"></a>Installation

Using npm:
```shell
$ npm install @antmedia/webrtc_adaptor
```

Using yarn:
```shell
$ yarn add @antmedia/webrtc_adaptor
```

## <a name="requirements"></a>Requirements

Before start using Ant Media Server WebRTC SDK, you need a distribution of the Ant Media Server running on a server or local machine.
[Quick Start - Ant Media Server](https://antmedia.io/docs/)

## <a name="usage">Usage

In your project, run:

```
npm i @antmedia/webrtc_adaptor
```
Then inside your javascript file:
#### <a name="initialize">Initialize the WebRTCAdaptor
```javascript
  // ...
import { WebRTCAdaptor } from '@antmedia/webrtc_adaptor';

const webRTCAdaptor = new WebRTCAdaptor({
    websocket_url: "wss://your-domain.tld:5443/WebRTCAppEE/websocket",
    mediaConstraints: {
        video: true,
        audio: true,
    },
    peerconnection_config: {
        'iceServers': [{'urls': 'stun:stun1.l.google.com:19302'}]
    },
    sdp_constraints: {
        OfferToReceiveAudio : false,
        OfferToReceiveVideo : false,
    },
    localVideoId: "id-of-video-element", // <video id="id-of-video-element" autoplay muted></video>
    bandwidth: int|string, // default is 900 kbps, string can be 'unlimited'
    dataChannelEnabled: true|false, // enable or disable data channel
    callback: (info, obj) => {}, // check info callbacks bellow
    callbackError: function(error, message) {}, // check error callbacks bellow
});
//...
```
In another part of your script:
#### <a name="publish">Publish
```javascript
// You can start streaming by calling the publish method
webRTCAdaptor.publish(streamId);
```

#### <a name="play">Play
```javascript
// You can start playing the stream by calling the play method
webRTCAdaptor.play(streamId);
```

## Samples
Visit The [Samples List](https://antmedia.io/webrtc-samples/) and look at their [sources codes](https://github.com/ant-media/StreamApp/tree/master/src/main/webapp)

## <a name="documentation">Documentation
[Javascript SDK Documentation](https://antmedia.io/docs/guides/developer-sdk-and-api/sdk-integration/javascript-sdk/)

## <a name="livedemo">Live Demo
You can check our [live demo](https://antmedia.io/live-demo).

## <a name="issues">Issues
Create issues on the [Ant-Media-Server](https://github.com/ant-media/Ant-Media-Server/issues)


## StreamApp for Ant Media Server Developers 

This repository includes the default streaming application for Ant Media Server. Ant Media Server Developer can use it as a base app to get started for their applications.
It has mainly three components.

### JS SDK
  The fileslocated under `src/main/js/` directory are the JS SDK. It's compiled, tested and deployed to `src/main/webapp/js` directory.
  They been published to npmjs.org as well as mentioned above.

### Embedded Player
  The files located under `embedded-player` are the embedded player for Ant Media Server. It mainly use [@antmedia/web_player](https://www.npmjs.com/package/@antmedia/web_player)
  to provide a embedded player for default applications. It's compiled and deployed to the `src/main/webapp/js` and it's being used by `src/main/webapp/play.html`
  
### Maven Project
  Generally this repo is a maven project and it provides java files, web.xml and properties file to creates a Streaming app. 
  
### How to Build
- In the main directory, run the following command to install npm packages
  ```
  npm install
  ```
- Go to embedded-player and install the npm packages
  ```
  cd embedded-player
  npm install
  ```
- Switch back to main directory and run the `redeploy.sh`. It compiles and copies the js files to the `src/main/webapp/js` 
  ```
  ./redeploy.sh
  ```

---
_Source: https://npm.io/package/@antmedia/webrtc_adaptor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
