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

Update the Unity library to handle split sources #404

Merged
merged 16 commits into from
Jun 16, 2020

Conversation

djee-ms
Copy link
Member

@djee-ms djee-ms commented Jun 8, 2020

Convert WebcamSource and MicrophoneSource to source objects shareable
among multiple peer connections.

Because the SceneVideoSender component uses the ARGB32 callback, also re-add
that callback, and add a TODO to remove all ARGB32 callbacks in favor of explicit
conversion utility functions, for clarity about the performance implication of the
conversion.

This change also splits the VideoChatDemo and SceneCaptureDemo for clarity,
leaving each demo with a single audio and video track per peer connection.
The SceneCaptureDemo now has a placeholder showing the capture camera
position. Multiple tracks per peer connection are demo-ed in the StandaloneDemo.

image

All demos are also updated to show essential components as Unity objects in the
scene, instead of adding multiple of them on the same GameObject. This helps with
discoverability.

image

Convert WebcamSource and MicrophoneSource to source objects shareable
among multiple peer connections.
@djee-ms djee-ms added enhancement New feature or request breaking change This change breaks the current API and requires migration labels Jun 8, 2020
@djee-ms djee-ms requested a review from fibann June 8, 2020 11:08
@djee-ms djee-ms self-assigned this Jun 8, 2020
Copy link
Member

@fibann fibann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some potential for hierarchy simplification + minor things to fix, see comments.

djee-ms added 4 commits June 10, 2020 14:34
- Split audio and video hierarchies
- Use base class VideoRendererSource for polymorphic serialization of
  the source of a VideoRenderer.
- Use interfaces for media types (audio or video), and serialize as
  MonoBehaviour. In the Unity UI, the concrete type used is always
  known, so we can override the UI and ensure proper filtering and
  selection mechanisms work as intended.
djee-ms added 4 commits June 11, 2020 14:30
Move OnEnable/OnDisable implementations into the concrete leaf classes
to flatten the track creation and destruction.
Merge the MediaSender and its derived classes AudioSender and
VideoSender into the MediaLine itself, since those classes contain very
few fields and the logic is entirely internal and managed by the
MediaLine object they are attached to.
@@ -61,17 +61,25 @@ protected override async void OnEnable()
}
#endif

protected override async Task CreateAudioTrackSourceAsyncImpl()
protected virtual async Task OnEnable()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why virtual?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why indeed ¯_(ツ)_/¯
I think that might have been an automated refactor removing the implementation in the base class, because I don't see why I'd have added that in a leaf class.
Also I just noted there are 2 implementations of OnEnable() now on UWP, will merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines 103 to 113
/// This value must comply with the 'msid' attribute rules as defined in
/// https://tools.ietf.org/html/draft-ietf-mmusic-msid-05#section-2, which in
/// particular constraints the set of allowed characters to those allowed for a
/// 'token' element as specified in https://tools.ietf.org/html/rfc4566#page-43:
/// - Symbols [!#$%'*+-.^_`{|}~] and ampersand &
/// - Alphanumerical characters [A-Za-z0-9]
///
/// Users can manually test if a string is a valid SDP token with the utility
/// method <see cref="SdpTokenAttribute.Validate(string, bool)"/>.
/// </remarks>
/// <seealso cref="SdpTokenAttribute.Validate(string, bool)"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we test that is a valid SDP token on set?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm is this done when assigning _senderTrackName?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_senderTrackName has the attribute, so this will make some error message appear when editing the field in the Unity editor if the SDP token is not valid. We can add some extra validation in the setter too for runtime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

@fibann fibann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor outstanding issues.

@djee-ms djee-ms merged commit 6601425 into microsoft:merge/split_source Jun 16, 2020
@djee-ms djee-ms deleted the split_source_unity branch June 16, 2020 14:39
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants