🔍 ✕
Back to Doc

SellyCloud Video

SellyCloud Video provides SDKs for Android, iOS, Web, and PC platforms that work seamlessly with SellyCloud Engine to deliver low-latency audio and video capabilities for your applications.

Overview

SellyCloud Video provides a complete streaming infrastructure that handles encoding, transcoding, and delivery of live and on-demand video content. Built for performance and reliability, it scales from small deployments to global CDN architectures.

Get Started

Choose your platform to start integrating SellyCloud Video SDK into your application. Our SDKs provide easy-to-use APIs for implementing real-time audio and video features.

iOS

Build powerful video applications for iPhone and iPad with our native iOS SDK. Written in Swift and Objective-C, it provides seamless integration with iOS frameworks.

1. Create Session

// Create SellyRTC session // YES for P2P mode (one-on-one call with lower latency) // NO for Room mode (multi-party conference) self.session = [[SellyRTCSession alloc] initWithType:YES]; self.session.delegate = self;

2. Set Local and Remote Canvas

SellyRtcVideoCanvas *local = [SellyRtcVideoCanvas new]; local.view = self.localView; [self.session setLocalCanvas:local]; SellyRtcVideoCanvas *remote = [SellyRtcVideoCanvas new]; remote.view = self.remoteView; remote.userId = @"remoteUserId"; [self.session setRemoteCanvas:remote];

3. Configure Video Parameters (Optional)

SellyRTCVideoConfiguration *config = [SellyRTCVideoConfiguration defaultConfig]; config.width = 720; config.height = 1280; config.frameRate = 24; self.session.videoConfig = config;

4. Start Local Preview

[self.session startPreview]; // Start preview [self.session stopPreview]; // Stop preview when needed

5. Join Channel (Start Call)

[self.session startWithChannelId:@"room_123" token:@"your-token"];

6. End Call

[self.session end];

Android

Develop feature-rich video applications for Android devices with our native Android SDK. Built with Kotlin and Java support for maximum compatibility.

The following example is based on InteractiveLiveActivity in the Demo, showing the minimal integration process.

1. Create InteractiveRtcEngine

Create and configure the RTC engine in your Activity:

