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

Add support of abs-capture-time extension to streaming plugin and forwarding of it's value from rtp source #3258

Closed
wants to merge 5 commits into from

Conversation

IbrayevRamil
Copy link
Contributor

  1. Added support of abs-capture-time extension in streaming plugin
  2. Added parsing of abs-capture-time extension from RTP source for forwarding it further to webrtc
  3. Removed memset(index+9, 0, 8); as it doesn't make sense to fill rest of bytes with zeroes if we parse only 8 bytes of extension.

@januscla
Copy link

Thanks for your contribution, @IbrayevRamil! Please make sure you sign our CLA, as it's a required step before we can merge this.

@mvollrath
Copy link

This is working for me, very cool!

Copy link
Member

@lminiero lminiero left a comment

Choose a reason for hiding this comment

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

Thanks for the patch, just added some notes. I think some changes are needed before this can be merged.

src/ice.c Outdated
@@ -4078,24 +4078,30 @@ static void janus_ice_rtp_extension_update(janus_ice_handle *handle, janus_ice_p
}
}
}
/* Parse the abs-capture-time extension from source if needed */
Copy link
Member

Choose a reason for hiding this comment

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

No, this is the wrong place to add this stuff. If you want the Streaming plugin to set a specific value, it's the Streaming plugin itself that must parse extension values, and set the extensions struct accordingly. It's the whole reason why we added that struct in the first place: allowing plugins to just set fields in a structure, and then let the core go through those values to physically build the RTP extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was thinking about this, but couldn't understand where to add it in streaming plugin.
Today, I've investigated it once again and think that found the right place in janus_streaming.c.

extbufsize -= 18;
index += 10;
extlen += 10;
extbufsize -= 10;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why you changed the block above? To my knowledge it wasn't broken. If it was please elaborate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't broken, but from the docs it says that abs-capture-time can be both shortened and full version (8 and 16 bytes respectively.
So, I thought that it doesn't make sense to use full version if we always fill it with zeros.

@@ -6114,6 +6114,7 @@ static void *janus_streaming_handler(void *data) {
JANUS_SDP_OA_DIRECTION, JANUS_SDP_SENDONLY,
JANUS_SDP_OA_EXTENSION, JANUS_RTP_EXTMAP_MID, janus_rtp_extension_id(JANUS_RTP_EXTMAP_MID),
JANUS_SDP_OA_EXTENSION, JANUS_RTP_EXTMAP_ABS_SEND_TIME, janus_rtp_extension_id(JANUS_RTP_EXTMAP_ABS_SEND_TIME),
JANUS_SDP_OA_EXTENSION, JANUS_RTP_EXTMAP_ABS_CAPTURE_TIME, janus_rtp_extension_id(JANUS_RTP_EXTMAP_ABS_CAPTURE_TIME),
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather make support for this optional and configurable (that is, only offered and used if specifically enabled when creating a mountpoint). The overwhelming majority of mountpoints will never use it, and just because you do doesn't mean we should always offer the extension (more work for the core) and parse all incoming packets needlessly for an extension that will almost always not be there (more work for the plugin).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you are right, made it optional and controllable with 'abscapturetime_ext' flag

@@ -10348,4 +10353,4 @@ static void *janus_streaming_helper_thread(void *data) {
janus_refcount_decrease(&mp->ref);
g_thread_unref(g_thread_self());
return NULL;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Please don't remove empty lines at the end of files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sry, reverted back

Copy link
Member

@lminiero lminiero left a comment

Choose a reason for hiding this comment

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

Apologies for the delay, I missed the "please review" notification. Added a few notes inline. Apart from those small remarks, it looks fine, even though I haven't tested it (I don't have a way to test this). That said, please notice that, once ready, this will still need me to merge the capture time PR first, before I can merge this, and I haven't received enough feedback on that one yet for it to happen.

@@ -2997,6 +3011,9 @@ json_t *janus_streaming_query_session(janus_plugin_session *handle) {
json_object_set_new(pd, "max-delay", json_integer(s->max_delay));
json_object_set_new(info, "playout-delay", pd);
}
if(session->abscapturetime_ext) {
json_object_set_new(info, "abs-capture-time", json_true());
}
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 the parenthesis around the action, since it's a simple one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

src/rtp.c Outdated
/*
It parses only the shortened version of abs-capture-time without estimated-capture-clock-offset
Check http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time for details.
*/
Copy link
Member

Choose a reason for hiding this comment

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

This comment is unneeded here. The other functions don't have such a description either. The description is already available in the header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -83,6 +83,12 @@
# assuming the browser supports the RTP extension in the first place.
# playoutdelay_ext = true
#
# To allow mountpoints to negotiate the abs-capture-time RTP extension,
# you can set the 'abscapturetime_ext' property to true: this way, any
# subscriber can receive the abs-capture-time of incoming video streams,
Copy link
Member

Choose a reason for hiding this comment

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

Why only video and not RTP in general? What if someone wants the capture time of audio?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, fixed the description

@lminiero lminiero added the multistream Related to Janus 1.x label Oct 2, 2023
@lminiero lminiero deleted the branch meetecho:capture-time November 16, 2023 15:31
@lminiero lminiero closed this Nov 16, 2023
@lminiero
Copy link
Member

Whoops, looks like deleting the PR branch closed this PR: could you rebase it on master and reopen or recreate it? Thanks and sorry about that!

@IbrayevRamil
Copy link
Contributor Author

Whoops, looks like deleting the PR branch closed this PR: could you rebase it on master and reopen or recreate it? Thanks and sorry about that!

no problem, rebased and created the new one, #3291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multistream Related to Janus 1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants