-
Notifications
You must be signed in to change notification settings - Fork 85
Send updated offers to subscribers after publisher renegotiations #195
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
Merged
fancycode
merged 2 commits into
strukturag:master
from
danxuliu:send-updated-offers-to-subscribers-after-publisher-renegotiations
Feb 25, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -563,6 +563,34 @@ func (s *ClientSession) SetClient(client *Client) *Client { | |||
| return prev | ||||
| } | ||||
|
|
||||
| func (s *ClientSession) sendOffer(client McuClient, sender string, streamType string, offer map[string]interface{}) { | ||||
|
fancycode marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: de-duplicate with nextcloud-spreed-signaling/hub.go Line 1873 in d141775
|
||||
| offer_message := &AnswerOfferMessage{ | ||||
| To: s.PublicId(), | ||||
| From: sender, | ||||
| Type: "offer", | ||||
| RoomType: streamType, | ||||
| Payload: offer, | ||||
|
fancycode marked this conversation as resolved.
|
||||
| Update: true, | ||||
| } | ||||
| offer_data, err := json.Marshal(offer_message) | ||||
| if err != nil { | ||||
| log.Println("Could not serialize offer", offer_message, err) | ||||
| return | ||||
| } | ||||
| response_message := &ServerMessage{ | ||||
| Type: "message", | ||||
| Message: &MessageServerMessage{ | ||||
| Sender: &MessageServerMessageSender{ | ||||
| Type: "session", | ||||
| SessionId: sender, | ||||
| }, | ||||
| Data: (*json.RawMessage)(&offer_data), | ||||
| }, | ||||
| } | ||||
|
|
||||
| s.sendMessageUnlocked(response_message) | ||||
| } | ||||
|
|
||||
| func (s *ClientSession) sendCandidate(client McuClient, sender string, streamType string, candidate interface{}) { | ||||
| candidate_message := &AnswerOfferMessage{ | ||||
| To: s.PublicId(), | ||||
|
|
@@ -628,6 +656,18 @@ func (s *ClientSession) SendMessages(messages []*ServerMessage) bool { | |||
| return true | ||||
| } | ||||
|
|
||||
| func (s *ClientSession) OnUpdateOffer(client McuClient, offer map[string]interface{}) { | ||||
| s.mu.Lock() | ||||
| defer s.mu.Unlock() | ||||
|
|
||||
| for _, sub := range s.subscribers { | ||||
| if sub.Id() == client.Id() { | ||||
| s.sendOffer(client, sub.Publisher(), client.StreamType(), offer) | ||||
| return | ||||
| } | ||||
| } | ||||
| } | ||||
|
|
||||
| func (s *ClientSession) OnIceCandidate(client McuClient, candidate interface{}) { | ||||
| s.mu.Lock() | ||||
| defer s.mu.Unlock() | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the
Updatereally needed? A client knows if it already has a connection with another peer and can with that determine if it's an update or not. Or am I missing something?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.
If an RTCPeerConnection handles an offer that is not an update it will end failing, but depending on the implementation it can take up to 30 seconds to fail (and in some cases I think that I saw it getting stuck, but I am not 100% sure).
In general this should not happen, but as offers are periodically requested until a connection is established in some corner cases with delayed messages and flaky connections it could happen that an offer was requested and just before receiving it a new request was made. The original connection is established, but Janus closes it due to receiving the new offer request. However, in some cases the browser could keep the connection open, so when the new offer is received it would be handled by the existing connection, rather than immediately establishing a new one.
Due to this Talk's WebUI closes the previous connection and starts a new one when an offer for the same participant is received, and this is why it needs to differentiate between normal offers, which closes the connection and start a new one, and updated offers, which apply to the existing one.