Skip to main content

Pion Interceptor

Pion Interceptor is a framework for building RTP/RTCP communication software. It provides a simple interface for creating interceptors that can inspect, modify, or generate RTP and RTCP packets as they flow through your real-time communication system.

Installation

Get started by installing the Pion Interceptor library in your Go project

Quick Start

Build your first interceptor in minutes with a working example

GitHub Repository

View source code, examples, and contribute to the project

API Reference

Browse the complete API documentation on pkg.go.dev

What is an Interceptor?

An interceptor is a component that sits in the data path of your RTP/RTCP streams. Each interceptor can:
  • Inspect incoming and outgoing packets
  • Modify packet headers and payloads
  • Generate new packets (like RTCP feedback)
  • Store metadata using the Attributes system
Interceptors are chained together sequentially, allowing you to compose complex packet processing pipelines from simple, focused components.

Core Capabilities

RTP Processing

Intercept and modify RTP packets for both local (outgoing) and remote (incoming) streams

RTCP Processing

Process RTCP feedback packets to implement congestion control and quality monitoring

Stream Lifecycle

React to stream creation and removal events to manage per-stream state

Composable

Chain multiple interceptors together to build sophisticated processing pipelines

Built-in Interceptors

Pion Interceptor comes with a rich set of production-ready interceptors:

NACK

Automatic retransmission for lost packets using Negative Acknowledgments

Sender/Receiver Reports

Generate and process RTCP SR/RR packets for quality monitoring

Transport-CC

Transport-wide congestion control feedback for bandwidth estimation

Google Congestion Control

Full GCC implementation with bandwidth estimation and probing

Stats

WebRTC-compliant statistics generation for monitoring

FlexFEC

Forward error correction using the FlexFEC-03 specification

Packet Dump

Debug tool to log all RTP/RTCP packets flowing through the system

Interval PLI

Generate periodic Picture Loss Indication when no decoder is available

Design Philosophy

Pion Interceptor was built with the following principles:
1

Useful Defaults

Each interceptor comes configured to provide a great out-of-the-box experience
2

Unblock Unique Use Cases

The flexible architecture empowers you to build custom solutions for novel applications
3

Encourage Modification

Add your own interceptors without forking, mixing them with built-in ones
4

Empower Learning

The codebase is designed to be readable and educational, even if you’re not using Pion

The Interceptor Interface

All interceptors implement a simple interface with four main method groups:
type Interceptor interface {
    // RTCP packet processing
    BindRTCPReader(reader RTCPReader) RTCPReader
    BindRTCPWriter(writer RTCPWriter) RTCPWriter

    // RTP stream processing
    BindLocalStream(info *StreamInfo, writer RTPWriter) RTPWriter
    BindRemoteStream(info *StreamInfo, reader RTPReader) RTPReader

    // Stream lifecycle
    UnbindLocalStream(info *StreamInfo)
    UnbindRemoteStream(info *StreamInfo)

    // Cleanup
    Close() error
}
You don’t need to implement all methods. Use the NoOp interceptor as an embedded base, then override only the methods you need.

Use Cases

Pion Interceptor is perfect for:
  • Building WebRTC applications with custom packet processing
  • Implementing congestion control algorithms
  • Adding forward error correction
  • Collecting quality metrics and statistics
  • Debugging RTP/RTCP streams
  • Building SFUs (Selective Forwarding Units)
  • Implementing custom retransmission strategies

Built for Pion WebRTC

While Interceptor was originally built for pion/webrtc, it’s designed to be consumable by any Go application that processes RTP/RTCP packets. The library has no hard dependency on the WebRTC stack.

Community and Support

Discord Community

Join the active Pion community for help and discussions

Bluesky

Follow for project updates and WebRTC news
Need commercial support or have a project to build? Contact the Pion team at [email protected]

Next Steps

Install the Library

Add Pion Interceptor to your Go project

Build Your First Interceptor

Follow the quick start guide to create a working example

Build docs developers (and LLMs) love