Twilio-video.js: Track Subscription REST API Support

Created on 1 Jun 2018  ·  17Comments  ·  Source: twilio/twilio-video.js

  • [x] I have verified that the issue occurs with the latest twilio-video.js release and is not marked as a known issue in the CHANGELOG.md.
  • [x] I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • [x] I verified that the Quickstart application works in my environment.

Code to reproduce the issue:

activeRoom.on('participantConnected', (participant) => {
  logger.log(`participantConnected ${participant.identity} sid is ${participant.sid}`);
  participant.on('trackPublished', (publication) => {
    logger.log('A new Track was published!', publication);
  });
  participant.on('trackUnpublished', (publication) => {
    logger.log('A new Track was unpublished!', publication);
  });
});

Expected behavior:
Audio and video track published event

Actual behavior:
Did not get audio and video track published event but got data track published event.

Twilio Log file - https://cl.ly/460u3S3X2t45

Software versions:

  • [x] Browser(s): Chrome
  • [x] Operating System: Mac OS
  • [x] twilio-video.js: 1.10.0
  • [x] Third-party libraries (e.g., Angular, React, etc.): React
bug

Most helpful comment

Hi @anand-io , @jeehyukwon ,

FYI, we have scheduled the work to fix this issue in the ongoing sprint. Please watch this space for updates.

Thanks,

Manjesh Malavalli
JSDK Team

All 17 comments

Hi @anand-io ,

Thanks for opening the issue. Can you give more context about how you are using "trackPublished" event listeners? You can follow the format specified in ISSUE_TEMPLATE.md.

Thanks,

Manjesh Malavalli
JSDK Team

Hi Manjesh, edited the issue description.

As the event was not emitted I tried to directly access the videoTrackPublications and attached these listeners

Room Sid - RMeaafa15fa712172d10a8786abafe9243

Track that was unsubscribed - MT82afc6724c8256c010be81f0885910cd
Using early access Subscription API.

Using this request URL (POST) -
https://video.twilio.com/v1/Rooms/RMeaafa15fa712172d10a8786abafe9243/Participants/d2d62647-236d-4081-b853-6955ac05c028/SubscribedTracks
Using this payload -
Track=MT82afc6724c8256c010be81f0885910cd&Status=unsubscribe
Response - Empty

The track got stopped on the client side but there was no unsubscribed event.
Screen Shot of the videoTrackPublications Object
https://cl.ly/2K3S3c060j0I

Trying to resubscribe the same track - MT82afc6724c8256c010be81f0885910cd

Using this request URL (POST)-
https://video.twilio.com/v1/Rooms/RMeaafa15fa712172d10a8786abafe9243/Participants/d2d62647-236d-4081-b853-6955ac05c028/SubscribedTracks
Using this payload -
Track=MT82afc6724c8256c010be81f0885910cd&Status=subscribe
Response - Empty

There was no subscribed event on the client side.
And the track did not start.

Subaccount - AC080e6e59515c35b8290399536fc59042

Twilio client-side logs https://cl.ly/460u3S3X2t45

Hi @anand-io ,

From analyzing the logs, it looks like the second Participant joins the Room with "audio" and "video" Tracks in ConnectOptions, and after joining the Room, it then publishes the "data" Track.

Tracks which are specified in ConnectOptions already have their corresponding RemoteTrackPublications present in the RemoteParticipant’s .trackPublications collection.
“trackPublished” events are emitted only for those Tracks which are published after joining the Room. So, it is recommended to iterate the .trackPublications collection of each new RemoteParticipant before listening to “trackPublished” events.

function onSubscribed(publication) {
  publication.on('subscribed', track => {
    console.log('Subscribed to Track:', track);
  });
}

room.on('participantConnected', participant => {
  // Since the RemoteParticipant joined with "audio" and "video"
  // Tracks, their corresponding RemoteTrackPublications
  // will already be present in the collection.
  participant.trackPublications.forEach(onSubscribed);  

  // Since the RemoteParticipant published the "data" Track
  // after joining the Room, a "trackPublished" event is
  // emitted with the corresponding RemoteTrackPublication.
  participant.on('trackPublished', onSubscribed);
});

I apologize for not making this clear in the migration guide. I'll make sure the documentation mentions
this behavior of the "trackPublished" event.

I'm still looking at the "subscribed" event issue you've raised. I should have something on it soon.

Thanks,

Manjesh Malavalli
JSDK Team

We have a exactly same problem, too.

Hi @anand-io ,

We have filed a bug regarding the issue with the subscription API behavior, and we will be looking at it in the coming sprint. We'll reach out to you as soon as we get to the bottom of it.

Thanks for bringing this to our notice.

Manjesh Malavalli
JSDK Team

Hi @anand-io , @jeehyukwon ,

FYI, we have scheduled the work to fix this issue in the ongoing sprint. Please watch this space for updates.

Thanks,

Manjesh Malavalli
JSDK Team

We are also waiting for a fix for this bug

@manjeshbhargav Will this bug be fixed in version 1.11?

Are there any updates on this issue?

We are experiencing the same problem and need it fixed ASAP.

Please help us Twilio! This is extremely critical for our business and has been damaging for our customers as well.

Hey @selvan, @jeehyukwon & @niccho123,

Are you guys asking for a fix for the early access Track Subscription REST API? @manjeshbhargav is working on that here: https://github.com/twilio/twilio-video.js/pull/330

To be clear, the "trackPublished" event is working as expected and we are not making any changes to this behavior, at least in 1.x.

Please let me know if y'all are waiting for the early access Track Subscription REST API fixes, or if you are still having trouble with the "trackPublished" event.

Thank you,
Mark

@markandrus

Not related to trackPublished, but inrelation to unsubscription bugs (using "track name" & "participant sid") we have experienced with server side "Track Subscription REST API".

Nice to know about Track Subscription REST API support being added to twilio-video.js

Thanks.

@anand-io , @selvan , @jeehyukwon , @niccho123 ,

[email protected] has been released. Now, "trackSubscribed" and "trackUnsubscribed" events are emitted on the RemoteParticipant when the REST API is used to subscribed to or unsubscribe from RemoteTracks.

Please let me know if this works for you.

Thanks,

Manjesh Malavalli
JSDK Team

@manjeshbhargav

Though able to receive "trackSubscribed" and "trackUnsubscribed" events emitted on a Room, track unsubscription among group of participants using "Track Subscription REST API" doesn't seem to work as expected for the following testcase scenario,

Testcase scenario:

Participants U1, U2, U3 and X join a room,

U1 unsubscribe to all tracks published by U2 and U3
U2 unsubscribe to all tracks published by U1 and U3
U3 unsubscribe to all tracks published by U1 and U2

After executing all required unsubscription calls, U1, U2 & U3 still have unwanted (previously unsubscribed) tracks apart from (only required) tracks of X.

Any thoughts?

Thanks.

Hi, we'd be interested in trying the early access Track Subscription features as well. Could you point us to any docs or steps to try it please?

Hi @embirico , @anand-io ,

You can access the docs for the Track Subscriptions REST API here.

Thanks,

Manjesh Malavalli
JSDK Team

Was this page helpful?
0 / 5 - 0 ratings