> ## Documentation Index
> Fetch the complete documentation index at: https://docs.liv.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# ILckService

> API reference for the ILckService interface in the LIV Camera Kit (LCK) Unity SDK, defining the public API for controlling capture, recording, streaming, audio, camera management, and lifecycle events.

## Description

`ILckService` defines the contract for interacting with the capture system. It exposes events for lifecycle notifications (recording, streaming, saving, etc.), and methods for managing capture sessions, configuring video/audio parameters, and controlling cameras and audio.

***

## Usage

Retrieve an `ILckService` instance through dependency injection or the DI container:

```csharp theme={null}
[InjectLck] private ILckService _lckService;
```

### Example: Start a Recording

```csharp theme={null}
_lckService.OnRecordingStarted += result =>
{
    if (result.Success)
        Debug.Log("Recording started successfully!");
    else
        Debug.LogError($"Failed to start recording: {result.ErrorMessage}");
};

var startResult = _lckService.StartRecording();
if (!startResult.Success)
    Debug.LogError($"Error: {startResult.ErrorMessage}");
```

### Example: Switch Capture Settings

```csharp theme={null}
// Change resolution before capturing
var resolution = new CameraResolutionDescriptor(1920, 1080);
var result = _lckService.SetTrackResolution(resolution);

if (!result.Success)
    Debug.LogError($"Failed to set resolution: {result.ErrorMessage}");
```

### Example: Control Audio

```csharp theme={null}
// Enable microphone capture
_lckService.SetMicrophoneCaptureActive(true);

// Adjust microphone gain
_lckService.SetMicrophoneGain(1.5f);

// Check microphone level
var micLevel = _lckService.GetMicrophoneOutputLevel();
Debug.Log($"Mic Output Level: {micLevel.Result}");
```

***

## Events

| Event              | Type                                                                   | Description                              |
| :----------------- | :--------------------------------------------------------------------- | :--------------------------------------- |
| OnRecordingStarted | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when recording starts.           |
| OnRecordingPaused  | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when recording is paused.        |
| OnRecordingResumed | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when recording resumes.          |
| OnRecordingStopped | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when recording stops.            |
| OnStreamingStarted | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when streaming starts.           |
| OnStreamingStopped | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when streaming stops.            |
| OnLowStorageSpace  | Action\<[`LckResult`](/api-reference/unity/LckResult)>                 | Invoked when low storage is detected.    |
| OnRecordingSaved   | Action\<[`LckResult`](/api-reference/unity/LckResult)\<RecordingData>> | Invoked when a recording has been saved. |

***

## Methods

| Method                                                    | Returns                                                                                               | Description                                         |
| :-------------------------------------------------------- | :---------------------------------------------------------------------------------------------------- | :-------------------------------------------------- |
| GetRecordingDuration()                                    | [`LckResult`](/api-reference/unity/LckResult)\<TimeSpan>                                              | Gets the duration of the current recording.         |
| GetStreamDuration()                                       | [`LckResult`](/api-reference/unity/LckResult)\<TimeSpan>                                              | Gets the duration of the current stream.            |
| StartRecording()                                          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Starts recording.                                   |
| PauseRecording()                                          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Pauses recording.                                   |
| ResumeRecording()                                         | [`LckResult`](/api-reference/unity/LckResult)                                                         | Resumes recording.                                  |
| StopRecording()                                           | [`LckResult`](/api-reference/unity/LckResult)                                                         | Stops recording.                                    |
| StartStreaming()                                          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Starts streaming.                                   |
| StopStreaming()                                           | [`LckResult`](/api-reference/unity/LckResult)                                                         | Stops streaming.                                    |
| SetTrackFramerate(uint)                                   | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the capture framerate.                         |
| SetTrackDescriptor(CameraTrackDescriptor)                 | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the track descriptor for capture.              |
| SetTrackDescriptor(LckCaptureType, CameraTrackDescriptor) | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the track descriptor for a given capture type. |
| SetTrackResolution(CameraResolutionDescriptor)            | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the capture resolution.                        |
| SetTrackBitrate(uint)                                     | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the video bitrate.                             |
| SetTrackAudioBitrate(uint)                                | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the audio bitrate.                             |
| SetCameraOrientation(LckCameraOrientation)                | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the camera orientation.                        |
| GetActiveCaptureType()                                    | [`LckResult`](/api-reference/unity/LckResult)\<LckCaptureType>                                        | Gets the currently active capture type.             |
| SetActiveCaptureType(LckCaptureType)                      | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the active capture type.                       |
| SetPreviewActive(bool)                                    | [`LckResult`](/api-reference/unity/LckResult)                                                         | Enables or disables preview rendering.              |
| IsRecording()                                             | [`LckResult`](/api-reference/unity/LckResult)\<bool>                                                  | Returns whether recording is active.                |
| IsStreaming()                                             | [`LckResult`](/api-reference/unity/LckResult)\<bool>                                                  | Returns whether streaming is active.                |
| IsCapturing()                                             | [`LckResult`](/api-reference/unity/LckResult)\<bool>                                                  | Returns whether capture is active.                  |
| SetGameAudioCaptureActive(bool)                           | [`LckResult`](/api-reference/unity/LckResult)                                                         | Enables/disables game audio capture.                |
| SetMicrophoneCaptureActive(bool)                          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Enables/disables microphone capture.                |
| GetMicrophoneOutputLevel()                                | [`LckResult`](/api-reference/unity/LckResult)\<float>                                                 | Gets the current microphone output level.           |
| SetMicrophoneGain(float)                                  | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets microphone gain.                               |
| SetGameAudioGain(float)                                   | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets game audio gain.                               |
| GetGameOutputLevel()                                      | [`LckResult`](/api-reference/unity/LckResult)\<float>                                                 | Gets the current game audio output level.           |
| IsGameAudioMute()                                         | [`LckResult`](/api-reference/unity/LckResult)\<bool>                                                  | Returns whether game audio is muted.                |
| SetActiveCamera(string, string monitorId = null)          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Sets the active camera (and optional monitor).      |
| PreloadDiscreetAudio(AudioClip, float, bool)              | [`LckResult`](/api-reference/unity/LckResult)                                                         | Preloads an audio clip for discreet playback.       |
| PlayDiscreetAudioClip(AudioClip)                          | [`LckResult`](/api-reference/unity/LckResult)                                                         | Plays a discreet audio clip.                        |
| StopAllDiscreetAudio()                                    | [`LckResult`](/api-reference/unity/LckResult)                                                         | Stops all discreet audio playback.                  |
| GetDescriptor()                                           | [`LckResult`](/api-reference/unity/LckResult)\<[`LckDescriptor`](/api-reference/unity/LckDescriptor)> | Gets the current descriptor.                        |
| CapturePhoto()                                            | [`LckResult`](/api-reference/unity/LckResult)                                                         | Captures a photo.                                   |
| Dispose()                                                 | void                                                                                                  | Cleans up and disposes the service.                 |
