arctos-SDK For developsarctos-SDK For develops
Home
Okuma
arctos
Contact
  • English
  • 繁體中文
Home
Okuma
arctos
Contact
  • English
  • 繁體中文
  • Guide

    • get-started
  • Spec

    • Peer to Peer Direct
    • Relay based
  • Api

    • Overview
    • Auth
    • Task
    • Business
    • Room
  • Peer to Peer Direct

    • overview
    • installization
    • features

      • initial_setting
      • room
      • camera
        • Set Resolution
        • Get Resolution
        • Enable Camera
        • Disable Camera
        • Switch Lens
        • Lock Camera Auto Rotate
        • Unlock Camera Auto Rotate
        • Enable Camera Zoom In
        • Disable Camera Zoom In
        • Types
      • conference
      • microphone
      • speaker
      • share_screen
      • paint_board
      • recording
      • layout
  • Relay based

    • overview
    • installization
    • features

      • initial_setting
      • camera
      • microphone
      • speaker
      • share_screen
      • paint_board
      • share_message
      • switch_template
      • video_filters

Camera

ArctosLinks.Media provides a set of APIs to manage and control various operations of the camera lens. These functions include enabling and disabling the lens, switching between front and rear lenses, setting resolution, enabling and disabling automatic lens rotation, etc.

Set Resolution

Function: Set the camera resolution.

Parameters:

  • resolution: The desired resolution to set, of type Resolution.

Return Value: The set resolution. If the device cannot use the desired resolution, the closest resolution will be used, and a warning will be displayed. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
func setCameraResolution(to resolution: ArctosLinks.Media.Resolution = .FHD) {
    ArctosLinks.Media.setCameraResolution(to: resolution) { result in
        switch result {
        case .success(let resolution, let warning):
            dump(resolution, name: "CameraResolution")
            if let warning { 
                print(warning)
            }
        case .failure(let error):
            print(error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun setCameraResolution(cameraResolution: CameraResolution) {
    lifecycleScope.launch {
        runCatching {
            ArctosLinks.getInstance(Context).mediaManager.setCameraResolution(
                cameraResolution
            ).getOrThrow()
        }.onSuccess {
            Log.d(TAG, "set camera resolution : $it")                
        }.onFailure {
            Log.d(TAG, "set camera resolution: Failed ${it.message}")
        }
    }
}
c++
#include arctos_qt.h

void setCameraResolution(arctos::Resolution resolution) {
    auto& arctos_app = arctos::ArctosQt::getInstance();
    const auto result = arctos_app.media()->setCameraResolution(resolution);
    if (!result) {
        LOG(ERROR) << result.error();
    }
}

Get Resolution

Function: Get the current camera resolution.

Return Value: The current Resolution. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
func getCameraResolution() {
    ArctosLinks.Media.getCameraResolution { result in
        switch result {
        case .success(let resolution):
            dump(resolution)
        case .failure(let error):
            print(error.localizedDescription)
        }
    }
}

Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun getCameraResolution() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.getCameraResolution()
            .getOrThrow()
    }.onSuccess {
        Log.d(TAG, "getCameraResolution: $it")
    }.onFailure {
        Log.d(TAG, "getCameraResolution: Failed ${it.message}")
    }
}

c++
#include "arctos_qt.h"

arctos::Resolution getCameraResolution() {
    auto& arctos_app = arctos::ArctosQt::getInstance();
    const auto result = arctos_app.media()->cameraResolution();
    if (!result) {
        LOG(ERROR) << result.error();
    }
    return *result;
}

Enable Camera

Function: Enable the camera and display it on the screen.

Return Value: If successfully enabled, complete. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
import AVFoundation

func enableCamera() {
    guard AVCaptureDevice.authorizationStatus(for: .video) == .authorized else { return }

    do {
        try ArctosLinks.Media.enableCamera { result in
            switch result {
            case .success():
                print("Successfully enabled the camera.")
            case .failure(let error):
                print("Failed to enable the camera: \(error.localizedDescription).")
            }
        }
    } catch {
        print(error.localizedDescription)
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun enableCamera() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.enableCamera().getOrThrow()
    }.onFailure {
        Log.d(TAG, "enableCamera: Failed ${it.message}")
    }
}
c++
#include "arctos_qt.h"

void enableCamera() {
    auto& arctos_app = arctos::ArctosQt::getInstance();
    const auto result = arctos_app.media()->enableCamera();
    if (!result) {
        LOG(ERROR) << result.error();
    }
}

Disable Camera

Function: Disable the camera, the screen will display black.

Return Value: If successfully disabled, complete. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
func disableCamera() {
    ArctosLinks.Media.disableCamera()
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun disableCamera() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.disableCamera().getOrThrow()
    }.onFailure {
        Log.d(TAG, "disableCamera: Failed ${it.message}")
    }
}
c++
#include "arctos_qt.h"

void disableCamera() {
    auto& arctos_app = arctos::ArctosQt::getInstance();
    const auto result = arctos_app.media()->disableCamera();
    if (!result) {
        LOG(ERROR) << result.error();
    }
}

Switch Lens

Function: Switch between front and rear lenses.

Return Value: If successfully switched, complete. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
func switchLens() {
    do {
        try ArctosLinks.Media.switchLens()
    } catch {
        print(error.localizedDescription)
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun switchLens() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.switchLens().getOrThrow()
    }.onFailure {
        Log.d(TAG, "switchLens: Failed ${it.message}")
    }
}

Lock Camera Auto Rotate

Function: Lock the camera auto-rotate function. When locked, the camera will not change the lens output direction based on the device's orientation.

Return Value:

Swift
import ArctosLinks
    
private func lockCameraAutoRotate() {
    ArctosLinks.Media.lockCameraAutoRotate { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            print(error.localizedDescription)
        }
    }
}

Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun lockCameraAutoRotate() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.lockCameraAutoRotate()
            .getOrThrow()
    }.onFailure {
        Log.d(TAG, "lockCameraAutoRotate: Failed ${it.message}")
    }
}

