Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions Runtime/Scripts/MediaStreamTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
namespace Unity.WebRTC
{
/// <summary>
///
/// Represents a single media track within a stream.
/// </summary>
/// <remarks>
/// `MediaStreamTrack` represents a single media track within a stream.
/// Typically, these are audio or video tracks, but other track types may exist as well.
/// Each track is associated with a `MediaStream` object.
/// </remarks>
/// <example>
/// <code lang="cs"><![CDATA[
/// IEnumerable<MediaStreamTrack> mediaStreamTracks = mediaStream.GetTracks();
/// ]]></code>
/// </example>
/// <seealso cref="MediaStream"/>
public class MediaStreamTrack : RefCountedObject
{
/// <summary>
///
/// Boolean value that indicates whether the track is allowed to render the source stream.
/// </summary>
/// <remarks>
/// When the value is `true`, a track's data is output from the source to the destination; otherwise, empty frames are output.
/// </remarks>
public bool Enabled
{
get
Expand All @@ -24,19 +38,19 @@ public bool Enabled
}

/// <summary>
///
/// TrackState value that describes the status of the track.
/// </summary>
public TrackState ReadyState =>
NativeMethods.MediaStreamTrackGetReadyState(GetSelfOrThrow());

/// <summary>
///
/// TrackKind value that describes the type of media for the track.
/// </summary>
public TrackKind Kind =>
NativeMethods.MediaStreamTrackGetKind(GetSelfOrThrow());

/// <summary>
///
/// String containing a unique identifier (GUID) for the track.
/// </summary>
public string Id =>
NativeMethods.MediaStreamTrackGetID(GetSelfOrThrow()).AsAnsiStringWithFreeMem();
Expand All @@ -47,16 +61,27 @@ internal MediaStreamTrack(IntPtr ptr) : base(ptr)
}

/// <summary>
///
/// Finalizer for MediaStreamTrack.
/// </summary>
/// <remarks>
/// Ensures that resources are released by calling the `Dispose` method
/// </remarks>
~MediaStreamTrack()
{
this.Dispose();
}

/// <summary>
///
/// Disposes of MediaStreamTrack.
/// </summary>
/// <remarks>
/// `Dispose` method disposes of the `MediaStreamTrack` and releases the associated resources.
/// </remarks>
/// <example>
/// <code lang="cs"><![CDATA[
/// mediaStreamTrack.Dispose();
/// ]]></code>
/// </example>
public override void Dispose()
{
if (this.disposed)
Expand All @@ -72,8 +97,16 @@ public override void Dispose()
}

/// <summary>
/// Disassociate track from its source(video or audio), not for destroying the track
/// Stops the track.
/// </summary>
/// <remarks>
/// `Stop` method disassociates the track from its source (video or audio) without destroying the track.
/// </remarks>
/// <example>
/// <code lang="cs"><![CDATA[
/// mediaStreamTrack.Stop();
/// ]]></code>
/// </example>
public void Stop()
{
WebRTC.Context.StopMediaStreamTrack(GetSelfOrThrow());
Expand Down