docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AudioStreamTrack

    Represents a single audio track within a stream.

    Inheritance
    object
    RefCountedObject
    MediaStreamTrack
    AudioStreamTrack
    Implements
    IDisposable
    Inherited Members
    MediaStreamTrack.Enabled
    MediaStreamTrack.ReadyState
    MediaStreamTrack.Kind
    MediaStreamTrack.Id
    MediaStreamTrack.Stop()
    RefCountedObject.disposed
    Namespace: Unity.WebRTC
    Assembly: Unity.WebRTC.dll
    Syntax
    public class AudioStreamTrack : MediaStreamTrack, IDisposable
    Remarks

    AudioStreamTrack is a MediaStreamTrack that represents a single audio track within a stream.

    Examples
    AudioStreamTrack audioStreamTrack = new AudioStreamTrack(texture);

    Constructors

    AudioStreamTrack()

    Creates a new AudioStreamTrack object.

    Declaration
    public AudioStreamTrack()
    Remarks

    AudioStreamTrack constructor creates an instance of AudioStreamTrack.

    Examples
    AudioStreamTrack audioStreamTrack = new AudioStreamTrack();
    See Also
    MediaStreamTrack
    WebRTC

    AudioStreamTrack(AudioListener)

    Creates a new AudioStreamTrack object.

    Declaration
    public AudioStreamTrack(AudioListener listener)
    Parameters
    Type Name Description
    AudioListener listener

    AudioListener object.

    Remarks

    AudioStreamTrack constructor creates an instance of AudioStreamTrack with a listener.

    Examples
    AudioStreamTrack audioStreamTrack = new AudioStreamTrack(listener);
    See Also
    MediaStreamTrack
    WebRTC

    AudioStreamTrack(AudioSource)

    Creates a new AudioStreamTrack object.

    Declaration
    public AudioStreamTrack(AudioSource source)
    Parameters
    Type Name Description
    AudioSource source

    AudioSource object.

    Remarks

    AudioStreamTrack constructor creates an instance of AudioStreamTrack with a source.

    Examples
    AudioStreamTrack audioStreamTrack = new AudioStreamTrack(source);
    See Also
    MediaStreamTrack
    WebRTC

    Properties

    Loopback

    This flag only works on sender side track. If True, Send audio input to remote and Play audio in local. If False, only send to remote. Not play audio in local.

    Declaration
    public bool Loopback { get; set; }
    Property Value
    Type Description
    bool
    See Also
    MediaStreamTrack
    WebRTC

    Source

    AudioSource object.

    Declaration
    public AudioSource Source { get; }
    Property Value
    Type Description
    AudioSource
    See Also
    MediaStreamTrack
    WebRTC

    Methods

    Dispose()

    Disposes of AudioStreamTrack.

    Declaration
    public override void Dispose()
    Overrides
    MediaStreamTrack.Dispose()
    Remarks

    Dispose method disposes of the AudioStreamTrack and releases the associated resources.

    Examples
    audioStreamTrack.Dispose();
    See Also
    MediaStreamTrack
    WebRTC

    SetData(float[], int, int)

    Provides the audio data to the track.

    Declaration
    public void SetData(float[] array, int channels, int sampleRate)
    Parameters
    Type Name Description
    float[] array

    Float array containing audio data samples.

    int channels

    Number of audio channels.

    int sampleRate

    Sample rate of the audio data

    Remarks

    SetData method provides the audio data to the track.

    Examples
    audioStreamTrack.SetData(array, channels, sampleRate);
    See Also
    MediaStreamTrack
    WebRTC

    SetData(ReadOnly, int, int)

    Declaration
    public void SetData(NativeArray<float>.ReadOnly nativeArray, int channels, int sampleRate)
    Parameters
    Type Name Description
    NativeArray<float>.ReadOnly nativeArray
    int channels
    int sampleRate
    See Also
    MediaStreamTrack
    WebRTC

    SetData(NativeSlice<float>, int, int)

    Declaration
    public void SetData(NativeSlice<float> nativeSlice, int channels, int sampleRate)
    Parameters
    Type Name Description
    NativeSlice<float> nativeSlice
    int channels
    int sampleRate
    See Also
    MediaStreamTrack
    WebRTC

    Events

    onReceived

    Event to be fired when new audio data is received.

    Declaration
    public event AudioReadEventHandler onReceived
    Event Type
    Type Description
    AudioReadEventHandler
    Remarks

    onReceived event is fired when new audio data is received.

    Examples
    audioStreamTrack.onReceived += (data, channels, sampleRate) =>
    {
    }
    See Also
    AudioReadEventHandler

    Implements

    IDisposable

    See Also

    MediaStreamTrack
    WebRTC
    In This Article
    • Constructors
      • AudioStreamTrack()
      • AudioStreamTrack(AudioListener)
      • AudioStreamTrack(AudioSource)
    • Properties
      • Loopback
      • Source
    • Methods
      • Dispose()
      • SetData(float[], int, int)
      • SetData(ReadOnly, int, int)
      • SetData(NativeSlice<float>, int, int)
    • Events
      • onReceived
    • Implements
    • See Also
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)