Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
harryz2000 committed Oct 23, 2024
1 parent 1a4c38f commit bf6d0f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/ClientConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ClientConnection extends Emitter
/** @type {Map<string, OutgoingStreamBridge>} */
this.streams = new Map();
this.maxStreamId = 0;
this.key = null;

//Create neative connection
this.connection = new Native.RTMPClientConnectionImpl(secure, this);
Expand Down Expand Up @@ -97,8 +98,11 @@ class ClientConnection extends Emitter
}


async publish(/** @type {(outgoingStream : OutgoingStreamBridge) => void} */ callback)
async publish(/** @type {(outgoingStream : OutgoingStreamBridge) => void} */ outgoingStreamReadyCallback)
{
if (!this.key)
throw new Error("RTMP Restream key is not set for server.");

//Create RTMP stream and get streamId
const [,streamId] = await new Promise((resolve,reject) => this.connection.CreateStream({resolve,reject}))
.catch(err => Promise.reject(new CommandError('createStream', err)));
Expand Down Expand Up @@ -128,7 +132,7 @@ class ClientConnection extends Emitter
//Check if we can start publishing
if (name === "onStatus" && cmd[1].code === Status.NetStream.Publish.Start.code)
{
callback(outgoingStream);
outgoingStreamReadyCallback(outgoingStream);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/OutgoingStreamBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class OutgoingStreamBridge extends Emitter
return video;
}

attachTo(incomingStream)
attachTo(/** @type {any} */ incomingStream)
{
//Dettach
this.detach();
Expand All @@ -121,13 +121,13 @@ class OutgoingStreamBridge extends Emitter
audio[i].attachTo(tracks[i]);
}

//Get all of our audio streams
//Get all of our video streams
const video = this.getVideoTracks();

//If we have any
if (video.length)
{
//Get incoming audiotracks
//Get incoming videotracks
const tracks = incomingStream.getVideoTracks();
//Try to match each ones
for (let i=0; i<video.length && i<tracks.length; ++i)
Expand Down

0 comments on commit bf6d0f3

Please sign in to comment.