Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Add standalone media track objects #152

Closed
djee-ms opened this issue Dec 18, 2019 · 0 comments · Fixed by #283
Closed

Add standalone media track objects #152

djee-ms opened this issue Dec 18, 2019 · 0 comments · Fixed by #283
Assignees
Labels
breaking change This change breaks the current API and requires migration enhancement New feature or request multitrack Issues related to multi-track support
Milestone

Comments

@djee-ms
Copy link
Member

djee-ms commented Dec 18, 2019

Currently in 1.0 the PeerConnection object supports a single local/remote audio/video track (so 4 in total). This corresponds to the simple video chat use case of a single A/V feed sent and received. In master a standalone LocalVideoTrack object has been added, and with it the ability to open multiple local video tracks per peer connection (see #35). However because a single remote video track is supported, there is currently no way to receive multiple video tracks on the remote peer. And for audio multi-tracks is simply not supported by a single peer connection (multiple connections can be used as a workaround).

This feature introduces some standalone media tracks for all 4 categories of local/remote audio/video tracks, to effectively enable multi-track support per peer connection.

@djee-ms djee-ms added the enhancement New feature or request label Dec 18, 2019
@djee-ms djee-ms added this to the 2.0.0 milestone Dec 18, 2019
@djee-ms djee-ms self-assigned this Dec 18, 2019
@djee-ms djee-ms mentioned this issue Dec 26, 2019
22 tasks
djee-ms added a commit that referenced this issue Jan 9, 2020
Fix the documentation and README.md to clarify that in 1.0 the
PeerConnection supports a single audio/video track per instance, and
multiple instances need to be used for sending/receiving more.

The support of multi-track per instance is tracked by issue #152.
djee-ms added a commit to djee-ms/MixedReality-WebRTC that referenced this issue Feb 26, 2020
This is part 1/N of the change, see global description below

----

Add standalone media track objects in both the C++ and C# library.
This enables supporting multiple audio and video tracks per peer
connection.

For local tracks, the `PeerConnection` interface is updated such that
the functionality of `AddLocalAudioTrackAsync()` and
`AddLocalVideoTrackAsync()` is split in 2 steps:

- the creation step, whose interface is on the local track object
itself, creates a standalone track object not associated with any peer
connection and not currently used by anything.

- the association step, which takes the track and attach it to a peer
connection via a transceiver.

For remote tracks, the `TrackAdded` and `TrackRemoved` events now
generate a new remote track object, which is passed to the event handler
as argument. The C# `PeerConnection` object also now keeps a list of all
the tracks attached to it, which can therefore be enumerated.

Because tracks are standalone objects, methods like
`PeerConnection.SetLocalAudioTrackEnabled()` are replaced with a
property `LocalAudioTrack.Enabled`, providing a more familiar pattern to
C# developers.

One important change required for remote tracks to be
paired by name is removing the legacy options
`RTCOfferAnswerOptions::offer_to_receive_video = true` and
`RTCOfferAnswerOptions::offer_to_receive_audio = true` from
`CreateOffer()` and `CreateAnswer()`. This change (see microsoft#75) has larger
implications that it looks when using Unified Plan (default), as
previously those options were implicitly making an offer to receive some
media, whereas this step is now explicit and the user needs to add some
transceiver in receive-only or send-receive mode before making an
offer/answer to allow the remote peer to send.

A new Unity demo `StandaloneDemo` shows how to use multiple tracks
between two peers. The demo is standalone in the sense signaling is
hard-coded and does not require an external node-dss server or any other
signaling solution.

Bug: microsoft#152
@djee-ms djee-ms linked a pull request Feb 26, 2020 that will close this issue
@djee-ms djee-ms removed a link to a pull request Feb 26, 2020
djee-ms added a commit that referenced this issue Mar 4, 2020
This is part 1/N of the change, see global description below

----

Add standalone media track objects in both the C++ and C# library.
This enables supporting multiple audio and video tracks per peer
connection.

For local tracks, the `PeerConnection` interface is updated such that
the functionality of `AddLocalAudioTrackAsync()` and
`AddLocalVideoTrackAsync()` is split in 2 steps:

- the creation step, whose interface is on the local track object
itself, creates a standalone track object not associated with any peer
connection and not currently used by anything.

- the association step, which takes the track and attach it to a peer
connection via a transceiver.

For remote tracks, the `TrackAdded` and `TrackRemoved` events now
generate a new remote track object, which is passed to the event handler
as argument. The C# `PeerConnection` object also now keeps a list of all
the tracks attached to it, which can therefore be enumerated.

Because tracks are standalone objects, methods like
`PeerConnection.SetLocalAudioTrackEnabled()` are replaced with a
property `LocalAudioTrack.Enabled`, providing a more familiar pattern to
C# developers.

One important change required for remote tracks to be
paired by name is removing the legacy options
`RTCOfferAnswerOptions::offer_to_receive_video = true` and
`RTCOfferAnswerOptions::offer_to_receive_audio = true` from
`CreateOffer()` and `CreateAnswer()`. This change (see #75) has larger
implications that it looks when using Unified Plan (default), as
previously those options were implicitly making an offer to receive some
media, whereas this step is now explicit and the user needs to add some
transceiver in receive-only or send-receive mode before making an
offer/answer to allow the remote peer to send.

A new Unity demo `StandaloneDemo` shows how to use multiple tracks
between two peers. The demo is standalone in the sense signaling is
hard-coded and does not require an external node-dss server or any other
signaling solution.

Bug: #152
djee-ms added a commit that referenced this issue Mar 30, 2020
Update the Unity tutorial in the documentation to reflect the latest API
changes introduced by the multi-track work (#152).

This change does not update the C++ and C# library documentations. This will be
done in a future change.

In addition, rename the CreateOffer() and SetRemoteDescriptionAsync() methods
of the PeerConnection Unity component to StartConnection() and
HandleConnectionMessageAsync(), respectively. This disambiguates them from the
methods of the PeerConnection class in the C# library, in an effort to
highlight that the former ones perform more work than the latter ones.
@djee-ms djee-ms added multitrack Issues related to multi-track support breaking change This change breaks the current API and requires migration labels Apr 14, 2020
@djee-ms djee-ms linked a pull request Apr 16, 2020 that will close this issue
djee-ms added a commit that referenced this issue Apr 21, 2020
Add support for multiple audio and video tracks per peer connection.

This change introduces a new transceiver API closely related to the same-named
concept in the WebRTC 1.0 standard. The transceiver API allows the user to add
audio and video transceivers to a peer connection, then optionally associate
some local track to send some media through those transceivers and/or receive
some media from the remote peer via a remote track associated with the
transceiver. The new API is more flexible and more powerful, offering more
control to the user and opening up many use cases not previously available, at
the expense of some moderately increased complexity. In particular it allows:
- multiple audio and video tracks per peer connection, limited only by the
  bandwidth
- hot-swapping a track for another track without a renegotiation, dramatically
  reducing the delay of replacing a track with another one (e.g.  switching to
  "on hold" music instead of voice chat)
- "track warm up" (getting a track transport ready even before the track media
  is available) and more aggressive media transport establishing (callee peer
  can start sending media to caller peer earlier than before)

This change constitutes a major API breaking change, which moves tracks
management away from the PeerConnection object to the new Transceiver object.
Users are encouraged to read the migration guide associated with this change to
migrate existing v1.0-style applications. In particular, understanding the
functioning of transceivers and the asymmetrical role of the caller peer (the
peer initiating a session with a new offer) and the callee peer (the peer
responding to a remote offer) are critical to be able to use this new API
correctly.

Bug: #144, #152
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This change breaks the current API and requires migration enhancement New feature or request multitrack Issues related to multi-track support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant