This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable multiple local video tracks per connection
This change introduces a standalone LocalVideoTrack object encapsulating a video track originating from the local peer and sent to the remote peer. This is an extension of the previously existing single local video track internally owned by the PeerConnection object, now existing as a standalone object. This change enables several new features and benefits: - The PeerConnection object now holds references to the LocalVideoTrack object, instead of owning it internally. This makes it possible to add multiple local video tracks per peer connection. - Interactions with the local video track, like enabling/disabling the track, is achieved by direct manipulation of the LocalVideoTrack object instance, without the need to know of nor keep a reference to the PeerConnection object the track may be attached to. - Looking forward, this extracting of the local video track, currently backed by a local video capture device, from the peer connection enables future changes to add new kinds of local video tracks backed by different track sources.
- Loading branch information
Showing
27 changed files
with
1,011 additions
and
369 deletions.
There are no files selected for viewing
This file contains 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
64 changes: 64 additions & 0 deletions
64
libs/Microsoft.MixedReality.WebRTC.Native/include/local_video_track.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include "api/mediastreaminterface.h" | ||
#include "api/peerconnectioninterface.h" | ||
#include "api/rtpsenderinterface.h" | ||
|
||
#include "callback.h" | ||
#include "interop/interop_api.h" | ||
#include "str.h" | ||
#include "video_frame_observer.h" | ||
|
||
namespace Microsoft::MixedReality::WebRTC { | ||
|
||
class PeerConnection; | ||
|
||
class LocalVideoTrack : public VideoFrameObserver, | ||
public rtc::RefCountInterface { | ||
public: | ||
LocalVideoTrack(PeerConnection& owner, | ||
rtc::scoped_refptr<webrtc::VideoTrackInterface> track, | ||
rtc::scoped_refptr<webrtc::RtpSenderInterface> sender, | ||
mrsLocalVideoTrackInteropHandle interop_handle) noexcept; | ||
MRS_API ~LocalVideoTrack() override; | ||
|
||
MRS_API [[nodiscard]] bool IsEnabled() const noexcept; | ||
MRS_API void SetEnabled(bool enabled) const noexcept; | ||
|
||
// | ||
// Advanced use | ||
// | ||
|
||
[[nodiscard]] webrtc::VideoTrackInterface* impl() const { | ||
return track_.get(); | ||
} | ||
|
||
[[nodiscard]] webrtc::RtpSenderInterface* sender() const { | ||
return sender_.get(); | ||
} | ||
|
||
[[nodiscard]] mrsLocalVideoTrackInteropHandle GetInteropHandle() const | ||
noexcept { | ||
return interop_handle_; | ||
} | ||
|
||
void RemoveFromPeerConnection(webrtc::PeerConnectionInterface& peer); | ||
|
||
private: | ||
/// PeerConnection object owning this track. | ||
PeerConnection* owner_{}; | ||
|
||
/// Underlying core implementation. | ||
rtc::scoped_refptr<webrtc::VideoTrackInterface> track_; | ||
|
||
/// RTP sender this track is associated with. | ||
rtc::scoped_refptr<webrtc::RtpSenderInterface> sender_; | ||
|
||
/// Optional interop handle, if associated with an interop wrapper. | ||
mrsLocalVideoTrackInteropHandle interop_handle_{}; | ||
}; | ||
|
||
} // namespace Microsoft::MixedReality::WebRTC |
This file contains 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
Oops, something went wrong.