Skip to main content

What Problem Does This Solve?

Recording and streaming have different requirements. Recording prioritizes quality and file size—you want high bitrate, 60fps, large files you’ll upload later. Streaming prioritizes bandwidth and latency—lower bitrate, 30fps, smaller data sent live. LckCaptureType lets you switch between these modes, which automatically applies the appropriate track descriptor from your quality options (recording vs. streaming settings).

When to Use This

Use LckCaptureType when:
  • Your app supports both recording and streaming
  • You want different quality settings for each mode
  • Users can toggle between “Record for upload” vs. “Stream live”
  • You need to optimize for bandwidth (streaming) vs. quality (recording)
Skip this if you only support one mode.

Quick Example

// Switch to streaming mode (applies streaming track descriptor)
var result = lckService.SetActiveCaptureType(LckCaptureType.Streaming);
if (!result.IsOk)
{
    Debug.LogError($"Failed to set capture type: {result.Message}");
}

// Later, switch back to recording
lckService.SetActiveCaptureType(LckCaptureType.Recording);

// Check current mode
var currentType = lckService.GetActiveCaptureType();
Debug.Log($"Current mode: {currentType.Result}");

How It Works

When you define a QualityOption, you specify two track descriptors:
var qualityOption = new QualityOption(
    name: "High",
    isDefault: true,
    cameraTrackDescriptor: new CameraTrackDescriptor(
        new CameraResolutionDescriptor(1920, 1080),
        bitrate: 10 << 20,  // 10 Mbps for recording
        framerate: 60
    ),
    streamingCameraTrackDescriptor: new CameraTrackDescriptor(
        new CameraResolutionDescriptor(1920, 1080),
        bitrate: 5 << 20,   // 5 Mbps for streaming
        framerate: 30
    )
);
When you set the capture type:
  • LckCaptureType.Recording → uses cameraTrackDescriptor
  • LckCaptureType.Streaming → uses streamingCameraTrackDescriptor
The SDK automatically applies the right settings.

Common Patterns

Toggle between modes with UI

public class CaptureTypeToggle : MonoBehaviour
{
    public void OnRecordingToggleChanged(bool isRecording)
    {
        var captureType = isRecording 
            ? LckCaptureType.Recording 
            : LckCaptureType.Streaming;
        
        var result = lckService.SetActiveCaptureType(captureType);
        
        if (!result.IsOk)
        {
            Debug.LogError($"Failed to switch mode: {result.Message}");
            return;
        }
        
        UpdateUI(captureType);
    }
    
    void UpdateUI(LckCaptureType type)
    {
        string mode = type == LckCaptureType.Recording ? "Recording" : "Streaming";
        modeLabel.text = $"Mode: {mode}";
    }
}

Auto-select based on network

void Start()
{
    // Use streaming if network available, recording otherwise
    bool hasNetwork = Application.internetReachability != NetworkReachability.NotReachable;
    
    var captureType = hasNetwork 
        ? LckCaptureType.Streaming 
        : LckCaptureType.Recording;
    
    lckService.SetActiveCaptureType(captureType);
    
    Debug.Log($"Selected {captureType} mode (network: {hasNetwork})");
}

Initialize to default mode

void InitializeLCK()
{
    // ... LckCore.Initialize() ...
    
    // Default to recording mode
    var result = lckService.SetActiveCaptureType(LckCaptureType.Recording);
    
    if (!result.IsOk)
    {
        Debug.LogError($"Failed to set default capture type: {result.Message}");
    }
}

Typical Settings by Mode

Recording Mode

Optimized for quality and upload:
  • Higher bitrate (8-12 Mbps) for better quality
  • Higher framerate (60 fps) for smooth motion
  • Larger file sizes acceptable
// Recording track example
new CameraTrackDescriptor(
    new CameraResolutionDescriptor(1920, 1080),
    bitrate: 10 << 20,     // 10 Mbps
    framerate: 60,
    audioBitrate: 256000   // 256 kbps
)

Streaming Mode

Optimized for bandwidth and latency:
  • Lower bitrate (3-5 Mbps) to reduce bandwidth
  • Standard framerate (30 fps) for stability
  • Smaller data packets for real-time delivery
// Streaming track example
new CameraTrackDescriptor(
    new CameraResolutionDescriptor(1920, 1080),
    bitrate: 5 << 20,      // 5 Mbps
    framerate: 30,
    audioBitrate: 192000   // 192 kbps
)

Enum Values

ValueDescriptionUse Case
RecordingLocal recording modeSave to device, upload later, prioritize quality
StreamingLive streaming modeReal-time delivery, prioritize bandwidth efficiency

API Reference

Set Capture Type

LckResult SetActiveCaptureType(LckCaptureType captureType)
Parameters:
  • captureTypeRecording or Streaming
Returns: LckResult indicating success/failure

Get Capture Type

LckResult<LckCaptureType> GetActiveCaptureType()
Returns: LckResult containing current capture type

When to Switch Modes

Before starting capture — Don’t change during active recording
Based on user preference — UI toggle for “Record” vs. “Stream”
Network availability — Auto-select streaming if online
Cannot change during recording — Returns CantEditSettingsWhileRecording error

Best Practices

// Good: Check before switching
var currentType = lckService.GetActiveCaptureType();
if (currentType.Result != desiredType)
{
    var result = lckService.SetActiveCaptureType(desiredType);
    if (!result.IsOk)
    {
        Debug.LogError($"Mode switch failed: {result.Message}");
    }
}

// Bad: Switching during recording (will fail)
lckService.StartRecording();
lckService.SetActiveCaptureType(LckCaptureType.Streaming); // ERROR
Define both tracks — Always configure recording and streaming in QualityOption
Test both modes — Ensure settings work for both use cases
Stop before switching — Don’t change modes during active recording