Broadcasting Setup & Configuration
This guide covers advanced broadcasting configuration, quality optimization, and professional streaming features across all platforms.
Overview
The broadcasting system handles:
- Camera and microphone management
- Video encoding and compression
- Quality adaptation and optimization
- Network transmission and monitoring
Broadcasting Setup
Video Quality & Resolution
The social.plus Video SDK supports three standard resolutions optimized for mobile streaming:
| Resolution | Dimensions | Bitrate | Aspect Ratio | Use Case |
|---|
| SD_480P | 480×854 | 1216 kbps | 9:16 | Mobile data, limited bandwidth |
| HD_720P | 720×1280 | 2496 kbps | 9:16 | Balanced quality and performance |
| FHD_1080P | 1080×1920 | 4992 kbps | 9:16 | High-quality streaming |
All video streaming uses a 16:9 aspect ratio optimized for mobile viewing. The SDK automatically handles encoding and compression for optimal streaming performance.
Broadcasting Controls
Camera Preview
Start the camera preview before going live to let users see what will be broadcast:
Start Broadcasting
Begin live streaming with title and description:
Stop Broadcasting
End the live stream session:
Camera Controls
Switch between front and back cameras during streaming:
Broadcasting State Management
Monitor and respond to broadcasting state changes across all platforms:
State Types
All platforms support these broadcasting states:
| State | Description | Next Actions |
|---|
| Idle | Ready to broadcast, no active session | Start broadcasting |
| Connecting | Establishing connection to streaming server | Show loading indicator |
| Connected | Successfully streaming live | Show live indicator |
| Disconnected | Connection lost or stream ended | Handle reconnection or cleanup |
State Observation
Required Permissions
Before broadcasting, ensure your app has the necessary permissions for camera and microphone access:
Error Handling & Recovery
Implement comprehensive error handling for broadcasting scenarios:
Common Broadcasting Errors
Connection Recovery
Implement automatic reconnection for network interruptions:
// Android reconnection logic
class ConnectionManager {
private var reconnectAttempts = 0
private val maxReconnectAttempts = 3
fun handleDisconnection() {
if (reconnectAttempts < maxReconnectAttempts) {
reconnectAttempts++
// Wait before reconnecting (exponential backoff)
val delay = (reconnectAttempts * 2000L) // 2s, 4s, 6s
Handler(Looper.getMainLooper()).postDelayed({
attemptReconnection()
}, delay)
} else {
// Max attempts reached, stop broadcast
showError("Unable to maintain connection. Stream ended.")
broadcaster.stopPublish()
}
}
private fun attemptReconnection() {
broadcaster.reconnect()
.subscribe({
// Reconnection successful
reconnectAttempts = 0
showMessage("Reconnected successfully")
}, { error ->
handleDisconnection() // Try again or give up
})
}
}
Important: Always handle permissions before attempting to start broadcasting. Users must explicitly grant camera and microphone access for live streaming to work.
Performance Tip: Monitor device temperature during long broadcasting sessions. Reduce video quality or suggest breaks if the device gets too hot.
Audio Configuration
Audio Quality Settings
Advanced Broadcasting Features
Adaptive Bitrate Streaming
Automatically adjust quality based on network conditions:
Connection Management
Handle network interruptions and reconnections:
Resource Management
class BroadcastResourceManager {
fun optimizeForBattery() {
// Reduce frame rate for battery saving
broadcaster.setFrameRate(24) // Lower than default 30fps
// Use lower bitrate
broadcaster.setBitrate(1800) // Reduced from default
// Disable unnecessary features
broadcaster.setHardwareAccelerationEnabled(false)
}
fun optimizeForQuality() {
// Maximum quality settings
broadcaster.setFrameRate(30)
broadcaster.setBitrate(4992) // 1080p bitrate
broadcaster.setHardwareAccelerationEnabled(true)
}
fun monitorTemperature() {
// Monitor device temperature (Android-specific)
val thermalManager = getSystemService(THERMAL_SERVICE) as ThermalManager
thermalManager.addThermalStatusListener { status ->
when (status) {
ThermalManager.THERMAL_STATUS_CRITICAL -> {
// Reduce quality to prevent overheating
optimizeForBattery()
showWarning("Device overheating - reducing quality")
}
}
}
}
}
Error Handling & Recovery
Comprehensive Error Handling
class BroadcastErrorHandler {
fun handleBroadcastErrors() {
broadcaster.errorFlowable
.subscribe { error ->
when (error) {
is CameraException -> handleCameraError(error)
is NetworkException -> handleNetworkError(error)
is EncodingException -> handleEncodingError(error)
is AuthenticationException -> handleAuthError(error)
else -> handleGenericError(error)
}
}
}
private fun handleCameraError(error: CameraException) {
when (error.reason) {
CameraException.REASON_PERMISSION_DENIED -> {
showError("Camera permission required")
requestCameraPermission()
}
CameraException.REASON_CAMERA_IN_USE -> {
showError("Camera is being used by another app")
suggestCameraRelease()
}
}
}
private fun handleNetworkError(error: NetworkException) {
when (error.type) {
NetworkException.TYPE_CONNECTION_TIMEOUT -> {
showError("Connection timeout - check your internet")
attemptReconnect()
}
NetworkException.TYPE_INSUFFICIENT_BANDWIDTH -> {
showWarning("Slow connection - reducing quality")
reduceBitrate()
}
}
}
private fun handleEncodingError(error: EncodingException) {
Log.e("Encoding", "Hardware encoding failed, falling back to software")
broadcaster.setHardwareAccelerationEnabled(false)
restartBroadcast()
}
}
Testing & Validation
Broadcasting Tests
class BroadcastTests {
fun testCameraInitialization() {
// Test camera access and initialization
assertTrue("Camera should initialize", broadcaster.isCameraReady())
// Test camera switching
broadcaster.switchCamera()
assertEquals("Camera should switch", CameraFacing.FRONT, broadcaster.currentCamera)
}
fun testBroadcastLifecycle() {
// Test complete broadcast lifecycle
broadcaster.startPreview()
assertTrue("Preview should start", broadcaster.isPreviewActive())
broadcaster.startBroadcast("test-stream-id")
// Wait for connection
Thread.sleep(5000)
assertTrue("Broadcast should be live", broadcaster.isLive())
broadcaster.stopBroadcast()
assertFalse("Broadcast should stop", broadcaster.isLive())
}
fun testErrorRecovery() {
// Simulate network failure
NetworkSimulator.simulateDisconnection()
// Verify automatic reconnection
Thread.sleep(10000)
assertTrue("Should reconnect automatically", broadcaster.isConnected())
}
}
Next Steps
With broadcasting configured:
- Camera Controls - Advanced camera management
- Advanced Features - Filters, effects, and customization
- Playback Setup - Configure stream viewing
- Push Notifications - Stream event notifications
For platform-specific optimizations, see: