Skip to main content
Version: 1.x

Class MediaStream

Base stream

Declaration
public abstract class MediaStream : IDisposable

Derived:
OdinNative.Odin.Media.MicrophoneStream, OdinNative.Odin.Media.PlaybackStream

Implements:
Global.IDisposable

Properties​

Id​

Handle ID

Declaration
public long Id { get; }

MediaConfig​

Audio config of the media stream

Declaration
public OdinMediaConfig MediaConfig { get; }

CancellationSource​

Control of async read and write tasks

Declaration
public CancellationTokenSource CancellationSource { get; }

IsActive​

Indicates wether or not the media stream is active and sending/receiving data

Declaration
public bool IsActive { get; }

HasErrors​

Indicates wether or not the last media stream api call result is an error code

Declaration
public bool HasErrors { get; }

IsInvalid​

Indicates wether or not the media stream handle is invalid or closed

Declaration
public bool IsInvalid { get; }

Methods​

GetMediaId()​

Returns the media stream ID and updates OdinNative.Odin.Media.MediaStream.Id.

Declaration
public ushort GetMediaId()
Returns​

System.UInt16: id value### GetPeerId() Returns the ID of the peer that own this media stream.

Declaration
public ulong GetPeerId()
Returns​

System.UInt64: id### AudioPushData(float[], int) Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.

Declaration
public virtual void AudioPushData(float[] buffer, int length)
Parameters​
TypeNameDescription
System.Single[]bufferaudio data
System.Int32lengthbytes to write

AudioPushData(float[])​

Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.

Declaration
public virtual void AudioPushData(float[] buffer)
Parameters​
TypeNameDescription
System.Single[]bufferaudio data

AudioPushDataTask(float[], CancellationToken)​

Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.

Declaration
public virtual Task AudioPushDataTask(float[] buffer, CancellationToken cancellationToken)
Returns​

Global.Task

Parameters​
TypeNameDescription
System.Single[]bufferinterleaved audio data
Global.CancellationTokencancellationToken

AudioPushDataAsync(float[])​

Sends audio data using a custom OdinNative.Odin.Media.MediaStream.CancellationSource. The data has to be interleaved [-1, 1] float data.

Declaration
public virtual void AudioPushDataAsync(float[] buffer)
Parameters​
TypeNameDescription
System.Single[]bufferinterleaved audio data

AudioReset()​

Declaration
public abstract bool AudioReset()
Returns​

System.Boolean

AudioReadData(float[])​

Reads data from the audio stream.

Declaration
public virtual uint AudioReadData(float[] buffer)
Returns​

System.UInt32: count of written bytes into buffer

Parameters​
TypeNameDescription
System.Single[]bufferbuffer to write into

AudioStats(out OdinAudioStreamStats)​

Retrieves statistics for the specified OdinNative.Odin.Media.MediaStream.

Declaration
public virtual bool AudioStats(out NativeBindings.OdinAudioStreamStats stats)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
OdinNative.Core.Imports.NativeBindings.OdinAudioStreamStatsstatsAudio stream statistics

AudioReadData(float[], int)​

Reads data from the audio stream.

Declaration
public virtual uint AudioReadData(float[] buffer, int length)
Returns​

System.UInt32: count of written bytes into buffer

Parameters​
TypeNameDescription
System.Single[]bufferbuffer to write into
System.Int32lengthbytes to read

AudioReadDataTask(float[], CancellationToken)​

Reads data from the audio stream.

Declaration
public virtual Task<uint> AudioReadDataTask(float[] buffer, CancellationToken cancellationToken)
Returns​

Global.Task<System.UInt32>: count of written bytes into buffer

Parameters​
TypeNameDescription
System.Single[]bufferbuffer to write into
Global.CancellationTokencancellationToken

AudioReadDataAsync(float[])​

Read audio data using a custom custom OdinNative.Odin.Media.MediaStream.CancellationSource.

Declaration
public virtual Task<uint> AudioReadDataAsync(float[] buffer)
Returns​

Global.Task<System.UInt32>: count of written bytes into buffer

Parameters​
TypeNameDescription
System.Single[]bufferbuffer to write into

AudioResample(float[], uint, out float[], out int)​

Set a resampler and resamples a chunk of audio.

Declaration
public virtual bool AudioResample(float[] input, uint outputSampleRate, out float[] output, out int capacity)
Returns​

System.Boolean: true on success or false if missmatch of capacity i.e. errorcode

Parameters​
TypeNameDescription
System.Single[]inputcurrent buffer
System.UInt32outputSampleRateresample samplerate
System.Single[]outputresampled buffer
System.Int32capacitysize of resampled buffer

AudioResample(float[], uint, float[], int)​

Set a resampler and resamples a chunk of audio.

Declaration
public virtual uint AudioResample(float[] input, uint outputSampleRate, float[] output, int capacity)
Returns​

System.UInt32: sample count on success or errorcode on failure

Parameters​
TypeNameDescription
System.Single[]inputsource buffer
System.UInt32outputSampleRateto samplerate
System.Single[]outputtarget buffer
System.Int32capacitytarget capacity

Cancel()​

Cancel the custom OdinNative.Odin.Media.MediaStream.CancellationSource.

Declaration
public bool Cancel()
Returns​

System.Boolean: true if the token was canceled or false### ToString() Debug

Declaration
public override string ToString()
Returns​

System.String: info### Dispose(bool) On dispose will free the stream and resampler

Declaration
protected virtual void Dispose(bool disposing)
Parameters​
TypeName
System.Booleandisposing

~MediaStream()​

Default deconstructor

Declaration
protected ~MediaStream()

Dispose()​

On dispose will free the stream and resampler

Declaration
public void Dispose()

Implements​

  • Global.IDisposable