123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #ifndef RVC_MOD_ASSISTANTCHANNEL_H__
- #define RVC_MOD_ASSISTANTCHANNEL_H__
- #include "SpBase.h"
- #include "SpTest.h"
- #include "modVer.h"
- #include "VideoDesc.h"
- #include "AssistantChannel_server_g.h"
- #include "AssistantChannel_def_g.h"
- #include "ListEntry.h"
- #include "mod_counterconnector/CallType.h"
- #include "bizchan.h"
- #include "rvc_media_common.h"
- #include "chan_protocol.h"
- #include "EventCode.h"
- #include "../mod_counterconnector/CallType.h"
- using namespace AssistantChannel;
- class CBizChannelEntity : public CEntityBase
- {
- public:
- CBizChannelEntity() : m_id_seq(0) {}
- virtual ~CBizChannelEntity() {}
- virtual const char* GetEntityName() const { return "AssistantChannel"; }
- const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
- virtual bool IsService()const { return true; }
- ON_ENTITYT_TEST()
- virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext);
- virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext);
- ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError);
- virtual void OnStarted();
- DeviceTypeEnum RvcGetDeviceType();
- ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError);
- virtual CServerSessionBase *OnNewSession(const char* pszRemoteEntityName, const char * pszClass);
- ErrorCodeEnum Connect(const char *ip, int port);
- ErrorCodeEnum Close();
- int GetState() { return m_eState; }
- ErrorCodeEnum RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx);
- ErrorCodeEnum RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx);
- void UnregisterState(int id);
- void UnregisterRxpkt(int id);
- ErrorCodeEnum Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data);
- //void on_recv_pkt(int type, int sub_type, const char *pkt, int pkt_size)
- void on_recv_pkt(int type, int sub_type, int id, CBlob &data);
- void on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc);
- void on_close();
- void _on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size);
- void _on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc);
- void _on_close();
- private:
- struct NotifyOnClose : public ITaskSp
- {
- CBizChannelEntity *m_pEntity;
- virtual void Process()
- {
- m_pEntity->on_close();
- }
- };
- struct NotifyOnRecvPkt : public ITaskSp
- {
- CBizChannelEntity *m_pEntity;
- int type;
- int sub_type;
- int id;
- CBlob data;
- virtual void Process()
- {
- m_pEntity->on_recv_pkt(type, sub_type, id, data);
- }
- };
- struct NotifyOnConnect : public ITaskSp
- {
- CBizChannelEntity *m_pEntity;
- int error;
- CSimpleStringA remote_rtp_ip;
- int remote_video_port;
- int remote_video_desc;
- virtual void Process()
- {
- m_pEntity->on_connect(error, (LPCSTR)remote_rtp_ip, remote_video_port, remote_video_desc);
- }
- };
- void ChangeState(int new_state, const char *param = NULL);
- private:
- DeviceTypeEnum m_eDeviceType;
- int m_eState;
- bizchan_t *m_pChan;
- int m_id_seq;
- struct state_entry
- {
- LIST_ENTRY entry;
- int id;
- SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx;
- };
- LIST_ENTRY m_stateList;
- struct rxpkt_entry
- {
- LIST_ENTRY entry;
- int id;
- SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx;
- };
- LIST_ENTRY m_rxpktList;
- };
- class ChannelServiceSession : public ChannelService_ServerSessionBase
- {
- public:
- ChannelServiceSession(CBizChannelEntity *pEntity, int id) : m_pEntity(pEntity), m_id(id) {}
- virtual void Handle_Connect(SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx);
- virtual void Handle_Close(SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx);
- virtual void Handle_GetState(SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx);
- virtual void Handle_BeginState(SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx);
- virtual void Handle_EndState(SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx);
- virtual void Handle_Send(SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx);
- virtual void Handle_BeginRecv(SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx);
- virtual void Handle_EndRecv(SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx);
- virtual void OnClose(ErrorCodeEnum eErrorCode);
- private:
- int m_id;
- CBizChannelEntity *m_pEntity;
- };
- #endif /*RVC_MOD_ASSISTANTCHANNEL_H__*/
|