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
///
/// Send Call request to a sip id
///
///
///
void SendCallRequest(string sipId, bool groupCall);
///
/// Stops ptt
///
///
void StopPTT(string sipId);
///
/// Accepts the sip invite from a sip id
///
/// The sip id that has sent the invite
void AcceptInvite(string callingSipID);
///
/// Sends a voice buffer in a specified format to the user in dialog with
///
/// The sip ID of the user
/// The audio buffer
/// The length of the buffer
/// The audio format of the buffer
void SendAudio(string idToSendVoice, byte[] audioBuffer, int bufferLength, AudioFormat format);
///
/// Declines an invite form a sip id
///
/// The sip id that has sent the invite
void Decline(string idToDeclineCall);
///
/// Method used to send an sms to sip id using the sip protocol
/// This method does not block the calling thread while waiting for the confirmation
///
/// The sip id where to send the sms
/// The sms text
/// True if the sms was received, else returns false
Task SendSmsAsync(string idToSendSMS, string text);
///
/// Unregisters from the Sip server and releases the resources
///
/// If true, the method runs async, without waiting for the complete unregistration
void Stop(bool async);
#endregion
#region Events
///
/// Occurs when the sip component receives an Invite. SD will accept automatically.
///
event EventHandler InviteReceived;
///
/// Occurs when the sip component registration state changes
///
event EventHandler RegistrationStateChanged;
///
/// Occurs when a sip sms is received by the sip component
///
event EventHandler SmsReceived;
///
/// Occurs when a sip dialog is established between SD and a remote sip id
///
event EventHandler DialogCreated;
///
/// Occurs when Sd can send voice to a remote sip id
///
event EventHandler SdCanSendVoice;
///
/// Occurs when the sip device does not allow Sd to send voice
///
event EventHandler SdCannotSendVoice;
///
/// Occurs when Sd receives call init from a remote sip id
///
event EventHandler SdReceivesCallInit;
///
/// Ocurs when Sd receives a voice buffer from a sip id
///
event EventHandler VoiceReceived;
///
/// Occurs when the sip dialog between sd and a sip id is closed
///
event EventHandler DialogClosed;
///
/// Occurs when sd receives stop ptt
///
event EventHandler SdReceivesStopPTT;
///
/// An error occured while attempting to establish a sip dialog session
///
event EventHandler 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;
}
}
}