diff --git a/CHANGES.md b/CHANGES.md index b7d04f2..ed676de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,9 @@ ## develop -- [ADD] ハードウェアエンコーダを利用するかどうかを設定する `UseHardwareEncoder` オプションを追加 +- [ADD] デバイスを掴まないようにする `NoVideoDevice`, `NoAudioDevice` を追加 + - @melpon +- [ADD] ハードウェアエンコーダを利用するかどうかを設定する `UseHardwareEncoder` を追加 - @melpon - [UPDATE] SoraClientContext を利用してコードを短くする - @melpon diff --git a/Sora/Sora.cs b/Sora/Sora.cs index e90ab1f..669197e 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -100,6 +100,8 @@ public class Config public SpotlightFocusRidType? SpotlightUnfocusRid; public bool? Simulcast; public SimulcastRidType? SimulcastRid = null; + public bool NoVideoDevice = false; + public bool NoAudioDevice = false; public CapturerType CapturerType = Sora.CapturerType.DeviceCamera; public UnityEngine.Camera UnityCamera = null; public int UnityCameraRenderTargetDepthBuffer = 16; @@ -282,6 +284,8 @@ public void Connect(Config config) cc.simulcast = config.Simulcast.GetValueOrDefault(); cc.simulcast_rid = config.SimulcastRid == null ? "" : config.SimulcastRid.Value.ToString().ToLower(); cc.insecure = config.Insecure; + cc.no_video_device = config.NoVideoDevice; + cc.no_audio_device = config.NoAudioDevice; cc.capturer_type = (int)config.CapturerType; cc.unity_camera_texture = unityCameraTexture.ToInt64(); cc.video = config.Video; diff --git a/proto/sora_conf_internal.proto b/proto/sora_conf_internal.proto index 59c69d4..4cc1120 100644 --- a/proto/sora_conf_internal.proto +++ b/proto/sora_conf_internal.proto @@ -54,6 +54,8 @@ message ConnectConfig { bool enable_simulcast = 14; bool simulcast = 15; string simulcast_rid = 16; + bool no_video_device = 160; + bool no_audio_device = 161; int32 capturer_type = 17; int64 unity_camera_texture = 18; string video_capturer_device = 19; diff --git a/src/sora.cpp b/src/sora.cpp index 207f797..1621341 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -209,10 +209,10 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, #endif unity_adm_ = CreateADM( - media_dependencies.task_queue_factory, false, cc.unity_audio_input, - cc.unity_audio_output, on_handle_audio_, cc.audio_recording_device, - cc.audio_playout_device, dependencies.worker_thread, worker_env, - worker_context); + media_dependencies.task_queue_factory, cc.no_audio_device, + cc.unity_audio_input, cc.unity_audio_output, on_handle_audio_, + cc.audio_recording_device, cc.audio_playout_device, + dependencies.worker_thread, worker_env, worker_context); media_dependencies.adm = unity_adm_; #if defined(SORA_UNITY_SDK_ANDROID) @@ -279,11 +279,11 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, } auto capturer = CreateVideoCapturer( - cc.capturer_type, (void*)cc.unity_camera_texture, + cc.capturer_type, (void*)cc.unity_camera_texture, cc.no_video_device, cc.video_capturer_device, cc.video_width, cc.video_height, cc.video_fps, on_frame, sora_context_->signaling_thread(), env, android_context, unity_context_); - if (!capturer) { + if (!cc.no_video_device && !capturer) { on_disconnect((int)sora_conf::ErrorCode::INTERNAL_ERROR, "Capturer Init Failed"); return; @@ -297,9 +297,12 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, audio_track_id, sora_context_->peer_connection_factory() ->CreateAudioSource(cricket::AudioOptions()) .get()); - std::string video_track_id = rtc::CreateRandomString(16); - video_track_ = sora_context_->peer_connection_factory()->CreateVideoTrack( - video_track_id, capturer.get()); + + if (capturer) { + std::string video_track_id = rtc::CreateRandomString(16); + video_track_ = sora_context_->peer_connection_factory()->CreateVideoTrack( + video_track_id, capturer.get()); + } } { @@ -627,6 +630,7 @@ bool Sora::InitADM(rtc::scoped_refptr adm, rtc::scoped_refptr Sora::CreateVideoCapturer( int capturer_type, void* unity_camera_texture, + bool no_video_device, std::string video_capturer_device, int video_width, int video_height, @@ -637,6 +641,10 @@ rtc::scoped_refptr Sora::CreateVideoCapturer( void* android_context, UnityContext* unity_context) { if (capturer_type == 0) { + if (no_video_device) { + return nullptr; + } + // 実カメラ(デバイス)を使う sora::CameraDeviceCapturerConfig config; config.width = video_width; diff --git a/src/sora.h b/src/sora.h index 8935e3b..c570ea6 100644 --- a/src/sora.h +++ b/src/sora.h @@ -112,6 +112,7 @@ class Sora : public std::enable_shared_from_this, CreateVideoCapturer( int capturer_type, void* unity_camera_texture, + bool no_video_device, std::string video_capturer_device, int video_width, int video_height,