Skip to content

Commit

Permalink
fix: no video in multi-source stream when main source id is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsong committed Oct 24, 2024
1 parent 6af9c59 commit 66afc4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/millicast-sdk/src/Signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
39 changes: 18 additions & 21 deletions packages/millicast-sdk/src/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
3 changes: 0 additions & 3 deletions packages/millicast-viewer-demo/src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 66afc4e

Please sign in to comment.