200 lines
6.9 KiB
C#
200 lines
6.9 KiB
C#
|
using SipComponent;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Dispatcher.Sip
|
|||
|
{
|
|||
|
interface ISipComponent
|
|||
|
{
|
|||
|
#region Methods
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Send Call request to a sip id
|
|||
|
/// </summary>
|
|||
|
/// <param name="sipId"></param>
|
|||
|
/// <param name="groupCall"></param>
|
|||
|
void SendCallRequest(string sipId, bool groupCall);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Stops ptt
|
|||
|
/// </summary>
|
|||
|
/// <param name="sipId"></param>
|
|||
|
void StopPTT(string sipId);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Accepts the sip invite from a sip id
|
|||
|
/// </summary>
|
|||
|
/// <param name="callingSipID">The sip id that has sent the invite</param>
|
|||
|
void AcceptInvite(string callingSipID);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Sends a voice buffer in a specified format to the user in dialog with
|
|||
|
/// </summary>
|
|||
|
/// <param name="idToSendVoice">The sip ID of the user</param>
|
|||
|
/// <param name="audioBuffer">The audio buffer</param>
|
|||
|
/// <param name="bufferLength">The length of the buffer</param>
|
|||
|
/// <param name="format">The audio format of the buffer</param>
|
|||
|
void SendAudio(string idToSendVoice, byte[] audioBuffer, int bufferLength, AudioFormat format);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Declines an invite form a sip id
|
|||
|
/// </summary>
|
|||
|
/// <param name="idToDeclineCall">The sip id that has sent the invite</param>
|
|||
|
void Decline(string idToDeclineCall);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Method used to send an sms to sip id using the sip protocol
|
|||
|
/// <para>This method does not block the calling thread while waiting for the confirmation</para>
|
|||
|
/// </summary>
|
|||
|
/// <param name="idToSendSMS">The sip id where to send the sms</param>
|
|||
|
/// <param name="text">The sms text</param>
|
|||
|
/// <returns>True if the sms was received, else returns false</returns>
|
|||
|
Task<bool> SendSmsAsync(string idToSendSMS, string text);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Unregisters from the Sip server and releases the resources
|
|||
|
/// </summary>
|
|||
|
/// <param name="async">If true, the method runs async, without waiting for the complete unregistration</param>
|
|||
|
void Stop(bool async);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Events
|
|||
|
/// <summary>
|
|||
|
/// Occurs when the sip component receives an Invite. SD will accept automatically.
|
|||
|
/// </summary>
|
|||
|
event EventHandler<InviteReceivedArgs> InviteReceived;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when the sip component registration state changes
|
|||
|
/// </summary>
|
|||
|
event EventHandler<RegistrationStateChangedEventArgs> RegistrationStateChanged;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when a sip sms is received by the sip component
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SmsReceivedEventsArgs> SmsReceived;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when a sip dialog is established between SD and a remote sip id
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SipDialogCreatedEventArgs> DialogCreated;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when Sd can send voice to a remote sip id
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SdCanSendVoiceEventArgs> SdCanSendVoice;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when the sip device does not allow Sd to send voice
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SdCannotSendVoiceEventArgs> SdCannotSendVoice;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when Sd receives call init from a remote sip id
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SdReceivedCallStatusEventArgs> SdReceivesCallInit;
|
|||
|
/// <summary>
|
|||
|
/// Ocurs when Sd receives a voice buffer from a sip id
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SipVoiceReceivedEventArgs> VoiceReceived;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when the sip dialog between sd and a sip id is closed
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SipDialogClosedEventArgs> DialogClosed;
|
|||
|
/// <summary>
|
|||
|
/// Occurs when sd receives stop ptt
|
|||
|
/// </summary>
|
|||
|
event EventHandler<SdReceivedCallStatusEventArgs> SdReceivesStopPTT;
|
|||
|
/// <summary>
|
|||
|
/// An error occured while attempting to establish a sip dialog session
|
|||
|
/// </summary>
|
|||
|
event EventHandler<ErrorEventArgs> ErrorOnCreatingDialog;
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
class SdCanSendVoiceEventArgs : EventArgs
|
|||
|
{
|
|||
|
public int TargetSipId { get; private set; }
|
|||
|
public bool GroupCall { get; private set; }
|
|||
|
|
|||
|
internal SdCanSendVoiceEventArgs(int targetSipId, bool groupCall)
|
|||
|
{
|
|||
|
this.TargetSipId = targetSipId;
|
|||
|
this.GroupCall = groupCall;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SdCannotSendVoiceEventArgs : EventArgs
|
|||
|
{
|
|||
|
public int TargetSipId { get; set; }
|
|||
|
public string Reason { get; set; }
|
|||
|
|
|||
|
internal SdCannotSendVoiceEventArgs(int targetSipId, string reason)
|
|||
|
{
|
|||
|
TargetSipId = targetSipId;
|
|||
|
Reason = reason;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SdReceivedCallStatusEventArgs : EventArgs
|
|||
|
{
|
|||
|
public bool GroupCall { get; private set; }
|
|||
|
public int SourceCallSipId { get; private set; }
|
|||
|
|
|||
|
public int? GroupSipId { get; private set; }
|
|||
|
|
|||
|
internal SdReceivedCallStatusEventArgs(int sourceCallSipId, int? groupSipId = null)
|
|||
|
{
|
|||
|
this.SourceCallSipId = sourceCallSipId;
|
|||
|
if (groupSipId.HasValue)
|
|||
|
{
|
|||
|
GroupSipId = groupSipId;
|
|||
|
GroupCall = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SipDialogClosedEventArgs : EventArgs
|
|||
|
{
|
|||
|
public int SipIdWhoClosed { get; private set; }
|
|||
|
public int SipIdInDialogWith { get; private set; }
|
|||
|
public string GroupId { get; private set; }
|
|||
|
|
|||
|
internal SipDialogClosedEventArgs(int sipIdInDialogWith, int sipIdWhoClosed, string groupId)
|
|||
|
{
|
|||
|
this.SipIdInDialogWith = sipIdInDialogWith;
|
|||
|
this.SipIdWhoClosed = sipIdWhoClosed;
|
|||
|
this.GroupId = groupId;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SipDialogCreatedEventArgs : EventArgs
|
|||
|
{
|
|||
|
public int SipIdWhoSentInvite { get; set; }
|
|||
|
public int SipIdWhoReceivedInvite { get; set; }
|
|||
|
public int? GroupId { get; set; }
|
|||
|
|
|||
|
internal SipDialogCreatedEventArgs(int sipIdWhoSentInvite, int sipIdWhoReceivedInvite, int? groupId)
|
|||
|
{
|
|||
|
this.SipIdWhoSentInvite = sipIdWhoSentInvite;
|
|||
|
this.SipIdWhoReceivedInvite = sipIdWhoReceivedInvite;
|
|||
|
this.GroupId = groupId;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class SipVoiceReceivedEventArgs : EventArgs
|
|||
|
{
|
|||
|
public byte[] Buffer { get; private set; }
|
|||
|
public int CallSourceId { get; private set; }
|
|||
|
public string GroupId { get; private set; }
|
|||
|
|
|||
|
internal SipVoiceReceivedEventArgs(int callSourceId, byte[] buffer, string groupId)
|
|||
|
{
|
|||
|
this.CallSourceId = callSourceId;
|
|||
|
this.Buffer = buffer;
|
|||
|
this.GroupId = groupId;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|