@startuml
!include skin.inc

autonumber "#'.'"

participant "<i>Browser</i>" as bro #ffffff
participant "Application" as app 
participant "Server" as srv 

note over bro, srv:  Both parties are in a call already.

note right of app: User requests addition / \nremoval of video

app -->> bro: <i>Update PeerConnection, e.g. adding or removing video stream</i>
app -->> bro: <i>offerSdp=peerConnection.CreateOffer()</i>
app -->> bro: <i>peerConnection.SetLocalDescription(offer, offerSdp)</i>

app -> srv: PUT WrtcsOffer(sessionId, offerSdp)
srv --> app: Response 
note right of srv: pass on the offer
note right of srv: receive answer

alt Alternative 1: Terminating participant declines update
	srv -> app: POST or NOTIFY WrtcsEventNotification(Declined)
	app -->> bro: <i>peerConnection.SetLocalDescription(rollback, null)</i>

	note over bro, srv: Call goes ahead without modification.
else Alternative 2: Terminating participant accepts update
	srv -> app: POST or NOTIFY WrtcsAcceptanceNotification(answer, answerSdp)
	app -->> bro: <i>peerConnection.setRemoteDescription(answer, answerSdp)</i>

	bro -->> app: <i>oniceconnectionstatechange(new)</i>
	app -> srv: PUT WrtcsIceStatus(New)
	srv --> app: Response
	note over bro, srv: Running ICE connectivity checks (if applicable).

	bro -->> app: <i>oniceconnectionstatechange(connected)</i>
	app -> srv: PUT WrtcsIceStatus(Connected)
	srv --> app: Response

	note over bro, srv: Call goes ahead with modified media streams.
end
@enduml