/// <summary> /// Attaches a call to the hold context. /// </summary> /// <param name="call"></param> public async Task HoldAsync(AudioVideoCall call) { if (call.State == CallState.Terminating || call.State == CallState.Terminated) return; // accept the call if not accepted yet if (call.State != CallState.Established) await call.AcceptAsync(); // start audio on first call if (musicPlayer.AudioVideoFlows.Count == 0) await StartAudioAsync(); // put the call on hold and attach player await call.Flow.HoldAsync(HoldType.RemoteEndpointMusicOnHold); musicPlayer.AttachFlow(call.Flow); }
/// <summary> /// Attempt to transfer the call to the given destination with the set transfer type. /// </summary> /// <param name="call"></param> /// <param name="callToReplace"></param> /// <param name="transferType"></param> /// <returns></returns> async Task<bool> TransferAsync(AudioVideoCall call, AudioVideoCall callToReplace) { try { // accept call if not accepted if (call.State != CallState.Established) await call.AcceptAsync(); // transfer to answered endpoint await call.TransferAsync(callToReplace, new CallTransferOptions(CallTransferType.Attended)); return true; } catch (RealTimeException) { return false; } }