Convert Figma logo to code with AI

pion logowebrtc

Pure Go implementation of the WebRTC API

13,642
1,649
13,642
78

Top Related Projects

4,102

A pure Rust implementation of WebRTC

4,215

WebRTC and ORTC implementation for Python using asyncio

node-webrtc is a Node.js Native Addon that provides bindings to WebRTC M87

Janus WebRTC Server

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

📡 Simple WebRTC video, voice, and data channels

Quick Overview

The pion/webrtc project is a pure Go implementation of the WebRTC protocol, allowing developers to build real-time communication applications without the need for a browser. It provides a comprehensive set of APIs for handling WebRTC signaling, media, and data channels, making it a powerful tool for building custom WebRTC-based applications.

Pros

  • Cross-Platform Compatibility: The project is written in Go, which provides excellent cross-platform support, allowing developers to build WebRTC applications for a wide range of platforms, including Windows, macOS, and Linux.
  • Lightweight and Efficient: As a pure Go implementation, pion/webrtc is lightweight and efficient, making it suitable for resource-constrained environments, such as IoT devices or edge computing scenarios.
  • Comprehensive API: The project offers a comprehensive set of APIs for handling various aspects of WebRTC, including signaling, media, and data channels, making it a versatile choice for building complex WebRTC applications.
  • Active Development and Community: The project has an active development team and a growing community, ensuring regular updates, bug fixes, and support for new WebRTC features.

Cons

  • Limited Browser Integration: As a standalone WebRTC implementation, pion/webrtc does not provide native integration with web browsers, which may be a limitation for some use cases that require seamless browser integration.
  • Steeper Learning Curve: Compared to using WebRTC directly in a web browser, working with pion/webrtc may have a steeper learning curve, as developers need to understand the project's APIs and handle signaling and other WebRTC-specific tasks themselves.
  • Potential Performance Limitations: While the project is designed to be lightweight and efficient, it may not match the performance of native WebRTC implementations in certain scenarios, especially for high-bandwidth or low-latency applications.
  • Limited Ecosystem Integration: As a standalone project, pion/webrtc may have a smaller ecosystem of third-party libraries and tools compared to WebRTC implementations that are more tightly integrated with popular web frameworks or platforms.

Code Examples

Here are a few code examples demonstrating the usage of pion/webrtc:

  1. Establishing a WebRTC Connection:
// Create a new WebRTC engine
engine := webrtc.NewEngine()

// Create a new peer connection
pc, err := engine.NewPeerConnection(webrtc.Configuration{})
if err != nil {
    panic(err)
}

// Add a media track to the peer connection
track, err := pc.NewTrack(webrtc.DefaultPayloadTypeVP8, rand.Uint32(), "video", "pion")
if err != nil {
    panic(err)
}
_, err = pc.AddTrack(track)
if err != nil {
    panic(err)
}

// Set the local description and start the ICE gathering process
offer, err := pc.CreateOffer(nil)
if err != nil {
    panic(err)
}
if err := pc.SetLocalDescription(offer); err != nil {
    panic(err)
}
  1. Handling WebRTC Signaling:
// Create a new WebRTC engine
engine := webrtc.NewEngine()

// Create a new peer connection
pc, err := engine.NewPeerConnection(webrtc.Configuration{})
if err != nil {
    panic(err)
}

// Handle the remote description
pc.OnRemoteDescription(func(description *webrtc.SessionDescription) {
    if err := pc.SetRemoteDescription(description); err != nil {
        panic(err)
    }

    // Create an answer and set the local description
    answer, err := pc.CreateAnswer(nil)
    if err != nil {
        panic(err)
    }
    if err := pc.SetLocalDescription(answer); err != nil {
        panic(err)
    }
})
  1. Handling WebRTC Data Channels:
// Create a new WebRTC engine
engine := webrtc.NewEngine()

