Class OdinEncoder
Freestanding encoder component that captures audio from an OdinNative.Unity.OdinEncoder.AudioProvider and sends it to an OdinNative.Unity.OdinRoom.
Place this anywhere in the scene. Assign OdinNative.Unity.OdinEncoder.Room and optionally an OdinNative.Unity.OdinEncoder.AudioProvider
(OdinNative.Unity.Audio.OdinMicrophoneReader or OdinNative.Unity.Audio.OdinAudioReader). Audio can also be pushed manually
via OdinNative.Unity.OdinEncoder.PushAudio(System.Single[],System.Int32,System.Boolean) wired through an Inspector UnityEvent or called directly.
Default behaviour:
- OdinNative.Unity.OdinEncoder.CreateEncoder()Called automatically when the room is joined
OdinNative.Unity.OdinEncoder.PushAudio(System.Single[],System.Int32,System.Boolean)Subscribed to OdinNative.Unity.OdinEncoder.AudioProviderOnAudioDatawhen set
Inheritance: System.Object -> UnityEngine.Object -> UnityEngine.Component -> UnityEngine.Behaviour -> UnityEngine.MonoBehaviour
Implements:
OdinNative.Wrapper.Media.IMedia
Properties
Id
Odin media id
Encoder
The owned OdinNative.Wrapper.MediaEncoder
ChannelMask
Position
Parent
The local peer this encoder sends audio as. Set when the encoder is linked to a room.
Fields
Room
The OdinNative.Unity.OdinRoom this encoder sends audio to
AudioProvider
Optional audio source: OdinNative.Unity.Audio.OdinMicrophoneReader or OdinNative.Unity.Audio.OdinAudioReader.
When set, OdinNative.Unity.OdinEncoder.PushAudio(System.Single[],System.Int32,System.Boolean) is subscribed to its OnAudioData event automatically in OdinNative.Unity.OdinEncoder.OnEnable .
Samplerate
Encoder samplerate. Auto-set from OdinNative.Unity.OdinEncoder.AudioProvider samplerate if it is an OdinNative.Unity.Audio.OdinMicrophoneReader.
Stereo
Encoder stereo flag
AutoDestroyMediaStream
Flag to dispose of OdinNative.Unity.OdinEncoder.Encoder on destroy
Methods
GetPipeline()
Get native effect pipeline
Returns
OdinNative.Wrapper.MediaPipeline: managed effect pipeline
CreateEncoder()
Create and start the OdinNative.Wrapper.MediaEncoder in the linked room. Called automatically when the room joins; safe to call manually after join.
PushAudio(float[], int, bool)
Push audio samples into the encoder pipeline and send to the server.
Wire this to an OdinNative.Unity.OdinEncoder.AudioProvider's OnAudioData event or call it directly.
Parameters
| Type | Name | Description |
|---|---|---|
System.Single[] | buffer | audio samples |
System.Int32 | position | read position in the source buffer |
System.Boolean | isSilent | silence flag |
AddEffect<T>()
Returns
<T>
Type Parameters
T
GetMedia<T>()
Returns
<T>
Type Parameters
T
GetEffect()
Returns
OdinNative.Wrapper.Media.PipelineEffect