@@ -17,12 +17,12 @@ use crate::{
1717 Track , TrackConfig ,
1818 file:: FileTrack ,
1919 rtp:: { RtpTrack , RtpTrackBuilder } ,
20- tts:: { TtsCommand , TtsHandle } ,
20+ tts:: SynthesisHandle ,
2121 webrtc:: WebrtcTrack ,
2222 websocket:: { WebsocketBytesReceiver , WebsocketTrack } ,
2323 } ,
2424 } ,
25- synthesis:: SynthesisOption ,
25+ synthesis:: { SynthesisCommand , SynthesisOption } ,
2626 useragent:: invitation:: PendingDialog ,
2727} ;
2828use anyhow:: Result ;
@@ -78,7 +78,7 @@ pub struct ActiveCall {
7878 pub session_id : String ,
7979 pub media_stream : Arc < MediaStream > ,
8080 pub track_config : TrackConfig ,
81- pub tts_handle : Mutex < Option < TtsHandle > > ,
81+ pub tts_handle : Mutex < Option < SynthesisHandle > > ,
8282 pub auto_hangup : Arc < Mutex < Option < ( u32 , CallRecordHangupReason ) > > > ,
8383 pub wait_input_timeout : Arc < Mutex < Option < u32 > > > ,
8484 pub event_sender : EventSender ,
@@ -519,7 +519,7 @@ impl ActiveCall {
519519 Some ( s) => Some ( s) ,
520520 None => tts_option. speaker . clone ( ) ,
521521 } ;
522- let mut play_command = TtsCommand {
522+ let mut play_command = SynthesisCommand {
523523 text,
524524 speaker,
525525 play_id : play_id. clone ( ) ,
@@ -533,7 +533,7 @@ impl ActiveCall {
533533 text = %play_command. text,
534534 speaker = ?play_command. speaker,
535535 auto_hangup = ?auto_hangup,
536- "new tts command"
536+ "new synthesis command"
537537 ) ;
538538
539539 let ssrc = rand:: random :: < u32 > ( ) ;
@@ -1181,14 +1181,21 @@ impl ActiveCall {
11811181 )
11821182 . await ?;
11831183
1184+ let offer = rtp_track. local_description ( ) . ok ( ) ;
11841185 let call_option = call_state_ref
1185- . read ( )
1186- . as_ref ( )
1187- . and_then ( |cs| Ok ( cs. option . clone ( ) ) )
1188- . unwrap_or_default ( )
1186+ . write ( )
1187+ . as_mut ( )
1188+ . ok ( )
1189+ . map ( |cs| {
1190+ cs. option . as_mut ( ) . map ( |o| {
1191+ o. offer = offer. clone ( ) ;
1192+ } ) ;
1193+ cs. start_time = Utc :: now ( ) ;
1194+ cs. option . clone ( )
1195+ } )
1196+ . flatten ( )
11891197 . unwrap_or_default ( ) ;
11901198
1191- let offer = rtp_track. local_description ( ) . ok ( ) ;
11921199 invite_option. offer = offer. clone ( ) . map ( |s| s. into ( ) ) ;
11931200
11941201 Self :: setup_track_with_stream (
@@ -1255,24 +1262,6 @@ impl ActiveCall {
12551262 . update_remote_description ( & track_id, & answer)
12561263 . await
12571264 . ok ( ) ;
1258-
1259- call_state_ref
1260- . write ( )
1261- . as_mut ( )
1262- . and_then ( |cs| {
1263- if cs. dialog . is_none ( ) {
1264- Some ( DialogGuard :: new (
1265- self . invitation . dialog_layer . clone ( ) ,
1266- dialog_id,
1267- ) ) ;
1268- }
1269- cs. option . as_mut ( ) . map ( |o| o. offer = offer) ;
1270- cs. answer = Some ( answer) ;
1271- cs. answer_time = Some ( Utc :: now ( ) ) ;
1272- cs. last_status_code = 200 ;
1273- Ok ( ( ) )
1274- } )
1275- . ok ( ) ;
12761265 Ok ( ( ) )
12771266 }
12781267
0 commit comments