这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Runtime/Scripts/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,18 @@ public static JSPromise<JSArray<LocalTrack>> CreateLocalScreenTracks(ScreenShare

return JSRef.Acquire<JSPromise<JSArray<LocalTrack>>>(JSNative.CallMethod(JSNative.LiveKit, "createLocalScreenTracks"));
}
public static AudioAnalyser CreateAudioAnalyser(Track track, AudioAnalyserOptions? options = null)
{
if (track == null)
{
throw new ArgumentNullException($"{nameof(CreateAudioAnalyser)} - {nameof(track)} should be a valid {nameof(Track)} instance");
}
JSNative.PushObject(track.NativeHandle);
if (options.HasValue)
{
JSNative.PushStruct(JsonConvert.SerializeObject(options.Value, JSNative.JsonSettings));
}
return JSRef.Acquire<AudioAnalyser>(JSNative.CallMethod(JSNative.LiveKit, "createAudioAnalyser"));
}
}
}
26 changes: 26 additions & 0 deletions Runtime/Scripts/Room/Track/AudioAnalyser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using UnityEngine.Scripting;

namespace LiveKit
{
public interface IAudioAnalyser
{
float CalculateAvgAmplitude();
void Cleanup();
}
public sealed class AudioAnalyser : JSObject, IAudioAnalyser
{
[Preserve]
internal AudioAnalyser(JSHandle handle) : base(handle)
{
}
public float CalculateAvgAmplitude()
{
var ret = JSNative.CallMethod(NativeHandle, "calculateVolume");
return (float)JSNative.GetNumber(ret);
}
public void Cleanup()
{
JSNative.CallMethod(NativeHandle, "cleanup");
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/Room/Track/AudioAnalyser.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Runtime/Scripts/Room/Track/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ public struct AudioCaptureOptions
[JsonProperty("sampleSize")]
public ConstrainULong? SampleSize;
}
public struct AudioAnalyserOptions
{
[JsonProperty("cloneTrack")]
public bool? CloneTrack { get; set; }

[JsonProperty("fftSize")]
public int? FftSize { get; set; }

[JsonProperty("smoothingTimeConstant")]
public float? SmoothingTimeConstant { get; set; }
}

public struct VideoResolution
{
Expand Down