Skip to content

Commit

Permalink
Add more method for Local/Remote Track. (#46)
Browse files Browse the repository at this point in the history
* Add more method for Local/Remote Track.

* update.

* update.

* Upgrade ffi protocol.

* fix: Flip the local texture2D for OSX.

* update.

* Add IRtcSource interface to LocalTrack to support synchronous mute calls.

* update.

* bump version for ffi.

* update ffi protocol.

* fix.
  • Loading branch information
cloudwebrtc authored Sep 6, 2024
1 parent 1e0e106 commit 9f9bfdf
Show file tree
Hide file tree
Showing 28 changed files with 10,323 additions and 4,910 deletions.
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-ios-arm64/liblivekit_ffi.a
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-ios-sim-arm64/liblivekit_ffi.a
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll
Git LFS file not shown
16 changes: 15 additions & 1 deletion Runtime/Scripts/AudioSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum RtcAudioSourceType
AudioSourceMicrophone = 1,
}

public class RtcAudioSource
public class RtcAudioSource : IRtcSource
{
#if UNITY_IOS
// iOS microphone sample rate is 24k,
Expand Down Expand Up @@ -45,6 +45,10 @@ public class RtcAudioSource
private Thread _readAudioThread;
private ThreadSafeQueue<AudioFrame> _frameQueue = new ThreadSafeQueue<AudioFrame>();

private bool _muted = false;

public override bool Muted => _muted;

public RtcAudioSource(AudioSource source, RtcAudioSourceType audioSourceType = RtcAudioSourceType.AudioSourceCustom)
{
_sourceType = audioSourceType;
Expand Down Expand Up @@ -137,6 +141,11 @@ private void ReadAudio()
try
{
AudioFrame frame = _frameQueue.Dequeue();

if(_muted)
{
continue;
}
unsafe
{
using var request = FFIBridge.Instance.NewRequest<CaptureAudioFrameRequest>();
Expand Down Expand Up @@ -166,5 +175,10 @@ private void UpdateSource(AudioSource source)
_audioSource = source;
_audioFilter = source.gameObject.AddComponent<AudioFilter>();
}

public override void SetMute(bool muted)
{
_muted = muted;
}
}
}
18 changes: 10 additions & 8 deletions Runtime/Scripts/Internal/FFIClients/FfiRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public static void Inject<T>(this FfiRequest ffiRequest, T request)
case SetSubscribedRequest setSubscribedRequest:
ffiRequest.SetSubscribed = setSubscribedRequest;
break;
case UpdateLocalMetadataRequest updateLocalMetadataRequest:
ffiRequest.UpdateLocalMetadata = updateLocalMetadataRequest;
case SetLocalMetadataRequest updateLocalMetadataRequest:
ffiRequest.SetLocalMetadata = updateLocalMetadataRequest;
break;
case UpdateLocalNameRequest updateLocalNameRequest:
ffiRequest.UpdateLocalName = updateLocalNameRequest;
case SetLocalNameRequest updateLocalNameRequest:
ffiRequest.SetLocalName = updateLocalNameRequest;
break;
case GetSessionStatsRequest getSessionStatsRequest:
ffiRequest.GetSessionStats = getSessionStatsRequest;
Expand Down Expand Up @@ -106,8 +106,9 @@ public static void EnsureClean(this FfiRequest request)
|| request.UnpublishTrack != null
|| request.PublishData != null
|| request.SetSubscribed != null
|| request.UpdateLocalMetadata != null
|| request.UpdateLocalName != null
|| request.SetLocalMetadata != null
|| request.SetLocalName != null
|| request.SetLocalAttributes != null
|| request.GetSessionStats != null
||

Expand Down Expand Up @@ -154,8 +155,9 @@ public static void EnsureClean(this FfiResponse response)
|| response.UnpublishTrack != null
|| response.PublishData != null
|| response.SetSubscribed != null
|| response.UpdateLocalMetadata != null
|| response.UpdateLocalName != null
|| response.SetLocalMetadata != null
|| response.SetLocalName != null
|| response.SetLocalAttributes != null
|| response.GetSessionStats != null
||

Expand Down
4 changes: 2 additions & 2 deletions Runtime/Scripts/Participant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public void PublishData(Span<byte> data, IReadOnlyCollection<string> destination

public void UpdateMetadata(string metadata)
{
using var request = FFIBridge.Instance.NewRequest<UpdateLocalMetadataRequest>();
using var request = FFIBridge.Instance.NewRequest<SetLocalMetadataRequest>();
var updateReq = request.request;
updateReq.Metadata = metadata;
var resp = request.Send();
}

public void UpdateName(string name)
{
using var request = FFIBridge.Instance.NewRequest<UpdateLocalNameRequest>();
using var request = FFIBridge.Instance.NewRequest<SetLocalNameRequest>();
var updateReq = request.request;
updateReq.Name = name;
var resp = request.Send();
Expand Down
Loading

0 comments on commit 9f9bfdf

Please sign in to comment.