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
      • 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

串流

ArctosLinks.Media 提供了一套 API 來管理與控制串流畫面的渲染操作。

設定串流視圖位置

畫面佈局

串流畫面的佈局由[會議室的更換模板功能](conference.md#切換屏幕佈局_hostswitchscreentemplate)設定,注意僅能在會議進行時,由會議室主持人使用。

功能:設定串流視圖的位置,根據指定的 UIView 和其所屬的 UIViewController 進行配置。操作會啟動視訊串流和揚聲器。

參數:

  • view: 串流視圖所錨定的 UIView。
  • viewController: 管理串流視圖錨定的 UIView 之 UIViewController。

返回值:如果成功設定則完成,若是使用時發生例外狀況,則返回錯誤。

Swift
import ArctosLinks
import UIKit

func activateRenderer() {
    ArctosLinks.Media.setStreaming(on: streamView, in: self)
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    //init UI ...
    lifecycleScope.launch {
        initArctosLinksMediaManager()
    }        
}

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    //init UI ...        
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.updateCameraRotation().getOrThrow()
    }.onFailure {
        Log.d(TAG, "updateCameraRotation: ${it.message}")
    }
    viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {                        
        runCatching {
            ArctosLinks.getInstance(Context).mediaManager.setGlSurfaceView(binding.surfaceView).getOrThrow()
        }.onFailure {
            Log.d(TAG, "setGlSurfaceView Failed ${it.message}: ")
        }

        runCatching {
            ArctosLinks.getInstance(Context).mediaManager.setWhiteBoardView(binding.whiteboard).getOrThrow()
        }.onFailure {
            Log.d(TAG, "setWhiteBoardView Failed ${it.message}: ")
        }
    }
}

private suspend fun initArctosLinksMediaManager() {
    runCatching {
        ArctosLinks.getInstance(Context).mediaManager.initMedia(
            context = Context,
            lifecycleOwner = viewLifecycleOwner
        ).onSuccess {
            Log.d(TAG, "initMedia success")
            runCatching {
                ArctosLinks.getInstance(Context).mediaManager.setGlSurfaceView(binding.surfaceView).getOrThrow()
            }.onFailure {
                Log.d(TAG, "setGlSurfaceView Failed ${it.message}: ")
            }
            runCatching {
                ArctosLinks.getInstance(Context).mediaManager.setWhiteBoardView(binding.whiteboard).getOrThrow()
            }.onFailure {
                Log.d(TAG, "setWhiteBoardView Failed ${it.message}: ")
            }
        }.onFailure {
            Log.d(TAG, "initMedia failed")
        }
    }
}

c++
#include "arctos_qt.h"

void setLayout(int layout_id /*1 - 4*/) {
    auto& arctos_app = arctos::ArctosQt::getInstance();
    arctos_app.media()->setTemplate(layout_id);
}

釋放多媒體資源

功能:停止串流、停止語音播放、停止麥克風收錄聲音、停止相機偵測影像並釋放資源。

返回值:如果成功釋放資源則完成,若是使用時發生例外狀況,則返回錯誤。

Swift
import ArctosLinks

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

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

void releaseMediaSources() {
    arctos_app.media()->stop();
}
Prev
recording