From 9d54c92f7797ba2a74b0759fc4a9ca2b2a944e06 Mon Sep 17 00:00:00 2001 From: Vincent Song Date: Thu, 24 Oct 2024 15:11:55 +1100 Subject: [PATCH] fix: no video in multi-source stream when main source id is not null (#465) * fix: no video in multi-source stream when main source id is not null * bump RC version and added changeset --- .changeset/shaggy-cats-swim.md | 5 +++ package-lock.json | 2 +- packages/millicast-sdk/package.json | 2 +- packages/millicast-sdk/src/Signaling.js | 2 +- packages/millicast-sdk/src/View.js | 39 +++++++++----------- packages/millicast-viewer-demo/src/viewer.js | 3 -- 6 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 .changeset/shaggy-cats-swim.md diff --git a/.changeset/shaggy-cats-swim.md b/.changeset/shaggy-cats-swim.md new file mode 100644 index 00000000..ef0704a0 --- /dev/null +++ b/.changeset/shaggy-cats-swim.md @@ -0,0 +1,5 @@ +--- +"@millicast/sdk": patch +--- + +fixed bug: no video when the main source id is not null diff --git a/package-lock.json b/package-lock.json index 4c6f0729..7489c091 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41638,7 +41638,7 @@ }, "packages/millicast-sdk": { "name": "@millicast/sdk", - "version": "0.3.0-RC-11", + "version": "0.3.0-RC-12", "license": "See in LICENSE file", "dependencies": { "@dolbyio/webrtc-stats": "^1.0.2", diff --git a/packages/millicast-sdk/package.json b/packages/millicast-sdk/package.json index 6571aa60..b21efc56 100644 --- a/packages/millicast-sdk/package.json +++ b/packages/millicast-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@millicast/sdk", - "version": "0.3.0-RC-11", + "version": "0.3.0-RC-12", "description": "SDK for building a realtime broadcaster using the Millicast platform.", "keywords": [ "sdk", diff --git a/packages/millicast-sdk/src/Signaling.js b/packages/millicast-sdk/src/Signaling.js index fc86bf94..98fef36f 100644 --- a/packages/millicast-sdk/src/Signaling.js +++ b/packages/millicast-sdk/src/Signaling.js @@ -197,7 +197,7 @@ export default class Signaling extends EventEmitter { sdp = SdpParser.adaptCodecName(sdp, 'AV1X', VideoCodec.AV1) // default events - const events = ['active', 'inative', 'layers', 'viewercount', 'vad', 'updated', 'migrate', 'stopped'] + const events = ['active', 'inactive', 'layers', 'viewercount', 'vad', 'updated', 'migrate', 'stopped'] const data = { sdp, streamId: this.streamName, pinnedSourceId: optionsParsed.pinnedSourceId, excludedSourceIds: optionsParsed.excludedSourceIds, events } if (optionsParsed.vad) { data.vad = true } diff --git a/packages/millicast-sdk/src/View.js b/packages/millicast-sdk/src/View.js index ceb10006..344543c1 100644 --- a/packages/millicast-sdk/src/View.js +++ b/packages/millicast-sdk/src/View.js @@ -301,28 +301,25 @@ export default class View extends BaseWebRTC { }) signalingInstance.on(signalingEvents.broadcastEvent, async (event) => { - if (event.data.sourceId === null) { - switch (event.name) { - case 'active': - if (this.DRMProfile == null) { - const subscriberData = await this.tokenGenerator() - if (subscriberData.drmObject) { - // cache the DRM license server URLs - this.DRMProfile = subscriberData.drmObject - } - } - this.emit(signalingEvents.broadcastEvent, event) - this.isMainStreamActive = true - while (this.eventQueue.length > 0) { - this.onTrackEvent(this.eventQueue.shift()) - } - return - case 'inactive': - this.isMainStreamActive = false - break - default: - break + if (!this.isMainStreamActive && event.name === 'active') { + // handle 'active' event for main stream + this.mainSourceId = event.data.sourceId + if (!this.DRMProfile && event.data.encryption) { + const subscriberData = await this.tokenGenerator() + if (subscriberData.drmObject) { + // cache the DRM license server URLs + this.DRMProfile = subscriberData.drmObject + } } + this.emit(signalingEvents.broadcastEvent, event) + this.isMainStreamActive = true + while (this.eventQueue.length > 0) { + this.onTrackEvent(this.eventQueue.shift()) + } + return + } + if (event.name === 'inactive' && this.isMainStreamActive && this.mainSourceId === event.data.sourceId) { + this.isMainStreamActive = false } this.emit(signalingEvents.broadcastEvent, event) }) diff --git a/packages/millicast-viewer-demo/src/viewer.js b/packages/millicast-viewer-demo/src/viewer.js index 313835b9..2f0e5ecf 100644 --- a/packages/millicast-viewer-demo/src/viewer.js +++ b/packages/millicast-viewer-demo/src/viewer.js @@ -81,9 +81,6 @@ const newViewer = () => { millicastView.configureDRM(drmOptions); } } - let layers = event.data["layers"] !== null ? event.data["layers"] : {}; - if (event.name === "layers" && Object.keys(layers).length <= 0) { - } }); millicastView.on("track", (event) => { if (!enableDRM) addStream(event.streams[0]);