-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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(multi-stream-support) Add track streaming status #1855
Conversation
Hi, thanks for your contribution! |
modules/RTC/TrackStreamingStatus.js
Outdated
RTCEvents.REMOTE_TRACK_UNMUTE, | ||
this._onTrackRtcUnmuted); | ||
|
||
this.track.off( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to handle the JitsiConferenceEvents.TRACK_REMOVED
event has been moved into the dispose
method of this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when a track is removed this instance will be disposed anyway, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will double check to confirm if that is true. If not, I can dispose it where we are emitting JitsiConferenceEvents.TRACK_REMOVED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I saw any logic in LJM that called dispose
when a tracked was removed. I wasn't sure if this is intended so I added logic to clear _trackStreamingStatusImpl
and _trackStreamingStatus
where the event was emitted
modules/RTC/TrackStreamingStatus.js
Outdated
* @param {Array<string>} enteringForwardedSources - The array of sourceName entering forwarded sources. | ||
* @private | ||
*/ | ||
_onForwardedSourcesChanged(leavingForwardedSources = [], enteringForwardedSources = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work as I expect it to. I'll need to move this logic somewhere else, perhaps JitsiConferenceEventManager
, and have it iterate through all the leaving and entering forwarded sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah because the timestamps will not be accurate since this instance may disappear. Lets try to think about it... Maybe we need to store the timestamps somewhere (the place which emits the forwarded sources changed event) and then expose that via a getter? Or better have a static part/helper class of TrackStreamingStatus
which would keep track of the timestamps (mostly because they are not used by any other logic) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking into using a static method/helper class and it was starting to get a bit messy since it would still need to call Never mind, we still have the issue of losing this timestamp when the instance disappearsfigureOutStreamingStatus
for each instances that is leaving/entering or when !browser.supportsVideoMuteOnConnInterrupted()
. If our only concern is having inaccurate timestamps and performance isn't an issue, can we just emit the timestamp with the forwarded sources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually make it so that the JitsiRemoteTrack
holds the timestamps when it entered/left the forwarded sources and this can happen any time the RTC
module emits the forwarded sources event?
modules/RTC/TrackStreamingStatus.js
Outdated
RTCEvents.REMOTE_TRACK_UNMUTE, | ||
this._onTrackRtcUnmuted); | ||
|
||
this.track.off( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when a track is removed this instance will be disposed anyway, right?
modules/RTC/TrackStreamingStatus.js
Outdated
* @param {Array<string>} enteringForwardedSources - The array of sourceName entering forwarded sources. | ||
* @private | ||
*/ | ||
_onForwardedSourcesChanged(leavingForwardedSources = [], enteringForwardedSources = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah because the timestamps will not be accurate since this instance may disappear. Lets try to think about it... Maybe we need to store the timestamps somewhere (the place which emits the forwarded sources changed event) and then expose that via a getter? Or better have a static part/helper class of TrackStreamingStatus
which would keep track of the timestamps (mostly because they are not used by any other logic) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @WillLiang918. Left few minor comments. One complaint that I have is there is a lot of code duplication.
f0e42e4
to
4063d1e
Compare
f1cc437
to
906cd6f
Compare
modules/RTC/TrackStreamingStatus.js
Outdated
* @param {Array<string>} enteringForwardedSources - The array of sourceName entering forwarded sources. | ||
* @private | ||
*/ | ||
_onForwardedSourcesChanged(leavingForwardedSources = [], enteringForwardedSources = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually make it so that the JitsiRemoteTrack
holds the timestamps when it entered/left the forwarded sources and this can happen any time the RTC
module emits the forwarded sources event?
906cd6f
to
d3902e1
Compare
Jenkins please add to whitelist |
Jenkins test this please. |
fb7b47f
to
8f30a79
Compare
JitsiConferenceEvents.js
Outdated
* @param {Array<string>|null} enteringForwardedSources the sourceNames of all the tracks which are entering forwarded | ||
* sources | ||
*/ | ||
export const FORWARDED_SOURCES_CHANGED = 'conference.forwardedSourcesChanged'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I wasn't paying attention to this earlier, but we need to add a getter to JitsiConference.getForwardedSources()
, so that a LJM user can get the current state without having to register the even listener from the start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it does make sense to allow us to access the current forwarded sources state without having to register a listener. Is this more of a best practice to expose this on the conference do you see an optimization we can make?
JitsiTrackEvents.js
Outdated
@@ -43,3 +43,16 @@ export const NO_DATA_FROM_SOURCE = 'track.no_data_from_source'; | |||
* the microphone that is currently selected. | |||
*/ | |||
export const NO_AUDIO_INPUT = 'track.no_audio_input'; | |||
|
|||
/** | |||
* Event fired when we detect local problem with the video track. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets reword it to Event fired whenever video track's streaming changes
import Statistics from '../statistics/statistics'; | ||
|
||
/** Track streaming statuses. */ | ||
type TrackStreamingStatus = 'active' | 'inactive' | 'interrupted' | 'restoring'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this an enum
and not have the TrackStreamingStatusMapType
?
modules/RTC/JitsiRemoteTrack.js
Outdated
/** | ||
* @returns {Boolean} Whether this is a muted video track. | ||
*/ | ||
isVideoMuted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this method? In place where it's used it should be enough to check isMuted()
modules/RTC/JitsiRemoteTrack.js
Outdated
/** | ||
* Disposes trackStreamingStatusImpl and clears trackStreamingStatus | ||
*/ | ||
disposeTrackStreamingStatus() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add underscore to this method's name? JitsiRemoteTrack
is exported by lib-jitsi-meet and this would look like a public method
modules/RTC/JitsiRemoteTrack.js
Outdated
/** | ||
* Clears the timestamp of when the track entered forwarded sources. | ||
*/ | ||
clearEnteredForwardedSourcesTimestamp() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add _
modules/RTC/JitsiRemoteTrack.js
Outdated
* | ||
* @param {number} timestamp the time in millis | ||
*/ | ||
setEnteredForwardedSourcesTimestamp(timestamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add _
modules/RTC/JitsiRemoteTrack.js
Outdated
* | ||
* @returns {number} the time in millis | ||
*/ | ||
getEnteredForwardedSourcesTimestamp() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add _
[key: string]: TrackStreamingStatus | ||
} | ||
|
||
type VideoType = 'camera' | 'desktop'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a place outside of TrackStreamingStatus
where this type can be defined? Maybe create a dedicated .ts
file? If that's too much work please mark this with a TODO comment that it should be removed from here once service/RTC/VideoType.js
is converted to type script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we import VideoType from service/RTC/VideoType.js here directly ?
ETA: What I meant was that we already have auto-generated type for VideoType. Can we use that instead of defining it here again ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely can! I found that type after Pawel pointed this out. I'll push another set of changes out shortly after testing it locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait do you mean the VideoType enum in types/hand-crafted/services/RTC/VideoType.d.ts or the VideoType object in VideoType.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to take a quick look to see if we can do something similar to the recent changes to /JitsiConferenceEvents.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to revert my changes and adding a TODO to use the VideoType enum in https://github.com/jitsi/lib-jitsi-meet/pull/1916/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry had to take half day off yesterday and was away. Yes, I was talking about VideoType from hand-crafted dir. It makes sense to use the VideoType enum from the newly created TS files after they get merged.
*/ | ||
const DEFAULT_RESTORING_TIMEOUT = 10000; | ||
|
||
export const TrackStreamingStatusMap: TrackStreamingStatusMapType = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per the other comment, if TrackStreamingStatusMapType
was replace with TrackStreamingStatus
enum
, will it be possible to get rid of this map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another look into this. I think I was having issues when I first tried it because TrackStreamingStatusMap
was being imported into non .ts
files where enum
s aren't supported
update JitsiRemoteTrack to init and dispose TrackStreamingStatus stop emitting LASTN_ENDPOINT_CHANGED event when source name signaling is enabled convert TrackStreamingStatus class to typescript
fc658c1
to
bc20d78
Compare
bc20d78
to
0bd5c53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's looking good! Left just one comment about JS docs
This change allow us handle the streaming status of each individual track when the feature flag is enabled. The emitted streaming status is mostly used for the connection indicator in the UI.
Related jitsi-meet PR: jitsi/jitsi-meet#10934
Todo/Follow up item:
TrackStreamingStatus#onForwardedSourcesChanged
logic out intoRTC#_onForwardedSourcesChanged
. The reason being is that since TrackStreamingStatus is only initialized when a track is rendered, there is a corner case where we are not capturing the timestamp of when it entered forwarded sources.