Skip to content
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

feat(JingleSession) Convert Jingle->SDP directly w/o interop layer. #2590

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

jallamsetty1
Copy link
Member

No description provided.

Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review is 50% hope, 50% substance 😅

removeSsrcInfo[idx] += `${ssrcLines.join('\r\n')}\r\n`;
removeSsrcInfo[idx] += lines;
}
for (const [ sourceName, sourceInfo ] of this._remoteSsrcMap.entries()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the .entries() to iterate a Map.

modules/RTC/TraceablePeerConnection.js Outdated Show resolved Hide resolved
* @property {Array<TPCGroupInfo>} groups - The SSRC groups associated with the track.
* @property {string} msid - The track's MSID.
*/
this._remoteSsrcMap = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at how we need to handle the code later on, doesn't it make sense to always have this initialized to a an empty Map?

Having its size be 0 would be equivalente to the current null value, but I bet it sill simplify some code and make things easier to work with.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a follow up PR that will get rid of localSSRCs/remoteSSRCs and start using _localSSCMap and _remoteSSRCMap for all other helper functions, I have them initialized to an empty map there. I should have done that here itself :) Modified it.

@@ -1145,7 +1154,7 @@ TraceablePeerConnection.prototype._processAndExtractSourceInfo = function(localS
const media = session.media.filter(mline => mline.direction === MediaDirection.SENDONLY
|| mline.direction === MediaDirection.SENDRECV);

if (!Array.isArray(media)) {
if (!media?.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the optional chaining necessary? media will always be an array since filter always returns one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its not, force of habit for some reason :)

*/
TraceablePeerConnection.prototype.updateRemoteSources = function(sourceMap, isAdd) {
if (this._remoteSsrcMap) {
for (const [ sourceName, ssrcInfo ] of sourceMap.entries()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for .entries()

this._remoteSsrcMap.delete(sourceName);
}
}
} else if (isAdd) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch wouldn't be necessary if the Map is always initialized.

modules/sdp/SDP.js Show resolved Hide resolved
modules/sdp/SDP.js Show resolved Hide resolved

// Update the SSRC map on the peerconnection.
if (sourceInfo) {
this.peerconnection._remoteSsrcMap.delete(oldSourceName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to dig in the private methods here looks nasty shall this have some API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I added TPC.updateRemoteSources for this exact purpose later but forgot to update it here. Thanks for pointing it out.

jallamsetty1 and others added 2 commits October 25, 2024 10:20
Address review comments, fix test faiilures for ssrc-rewriting case and add unit tests.
Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments and LGTM!

* @type {Map<string, TPCSourceInfo>}
* @property {string} msid - The track's MSID.
* @property {Array<string>} ssrcs - The SSRCs associated with the track.
* @property {Array<TPCGroupInfo>} groups - The SSRC groups associated with the track.
*/
this._localSsrcMap = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to initialize this to a new map too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some more work planned around this, i.e., getting rid of localSSRCs and remoteSSRCs in favor of these. Lets restrict this PR to only the SDP conversion, WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks odd that one is a map and the other one is null. If it's not a huge change it would be nice to at least have them aligned. No worries if it would break things, we can do it later.

modules/RTC/TraceablePeerConnection.js Show resolved Hide resolved
* Returns the remote sourceInfo for a given source name.
*
* @param {string} sourceName - The source name.
* @returns {TPCSourceInfo}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also return null, but I think undefined is also good, see below.

modules/RTC/TraceablePeerConnection.js Outdated Show resolved Hide resolved
modules/sdp/SDP.js Show resolved Hide resolved
if (type === MediaType.APPLICATION) {
const newMline = cloneDeep(mLine);

newMline.mid = newMedia.length.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what we really want? The lengfth as a string? Not its index?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the requirement. The mid for the new m-line needs to be a string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean for the MID to the the length. I guess it's the index for the last added element, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

newMline.direction = idx ? 'sendonly' : 'sendrecv';

// Add the sources and the related FID source group to the new m-line.
const group = mLine.ssrcGroups?.find(g => g.ssrcs.includes(ssrc.id.toString()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are converting the ssrc id into a string many times here, calculate it once: const idStr = ssrc.id.toString(); and then compare with it.

@jallamsetty1 jallamsetty1 merged commit d51e557 into master Oct 29, 2024
2 checks passed
@jallamsetty1 jallamsetty1 deleted the ref-jingle-sdp branch October 29, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants