pub struct RealtimeSession {
pub id: String,
/* private fields */
}Expand description
Real-time audio session
Fields§
§id: StringSession ID
Implementations§
Source§impl RealtimeSession
impl RealtimeSession
Sourcepub async fn send_event(&self, event: RealtimeEvent) -> Result<()>
pub async fn send_event(&self, event: RealtimeEvent) -> Result<()>
Send an event to the server
Sourcepub async fn send_audio(&self, audio_buffer: AudioBuffer) -> Result<()>
pub async fn send_audio(&self, audio_buffer: AudioBuffer) -> Result<()>
Send audio data
Sourcepub async fn start_audio_input(&self) -> Result<()>
pub async fn start_audio_input(&self) -> Result<()>
Start audio streaming from microphone
Sourcepub async fn stop_audio_input(&self) -> Result<()>
pub async fn stop_audio_input(&self) -> Result<()>
Stop audio streaming
Sourcepub async fn handle_data_channel_message(
&self,
msg: DataChannelMessage,
) -> Result<()>
pub async fn handle_data_channel_message( &self, msg: DataChannelMessage, ) -> Result<()>
Handle incoming data channel message
Sourcepub async fn handle_incoming_track(&self, track: Arc<TrackRemote>)
pub async fn handle_incoming_track(&self, track: Arc<TrackRemote>)
Handle incoming audio track
Source§impl RealtimeSession
impl RealtimeSession
Sourcepub fn new(
id: String,
peer_connection: Arc<RTCPeerConnection>,
event_sender: UnboundedSender<RealtimeEvent>,
event_receiver: UnboundedReceiver<RealtimeEvent>,
audio_sender: UnboundedSender<AudioBuffer>,
audio_receiver: UnboundedReceiver<AudioBuffer>,
config: RealtimeSessionConfig,
vad: VoiceActivityDetector,
) -> Self
pub fn new( id: String, peer_connection: Arc<RTCPeerConnection>, event_sender: UnboundedSender<RealtimeEvent>, event_receiver: UnboundedReceiver<RealtimeEvent>, audio_sender: UnboundedSender<AudioBuffer>, audio_receiver: UnboundedReceiver<AudioBuffer>, config: RealtimeSessionConfig, vad: VoiceActivityDetector, ) -> Self
Create a new realtime session
Sourcepub async fn event_stream(&self) -> Option<UnboundedReceiver<RealtimeEvent>>
pub async fn event_stream(&self) -> Option<UnboundedReceiver<RealtimeEvent>>
Get event stream
Sourcepub async fn audio_stream(&self) -> Option<UnboundedReceiver<AudioBuffer>>
pub async fn audio_stream(&self) -> Option<UnboundedReceiver<AudioBuffer>>
Get audio stream
Sourcepub async fn get_stats(&self) -> WebRtcStats
pub async fn get_stats(&self) -> WebRtcStats
Get session statistics
Sourcepub fn started_at(&self) -> DateTime<Utc>
pub fn started_at(&self) -> DateTime<Utc>
Get session start time
Sourcepub async fn set_data_channel(&self, data_channel: Arc<RTCDataChannel>)
pub async fn set_data_channel(&self, data_channel: Arc<RTCDataChannel>)
Set the data channel
Sourcepub async fn set_audio_track(&self, audio_track: Arc<TrackLocalStaticSample>)
pub async fn set_audio_track(&self, audio_track: Arc<TrackLocalStaticSample>)
Set the audio track
Sourcepub async fn connection_state(&self) -> WebRtcConnectionState
pub async fn connection_state(&self) -> WebRtcConnectionState
Get the connection state
Sourcepub async fn set_connection_state(&self, state: WebRtcConnectionState)
pub async fn set_connection_state(&self, state: WebRtcConnectionState)
Set the connection state
Sourcepub fn peer_connection(&self) -> &Arc<RTCPeerConnection>
pub fn peer_connection(&self) -> &Arc<RTCPeerConnection>
Get the peer connection
Auto Trait Implementations§
impl Freeze for RealtimeSession
impl !RefUnwindSafe for RealtimeSession
impl Send for RealtimeSession
impl Sync for RealtimeSession
impl Unpin for RealtimeSession
impl !UnwindSafe for RealtimeSession
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more