private var rtcEngine: InteractiveRtcEngine? = null private var beautyRenderer: FURenderer? = null private var fuFrameInterceptor: FuVideoFrameInterceptor? = null @Volatile private var isFrontCamera = true @Volatile private var beautyEnabled: Boolean = true private fun initRtcEngine() { val appId = getString(R.string.signaling_app_id) val token = getString(R.string.signaling_token).takeIf { it.isNotBlank() } // Optional: Initialize beauty filter beautyRenderer = FURenderer(this).also { it.setup() } fuFrameInterceptor = beautyRenderer?.let { FuVideoFrameInterceptor(it).apply { setFrontCamera(isFrontCamera) setEnabled(beautyEnabled) } } rtcEngine = InteractiveRtcEngine.create( InteractiveRtcEngineConfig( context = applicationContext, appId = appId, defaultToken = token ) ).apply { // Set event handler setEventHandler(rtcEventHandler) // Set client role: Broadcaster/Audience, default is BROADCASTER in Demo setClientRole(InteractiveRtcEngine.ClientRole.BROADCASTER) // Configure video parameters setVideoEncoderConfiguration( InteractiveVideoEncoderConfig( width = 640, height = 480, fps = 20, minBitrateKbps = 150, maxBitrateKbps = 350 ) ) // Default audio route to speakerphone setDefaultAudioRoutetoSpeakerphone(true) // Video frame interceptor for beauty filters setCaptureVideoFrameInterceptor { frame -> if (!beautyEnabled) return@setCaptureVideoFrameInterceptor frame fuFrameInterceptor?.process(frame) ?: frame } } }

Lifecycle Note: Remember to call leaveChannel() and destroy the engine in onDestroy

override fun onDestroy() { super.onDestroy() rtcEngine?.setCaptureVideoFrameInterceptor(null) leaveChannel() InteractiveRtcEngine.destroy(rtcEngine) rtcEngine = null }

2. Setup Local & Remote Video Views

Initialize local and remote rendering views:

private var localRenderer: SurfaceViewRenderer? = null private val remoteRendererMap = mutableMapOf<String, SurfaceViewRenderer>() private fun createRenderer(): SurfaceViewRenderer = SurfaceViewRenderer(this).apply { setZOrderMediaOverlay(false) } // Bind local video val renderer = localRenderer ?: createRenderer().also { localRenderer = it } rtcEngine?.setupLocalVideo(InteractiveVideoCanvas(renderer, localUserId)) // Bind remote video private fun ensureRemoteRenderer(userId: String): SurfaceViewRenderer { return remoteRendererMap[userId] ?: createRenderer().also { renderer -> remoteRendererMap[userId] = renderer rtcEngine?.setupRemoteVideo(InteractiveVideoCanvas(renderer, userId)) } }

3. Configure Video Parameters (Optional)

rtcEngine?.setVideoEncoderConfiguration( InteractiveVideoEncoderConfig( width = 640, height = 480, fps = 20, minBitrateKbps = 150, maxBitrateKbps = 350 ) )

4. Join Channel / Start Call

// Prepare CallType and channel options val options = InteractiveChannelMediaOptions( callType = if (isP2P) CallType.ONE_TO_ONE else CallType.GROUP ) // Call joinChannel rtcEngine?.joinChannel( token = request.token, callId = request.callId, userId = request.userId, options = request.options, tokenSecret = request.tokenSecret, tokenExpiresAtSec = request.tokenExpiresAtSec, tokenTtlSeconds = request.tokenTtlSeconds ) // Success callback override fun onJoinChannelSuccess(channel: String, userId: String, code: Int) { // Successfully joined the channel, update UI state }

5. End Call

private fun leaveChannel() { rtcEngine?.leaveChannel() resetUiAfterLeave() // Clean UI and release renderers } override fun onLeaveChannel(durationSeconds: Int) { // Call duration in seconds }

Video API

Explore our comprehensive Video APIs for each platform. These APIs provide full control over video streaming and real-time communication features.

iOS API

Methods

SellyRTCEngine (Singleton Mode)

Global RTC engine management with singleton pattern.

Method Description
+ (instancetype)sharedEngine Get the singleton instance of the RTC engine
- (void)startUp Engine initialization, must be called once when app starts
Property Type Description
userId NSString Current user ID (must be set before creating Session)
supportSimulcast BOOL Whether to support Simulcast multi-bitrate, default YES
SellyRTCSession (Instance Mode)

RTC session instance for individual calls, created for each call session.

Initialization Method:

Method Parameter Description
- (instancetype)initWithType: BOOL isP2p Initialize a Session instance: YES for one-to-one call, NO for multi-party conference

Call Control:

Method Parameters Description
- (void)startWithChannelId:token: NSString *channelId
NSString *token
Join a call or conference. channelId: channel ID for the call, token: authentication token
- (void)end - End the current call or conference and release all resources
- (void)renewToken: NSString *token Renew authentication token when it's about to expire

Preview Control:

Method Description
- (void)startPreview Start local video preview
- (void)stopPreview Stop local video preview

Audio/Video Control:

Method Parameter Description
- (void)enableLocalVideo: BOOL enable Enable/disable local video capture and publishing, default disabled
- (void)enableLocalAudio: BOOL enable Enable/disable local audio capture and publishing, default enabled
- (void)switchCamera - Switch between front and rear cameras
- (void)muteRemoteAudioStream:mute: NSString *userId
BOOL mute
Mute/unmute a remote user's audio
- (void)setAudioOutput: AVAudioSessionPortOverride Set audio output device (receiver or speaker)

Canvas Setup:

Method Parameter Description
- (void)setLocalCanvas: SellyRtcVideoCanvas *canvas Set local video rendering canvas
- (void)setRemoteCanvas: SellyRtcVideoCanvas *canvas Set remote video rendering canvas. Canvas contains userId to specify remote user

Advanced Features:

Method Parameters Description
- (void)sendMessage:completion: NSString *message
MessageBlock completion
Send custom signaling message within the session
- (void)startScreenCapture - Start screen sharing (requires iOS screen recording support)
- (void)pushExternalVideoFrame: CVPixelBufferRef pixelBuffer Push external video frames, typically for beauty filter processing

Properties:

Property Type Description
delegate id<SellyRTCSessionDelegate> Event callback delegate
videoConfig SellyRTCVideoConfiguration Video encoding parameter configuration
connectionState SellyRTCConnectState Current call connection state (read-only)

Callbacks

Implement the SellyRTCSessionDelegate protocol to receive call event callbacks.

Connection Status Callbacks:

Callback Parameters Description
- (void)rtcSession:didChangeState: SellyRTCSession *session
SellyRTCConnectState state
Connection state change callback
- (void)rtcSession:connectionChangedToState:reason: SellyRTCSession *session
SellyRoomConnectionState state
SellyRoomConnectionReason reason
Detailed room connection state and reason

User Event Callbacks:

Callback Parameters Description
- (void)rtcSession:didJoinedOfUid: SellyRTCSession *session
NSString *userId
Remote user joined the call
- (void)rtcSession:didOfflineOfUid:reason: SellyRTCSession *session
NSString *userId
SellyUserOfflineReason reason
Remote user left the call
- (void)rtcSession:didAudioMuted:byUid: SellyRTCSession *session
BOOL muted
NSString *userId
Remote user's audio mute state changed
- (void)rtcSession:didVideoMuted:byUid: SellyRTCSession *session
BOOL muted
NSString *userId
Remote user's video mute state changed

Data Callbacks:

Callback Parameters Description
- (void)rtcSession:didReceivedMessage:fromUid: SellyRTCSession *session
NSString *message
NSString *userId
Received custom signaling message
- (void)rtcSession:reportRtcStats: SellyRTCSession *session
SellyRtcStats *stats
RTC call quality statistics report (called every 2 seconds)

Video Processing Callbacks:

Callback Parameters Description
- (CVPixelBufferRef)rtcSession:didCaptureVideoPixelBuffer: SellyRTCSession *session
CVPixelBufferRef pixelBuffer
Captured original video frame, can process and return new frame

Token Management Callbacks:

Callback Parameters Description
- (void)rtcSessionTokenPrivilegeWillExpire: SellyRTCSession *session Token is about to expire (30 seconds before expiration), need to renew token
- (void)rtcSessionRequestToken: SellyRTCSession *session Token has expired, need to provide new token immediately

Screen Sharing Callbacks:

Callback Parameters Description
- (void)rtcSession:screenCaptureStateChanged: SellyRTCSession *session
SellyScreenShareState state
Screen sharing state changed

Call Statistics

SellyRtcStats object contains comprehensive RTC call quality statistics.

Basic Information:

Property Type Description
duration NSInteger Call duration in seconds
txKBitRate NSInteger Total send bitrate in Kbps
rxKBitRate NSInteger Total receive bitrate in Kbps
rtt NSInteger Round-trip time in milliseconds
audioProtocol NSString Audio protocol used (e.g., opus)
videoProtocol NSString Video protocol used (e.g., H264, VP8)

Video Send Information:

Property Type Description
txVideoWidth NSInteger Send video width
txVideoHeight NSInteger Send video height
txVideoFps NSInteger Send video frame rate

Video Receive Information:

Property Type Description
rxVideoWidth NSInteger Receive video width
rxVideoHeight NSInteger Receive video height
rxVideoFps NSInteger Receive video frame rate

Audio Bitrate Statistics:

Property Type Description
txAudioKBitRate NSInteger Audio send bitrate in Kbps
rxAudioKBitRate NSInteger Audio receive bitrate in Kbps

Video Bitrate Statistics:

Property Type Description
txVideoKBitRate NSInteger Video send bitrate in Kbps
rxVideoKBitRate NSInteger Video receive bitrate in Kbps

Cumulative Byte Statistics:

Property Type Description
txBytes NSInteger Total bytes sent
rxBytes NSInteger Total bytes received
txAudioBytes NSInteger Audio bytes sent
rxAudioBytes NSInteger Audio bytes received
txVideoBytes NSInteger Video bytes sent
rxVideoBytes NSInteger Video bytes received

Enumerations

SellyRTCConnectState - Connection State:

Value Description
SellyRTCConnectStateDisconnected Disconnected state
SellyRTCConnectStateConnecting Connecting
SellyRTCConnectStateConnected Connected successfully
SellyRTCConnectStateReconnecting Reconnecting
SellyRTCConnectStateFailed Connection failed

SellyRoomConnectionState - Room Connection State:

Value Description
SellyRoomConnectionStateIdle Idle state, not yet joined
SellyRoomConnectionStateConnecting Joining room
SellyRoomConnectionStateConnected Joined successfully
SellyRoomConnectionStateDisconnected Disconnected from room

SellyVideoCodecType - Video Codec Type:

Value Description
SellyVideoCodecTypeH264 H.264 codec
SellyVideoCodecTypeVP8 VP8 codec

SellyRTCVideoResolution - Video Resolution Presets:

Value Resolution
SellyRTCVideoResolution120x120 120×120
SellyRTCVideoResolution180x180 180×180
SellyRTCVideoResolution240x240 240×240
SellyRTCVideoResolution480x480 480×480
SellyRTCVideoResolution640x480 640×480 (VGA)
SellyRTCVideoResolution960x720 960×720
SellyRTCVideoResolution1280x720 1280×720 (720p)
SellyRTCVideoResolution1920x1080 1920×1080 (1080p)

SellyScreenShareState - Screen Sharing State:

Value Description
SellyScreenShareStateIdle Not sharing
SellyScreenShareStateStart Screen sharing started
SellyScreenShareStateStop Screen sharing stopped

Android API

1. Methods

RTC call core engine - InteractiveRtcEngine

Class Methods
Method Parameters Returns Description
create(config) config: InteractiveRtcEngineConfig InteractiveRtcEngine Create RTC engine
destroy(engine) engine: InteractiveRtcEngine? - Destroy RTC engine
Channel Management
Method Parameters Description
joinChannel(...) See joinChannel Parameters table below Join channel
leaveChannel() - Leave channel
renewToken(token) token: String Update Token

joinChannel Parameters:

Parameter Type Description
token String? Authentication Token
callId String Channel ID
userId String User ID
options InteractiveChannelMediaOptions Channel options
tokenSecret String? Token secret (for automatic renewal)
tokenExpiresAtSec Long? Token expiration timestamp
tokenTtlSeconds Long Token validity period (seconds)
Video Control
Method Parameters Description
setupLocalVideo(canvas) canvas: InteractiveVideoCanvas Set local video canvas
setupRemoteVideo(canvas) canvas: InteractiveVideoCanvas Set remote video canvas
clearRemoteVideo(userId) userId: String Clear remote video canvas
enableLocalVideo(enabled) enabled: Boolean Enable/disable local video
switchCamera() - Switch front/rear camera
Audio Control
Method Parameters Description
enableLocalAudio(enabled) enabled: Boolean Enable/disable local audio
setDefaultAudioRoutetoSpeakerphone(speakerOn) speakerOn: Boolean Set audio output route
muteRemoteAudioStream(userId, muted) userId: String, muted: Boolean Mute/unmute remote user
muteRemoteVideoStream(userId, muted) userId: String, muted: Boolean Disable/enable remote video
Role Settings
Method Parameters Description
setClientRole(role) role: ClientRole Set user role
Encoding Configuration
Method Parameters Description
setVideoEncoderConfiguration(config) config: InteractiveVideoEncoderConfig Set video encoding parameters
Message Sending
Method Parameters Description
sendMessage(message, callback) message: String, callback: (Error?) -> Unit Send custom message
Screen Sharing
Method Parameters Returns Description
startScreenShare(resultCode, data, width, height, fps) resultCode: Int, data: Intent, width: Int, height: Int, fps: Int Boolean Start screen sharing
stopScreenShare() - Boolean Stop screen sharing
Beauty Filter/Video Processing
Method Parameters Description
setCaptureVideoFrameInterceptor(interceptor) interceptor: (VideoFrame) -> VideoFrame? Set video frame interceptor
Event Callbacks
Method Parameters Description
setEventHandler(handler) handler: InteractiveRtcEngineEventHandler Set event callback
Configuration Objects

InteractiveRtcEngineConfig: RTC engine initialization configuration

Property Type Description
context Context Application context
appId String Application ID
defaultToken String? Default Token

InteractiveVideoEncoderConfig: Video encoding parameter configuration

Property Type Default Description
width Int 640 Video width
height Int 480 Video height
fps Int 20 Frame rate
minBitrateKbps Int 150 Minimum bitrate (Kbps)
maxBitrateKbps Int 850 Maximum bitrate (Kbps)

InteractiveVideoCanvas: Video rendering canvas configuration

Property Type Description
renderer SurfaceViewRenderer Video rendering view
userId String User ID

InteractiveChannelMediaOptions: Channel media options configuration

Property Type Description
callType CallType Call type
Next: Technical Specifications →
Last updated 2 months ago