Skip to content

v1.4.0 - upgrade client sdk js #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2023
Merged
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
4 changes: 2 additions & 2 deletions Bridge~/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@livekit/livekit-unity",
"version": "1.3.0",
"version": "1.4.0",
"description": "LiveKit Unity Bridge for WebGL",
"main": "./dist/index.js",
"source": "./src/index.ts",
Expand All @@ -20,7 +20,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"livekit-client": "^1.3.0",
"livekit-client": "^1.6.3",
"typed-emitter": "^2.1.0"
},
"devDependencies": {
Expand Down
14 changes: 10 additions & 4 deletions Bridge~/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,10 @@ kind-of@^6.0.2:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

livekit-client@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/livekit-client/-/livekit-client-1.3.0.tgz#c728f10cb6c9e553db87e04050a05e453714c8c9"
integrity sha512-Ls3ADbc2fVFDTOxjVkbBbLAxzhXh0DYJa+uWaTFOviyiV5gK6/rW3Sp9x5RSJfu7IbZqD+wg8VghiXCgNmNAxQ==
livekit-client@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/livekit-client/-/livekit-client-1.6.3.tgz#4ff46f1fbdaaa7982c339738964d18e8b43fd3d5"
integrity sha512-hnVN/rQ9pVWK0L1lemLSOzBI6IXoJepgHP/USqmGJ6eucaoLMx1jK0iMWpR5T2/pg97GmZaUaRSUcXlELNSsoA==
dependencies:
async-await-queue "^1.2.1"
events "^3.3.0"
Expand All @@ -595,6 +595,7 @@ livekit-client@^1.3.0:
sdp-transform "^2.14.1"
ts-debounce "^4.0.0"
typed-emitter "^2.1.0"
ua-parser-js "^1.0.2"
webrtc-adapter "^8.1.1"

loader-runner@^4.2.0:
Expand Down Expand Up @@ -931,6 +932,11 @@ typescript@^4.5.5:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d"
integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==

ua-parser-js@^1.0.2:
version "1.0.33"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.33.tgz#f21f01233e90e7ed0f059ceab46eb190ff17f8f4"
integrity sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==

uri-js@^4.2.2:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
Expand Down
13 changes: 10 additions & 3 deletions Runtime/Plugins/livekit-bridge.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,23 @@ var NativeLib = {
AttachVideo: function (videoPtr, texId) {
var tex = GL.textures[texId];
var lastTime = -1;


var initialVideo = LKBridge.Data.get(videoPtr);
initialVideo.style.opacity = 0;
initialVideo.style.width = 0;
initialVideo.style.height = 0;
document.body.appendChild(initialVideo);

var updateVideo = function () {
var video = LKBridge.Data.get(videoPtr);
if (video === undefined)
if (video === undefined) {
initialVideo.remove();
return;
}

var time = video.currentTime;
if (!video.paused && video.srcObject !== null && time !== lastTime) {
lastTime = time;

GLctx.bindTexture(GLctx.TEXTURE_2D, tex);

// Flip Y
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Plugins/livekit-client.jspre

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Runtime/Scripts/Internal/HTMLVideoElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public int VideoWidth
get
{
JSNative.PushString("videoWidth");
return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle));
return (int)JSNative.GetNumber(JSNative.GetProperty(NativeHandle));
}
}

public int VideoHeight
{
get
{
JSNative.PushString("videoHeight");
return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle));
return (int)JSNative.GetNumber(JSNative.GetProperty(NativeHandle));
}
}

[MonoPInvokeCallback(typeof(JSNative.JSDelegate))]
private static void ResizeEvent(IntPtr ptr)
{
Expand All @@ -34,13 +34,13 @@ private static void ResizeEvent(IntPtr ptr)
var handle = new JSHandle(ptr, true);
if (!JSNative.IsObject(handle))
return;

var el = Acquire<HTMLVideoElement>(handle);
Log.Debug($"Received HTMLVideoElement.Resize {el.VideoWidth}x{el.VideoHeight}");

if (el.VideoWidth == 0 || el.VideoHeight == 0)
Debug.LogError($"HTMLVideoElement.Resize - Wrong size: {el.VideoWidth}*{el.VideoHeight}");

el.SetupTexture();
el.VideoReceived?.Invoke(el.Texture);
}
Expand All @@ -49,10 +49,10 @@ private static void ResizeEvent(IntPtr ptr)
Log.Error($"Error happened on HTMLVideoElement.VideoReceived ( Is your listeners working correctly ? ): {Environment.NewLine} {e.Message}");
}
}

public delegate void VideoReceivedDelegate(Texture2D tex);
public event VideoReceivedDelegate VideoReceived;

public Texture2D Texture { get; private set; }
private readonly int m_TextureId;

Expand All @@ -76,8 +76,8 @@ void SetupTexture()
{
if (Texture != null)
Object.Destroy(Texture);
Texture = Texture2D.CreateExternalTexture(VideoWidth, VideoHeight, TextureFormat.RGBA32, false, true, (IntPtr) m_TextureId);

Texture = Texture2D.CreateExternalTexture(VideoWidth, VideoHeight, TextureFormat.RGBA32, false, true, (IntPtr)m_TextureId);
}
}
}
};
2 changes: 1 addition & 1 deletion Runtime/Scripts/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public struct RoomConnectOptions
[JsonProperty("publishOnly")]
public string PublishOnly;
}
}
}
8 changes: 4 additions & 4 deletions Runtime/Scripts/Room/Track/LocalTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public string GetId()

return JSNative.GetStruct<TrackDimensions>(ptr);
}

public DeviceIdPromise GetDeviceId()
{
return Acquire<DeviceIdPromise>(JSNative.CallMethod(NativeHandle, "getDeviceId"));
Expand All @@ -49,12 +49,12 @@ internal DeviceIdPromise(JSHandle handle) : base(handle)
{

}
protected virtual void OnResolve()

protected override void OnResolve()
{
base.OnResolve();
if (!JSNative.IsUndefined(ResolveHandle))
DeviceId = JSNative.GetString(ResolveHandle);
}
}
}
}
2 changes: 1 addition & 1 deletion Samples~/JSExample/JSPackage~/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@livekit/livekit-unity": "^0.0.4"
"@livekit/livekit-unity": "^1.4.0"
},
"devDependencies": {
"ts-loader": "^9.2.7",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io.livekit.unity",
"version": "1.3.0",
"version": "1.4.0",
"displayName": "LiveKit WebGL SDK",
"description": "LiveKit Unity Bridge for WebGL",
"unity": "2021.3",
Expand All @@ -19,4 +19,4 @@
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.0"
}
}
}