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

[MM-42737] Use stream ids instead of track ids #38

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions server/channel_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ type callStats struct {
}

type callState struct {
ID string `json:"id"`
StartAt int64 `json:"create_at"`
Users map[string]*userState `json:"users,omitempty"`
ThreadID string `json:"thread_id"`
ScreenSharingID string `json:"screen_sharing_id"`
ScreenTrackID string `json:"screen_track_id"`
ScreenAudioTrackID string `json:"screen_audio_track_id"`
Stats callStats `json:"stats"`
ID string `json:"id"`
StartAt int64 `json:"create_at"`
Users map[string]*userState `json:"users,omitempty"`
ThreadID string `json:"thread_id"`
ScreenSharingID string `json:"screen_sharing_id"`
ScreenStreamID string `json:"screen_stream_id"`
Stats callStats `json:"stats"`
}

type channelState struct {
Expand Down
3 changes: 1 addition & 2 deletions server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ func (p *Plugin) removeUserSession(userID, channelID string) (channelState, chan

if state.Call.ScreenSharingID == userID {
state.Call.ScreenSharingID = ""
state.Call.ScreenTrackID = ""
state.Call.ScreenAudioTrackID = ""
state.Call.ScreenStreamID = ""
if call := p.getCall(channelID); call != nil {
call.setScreenSession(nil)
}
Expand Down
8 changes: 4 additions & 4 deletions server/sfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (p *Plugin) initRTCConn(userID string) {
p.LogDebug(fmt.Sprintf("%+v", remoteTrack.Codec().RTPCodecCapability))
p.LogDebug(fmt.Sprintf("Track has started, of type %d: %s", remoteTrack.PayloadType(), remoteTrack.Codec().MimeType))

trackID := remoteTrack.ID()
streamID := remoteTrack.StreamID()
state, err := p.kvGetChannelState(userSession.channelID)
if err != nil {
p.LogError(err.Error())
Expand All @@ -367,7 +367,7 @@ func (p *Plugin) initRTCConn(userID string) {

if remoteTrack.Codec().MimeType == rtpAudioCodec.MimeType {
trackType := "voice"
if trackID != "" && trackID == state.Call.ScreenAudioTrackID {
if streamID == state.Call.ScreenStreamID {
p.LogDebug("received screen sharing audio track")
trackType = "screen-audio"
}
Expand Down Expand Up @@ -432,8 +432,8 @@ func (p *Plugin) initRTCConn(userID string) {

}
} else if remoteTrack.Codec().MimeType == rtpVideoCodecVP8.MimeType {
if trackID == "" || trackID != state.Call.ScreenTrackID {
p.LogError("received unexpected video track", "trackID", trackID)
if streamID != state.Call.ScreenStreamID {
p.LogError("received unexpected video track", "streamID", streamID, "ScreenStreamID", state.Call.ScreenStreamID)
return
}

Expand Down
6 changes: 2 additions & 4 deletions server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ func (p *Plugin) handleClientMessageTypeScreen(msg clientMessage, channelID, use
return nil, fmt.Errorf("cannot start screen sharing, someone else is sharing already: %q", state.Call.ScreenSharingID)
}
state.Call.ScreenSharingID = userID
state.Call.ScreenTrackID = data["screenTrackID"]
state.Call.ScreenAudioTrackID = data["screenAudioTrackID"]
state.Call.ScreenStreamID = data["screenStreamID"]
} else {
if state.Call.ScreenSharingID != userID {
return nil, fmt.Errorf("cannot stop screen sharing, someone else is sharing already: %q", state.Call.ScreenSharingID)
}
state.Call.ScreenSharingID = ""
state.Call.ScreenTrackID = ""
state.Call.ScreenAudioTrackID = ""
state.Call.ScreenStreamID = ""
if call := p.getCall(channelID); call != nil {
call.setScreenSession(nil)
}
Expand Down
3 changes: 1 addition & 2 deletions webapp/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ export default class CallsClient extends EventEmitter {

this.ws.send('screen_on', {
data: JSON.stringify({
screenTrackID: screenTrack.id,
screenAudioTrackID: screenAudioTrack?.id,
screenStreamID: screenStream.id,
}),
});
}
Expand Down