Unlock Camera Auto Rotate

Function: Disable the lock on the camera auto-rotate function.

Return Value:

Swift
import ArctosLinks
    
private func unlockCameraAutoRotate() {
    ArctosLinks.Media.unlockCameraAutoRotate { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            print(error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun unlockCameraAutoRotate() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.unlockCameraAutoRotate()
            .getOrThrow()
    }.onFailure {
        Log.d(TAG, "unlockCameraAutoRotate: Failed ${it.message}")
    }
}

Enable Camera Zoom In

Function: Set the camera lens to zoom in to 2x magnification.

Return Value: If successfully set, complete. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
private func enableCameraZoomIn() {
    ArctosLinks.Media.enableCameraZoomIn { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            displayNotification(title: "🚨 Process ERROR", body: error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun enableCameraZoomIn() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.enableCameraZoomIn()
            .getOrThrow()
    }.onFailure {
        Log.d(TAG, "enableCameraZoomIn: Failed ${it.message}")
    }
}

Disable Camera Zoom In

Function: Reset the camera lens to the original magnification.

Return Value: If successfully reset, complete. If an exception occurs during use, an error will be returned.

Swift
import ArctosLinks
    
private func disableCameraZoomIn() {
    ArctosLinks.Media.disableCameraZoomIn { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            displayNotification(title: "🚨 Process ERROR", body: error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

private fun disableCameraZoomIn() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.disableCameraZoomIn()
            .getOrThrow()
    }.onFailure {
        Log.d(TAG, "disableCameraZoomIn: Failed ${it.message}")
    }
}

Types

Resolution

Function: Used to enumerate the resolutions that can be selected when changing the resolution.

Members:

  • FHD: 1080p, 1920*1080.
  • HD: 720p, 1280*720.
  • VGA: 480p, 640*480.
Swift
/// The camera resolution
public enum Resolution : String, CaseIterable {
    case FHD
    case HD
    case VGA
}
Kotlin
enum class CameraResolution() {
    RESOLUTION_FULL_HD,
    RESOLUTION_HD,
    RESOLUTION_VGA
}
c++
enum class Resolution {
    kFHD,
    kHD,
    kVGA,
};

Prev
room
Next
conference