// Create a new peer connection
pc, err := engine.NewPeerConnection(webrtc.Configuration{})
if err != nil {
    panic

Competitor Comparisons

4,102

A pure Rust implementation of WebRTC

Pros of webrtc-rs

  • Written in Rust, offering memory safety and concurrency benefits
  • Potentially better performance due to Rust's low-level control and zero-cost abstractions
  • Growing ecosystem of Rust libraries and tools for integration

Cons of webrtc-rs

  • Smaller community and less mature compared to pion/webrtc
  • Fewer examples and documentation available
  • May have a steeper learning curve for developers not familiar with Rust

Code Comparison

webrtc-rs example:

let mut m = MediaEngine::default();
m.register_default_codecs()?;
let mut s = SettingEngine::default();
s.set_ice_multicast_dns_mode(ice::MulticastDnsMode::Disabled);
let api = APIBuilder::new().with_media_engine(m).with_setting_engine(s).build();

pion/webrtc example:

m := &webrtc.MediaEngine{}
if err := m.RegisterDefaultCodecs(); err != nil {
    panic(err)
}
s := webrtc.SettingEngine{}
s.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
api := webrtc.NewAPI(webrtc.WithMediaEngine(m), webrtc.WithSettingEngine(s))

Both examples demonstrate similar setup processes, with webrtc-rs using Rust's ownership model and pion/webrtc using Go's error handling approach.

4,215

WebRTC and ORTC implementation for Python using asyncio

Pros of aiortc

  • Written in Python, making it more accessible for developers familiar with the language
  • Supports both client-side and server-side WebRTC implementations
  • Includes built-in support for various audio and video codecs

Cons of aiortc

  • Generally slower performance compared to Go-based implementations
  • Limited ecosystem and community support compared to more established WebRTC libraries

Code Comparison

aiortc example:

import asyncio
from aiortc import RTCPeerConnection, RTCSessionDescription

pc = RTCPeerConnection()
await pc.setRemoteDescription(offer)
answer = await pc.createAnswer()
await pc.setLocalDescription(answer)

pion/webrtc example:

import "github.com/pion/webrtc/v3"

peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
err = peerConnection.SetRemoteDescription(offer)
answer, err := peerConnection.CreateAnswer(nil)
err = peerConnection.SetLocalDescription(answer)

Both libraries provide similar APIs for creating peer connections and handling WebRTC signaling, with syntax differences reflecting their respective programming languages.

node-webrtc is a Node.js Native Addon that provides bindings to WebRTC M87

Pros of node-webrtc

  • Native integration with Node.js ecosystem
  • Supports both browser and server-side WebRTC implementations
  • Extensive documentation and examples for various use cases

Cons of node-webrtc

  • Requires compilation of native modules, which can be complex
  • Limited platform support compared to pure JavaScript implementations
  • Potentially higher resource usage due to native code execution

Code Comparison

node-webrtc:

const wrtc = require('node-webrtc');
const pc = new wrtc.RTCPeerConnection();
pc.createOffer().then(offer => pc.setLocalDescription(offer));

pion/webrtc:

import "github.com/pion/webrtc/v3"

peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
offer, err := peerConnection.CreateOffer(nil)
peerConnection.SetLocalDescription(offer)

Both libraries provide similar core functionality for creating peer connections and handling WebRTC operations. The main difference lies in the language and ecosystem integration, with node-webrtc being tailored for Node.js applications and pion/webrtc designed for Go projects.

Janus WebRTC Server

Pros of Janus-gateway

  • Written in C, offering potentially better performance for high-load scenarios
  • Supports a wider range of WebRTC use cases out-of-the-box, including video conferencing and streaming
  • More mature project with a larger community and ecosystem

Cons of Janus-gateway

  • More complex setup and configuration compared to the Go-based Webrtc
  • Less flexibility for integration into Go-based applications
  • Steeper learning curve for developers not familiar with C

Code Comparison

Janus-gateway (C):

janus_plugin *create(void) {
    janus_plugin *plugin = (janus_plugin *)calloc(1, sizeof(janus_plugin));
    plugin->init = janus_echotest_init;
    plugin->destroy = janus_echotest_destroy;
    plugin->handle_message = janus_echotest_handle_message;
    return plugin;
}

Webrtc (Go):

func NewPeerConnection(configuration Configuration) (*PeerConnection, error) {
    pc := &PeerConnection{}
    pc.configuration = configuration
    pc.api = NewAPI()
    return pc, nil
}

The code snippets show the different approaches to initializing core components in each project, reflecting their respective languages and architectures.

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Pros of jitsi-meet

  • Full-featured video conferencing solution with a ready-to-use web interface
  • Supports large-scale meetings with features like breakout rooms and live streaming
  • Extensive documentation and active community support

Cons of jitsi-meet

  • More complex setup and deployment compared to a lightweight library
  • Higher resource requirements for hosting and running the application
  • Less flexibility for custom implementations due to its comprehensive nature

Code Comparison

jitsi-meet (JavaScript):

const options = {
    roomName: 'MyConferenceRoom',
    width: 700,
    height: 700,
    parentNode: document.querySelector('#meet')
};
const api = new JitsiMeetExternalAPI(domain, options);

webrtc (Go):

peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
if err != nil {
    panic(err)
}
// Add tracks, set up signaling, etc.

Summary

jitsi-meet is a comprehensive video conferencing solution with a rich feature set, while webrtc is a lightweight WebRTC library. jitsi-meet offers a complete application but requires more resources and setup, whereas webrtc provides more flexibility for custom implementations but requires more development effort to create a full application.

📡 Simple WebRTC video, voice, and data channels

Pros of simple-peer

  • Simpler API and easier to use for beginners
  • Built-in support for data channels
  • Lightweight and focused on peer-to-peer connections

Cons of simple-peer

  • Limited to JavaScript environments
  • Less flexibility for advanced WebRTC features
  • Smaller community and fewer updates compared to webrtc

Code Comparison

simple-peer:

const peer = new SimplePeer({ initiator: true })
peer.on('signal', data => {
  // send signal data to peer
})
peer.on('connect', () => {
  peer.send('Hello, peer!')
})

webrtc:

peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
dataChannel, err := peerConnection.CreateDataChannel("data", nil)
dataChannel.OnOpen(func() {
    dataChannel.SendText("Hello, peer!")
})

Both libraries provide ways to create peer connections and send data, but simple-peer offers a more straightforward API in JavaScript, while webrtc provides a more comprehensive set of features in Go.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Pion WebRTC
Pion WebRTC

A pure Go implementation of the WebRTC API

Pion WebRTC Sourcegraph Widget Slack Widget Twitter Widget
GitHub Workflow Status Go Reference Coverage Status Go Report Card License: MIT


Usage

Go Modules are mandatory for using Pion WebRTC. So make sure you set export GO111MODULE=on, and explicitly specify /v4 (or an earlier version) when importing.

example applications contains code samples of common things people build with Pion WebRTC.

example-webrtc-applications contains more full featured examples that use 3rd party libraries.

awesome-pion contains projects that have used Pion, and serve as real world examples of usage.

GoDoc is an auto generated API reference. All our Public APIs are commented.

FAQ has answers to common questions. If you have a question not covered please ask in Slack we are always looking to expand it.

Now go build something awesome! Here are some ideas to get your creative juices flowing:

  • Send a video file to multiple browser in real time for perfectly synchronized movie watching.
  • Send a webcam on an embedded device to your browser with no additional server required!
  • Securely send data between two servers, without using pub/sub.
  • Record your webcam and do special effects server side.
  • Build a conferencing application that processes audio/video and make decisions off of it.
  • Remotely control a robots and stream its cameras in realtime.

Want to learn more about WebRTC?

Join our Office Hours. Come hang out, ask questions, get help debugging and hear about the cool things being built with WebRTC. We also start every meeting with basic project planning.

Check out WebRTC for the Curious. A book about WebRTC in depth, not just about the APIs. Learn the full details of ICE, SCTP, DTLS, SRTP, and how they work together to make up the WebRTC stack.

This is also a great resource if you are trying to debug. Learn the tools of the trade and how to approach WebRTC issues.

This book is vendor agnostic and will not have any Pion specific information.

Features

PeerConnection API

  • Go implementation of webrtc-pc and webrtc-stats
  • DataChannels
  • Send/Receive audio and video
  • Renegotiation
  • Plan-B and Unified Plan
  • SettingEngine for Pion specific extensions

Connectivity

  • Full ICE Agent
  • ICE Restart
  • Trickle ICE
  • STUN
  • TURN (UDP, TCP, DTLS and TLS)
  • mDNS candidates

DataChannels

  • Ordered/Unordered
  • Lossy/Lossless

Media

Security

  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 and TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA for DTLS v1.2
  • SRTP_AEAD_AES_256_GCM and SRTP_AES128_CM_HMAC_SHA1_80 for SRTP
  • Hardware acceleration available for GCM suites

Pure Go

  • No Cgo usage
  • Wide platform support
    • Windows, macOS, Linux, FreeBSD
    • iOS, Android
    • WASM see examples
    • 386, amd64, arm, mips, ppc64
  • Easy to build Numbers generated on Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
    • Time to build examples/play-from-disk - 0.66s user 0.20s system 306% cpu 0.279 total
    • Time to run entire test suite - 25.60s user 9.40s system 45% cpu 1:16.69 total
  • Tools to measure performance provided

Roadmap

The library is in active development, please refer to the roadmap to track our major milestones. We also maintain a list of Big Ideas these are things we want to build but don't have a clear plan or the resources yet. If you are looking to get involved this is a great place to get started! We would also love to hear your ideas! Even if you can't implement it yourself, it could inspire others.

Sponsoring

Work on Pion's congestion control and bandwidth estimation was funded through the User-Operated Internet fund, a fund established by NLnet made possible by financial support from the PKT Community/The Network Steward and stichting Technology Commons Trust.

Community

Pion has an active community on the Slack.

Follow the Pion Twitter for project updates and important WebRTC news.

We are always looking to support your projects. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible

License

MIT License - see LICENSE for full text