# Remote camera control

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

The Video SDK for Android lets one user request control of another user's camera by panning, tilting, and zooming it remotely. This is useful for remote-assistance, inspection, and remote-monitoring workflows where one participant needs to direct what another participant's camera shows.

The control flow has four steps:

1. **The requester** asks for control of a specific user's camera.
2. **The receiver** approves or declines the request.
3. If approved, **the requester** pans, tilts, or zooms the receiver's camera.
4. **The requester** releases control when done.

Both users must support the PTZ-compatible camera capabilities for the operations to take effect on the receiver's device.

## Request control of a remote camera

Get the remote-control helper from the target `ZoomVideoSDKUser` and call `requestControlRemoteCamera()`.

```kotlin
val helper = targetUser.remoteCameraControlHelper
val result = helper.requestControlRemoteCamera()

// result is ZoomVideoSDKErrors.Errors_Success on success
```

```java
ZoomVideoSDKRemoteCameraControlHelper helper = targetUser.getRemoteCameraControlHelper();
int result = helper.requestControlRemoteCamera();

// result is ZoomVideoSDKErrors.Errors_Success on success
```

The requester is notified of the outcome via the `onCameraControlRequestResult` callback on `ZoomVideoSDKDelegate`.

## Approve or decline an incoming request

When a request arrives on the receiver's side, the `onCameraControlRequestReceived` callback fires with a `ZoomVideoSDKCameraControlRequestHandler`. Show a confirmation UI, then call `approve()` or `decline()` on the handler.

```kotlin
override fun onCameraControlRequestReceived(
    user: ZoomVideoSDKUser?,
    requestType: ZoomVideoSDKCameraControlRequestType?,
    requestHandler: ZoomVideoSDKCameraControlRequestHandler?
) {
    // Display a confirmation dialog to the user, then either:
    requestHandler?.approve()
    // ...or:
    requestHandler?.decline()
}
```

```java
@Override
public void onCameraControlRequestReceived(ZoomVideoSDKUser user,
                                           ZoomVideoSDKCameraControlRequestType requestType,
                                           ZoomVideoSDKCameraControlRequestHandler requestHandler) {
    // Display a confirmation dialog to the user, then either:
    requestHandler.approve();
    // ...or:
    requestHandler.decline();
}
```

Both `approve()` and `decline()` return an `int` status (`ZoomVideoSDKErrors.Errors_Success` on success, otherwise an error code).

## Pan, tilt, and zoom

Once a request is approved, the requester can move the remote camera using `turnLeft`, `turnRight`, `turnUp`, `turnDown`, `zoomIn`, and `zoomOut`. Each method takes a `range` parameter between 10 and 100 that controls how far the camera moves per call.

```kotlin
val helper = targetUser.remoteCameraControlHelper

helper.turnLeft(20)
helper.turnRight(20)
helper.turnUp(20)
helper.turnDown(20)
helper.zoomIn(15)
helper.zoomOut(15)
```

```java
ZoomVideoSDKRemoteCameraControlHelper helper = targetUser.getRemoteCameraControlHelper();

helper.turnLeft(20);
helper.turnRight(20);
helper.turnUp(20);
helper.turnDown(20);
helper.zoomIn(15);
helper.zoomOut(15);
```

Smaller `range` values produce finer movement, which makes UI controls (such as press-and-hold arrow buttons) feel responsive without overshooting the target.

## Give up control

When the requester is finished, call `giveUpControlRemoteCamera()` to release control of the camera.

```kotlin
targetUser.remoteCameraControlHelper.giveUpControlRemoteCamera()
```

```java
targetUser.getRemoteCameraControlHelper().giveUpControlRemoteCamera();
```
