Skip to content

Commit

Permalink
Merge pull request #77 from shiguredo/feature/misc
Browse files Browse the repository at this point in the history
機能追加とアップデートと修正とコード整理
  • Loading branch information
voluntas authored Sep 8, 2023
2 parents 7570295 + d35296e commit 9f521b8
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 129 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@
- [CHANGE] `Sora.Config` 中にあるキャプチャラに関するフィールドを `Sora.CameraConfig` に移動する
- 修正方法は (TODO: @miosakuma がドキュメントへのリンクに差し替える) を参照して下さい
- @melpon
- [UPDATE] SoraClientContext を利用してコードを短くする
- @melpon
- [UPDATE] Sora C++ SDK を `2023.12.0` に上げる
- @melpon
- [UPDATE] libwebrtc を `m116.5845.6.1` に上げる
- @melpon
- [ADD] 接続中にキャプチャラを切り替える機能を実装
- @melpon
- [ADD] デバイスを掴まないようにする `NoVideoDevice`, `NoAudioDevice` を追加
- @melpon
- [ADD] ハードウェアエンコーダを利用するかどうかを設定する `UseHardwareEncoder` を追加
- @melpon
- [ADD] `SelectedSignalingURL``ConnectedSignalingURL` プロパティを追加
- @melpon
- [FIX] IosAudioInit を初回接続の場合のみ呼び出すようにすることで、iOS で連続して接続しようとすると落ちることがあったのを修正
- @melpon

## 2023.3.0 (2023-08-08)

Expand Down
46 changes: 42 additions & 4 deletions Sora/Sora.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public class Config
public SpotlightFocusRidType? SpotlightUnfocusRid;
public bool? Simulcast;
public SimulcastRidType? SimulcastRid = null;
public bool NoVideoDevice = false;
public bool NoAudioDevice = false;
public CameraConfig CameraConfig = new CameraConfig();
public bool Video = true;
public bool Audio = true;
Expand Down Expand Up @@ -185,6 +187,8 @@ public class Config
public string ProxyAgent = "";

public ForwardingFilter ForwardingFilter;

public bool? UseHardwareEncoder;
}

IntPtr p;
Expand Down Expand Up @@ -302,16 +306,18 @@ public void Connect(Config config)
cc.signaling_notify_metadata = config.SignalingNotifyMetadata;
cc.role = role;
cc.enable_multistream = config.Multistream != null;
cc.multistream = config.Multistream == null ? false : config.Multistream.Value;
cc.multistream = config.Multistream.GetValueOrDefault();
cc.enable_spotlight = config.Spotlight != null;
cc.spotlight = config.Spotlight == null ? false : config.Spotlight.Value;
cc.spotlight = config.Spotlight.GetValueOrDefault();
cc.spotlight_number = config.SpotlightNumber;
cc.spotlight_focus_rid = config.SpotlightFocusRid == null ? "" : config.SpotlightFocusRid.Value.ToString().ToLower();
cc.spotlight_unfocus_rid = config.SpotlightUnfocusRid == null ? "" : config.SpotlightUnfocusRid.Value.ToString().ToLower();
cc.enable_simulcast = config.Simulcast != null;
cc.simulcast = config.Simulcast == null ? false : config.Simulcast.Value;
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.video = config.Video;
cc.audio = config.Audio;
cc.camera_config.capturer_type = (int)config.CameraConfig.CapturerType;
Expand All @@ -332,7 +338,7 @@ public void Connect(Config config)
cc.audio_codec_type = config.AudioCodecType.ToString();
cc.audio_codec_lyra_bitrate = config.AudioCodecLyraBitrate;
cc.enable_audio_codec_lyra_usedtx = config.AudioCodecLyraUsedtx != null;
cc.audio_codec_lyra_usedtx = config.AudioCodecLyraUsedtx == null ? false : config.AudioCodecLyraUsedtx.Value;
cc.audio_codec_lyra_usedtx = config.AudioCodecLyraUsedtx.GetValueOrDefault();
cc.check_lyra_version = config.CheckLyraVersion;
cc.audio_bit_rate = config.AudioBitRate;
cc.audio_streaming_language_code = config.AudioStreamingLanguageCode;
Expand Down Expand Up @@ -404,6 +410,8 @@ public void Connect(Config config)
cc.forwarding_filter.rules.Add(ccrs);
}
}
cc.enable_use_hardware_encoder = config.UseHardwareEncoder != null;
cc.use_hardware_encoder = config.UseHardwareEncoder.GetValueOrDefault();

sora_connect(p, Jsonif.Json.ToJson(cc));
}
Expand Down Expand Up @@ -820,6 +828,28 @@ public bool VideoEnabled
set { sora_set_video_enabled(p, value ? 1 : 0); }
}

public string SelectedSignalingURL
{
get
{
int size = sora_get_selected_signaling_url_size(p);
byte[] buf = new byte[size];
sora_get_selected_signaling_url(p, buf, size);
return System.Text.Encoding.UTF8.GetString(buf);
}
}

public string ConnectedSignalingURL
{
get
{
int size = sora_get_connected_signaling_url_size(p);
byte[] buf = new byte[size];
sora_get_connected_signaling_url(p, buf, size);
return System.Text.Encoding.UTF8.GetString(buf);
}
}

#if UNITY_IOS && !UNITY_EDITOR
private const string DllName = "__Internal";
#else
Expand Down Expand Up @@ -888,4 +918,12 @@ public bool VideoEnabled
private static extern int sora_get_video_enabled(IntPtr p);
[DllImport(DllName)]
private static extern void sora_set_video_enabled(IntPtr p, int enabled);
[DllImport(DllName)]
private static extern int sora_get_selected_signaling_url_size(IntPtr p);
[DllImport(DllName)]
private static extern int sora_get_connected_signaling_url_size(IntPtr p);
[DllImport(DllName)]
private static extern void sora_get_selected_signaling_url(IntPtr p, [Out] byte[] buf, int size);
[DllImport(DllName)]
private static extern void sora_get_connected_signaling_url(IntPtr p, [Out] byte[] buf, int size);
}
4 changes: 4 additions & 0 deletions proto/sora_conf_internal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ message ConnectConfig {
bool enable_simulcast = 14;
bool simulcast = 15;
string simulcast_rid = 16;
bool no_video_device = 160;
bool no_audio_device = 161;
CameraConfig camera_config = 17;
bool video = 20;
bool audio = 21;
Expand Down Expand Up @@ -98,4 +100,6 @@ message ConnectConfig {
string signaling_notify_metadata = 49;
bool enable_forwarding_filter = 50;
ForwardingFilter forwarding_filter = 51;
bool enable_use_hardware_encoder = 52;
bool use_hardware_encoder = 53;
}
Loading

0 comments on commit 9f521b8

Please sign in to comment.