File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ use crate::{
5
5
} ;
6
6
use egui:: { Rounding , Stroke } ;
7
7
use livekit:: { e2ee:: EncryptionType , prelude:: * , SimulateScenario } ;
8
+ use livekit:: webrtc:: { audio_stream:: native:: NativeAudioStream } ;
8
9
use std:: collections:: HashMap ;
10
+ use futures:: StreamExt ;
9
11
10
12
/// The state of the application are saved on app exit and restored on app start.
11
13
#[ derive( serde:: Deserialize , serde:: Serialize ) ]
@@ -88,8 +90,15 @@ impl LkApp {
88
90
) ;
89
91
self . video_renderers
90
92
. insert ( ( participant. identity ( ) , track. sid ( ) ) , video_renderer) ;
91
- } else if let RemoteTrack :: Audio ( _) = track {
92
- // TODO(theomonnom): Once we support media devices, we can play audio tracks here
93
+ } else if let RemoteTrack :: Audio ( ref audio_track) = track {
94
+ let rtc_track = audio_track. rtc_track ( ) ;
95
+ let mut audio_stream = NativeAudioStream :: new ( rtc_track, 48000 , 2 ) ;
96
+ // Receive the audio frames in a new task
97
+ tokio:: spawn ( async move {
98
+ while let Some ( frame) = audio_stream. next ( ) . await {
99
+ println ! ( "Received audio frame {:?}" , frame) ;
100
+ }
101
+ } ) ;
93
102
}
94
103
}
95
104
RoomEvent :: TrackUnsubscribed {
Original file line number Diff line number Diff line change @@ -167,12 +167,14 @@ bool AudioDevice::RecordingIsInitialized() const {
167
167
int32_t AudioDevice::StartPlayout () {
168
168
webrtc::MutexLock lock (&mutex_);
169
169
playing_ = true ;
170
+ audio_device_buffer_.StartPlayout ();
170
171
return 0 ;
171
172
}
172
173
173
174
int32_t AudioDevice::StopPlayout () {
174
175
webrtc::MutexLock lock (&mutex_);
175
176
playing_ = false ;
177
+ audio_device_buffer_.StopPlayout ();
176
178
return 0 ;
177
179
}
178
180
@@ -182,10 +184,12 @@ bool AudioDevice::Playing() const {
182
184
}
183
185
184
186
int32_t AudioDevice::StartRecording () {
187
+ audio_device_buffer_.StartRecording ();
185
188
return 0 ;
186
189
}
187
190
188
191
int32_t AudioDevice::StopRecording () {
192
+ audio_device_buffer_.StopRecording ();
189
193
return 0 ;
190
194
}
191
195
You can’t perform that action at this time.
0 commit comments