media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _CC_SIPCC_SERVICE_H
     1.9 +#define _CC_SIPCC_SERVICE_H
    1.10 +
    1.11 +#include "CC_Service.h"
    1.12 +
    1.13 +extern "C" {
    1.14 +	// Callbacks from SIPCC.
    1.15 +    void configCtlFetchReq(int device_handle);
    1.16 +    char* platGetIPAddr();
    1.17 +
    1.18 +    void CCAPI_DeviceListener_onDeviceEvent(ccapi_device_event_e type, cc_device_handle_t hDevice, cc_deviceinfo_ref_t dev_info);
    1.19 +    void CCAPI_DeviceListener_onFeatureEvent(ccapi_device_event_e type, cc_deviceinfo_ref_t /* device_info */, cc_featureinfo_ref_t feature_info);
    1.20 +    void CCAPI_LineListener_onLineEvent(ccapi_line_event_e eventType, cc_lineid_t line, cc_lineinfo_ref_t info);
    1.21 +    void CCAPI_CallListener_onCallEvent(ccapi_call_event_e eventType, cc_call_handle_t handle, cc_callinfo_ref_t info);
    1.22 +}
    1.23 +
    1.24 +#include "VcmSIPCCBinding.h"
    1.25 +#include "CSFAudioControlWrapper.h"
    1.26 +#include "CSFVideoControlWrapper.h"
    1.27 +#include "CSFMediaProvider.h"
    1.28 +
    1.29 +#include "base/lock.h"
    1.30 +#include "base/waitable_event.h"
    1.31 +
    1.32 +#include <vector>
    1.33 +#include <set>
    1.34 +#include "mozilla/Mutex.h"
    1.35 +
    1.36 +namespace CSF
    1.37 +{
    1.38 +    class PhoneConfig;
    1.39 +	DECLARE_NS_PTR(CC_SIPCCService);
    1.40 +
    1.41 +	class CC_SIPCCService : public CC_Service, public StreamObserver, public MediaProviderObserver
    1.42 +    {
    1.43 +	    friend void ::configCtlFetchReq(int device_handle);
    1.44 +	    friend char* ::platGetIPAddr();
    1.45 +
    1.46 +	public:
    1.47 +	    CC_SIPCCService();
    1.48 +	    virtual ~CC_SIPCCService();
    1.49 +
    1.50 +	    /**
    1.51 +	     * Public API
    1.52 +	     */
    1.53 +	    virtual void addCCObserver ( CC_Observer * observer );
    1.54 +	    virtual void removeCCObserver ( CC_Observer * observer );
    1.55 +
    1.56 +	    virtual bool init(const std::string& user, const std::string& password, const std::string& domain, const std::string& deviceName);
    1.57 +	    virtual void destroy();
    1.58 +
    1.59 +	    virtual void setDeviceName(const std::string& deviceName);
    1.60 +	    virtual void setLoggingMask(int mask);
    1.61 +	    virtual void setLocalAddressAndGateway(const std::string& localAddress, const std::string& defaultGW);
    1.62 +
    1.63 +	    virtual bool startService();
    1.64 +	    virtual void stop();
    1.65 +
    1.66 +	    virtual bool isStarted();
    1.67 +
    1.68 +	    virtual CC_DevicePtr getActiveDevice();
    1.69 +	    virtual std::vector<CC_DevicePtr> getDevices();
    1.70 +
    1.71 +	    virtual AudioControlPtr getAudioControl();
    1.72 +	    virtual VideoControlPtr getVideoControl();
    1.73 +
    1.74 +	    // From the StreamObserver interface
    1.75 +	    virtual void registerStream(cc_call_handle_t call, int streamId, bool isVideo);
    1.76 +    	virtual void deregisterStream(cc_call_handle_t call, int streamId);
    1.77 +    	virtual void dtmfBurst(int digit, int direction, int duration);
    1.78 +    	virtual void sendIFrame(cc_call_handle_t call);
    1.79 +
    1.80 +		virtual void onVideoModeChanged( bool enable );
    1.81 +		virtual void onKeyFrameRequested( int stream );
    1.82 +		virtual void onMediaLost( int callId );
    1.83 +		virtual void onMediaRestored( int callId );
    1.84 +
    1.85 +		virtual bool setLocalVoipPort(int port);
    1.86 +		virtual bool setRemoteVoipPort(int port);
    1.87 +		virtual bool setP2PMode(bool mode);
    1.88 +		virtual bool setSDPMode(bool mode);
    1.89 +
    1.90 +        /**
    1.91 +         * End of public API
    1.92 +         */
    1.93 +
    1.94 +    public:
    1.95 +        // These are used by the C callback functions to raise events.
    1.96 +        // This layer:
    1.97 +        //   - converts the C handles to C++ objects
    1.98 +        //   - invokes the member notify* functions to propagate events upwards
    1.99 +        //   - invokes any other functions needed to perform "value added" event handling in ECC.
   1.100 +        static void onDeviceEvent(ccapi_device_event_e type, cc_device_handle_t hDevice, cc_deviceinfo_ref_t dev_info);
   1.101 +        static void onFeatureEvent(ccapi_device_event_e type, cc_deviceinfo_ref_t /* device_info */, cc_featureinfo_ref_t feature_info);
   1.102 +        static void onLineEvent(ccapi_line_event_e eventType, cc_lineid_t line, cc_lineinfo_ref_t info);
   1.103 +        static void onCallEvent(ccapi_call_event_e eventType, cc_call_handle_t handle, cc_callinfo_ref_t info);
   1.104 +
   1.105 +	private: // Helper functions
   1.106 +
   1.107 +        //These notify functions call through to CallControlManager
   1.108 +        void notifyDeviceEventObservers  (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info);
   1.109 +        void notifyFeatureEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info);
   1.110 +        void notifyCallEventObservers    (ccapi_call_event_e callEvent,     CC_CallPtr callPtr, CC_CallInfoPtr info);
   1.111 +        void notifyLineEventObservers    (ccapi_line_event_e lineEvent,     CC_LinePtr linePtr, CC_LineInfoPtr info);
   1.112 +
   1.113 +        void endAllActiveCalls();
   1.114 +
   1.115 +        void applyLoggingMask(int newMask);
   1.116 +        void applyAudioVideoConfigSettings (PhoneConfig & phoneConfig);
   1.117 +
   1.118 +        bool isValidMediaPortRange(int mediaStartPort, int mediaEndPort);
   1.119 +        bool isValidDSCPValue(int value);
   1.120 +
   1.121 +    private: // Data Store
   1.122 +        // Singleton
   1.123 +        static CC_SIPCCService* _self;
   1.124 +
   1.125 +	    std::string deviceName;
   1.126 +        cc_int32_t loggingMask;
   1.127 +
   1.128 +        //IP Address Info
   1.129 +        std::string localAddress;
   1.130 +        std::string defaultGW;
   1.131 +
   1.132 +	    // SIPCC lifecycle
   1.133 +        bool bCreated;
   1.134 +        bool bStarted;
   1.135 +        mozilla::Mutex m_lock;
   1.136 +
   1.137 +        // Media Lifecycle
   1.138 +        VcmSIPCCBinding vcmMediaBridge;
   1.139 +
   1.140 +        // Observers
   1.141 +    	std::set<CC_Observer *> ccObservers;
   1.142 +
   1.143 +		//AV Control Wrappers
   1.144 +		AudioControlWrapperPtr audioControlWrapper;
   1.145 +		VideoControlWrapperPtr videoControlWrapper;
   1.146 +
   1.147 +		// Santization work
   1.148 +		bool bUseConfig;
   1.149 +		std::string sipUser;
   1.150 +		std::string sipPassword;
   1.151 +		std::string sipDomain;
   1.152 +    };
   1.153 +}
   1.154 +
   1.155 +#endif

mercurial