Red5 + PubNub Integration
Overview
The collaboration between Red5 and PubNub delivers a fully composable real-time technology stack. This partnership combines Red5’s ultra-low latency (sub-250ms) video streaming via the Experience Delivery Network (XDN) with PubNub’s real-time data and chat infrastructure (sub-100ms).
This integration allows developers to build immersive applications where live video and real-time interaction (chat, reactions, metadata) are perfectly synchronized, scalable, and easy to implement.
Key Benefits
- Unified Developer Experience: Access both video and chat credentials directly from the Red5 Cloud dashboard.
- Synchronized Interactivity: Video and data streams operate in parallel, enabling features like “frame-accurate” chat and overlays.
- Cross-Platform Support: Seamless integration across HTML5, iOS, and Android WebRTC SDKs.
Getting Started
Account Creation & Key Provisioning
When a user creates a Red5 Cloud account, the platform automatically provisions a corresponding set of PubNub API keys. This eliminates the need to manage separate accounts for video and chat services during the initial development phase.
Retrieving Your Keys
To access your specific PubNub keysets for integration:
- Log in to your Red5 Cloud Console.
- Navigate to the Dev Resources page in the main dashboard.
- Locate the PubNub Chat Integration section.
- Copy your unique Publish Key and Subscribe Key.
Note: These keys are pre-configured to work with the sample code and SDK integrations provided by Red5.
SDK Integration Guide
Red5’s SDKs (HTML5, iOS, and Android) are designed to work harmoniously with PubNub. While Red5 handles the heavy lifting of audio/video packets via WebRTC/RTMP, PubNub manages the signaling, chat messages, and user presence.
HTML5 SDK Integration
The HTML5 SDK integration involves initializing the Red5 WHIPClient (or RTCSubscriber) for video alongside the PubNub JavaScript SDK for chat.
iOS WebRTC SDK Integration
For iOS development (Swift/Obj-C), the integration follows a similar pattern using the Red5 Pro iOS SDK and the PubNub Swift SDK.
- Video: The
R5Configurationobject configures the stream connection. - Chat: The
PubNubclient is instantiated using the keys from the Red5 resources page. - Sync: It is best practice to use the
streamNameas the PubNub channel name to ensure users watching a specific stream are automatically in the correct chat room.
Red5WebrtcClientBuilder()
.setPubnubPublishKey(config.pubnubPublishKey ?? "")
.setPubnubSubscribeKey(config.pubnubSubscribeKey ?? "")
.setLicenseKey(config.licenseKey ?? "")
.setEventListener(ChatEventListener(chatView: self))
.build()
Android WebRTC SDK Integration
The Android integration utilizes the Red5 Pro Android SDK for the video surface and the PubNub Java/Kotlin SDK for messaging.
- Setup: Add both dependencies to your
build.gradle. - Workflow:
- Start the Red5
R5Streamto publish or subscribe to video. - In the same Activity, initialize the
PubNubinstance. - Use PubNub
Messagesto trigger UI updates overlaid on the Red5SurfaceView.
- Start the Red5
IRed5WebrtcClient webrtcClient = IRed5WebrtcClient.builder()
.setActivity(this)
.setLicenseKey(YOUR_SDK_LICENSE_KEY)
// A unique chat user id.
// If auth is enabled for chat, you must send this userId to your application backend for token generation.
.setChatUserId(USER_ID)
// If chat authentication is enabled, set the token received from your backend server.
// Use Red5 backend SDKs to generate chat tokens: https://github.com/red5pro/red5-bcs-node
// Chat tokens can also be updated after the client is initialized.
// .setChatToken("")
.setPubnubPublishKey(YOUR_PUBNUB_PUBLISH_KEY)
.setPubnubSubscribeKey(YOUR_PUBNUB_SUBSCRIBE_KEY)
.setEventListener(this)
.build();
TrueTime Meetings App
TrueTime Meetings is Red5’s flagship application demonstrating the power of this collaboration. It is a ready-to-deploy conferencing solution that features built-in PubNub integration.
How it Works
Unlike raw SDK implementations where you write the glue code, TrueTime Meetings comes pre-wired:
- Zero-Config Chat: The app automatically uses the PubNub keys associated with your Red5 Cloud account.
- Features:
- Live Chat: Real-time text messaging alongside the video grid.
- Presence: Automatically detects who is “online” in the meeting room.
- Signaling: Uses PubNub to handle meeting logic, such as “raise hand” features or muting participants.
Users simply launch a TrueTime Meeting instance from their Red5 Cloud dashboard, and the chat functionality is immediately active and scalable, backed by PubNub’s global network.