instrumentisto/medea

Add/delete endpoints to/from already interconnected members

Opened this issue · 1 comments

Summary

When we trying to create interconnected Endpoints for Members which already interconnected, panic will be throwed with PeerError::WrongState error.

Also if we delete some Endpoint from interconnected Members they Peers will be removed even if some interconnected Endpoints still exists. This is related bug because we can fix it with Event::TracksRemoved. Steps to reproduce for this bug will be in discussion to this issue.

Steps to reproduce

  1. Create room with this spec:
kind: Room
id: pub-sub-video-call
spec:
  pipeline:
    caller:
      kind: Member
      credentials: test
      spec:
        pipeline:
          publish:
            kind: WebRtcPublishEndpoint
            spec:
              p2p: Always
    responder:
      kind: Member
      credentials: test
      spec:
        pipeline:
          play:
            kind: WebRtcPlayEndpoint
            spec:
              src: "local://pub-sub-video-call/caller/publish"
  1. Start call for responder and caller
  2. Add WebRtcPublishEndpoint to responder:
id: publish
kind: WebRtcPublishEndpoint
spec:
  p2p: Always
  1. Add WebRtcPlayEndpoint to caller:
id: play
kind: WebRtcPlayEndpoint
spec:
  src: "local://pub-sub-video-call/responder/publish"

What is the current bug behavior?

Panic with PeerError::WrongState error should be thrown.

What is the expected correct behavior?

New MediaTrack should be applied to the caller and responder.

Relevant logs and/or screenshots

This panic you may find in medea::signalling::room::Room::connect_endpoints.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PeerError(WrongState(PeerId(1), "New", "Stable"))', src/libcore/result.rs:1084:5

Possible fixes

Implementation of Event::TracksApplied and Event::TracksRemoved should fix this bug.

Steps to reproduce for deleting Endpoint from already interconnected Members

  1. Create Room with this spec:
kind: Room
id: pub-pub-video-call
spec:
  pipeline:
    caller:
      kind: Member
      credentials: test
      spec:
        pipeline:
          publish:
            kind: WebRtcPublishEndpoint
            spec:
              p2p: Always
          play-responder:
            kind: WebRtcPlayEndpoint
            spec:
              src: "local://pub-pub-video-call/responder/publish"
    responder:
      kind: Member
      credentials: test
      spec:
        pipeline:
          publish:
            kind: WebRtcPublishEndpoint
            spec:
              p2p: Always
          play-caller:
            kind: WebRtcPlayEndpoint
            spec:
              src: "local://pub-pub-video-call/caller/publish"
  1. Connect caller and responder
  2. Delete local://pub-pub-video-call/caller/play-responder endpoint

What is the current bug behavior?

Peers between caller and responder will be deleted.

What is the expected correct behavior?

Only some MediaTracks should be deleted from Peers with Event::TracksRemoved.