void AudioVideoCall_EstablishCompleted(IAsyncResult result) { try { AudioVideoCall avCall = result.AsyncState as AudioVideoCall; avCall.EndEstablish(result); Message m = new Message("AudioVideoCall Established. Call state: " + _audioVideoCall.State.ToString() + ". CallId: " + _audioVideoCall.CallId + ".", _audioVideoCall.RemoteEndpoint.Participant.DisplayName, _audioVideoCall.RemoteEndpoint.Participant.UserAtHost, _audioVideoCall.RemoteEndpoint.Participant.Uri, MessageType.Audio, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming); _transcriptRecorder.OnMessageReceived(m); _transcriptRecorder.OnRemoteParticipantAdded(null, avCall.RemoteEndpoint); } catch (RealTimeException ex) { NonBlockingConsole.WriteLine("Error: avCall.EndEstablish failed. Exception: {0}", ex.ToString()); // TODO: Error message } finally { _state = TranscriptRecorderState.Active; _waitForAudioVideoCallEstablished.Set(); } }
private void EstablishCall() { // Create a new Conversation. Conversation conversation = new Conversation(_appEndpoint); // Create a new IM call. _avCall = new AudioVideoCall(conversation); try { // Establish the IM call. _avCall.BeginEstablish(_destinationSipUri, new CallEstablishOptions(), result => { try { // Finish the asynchronous operation. _avCall.EndEstablish(result); } catch (RealTimeException ex) { // Catch and log exceptions. _logger.Log("Failed establishing A/V call", ex); } }, null ); } catch (InvalidOperationException ioex) { _logger.Log("Failed establishing A/V call", ioex); } }
private void EstablishServiceChannel(AsyncTask task, object state) { task.DoOneStep( delegate() { m_serviceChannelCall = new AudioVideoCall(m_serviceHub.Conversation); var options = new AudioVideoCallEstablishOptions(); // Ee need to use generated user identity for the call as this is hidden participant // of the conference for service purpose. options.UseGeneratedIdentityForTrustedConference = !this.IsPrimaryServiceChannel; if (!this.IsPrimaryServiceChannel) { this.RegisterServiceCallHandlers(); // Service call does not need to be in default mix of the conference. The purpose is to service a specific target user in the conference. options.AudioVideoMcuDialInOptions.RemoveFromDefaultRouting = true; } m_serviceChannelCall.BeginEstablish( options, delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_serviceChannelCall.EndEstablish(ar); }); }, null); }); }
void EstablishControlCall() { AudioVideoCallEstablishOptions ceo = new AudioVideoCallEstablishOptions() { UseGeneratedIdentityForTrustedConference = true }; _controlAVCall = new AudioVideoCall(_location.Conversation); _controlAVCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(_controlAVCall_AudioVideoFlowConfigurationRequested); _controlAVCall.BeginEstablish(ceo, ar => { try { _controlAVCall.EndEstablish(ar); List <IncomingAudioRoute> routesin = new List <IncomingAudioRoute>(); List <OutgoingAudioRoute> routesout = new List <OutgoingAudioRoute>(); ParticipantEndpoint localEndpoint = GetLocalParticipant().GetEndpoints()[0]; ParticipantEndpoint remoteEndpoint = _controlAVCall.RemoteEndpoint; routesin.Add(new IncomingAudioRoute(localEndpoint)); routesin.Add(new IncomingAudioRoute(remoteEndpoint)); routesout.Add(new OutgoingAudioRoute(localEndpoint)); routesout.Add(new OutgoingAudioRoute(remoteEndpoint)); _controlAVCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(routesout, routesin, ar2 => { try { _controlAVCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar2); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); }
private void TransferringCallEstablishCompleted(IAsyncResult ar) { AudioVideoCall call = ar.AsyncState as AudioVideoCall; RealTimeException ex = null; try { call.EndEstablish(ar); Console.WriteLine(""); Console.WriteLine("Now beginning the transfer..."); Console.WriteLine(""); // Now that both calls are connected and have been accepted by // the called participant, we can use the transferor endpoint to // transfer the call from the initial to the final. Note that the // transferor endpoint retains it's position of control over both // calls. This form of transfer is most suitable for a proxy // application, where the proxying agent needs to remain in the // signaling channel (For instance, for quality assurance purposes.) call.BeginTransfer(_avCallTransferringtoInitial, TransferCallCompleted, call); Console.WriteLine("The call with Local Participant: " + call.Conversation.LocalParticipant + " and Remote Participant: " + call.RemoteEndpoint.Participant + " is now in the established state."); } catch (OperationFailureException opFailEx) { // OperationFailureException: Indicates failure to connect the // call to the remote party. // TODO (Left to the reader): Add error handling code here. ex = opFailEx; } catch (RealTimeException exception) { // RealTimeException may be thrown on media or link-layer failures. // TODO (Left to the reader): Add error handling code here. ex = exception; } finally { if (ex != null) { Console.WriteLine(ex.ToString()); Console.WriteLine("Terminating the application due to failure"); _sampleCompleted.Set(); } } }
/// <summary> /// Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void AudioVideoCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_avCall.EndEstablish(asyncResult); exceptionEncountered = false; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } else { AudioVideoCallContext avCallContext = m_avCall.ApplicationContext as AudioVideoCallContext; Debug.Assert(null != avCallContext, "Av call context is null"); Debug.Assert(null != avCallContext.WebAvcall, "Av call in av call context is null"); m_webConversation.WebAvCall = avCallContext.WebAvcall; //If no exception occured, create a web av call. EstablishAudioVideoCallResponse response = new EstablishAudioVideoCallResponse(m_establishAvCallRequest, avCallContext.WebAvcall); this.CompleteEstablishOperationSuccessfully(response); } } }
/// <summary> /// Callback Av call establish completed callback method. /// </summary> /// <param name="asyncResult">Async result.</param> private void CallbackAudioVideoCallEstablishCompleted(IAsyncResult asyncResult) { Exception exceptionCaught = null; bool exceptionEncountered = true; try { m_callbackCall.EndEstablish(asyncResult); //If establish operation succeeds immediately trigger a self transfer. m_callbackCall.BeginTransfer(m_callbackCall, null /*transferOptions*/, this.SelfTransferCompleted, null /*asyncState*/); exceptionEncountered = false; } catch (InvalidOperationException ioe) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe)); exceptionCaught = ioe; } catch (RealTimeException rte) { Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte)); exceptionCaught = rte; } finally { if (exceptionEncountered) { OperationFault operationFault = null; if (exceptionCaught != null) { operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException); } else { operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/); } this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault)); } } }
public Location(int id, string name, string fileName, LocalEndpoint endpoint) { if (!File.Exists(fileName)) throw new FileNotFoundException(fileName); _id = id; _Name = name; _FileName = fileName; _Endpoint = endpoint; ConferenceScheduleInformation csi = new ConferenceScheduleInformation() { AccessLevel = ConferenceAccessLevel.Everyone, Description = _Name, ExpiryTime = DateTime.Now.AddYears(5), AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone }; csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo)); _Endpoint.ConferenceServices.BeginScheduleConference(csi, ar => { try { _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar); Log("Conference " + _conference.ConferenceId + " scheduled. Starting music..."); Log(_conference.ConferenceUri); ConversationSettings cs = new ConversationSettings() { Subject = _Name }; _conversation = new Conversation(_Endpoint, cs); ConferenceJoinOptions cjo = new ConferenceJoinOptions() { JoinMode = JoinMode.TrustedParticipant }; _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri, cjo, ar1 => { try { _conversation.ConferenceSession.EndJoin(ar1); _avCall = new AudioVideoCall(_conversation); _avCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested); AudioVideoCallEstablishOptions options = new AudioVideoCallEstablishOptions() { UseGeneratedIdentityForTrustedConference = true, SupportsReplaces = CapabilitySupport.Supported }; _avCall.BeginEstablish( options, ar2 => { try { _avCall.EndEstablish(ar2); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); }
private void OnTransferReceived(object sender, AudioVideoCallTransferReceivedEventArgs e) { // Unregister the event handlers. _avCall.TransferReceived -= OnTransferReceived; _avCall.Forwarded -= OnCallForwarded; // Accept the REFER request with no special headers. e.Accept(null); // Create a new A/V call with the transfer-to URI using the // pre-initialized Conversation object. AudioVideoCall newCall = new AudioVideoCall(e.NewConversation); try { // Establish the call to the transfer-to endpoint. newCall.BeginEstablish(e.TransferDestination, null, ar => { try { newCall.EndEstablish(ar); } catch (RealTimeException rtex) { _logger.Log("Failed establishing new call following transfer.", rtex); } }, null ); } catch (InvalidOperationException ioex) { _logger.Log("Failed establishing new call following transfer.", ioex); } }
void EstablishControlCall() { AudioVideoCallEstablishOptions ceo = new AudioVideoCallEstablishOptions() { UseGeneratedIdentityForTrustedConference = true }; _controlAVCall = new AudioVideoCall(_location.Conversation); _controlAVCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(_controlAVCall_AudioVideoFlowConfigurationRequested); _controlAVCall.BeginEstablish(ceo, ar => { try { _controlAVCall.EndEstablish(ar); List<IncomingAudioRoute> routesin = new List<IncomingAudioRoute>(); List<OutgoingAudioRoute> routesout = new List<OutgoingAudioRoute>(); ParticipantEndpoint localEndpoint = GetLocalParticipant().GetEndpoints()[0]; ParticipantEndpoint remoteEndpoint = _controlAVCall.RemoteEndpoint; routesin.Add(new IncomingAudioRoute(localEndpoint)); routesin.Add(new IncomingAudioRoute(remoteEndpoint)); routesout.Add(new OutgoingAudioRoute(localEndpoint)); routesout.Add(new OutgoingAudioRoute(remoteEndpoint)); _controlAVCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes(routesout, routesin, ar2 => { try { _controlAVCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar2); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); }
public void ExtablishOutboundAVCall(ApplicationEndpoint appEndpoint, string destinationSipUri, string message) { try { Conversation conversation = new Conversation(appEndpoint); AudioVideoCall call = new AudioVideoCall(conversation); call.BeginEstablish(destinationSipUri, new CallEstablishOptions(), result => { try { call.EndEstablish(result); SpeakMessage(call.Flow, message); /* string.Format("Hello, {0}. This my UCMA app calling you. " + "Your SIP URI is {1}", call.RemoteEndpoint.Participant.DisplayName, call.RemoteEndpoint.Participant.Uri)); * */ } catch (RealTimeException ex) { Console.WriteLine("Failed establishing AV call {0}", ex); } }, null); } catch (InvalidOperationException ex) { Console.WriteLine("Failed establishing AV call {0}", ex); } }
public Location(int id, string name, string fileName, LocalEndpoint endpoint) { if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } _id = id; _Name = name; _FileName = fileName; _Endpoint = endpoint; ConferenceScheduleInformation csi = new ConferenceScheduleInformation() { AccessLevel = ConferenceAccessLevel.Everyone, Description = _Name, ExpiryTime = DateTime.Now.AddYears(5), AutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone }; csi.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo)); _Endpoint.ConferenceServices.BeginScheduleConference(csi, ar => { try { _conference = _Endpoint.ConferenceServices.EndScheduleConference(ar); Log("Conference " + _conference.ConferenceId + " scheduled. Starting music..."); Log(_conference.ConferenceUri); ConversationSettings cs = new ConversationSettings() { Subject = _Name }; _conversation = new Conversation(_Endpoint, cs); ConferenceJoinOptions cjo = new ConferenceJoinOptions() { JoinMode = JoinMode.TrustedParticipant }; _conversation.ConferenceSession.BeginJoin(_conference.ConferenceUri, cjo, ar1 => { try { _conversation.ConferenceSession.EndJoin(ar1); _avCall = new AudioVideoCall(_conversation); _avCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(_avCall_AudioVideoFlowConfigurationRequested); AudioVideoCallEstablishOptions options = new AudioVideoCallEstablishOptions() { UseGeneratedIdentityForTrustedConference = true, SupportsReplaces = CapabilitySupport.Supported }; _avCall.BeginEstablish( options, ar2 => { try { _avCall.EndEstablish(ar2); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); } catch (Exception ex) { Log(ex.ToString()); } }, null); }
private void PerformSupervisedTransfer() { ConversationSettings settings = new ConversationSettings() { Subject = "Supervised transfer" }; Conversation newConversation = new Conversation(_appEndpoint, settings); AudioVideoCall newCall = new AudioVideoCall(newConversation); try { newCall.BeginEstablish(_destinationSipUri, null, ar => { try { newCall.EndEstablish(ar); ReplaceNewCallWithIncomingCall(newCall); } catch (RealTimeException rtex) { _logger.Log("Failed establishing second call.", rtex); } }, null ); } catch (InvalidOperationException ioex) { _logger.Log("Failed establishing second call.", ioex); } }
private void InviteSupervisor() { Console.WriteLine("Inviting the supervisor (" + _supervisorSipUri + ") to incoming call."); LocalEndpoint localEndpoint = _backEndCallLeg.Conversation.Endpoint; // Create a new audio call to call the supervisor. Conversation supervisorConversation = new Conversation(localEndpoint); AudioVideoCall supervisorCall = new AudioVideoCall(supervisorConversation); try { // Place an outbound call to the supervisor. supervisorCall.BeginEstablish(_supervisorSipUri, default(CallEstablishOptions), establishAsyncResult => { try { supervisorCall.EndEstablish(establishAsyncResult); // Wait for a couple of seconds before transferring. Thread.Sleep(2000); SelfTransferSupervisorCall(supervisorCall); } catch (RealTimeException ex) { Console.WriteLine(ex); } }, null); } catch (InvalidOperationException ex) { Console.WriteLine(ex); } }