IEnumerator StartVideo() { if (WebCamTexture.devices.Length == 0) { Debug.LogFormat("WebCam device not found"); yield break; } yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); if (!Application.HasUserAuthorization(UserAuthorization.WebCam)) { Debug.LogFormat("authorization for using the device is denied"); yield break; } WebCamDevice userCameraDevice = WebCamTexture.devices[deviceIndex]; m_webCamTexture = new WebCamTexture(userCameraDevice.name, streamingSize.x, streamingSize.y); m_webCamTexture.Play(); yield return(new WaitUntil(() => m_webCamTexture.didUpdateThisFrame)); m_track = new VideoStreamTrack(gameObject.name, m_webCamTexture); RenderStreaming.Instance?.AddVideoStreamTrack(m_track); OnEnableComplete?.Invoke(); }
void OnEnable() { // todo(kazuki): remove bitrate parameter because it is not supported m_track = m_camera.CaptureStreamTrack(streamingSize.x, streamingSize.y, 1000000); RenderStreaming.Instance?.AddVideoStreamTrack(m_track); OnEnableComplete?.Invoke(); }