39 class OpalSkinnyConnection;
54 const char *prefix =
"sccp"
59 virtual ~OpalSkinnyEndPoint();
90 virtual void NewIncomingConnection(
124 const PString & party,
126 unsigned int options,
143 virtual OpalSkinnyConnection * CreateConnection(
145 PhoneDevice & client,
146 unsigned callIdentifier,
147 const PString & dialNumber,
149 unsigned int options,
156 enum { DefaultDeviceType = 30016 };
161 const PString & server,
162 const PString & name,
163 unsigned deviceType = DefaultDeviceType,
164 const PString & localInterface = PString::Empty()
174 PhoneDevice * CreatePhoneDevice(
175 const PString & name,
177 const PIPAddressAndPort & binding
180 PhoneDevice * GetPhoneDevice(
182 )
const {
return m_phoneDevices.GetAt(name); }
184 PArray<PString> GetPhoneDeviceNames()
const {
return m_phoneDevices.GetKeys(); }
190 class PhoneDevice :
public PObject
192 PCLASSINFO(PhoneDevice, PObject);
194 PhoneDevice(OpalSkinnyEndPoint & ep,
const PString & name,
unsigned deviceType,
const PIPAddressAndPort & binding);
195 ~PhoneDevice() { Close(); }
197 virtual void PrintOn(ostream & strm)
const;
199 bool Start(
const PString & server);
203 bool SendSkinnyMsg(
const SkinnyMsg & msg);
205 const PString &
GetName()
const {
return m_name; }
206 unsigned GetDeviceType()
const {
return m_deviceType; }
207 const PString & GetStatus()
const {
return m_status; }
211 void HandleTransport();
212 bool SendRegisterMsg();
213 PDECLARE_NOTIFIER(PTimer, OpalSkinnyEndPoint::PhoneDevice, OnKeepAlive);
215 template <
class MSG>
bool OnReceiveMsg(
const MSG & msg)
217 PTRACE(3,
"Skinny",
"Received " << msg);
218 return m_endpoint.OnReceiveMsg(*
this, msg);
221 OpalSkinnyEndPoint & m_endpoint;
223 unsigned m_deviceType;
225 PTimeInterval m_delay;
228 PTimer m_keepAliveTimer;
231 PSafePtr<OpalSkinnyConnection> m_activeConnection;
233 friend class OpalSkinnyEndPoint;
234 friend class OpalSkinnyConnection;
239 class SkinnyMsg :
public PObject
241 PCLASSINFO(SkinnyMsg, PObject);
243 SkinnyMsg(uint32_t
id, PINDEX len, PINDEX extraSpace);
244 void Construct(
const PBYTEArray & pdu);
247 uint32_t GetID()
const {
return m_messageId; }
249 const BYTE * GetPacketPtr()
const {
return (
const BYTE *)&m_length; }
250 PINDEX GetPacketLen()
const {
return m_length +
sizeof(m_length) +
sizeof(m_headerVersion); }
257 PUInt32l m_headerVersion;
258 PUInt32l m_messageId;
262 #define OPAL_SKINNY_MSG2(cls, base, id, extraSpace, vars) \
263 class cls : public base \
265 PCLASSINFO(cls, base); \
268 cls() : base(ID, sizeof(*this), extraSpace) { } \
269 cls(const PBYTEArray & pdu) : base(ID, sizeof(*this), extraSpace) { Construct(pdu); } \
272 virtual bool OnReceiveMsg(PhoneDevice & client, const cls & msg)
274 #define OPAL_SKINNY_MSG(cls, id, vars) OPAL_SKINNY_MSG2(cls, SkinnyMsg, id, 0, vars)
276 OPAL_SKINNY_MSG(KeepAliveMsg, 0x0000,
280 OPAL_SKINNY_MSG(KeepAliveAckMsg, 0x0100,
289 friend ostream &
operator<<(ostream & strm,
const Proto & protocol);
292 OPAL_SKINNY_MSG(RegisterMsg, 0x0001,
293 enum { MaxNameSize = 15 };
294 char m_deviceName[MaxNameSize+1];
298 PUInt32l m_deviceType;
299 PUInt32l m_maxStreams;
300 PUInt32l m_activeStreams;
302 PUInt32l m_socketType;
304 char m_macAddress[12];
306 virtual void PrintOn(ostream & strm)
const;
309 OPAL_SKINNY_MSG(RegisterAckMsg, 0x0081,
310 PUInt32l m_keepAlive;
311 char m_dateFormat[6];
313 PUInt32l m_secondaryKeepAlive;
316 virtual void PrintOn(ostream & strm)
const;
319 OPAL_SKINNY_MSG(RegisterRejectMsg, 0x009d,
320 char m_errorText[32];
323 OPAL_SKINNY_MSG(UnregisterMsg, 0x0027,
326 OPAL_SKINNY_MSG(UnregisterAckMsg, 0x0118,
330 OPAL_SKINNY_MSG(PortMsg, 0x0002,
333 virtual void PrintOn(ostream & strm)
const;
336 OPAL_SKINNY_MSG(CapabilityRequestMsg, 0x009B,
339 OPAL_SKINNY_MSG(CapabilityResponseMsg, 0x0010,
344 PUInt32l m_maxFramesPerPacket;
345 PUInt32l m_g7231BitRate;
349 virtual void PrintOn(ostream & strm)
const;
350 void SetCount(PINDEX count);
353 P_DECLARE_STREAMABLE_ENUM(CallStates,
367 eStateCallRemoteMultiline,
370 OPAL_SKINNY_MSG(CallStateMsg, 0x0111,
372 PUInt32l m_lineInstance;
373 PUInt32l m_callIdentifier;
376 __inline CallStates GetState()
const {
return (CallStates)(uint32_t)m_state; }
377 virtual void PrintOn(ostream & strm)
const;
380 P_DECLARE_STREAMABLE_ENUM(CallType,
387 class CallInfoCommon :
public SkinnyMsg
390 CallInfoCommon(uint32_t
id, PINDEX len, PINDEX extraSpace) : SkinnyMsg(id, len, extraSpace) { }
392 virtual const PUInt32l & GetLineInstance()
const = 0;
393 virtual const PUInt32l & GetCallIdentifier()
const = 0;
394 virtual CallType GetType()
const = 0;
395 virtual const char * GetCalledPartyName()
const = 0;
396 virtual const char * GetCalledPartyNumber()
const = 0;
397 virtual const char * GetCallingPartyName()
const = 0;
398 virtual const char * GetCallingPartyNumber()
const = 0;
399 virtual const char * GetRedirectingPartyNumber()
const = 0;
401 virtual void PrintOn(ostream & strm)
const;
404 OPAL_SKINNY_MSG2(CallInfoMsg, CallInfoCommon, 0x008f, 0,
405 char m_callingPartyName[40];
406 char m_callingPartyNumber[24];
407 char m_calledPartyName[40];
408 char m_calledPartyNumber[24];
409 PUInt32l m_lineInstance;
410 PUInt32l m_callIdentifier;
412 char m_originalCalledPartyName[40];
413 char m_originalCalledPartyNumber[24];
414 char m_lastRedirectingPartyName[40];
415 char m_lastRedirectingPartyNumber[24];
416 PUInt32l m_originalCalledPartyRedirectReason;
417 PUInt32l m_lastRedirectingReason;
418 char m_callingPartyVoiceMailbox[24];
419 char m_calledPartyVoiceMailbox[24];
420 char m_originalCalledPartyVoiceMailbox[24];
421 char m_lastRedirectingVoiceMailbox[24];
422 PUInt32l m_callInstance;
423 PUInt32l m_callSecurityStatus;
424 PUInt32l m_partyPIRestrictionBits;
426 virtual const PUInt32l & GetLineInstance()
const {
return m_lineInstance; }
427 virtual const PUInt32l & GetCallIdentifier()
const {
return m_callIdentifier; }
428 virtual CallType GetType()
const {
return (CallType)(uint32_t)m_callType; }
429 virtual const char * GetCalledPartyName()
const {
return m_calledPartyName; }
430 virtual const char * GetCalledPartyNumber()
const {
return m_calledPartyNumber; }
431 virtual const char * GetCallingPartyName()
const {
return m_callingPartyName; }
432 virtual const char * GetCallingPartyNumber()
const {
return m_callingPartyNumber; }
433 virtual const char * GetRedirectingPartyNumber()
const {
return m_lastRedirectingPartyNumber; }
436 enum { CallInfo5MsgStringSpace = 200 };
437 OPAL_SKINNY_MSG2(CallInfo5Msg, CallInfoCommon, 0x014a, CallInfo5MsgStringSpace,
438 PUInt32l m_lineInstance;
439 PUInt32l m_callIdentifier;
441 PUInt32l m_originalCalledPartyRedirectReason;
442 PUInt32l m_lastRedirectingReason;
443 PUInt32l m_callInstance;
444 PUInt32l m_callSecurityStatus;
445 PUInt32l m_partyPIRestrictionBits;
446 char m_strings[CallInfo5MsgStringSpace+11];
448 virtual const PUInt32l & GetLineInstance()
const {
return m_lineInstance; }
449 virtual const PUInt32l & GetCallIdentifier()
const {
return m_callIdentifier; }
450 virtual CallType GetType()
const {
return (CallType)(uint32_t)m_callType; }
451 virtual const char * GetCalledPartyName()
const {
return GetStringByIndex(9); }
452 virtual const char * GetCalledPartyNumber()
const {
return GetStringByIndex(1); }
453 virtual const char * GetCallingPartyName()
const {
return GetStringByIndex(8); }
454 virtual const char * GetCallingPartyNumber()
const {
return GetStringByIndex(0); }
455 virtual const char * GetRedirectingPartyNumber()
const {
return GetStringByIndex(3); }
458 const char * GetStringByIndex(PINDEX idx)
const;
468 OPAL_SKINNY_MSG(SetRingerMsg, 0x0085,
471 PUInt32l m_lineInstance;
472 PUInt32l m_callIdentifier;
474 __inline RingType GetType()
const {
return (RingType)(uint32_t)m_ringType; }
475 __inline
bool IsForever()
const {
return m_ringMode == 1; }
476 virtual void PrintOn(ostream & strm)
const;
479 OPAL_SKINNY_MSG(OffHookMsg, 0x0006,
480 PUInt32l m_lineInstance;
481 PUInt32l m_callIdentifier;
483 virtual void PrintOn(ostream & strm)
const;
486 OPAL_SKINNY_MSG(OnHookMsg, 0x0007,
487 PUInt32l m_lineInstance;
488 PUInt32l m_callIdentifier;
490 virtual void PrintOn(ostream & strm)
const;
500 eToneCallWaiting = 45,
503 OPAL_SKINNY_MSG(StartToneMsg, 0x0082,
506 PUInt32l m_lineInstance;
507 PUInt32l m_callIdentifier;
509 __inline Tones GetType()
const {
return (Tones)(uint32_t)m_tone; }
510 virtual void PrintOn(ostream & strm)
const;
513 OPAL_SKINNY_MSG(StopToneMsg, 0x0083,
514 PUInt32l m_lineInstance;
515 PUInt32l m_callIdentifier;
517 virtual void PrintOn(ostream & strm)
const;
520 OPAL_SKINNY_MSG(KeyPadButtonMsg, 0x0003,
523 PUInt32l m_lineInstance;
524 PUInt32l m_callIdentifier;
526 virtual void PrintOn(ostream & strm)
const;
529 P_DECLARE_STREAMABLE_ENUM(SoftKeyEvents,
537 eSoftKeyCfwdNoAnswer,
548 eSoftKeyGrpCallPickup,
552 OPAL_SKINNY_MSG(SoftKeyEventMsg, 0x0026,
554 PUInt32l m_lineInstance;
555 PUInt32l m_callIdentifier;
557 __inline SoftKeyEvents GetEvent()
const {
return (SoftKeyEvents)(uint32_t)m_event; }
558 virtual void PrintOn(ostream & strm)
const;
561 OPAL_SKINNY_MSG(OpenReceiveChannelMsg, 0x0105,
562 PUInt32l m_callIdentifier;
563 PUInt32l m_passThruPartyId;
564 PUInt32l m_msPerPacket;
565 PUInt32l m_payloadCapability;
566 PUInt32l m_echoCancelType;
567 PUInt32l m_g723Bitrate;
570 virtual void PrintOn(ostream & strm)
const;
573 OPAL_SKINNY_MSG(OpenReceiveChannelAckMsg, 0x0022,
578 PUInt32l m_passThruPartyId;
579 virtual void PrintOn(ostream & strm)
const;
582 OPAL_SKINNY_MSG(CloseReceiveChannelMsg, 0x0106,
583 PUInt32l m_callIdentifier;
584 PUInt32l m_passThruPartyId;
585 PUInt32l m_conferenceId2;
587 virtual void PrintOn(ostream & strm)
const;
590 OPAL_SKINNY_MSG(StartMediaTransmissionMsg, 0x008a,
591 PUInt32l m_callIdentifier;
592 PUInt32l m_passThruPartyId;
596 PUInt32l m_msPerPacket;
597 PUInt32l m_payloadCapability;
598 PUInt32l m_precedence;
599 PUInt32l m_silenceSuppression;
600 PUInt32l m_maxFramesPerPacket;
601 PUInt32l m_g723Bitrate;
604 virtual void PrintOn(ostream & strm)
const;
607 OPAL_SKINNY_MSG(StopMediaTransmissionMsg, 0x008b,
608 PUInt32l m_callIdentifier;
609 PUInt32l m_passThruPartyId;
610 PUInt32l m_conferenceId2;
612 virtual void PrintOn(ostream & strm)
const;
617 const PFilePath & GetSimulatedFarAudioFile()
const {
return m_simulatedFarAudioFile; }
618 void SetSimulatedFarAudioFile(
const PString str) { m_simulatedFarAudioFile = str; }
619 const PFilePath & GetSimulatedNearAudioFile()
const {
return m_simulatedNearAudioFile; }
620 void SetSimulatedNearAudioFile(
const PString str) { m_simulatedNearAudioFile = str; }
622 const PDirectory & GetSimulatedAudioFolder()
const {
return m_simulatedAudioFolder; }
623 void SetSimulatedAudioFolder(
const PString str) { m_simulatedAudioFolder = str; }
625 PFilePath GetEndpointSimulatedAudioFile(
const PString& name,
unsigned sessionId)
const;
627 bool IsSecondaryAudioAlwaysSimulated()
const {
return m_secondaryAudioAlwaysSimulated; }
628 void SetSecondaryAudioAlwaysSimulated(
bool v) { m_secondaryAudioAlwaysSimulated = v; }
633 template <
class MSG>
bool DelegateMsg(
const PhoneDevice & client,
const MSG & msg);
635 typedef PDictionary<PString, PhoneDevice> PhoneDeviceDict;
636 PhoneDeviceDict m_phoneDevices;
639 PFilePath m_simulatedFarAudioFile;
640 PFilePath m_simulatedNearAudioFile;
641 PDirectory m_simulatedAudioFolder;
642 bool m_secondaryAudioAlwaysSimulated;
656 OpalSkinnyConnection(
658 OpalSkinnyEndPoint & ep,
659 OpalSkinnyEndPoint::PhoneDevice & client,
660 unsigned callIdentifier,
661 const PString & dialNumber,
718 const PString & calleeName,
764 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::CallStateMsg & msg);
765 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::CallInfoMsg & msg);
766 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::CallInfo5Msg & msg);
767 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::SetRingerMsg & msg);
768 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::StartToneMsg & msg);
769 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::OpenReceiveChannelMsg & msg);
770 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::CloseReceiveChannelMsg & msg);
771 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::StartMediaTransmissionMsg & msg);
772 virtual bool OnReceiveMsg(
const OpalSkinnyEndPoint::StopMediaTransmissionMsg & msg);
776 bool OnReceiveCallInfo(
const OpalSkinnyEndPoint::CallInfoCommon & msg);
780 MediaInfo(
const OpalSkinnyEndPoint::OpenReceiveChannelMsg & msg);
781 MediaInfo(
const OpalSkinnyEndPoint::CloseReceiveChannelMsg & msg);
782 MediaInfo(
const OpalSkinnyEndPoint::StartMediaTransmissionMsg & msg);
783 MediaInfo(
const OpalSkinnyEndPoint::StopMediaTransmissionMsg & msg);
785 bool operator<(
const MediaInfo & other)
const;
788 uint32_t m_passThruPartyId;
789 uint32_t m_payloadCapability;
791 mutable unsigned m_sessionId;
793 void OpenMediaChannel(
const MediaInfo & info);
794 void OpenSimulatedMediaChannel(
const MediaInfo & info,
const OpalMediaFormat & mediaFormat);
798 OpalSkinnyEndPoint::PhoneDevice & m_phoneDevice;
800 uint32_t m_lineInstance;
801 uint32_t m_callIdentifier;
802 PString m_alertingType;
803 bool m_needSoftKeyEndcall;
807 std::set<MediaInfo> m_passThruMedia;
808 std::set<unsigned> m_simulatedTransmitters;
812 template <
class MSG>
bool OpalSkinnyEndPoint::DelegateMsg(
const PhoneDevice & phone,
const MSG & msg)
814 PSafePtr<OpalSkinnyConnection> connection = phone.m_activeConnection;
815 PTRACE_CONTEXT_ID_PUSH_THREAD(connection);
816 return connection == NULL || !connection.SetSafetyMode(PSafeReadWrite) || connection->OnReceiveMsg(msg);
820 #endif // OPAL_SKINNY
822 #endif // OPAL_SKINNY_H
void PrintOn(ostream &strm) const
Definition: manager.h:150
PString GetName(const OpalMediaType &mediaType)
virtual void OnReleased()
PDECLARE_MUTEX(m_connectionsByRtpMutex)
Definition: transports.h:1104
Definition: transports.h:411
virtual PBoolean SetConnected()
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)=0
OpalEndPoint & m_endpoint
Definition: connection.h:1961
Definition: connection.h:530
virtual WORD GetDefaultSignalPort() const
virtual PBoolean SetAlerting(const PString &calleeName, PBoolean withMedia)
#define PTRACE(level, section, args)
Definition: opalplugin.hpp:84
virtual PBoolean SetUpConnection()
ostream & operator<<(ostream &strm, OpalSilenceDetector::Mode mode)
virtual void OnClosedMediaStream(const OpalMediaStream &stream)
virtual bool IsNetworkConnection() const =0
PSafePtr< OpalTransport > OpalTransportPtr
Definition: transports.h:50
virtual PString GetAlertingType() const
virtual PBoolean GarbageCollection()
virtual OpalMediaType::AutoStartMode GetAutoStart(const OpalMediaType &mediaType) const
Definition: transports.h:151
Definition: transports.h:326
virtual OpalMediaFormatList GetMediaFormats() const
virtual PString GetDefaultTransport() const
virtual OpalTransportAddress GetRemoteAddress() const
Definition: connection.h:1738