|
@@ -1,19 +1,12 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "mod_assistantchannel.h"
|
|
|
-
|
|
|
-#include "VideoDesc.h"
|
|
|
-#include "AssistantChannel_server_g.h"
|
|
|
-#include "../../Other/rvcmediacommon/rvc_media_common.h"
|
|
|
-#include "chan_protocol.h"
|
|
|
-
|
|
|
-using namespace AssistantChannel;
|
|
|
+#include "../include/EventCode.h"
|
|
|
|
|
|
static const char *__states[] = {
|
|
|
"Idle", "Connecting", "Connected", "Closing"
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
inline const char *state2str(int state)
|
|
|
{
|
|
|
return __states[state];
|
|
@@ -65,321 +58,387 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
|
|
|
}
|
|
|
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
- {
|
|
|
- //MessageBoxA(0,0,0,0);
|
|
|
- bizchan_lib_init();
|
|
|
- m_eState = eChannelState_Idle;
|
|
|
- m_pChan = NULL;
|
|
|
- m_eDeviceType = eStand2sType;
|
|
|
- //is Pad Version
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
- CSystemStaticInfo stStaticinfo;
|
|
|
- spFunction->GetSystemStaticInfo(stStaticinfo);
|
|
|
- if (stricmp(stStaticinfo.strMachineType,"RVC.PAD")==0)
|
|
|
- {
|
|
|
- if (stricmp(stStaticinfo.strSite,"CMB.FLB")==0)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is mobile pad");
|
|
|
- m_eDeviceType = eMobilePadType;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is pad");
|
|
|
- m_eDeviceType = ePadtype;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (stricmp(stStaticinfo.strMachineType,"RVC.Desk2S")==0)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is Desk2S");
|
|
|
- m_eDeviceType = eDesk2SType;
|
|
|
- }
|
|
|
- else if (stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is RPM.Stand1S");
|
|
|
- m_eDeviceType = eRpm1sType;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is standard");
|
|
|
- m_eDeviceType = eStand2sType;
|
|
|
- }
|
|
|
- ListEntry_InitHead(&m_stateList);
|
|
|
- ListEntry_InitHead(&m_rxpktList);
|
|
|
+static void __on_recv_pkt(bizchan_t *chan, int type, int sub_type, int id, const char *pkt, int pkt_size, void *user_data)
|
|
|
+{
|
|
|
+ CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
|
|
|
+ pThis->_on_recv_pkt(type, sub_type, id, pkt, pkt_size);
|
|
|
+}
|
|
|
+
|
|
|
+static void __on_connect(bizchan_t *chan, int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc, const char *remote_client_id, void *user_data)
|
|
|
+{
|
|
|
+ CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
|
|
|
+ pThis->_on_connect(error, remote_ip, remote_video_rtp, remote_video_desc);
|
|
|
+}
|
|
|
|
|
|
+static void __on_close(bizchan_t *chan, void *user_data)
|
|
|
+{
|
|
|
+ CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
|
|
|
+ pThis->_on_close();
|
|
|
+}
|
|
|
+
|
|
|
+static void __on_destroy(bizchan_t *chan, void *user_data)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
- //Connect("99.1.100.215", 2323, "9990", NORMAL_CALLTYPE);
|
|
|
- return Error_Succeed;
|
|
|
+static void __dbg(void *user_data, const char *fmt, va_list arg)
|
|
|
+{
|
|
|
+ //vDbg(fmt, arg);
|
|
|
+ int n = _scprintf(fmt, arg);
|
|
|
+ if (n >= MAX_PATH) {
|
|
|
+ char* buf = (char*)malloc((size_t)(n + 1));
|
|
|
+ _snprintf(buf, n + 1, fmt, arg);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
|
|
|
+ free(buf);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ char strlog[MAX_PATH] = { 0 };
|
|
|
+ _snprintf(strlog, MAX_PATH, fmt, arg);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
|
|
|
- {
|
|
|
- //.....
|
|
|
- bizchan_lib_term();
|
|
|
- return Error_Succeed;
|
|
|
+
|
|
|
+
|
|
|
+void CBizChannelEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = __OnStart(Error_Succeed);
|
|
|
+ pTransactionContext->SendAnswer(Error);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CBizChannelEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = __OnClose(Error_Succeed);
|
|
|
+ pTransactionContext->SendAnswer(Error);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ErrorCodeEnum CBizChannelEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
+{
|
|
|
+ //MessageBoxA(0,0,0,0);
|
|
|
+ bizchan_lib_init();
|
|
|
+ m_eState = eChannelState_Idle;
|
|
|
+ m_pChan = NULL;
|
|
|
+ m_eDeviceType = RvcGetDeviceType();
|
|
|
+ ListEntry_InitHead(&m_stateList);
|
|
|
+ ListEntry_InitHead(&m_rxpktList);
|
|
|
+ return Error_Succeed;
|
|
|
+}
|
|
|
+
|
|
|
+void CBizChannelEntity::OnStarted()
|
|
|
+{
|
|
|
+ LogEvent(Severity_Middle, LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS, "assistant channel started successfully.");
|
|
|
+}
|
|
|
+
|
|
|
+DeviceTypeEnum CBizChannelEntity::RvcGetDeviceType()
|
|
|
+{
|
|
|
+ DeviceTypeEnum eType = eStand2sType;
|
|
|
+ CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
+ CSystemStaticInfo stStaticinfo;
|
|
|
+ spFunction->GetSystemStaticInfo(stStaticinfo);
|
|
|
+ if (_stricmp(stStaticinfo.strMachineType,"RVC.PAD")==0){
|
|
|
+ if (_stricmp(stStaticinfo.strSite,"CMB.FLB")==0){
|
|
|
+ eType = eMobilePadType;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ eType = ePadtype;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk2S")==0){
|
|
|
+ eType = eDesk2SType;
|
|
|
+ WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
|
|
|
+ WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MachineVersion is %d.%d", nMajor, nMinor);
|
|
|
+ if (2 == nMajor){
|
|
|
+ eType = eDesk2SIntegratedType;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (_stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0){
|
|
|
+ eType = eRpm1sType;
|
|
|
+ }
|
|
|
+ else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk1S")==0){
|
|
|
+ eType = eDesk1SType;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ eType = eStand2sType;
|
|
|
}
|
|
|
|
|
|
- CServerSessionBase * CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
|
|
|
- {
|
|
|
- //LOG_FUNCTION();
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
|
|
|
- return new ChannelServiceSession(this, m_id_seq++);
|
|
|
+ if (eType >= 0 && eType < sizeof(Device_Type_Table)/sizeof(char*)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
|
|
|
}
|
|
|
+
|
|
|
+ return eType;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
|
|
|
+{
|
|
|
+ //.....
|
|
|
+ bizchan_lib_term();
|
|
|
+ return Error_Succeed;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+CServerSessionBase* CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
|
|
|
+{
|
|
|
+ LOG_FUNCTION();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
|
|
|
+ return new ChannelServiceSession(this, m_id_seq++);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::Connect(const char *ip, int port, const char *callno, CallingTypeEnum eType)
|
|
|
+ErrorCodeEnum CBizChannelEntity::Connect(const char *ip, int port, const char *callno, CallingTypeEnum eType)
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = Error_Succeed;
|
|
|
+ if (m_eState == eChannelState_Idle)
|
|
|
{
|
|
|
- ErrorCodeEnum Error = Error_Succeed;
|
|
|
- if (m_eState == eChannelState_Idle)
|
|
|
- {
|
|
|
- CSystemStaticInfo Info;
|
|
|
- bizchan_config_t config = {0};
|
|
|
- bizchan_callback_t cb = {0};
|
|
|
- GetFunction()->GetSystemStaticInfo(Info);
|
|
|
- config.proxy_server = const_cast<char*>(ip);
|
|
|
- config.proxy_server_port = port;
|
|
|
- if (MOBILETOPAD_CALLTYPE == eType || PADTOPAD_CALLTYPE == eType){
|
|
|
- config.session_id = const_cast<char*>(callno);
|
|
|
- }else{
|
|
|
- config.session_id = const_cast<char*>(((const char*)Info.strTerminalID));
|
|
|
- }
|
|
|
+ CSystemStaticInfo Info;
|
|
|
+ bizchan_config_t config = {0};
|
|
|
+ bizchan_callback_t cb = {0};
|
|
|
+ GetFunction()->GetSystemStaticInfo(Info);
|
|
|
+ config.proxy_server = const_cast<char*>(ip);
|
|
|
+ config.proxy_server_port = port;
|
|
|
+ if (MOBILETOPAD_CALLTYPE == eType || PADTOPAD_CALLTYPE == eType){
|
|
|
+ config.session_id = const_cast<char*>(callno);
|
|
|
+ }else{
|
|
|
+ config.session_id = const_cast<char*>(((const char*)Info.strTerminalID));
|
|
|
+ }
|
|
|
|
|
|
- if (MOBILETOPAD_CALLTYPE == eType){
|
|
|
- config.crypt_type = 1;
|
|
|
- }
|
|
|
- config.call_no = const_cast<char*>(callno);
|
|
|
- config.client_id = "";
|
|
|
- config.video.desc = MakeDesc(Info.eScreen,m_eDeviceType);
|
|
|
- config.video.rtp_port = REC_COMMON_VIDEO_PORT;
|
|
|
- cb.user_data = this;
|
|
|
- cb.on_close = &__on_close;
|
|
|
- cb.on_connect = &__on_connect;
|
|
|
- cb.on_destroy = &__on_destroy;
|
|
|
- cb.on_recv_pkt = &__on_recv_pkt;
|
|
|
- cb.dbg = &__dbg;
|
|
|
- int rc = bizchan_create(&config, &cb, &m_pChan);
|
|
|
- if (rc == 0)
|
|
|
- {
|
|
|
- rc = bizchan_start_connect(m_pChan);
|
|
|
- }
|
|
|
- if (rc != 0)
|
|
|
- Error = Error_Unexpect;
|
|
|
- else
|
|
|
- ChangeState(eChannelState_Connecting);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (MOBILETOPAD_CALLTYPE == eType){
|
|
|
+ config.crypt_type = 1;
|
|
|
+ }
|
|
|
+ config.call_no = const_cast<char*>(callno);
|
|
|
+ config.client_id = "";
|
|
|
+ config.video.desc = MakeDesc(Info.eScreen,m_eDeviceType);
|
|
|
+ config.video.rtp_port = REC_COMMON_VIDEO_PORT;
|
|
|
+ cb.user_data = this;
|
|
|
+ cb.on_close = &__on_close;
|
|
|
+ cb.on_connect = &__on_connect;
|
|
|
+ cb.on_destroy = &__on_destroy;
|
|
|
+ cb.on_recv_pkt = &__on_recv_pkt;
|
|
|
+ cb.dbg = &__dbg;
|
|
|
+ int rc = bizchan_create(&config, &cb, &m_pChan);
|
|
|
+ if (rc == 0)
|
|
|
{
|
|
|
- Error = Error_InvalidState;
|
|
|
+ rc = bizchan_start_connect(m_pChan);
|
|
|
}
|
|
|
-
|
|
|
- //Dbg("Connect: %d", Error);
|
|
|
- return Error;
|
|
|
+ if (rc != 0)
|
|
|
+ Error = Error_Unexpect;
|
|
|
+ else
|
|
|
+ ChangeState(eChannelState_Connecting);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Error = Error_InvalidState;
|
|
|
}
|
|
|
+ return Error;
|
|
|
+}
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::Close()
|
|
|
- {
|
|
|
- ErrorCodeEnum Error = Error_Succeed;
|
|
|
- if (m_eState == eChannelState_Connecting || m_eState == eChannelState_Connected) {
|
|
|
- int rc = bizchan_start_close(m_pChan);
|
|
|
- if (rc == 0) {
|
|
|
- ChangeState(eChannelState_Closing);
|
|
|
- } else {
|
|
|
- Error = Error_Unexpect;
|
|
|
- }
|
|
|
+
|
|
|
+ErrorCodeEnum CBizChannelEntity::Close()
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = Error_Succeed;
|
|
|
+ if (m_eState == eChannelState_Connecting || m_eState == eChannelState_Connected) {
|
|
|
+ int rc = bizchan_start_close(m_pChan);
|
|
|
+ if (rc == 0) {
|
|
|
+ ChangeState(eChannelState_Closing);
|
|
|
} else {
|
|
|
- Error = Error_InvalidState;
|
|
|
+ Error = Error_Unexpect;
|
|
|
}
|
|
|
- return Error_Succeed;
|
|
|
+ } else {
|
|
|
+ Error = Error_InvalidState;
|
|
|
}
|
|
|
+ return Error_Succeed;
|
|
|
+}
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
|
|
|
+
|
|
|
+ErrorCodeEnum CBizChannelEntity::RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
|
|
|
+{
|
|
|
+ state_entry *pos;
|
|
|
+ ListEntry_ForEach(pos, &m_stateList, state_entry, entry)
|
|
|
{
|
|
|
- state_entry *pos;
|
|
|
- ListEntry_ForEach(pos, &m_stateList, state_entry, entry)
|
|
|
+ if (pos->id == id)
|
|
|
{
|
|
|
- if (pos->id == id)
|
|
|
- {
|
|
|
- return Error_AlreadyExist;
|
|
|
- }
|
|
|
+ return Error_AlreadyExist;
|
|
|
}
|
|
|
- pos = new state_entry();
|
|
|
- pos->ctx = ctx;
|
|
|
- pos->id = id;
|
|
|
- ListEntry_AddTail(&m_stateList, &pos->entry);
|
|
|
- return Error_Succeed;
|
|
|
}
|
|
|
+ pos = new state_entry();
|
|
|
+ pos->ctx = ctx;
|
|
|
+ pos->id = id;
|
|
|
+ ListEntry_AddTail(&m_stateList, &pos->entry);
|
|
|
+ return Error_Succeed;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
|
|
|
+ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
|
|
|
+{
|
|
|
+ rxpkt_entry *pos;
|
|
|
+ ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
{
|
|
|
- rxpkt_entry *pos;
|
|
|
- ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
+ if ((pos->id == id)&&(pos->ctx->Req.type == ctx->Req.type))
|
|
|
{
|
|
|
- if ((pos->id == id)&&(pos->ctx->Req.type == ctx->Req.type))
|
|
|
- {
|
|
|
-
|
|
|
- return Error_AlreadyExist;
|
|
|
- }
|
|
|
+ return Error_AlreadyExist;
|
|
|
}
|
|
|
- //Dbg("RegisterRxPkt id = %d",id);
|
|
|
- pos = new rxpkt_entry();
|
|
|
- pos->id = id;
|
|
|
- pos->ctx = ctx;
|
|
|
- ListEntry_AddTail(&m_rxpktList, &pos->entry);
|
|
|
- return Error_Succeed;
|
|
|
}
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RegisterRxPkt id = %d",id);
|
|
|
+ pos = new rxpkt_entry();
|
|
|
+ pos->id = id;
|
|
|
+ pos->ctx = ctx;
|
|
|
+ ListEntry_AddTail(&m_rxpktList, &pos->entry);
|
|
|
+ return Error_Succeed;
|
|
|
+}
|
|
|
|
|
|
- void CBizChannelEntity::UnregisterState(int id)
|
|
|
- {
|
|
|
- state_entry *pos,*n;
|
|
|
- ListEntry_ForEachSafe(pos,n, &m_stateList, state_entry, entry) {
|
|
|
- if (pos->id == id) {
|
|
|
- ListEntry_DeleteNode(&pos->entry);
|
|
|
- delete pos;
|
|
|
- }
|
|
|
+
|
|
|
+void CBizChannelEntity::UnregisterState(int id)
|
|
|
+{
|
|
|
+ state_entry *pos,*n;
|
|
|
+ ListEntry_ForEachSafe(pos,n, &m_stateList, state_entry, entry) {
|
|
|
+ if (pos->id == id) {
|
|
|
+ ListEntry_DeleteNode(&pos->entry);
|
|
|
+ delete pos;
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- void CBizChannelEntity::UnregisterRxpkt(int id)
|
|
|
+
|
|
|
+void CBizChannelEntity::UnregisterRxpkt(int id)
|
|
|
+{
|
|
|
+ rxpkt_entry *pos,*n;
|
|
|
+ //ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
+ ListEntry_ForEachSafe(pos, n, &m_rxpktList, rxpkt_entry, entry)
|
|
|
{
|
|
|
- rxpkt_entry *pos,*n;
|
|
|
- //ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
- ListEntry_ForEachSafe(pos, n, &m_rxpktList, rxpkt_entry, entry)
|
|
|
+ if((pos->id == id))
|
|
|
{
|
|
|
- if((pos->id == id))
|
|
|
- {
|
|
|
- //Dbg("UnregisterRxpkt id = %d",pos->id);
|
|
|
- ListEntry_DeleteNode(&pos->entry);
|
|
|
- delete pos;
|
|
|
- }
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UnregisterRxpkt id = %d",pos->id);
|
|
|
+ ListEntry_DeleteNode(&pos->entry);
|
|
|
+ delete pos;
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data)
|
|
|
+ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data)
|
|
|
+{
|
|
|
+ if (m_eState == eChannelState_Connected) {
|
|
|
+ //LOG_TRACE("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
+ //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
+ int rc = bizchan_post_pkt(m_pChan, type, compress, encrypt, sub_type, id, (const char*)data.m_pData, data.m_iLength);
|
|
|
+ return rc == 0 ? Error_Succeed : Error_NetBroken;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- if (m_eState == eChannelState_Connected) {
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
- //Dbg("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
- int rc = bizchan_post_pkt(m_pChan, type, compress, encrypt, sub_type, id, (const char*)data.m_pData, data.m_iLength);
|
|
|
- return rc == 0 ? Error_Succeed : Error_NetBroken;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return Error_NetBroken;
|
|
|
- }
|
|
|
+ return Error_NetBroken;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- void CBizChannelEntity::ChangeState(int new_state, const char *param)
|
|
|
- {
|
|
|
- if (m_eState != new_state) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change state from %s to %s", state2str(m_eState), state2str(new_state));
|
|
|
- m_eState = new_state;
|
|
|
- state_entry *pos;
|
|
|
- ListEntry_ForEach(pos, &m_stateList, state_entry, entry) {
|
|
|
- ChannelService_State_Info State;
|
|
|
- State.state = new_state;
|
|
|
- State.status = state2str(new_state);
|
|
|
- if (param) {
|
|
|
- State.param = param;
|
|
|
- }
|
|
|
- pos->ctx->SendMessage(State);
|
|
|
+
|
|
|
+void CBizChannelEntity::ChangeState(int new_state, const char *param)
|
|
|
+{
|
|
|
+ if (m_eState != new_state) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change state from %s to %s", state2str(m_eState), state2str(new_state));
|
|
|
+ m_eState = new_state;
|
|
|
+ state_entry *pos;
|
|
|
+ ListEntry_ForEach(pos, &m_stateList, state_entry, entry) {
|
|
|
+ ChannelService_State_Info State;
|
|
|
+ State.state = new_state;
|
|
|
+ State.status = state2str(new_state);
|
|
|
+ if (param) {
|
|
|
+ State.param = param;
|
|
|
}
|
|
|
+ pos->ctx->SendMessage(State);
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- //void on_recv_pkt(int type, int sub_type, const char *pkt, int pkt_size)
|
|
|
- void CBizChannelEntity::on_recv_pkt(int type, int sub_type, int id, CBlob &data)
|
|
|
+
|
|
|
+//void on_recv_pkt(int type, int sub_type, const char *pkt, int pkt_size)
|
|
|
+void CBizChannelEntity::on_recv_pkt(int type, int sub_type, int id, CBlob &data)
|
|
|
+{
|
|
|
+ //LOG_TRACE("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
+ //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
+ rxpkt_entry *pos;
|
|
|
+ ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
{
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
- //Dbg("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
|
|
|
- rxpkt_entry *pos;
|
|
|
- ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
|
|
|
+ if (pos->ctx->Req.type == type)
|
|
|
{
|
|
|
- if (pos->ctx->Req.type == type)
|
|
|
- {
|
|
|
- ChannelService_Packet_Info pkt;
|
|
|
- pkt.type = type;
|
|
|
- pkt.sub_type = sub_type;
|
|
|
- pkt.id = id;
|
|
|
- //pkt.data.m_bManaged = true;
|
|
|
- pkt.data = data;
|
|
|
- //data.m_bManaged = false;
|
|
|
- pos->ctx->SendMessage(pkt);
|
|
|
- //break;
|
|
|
- }
|
|
|
+ ChannelService_Packet_Info pkt;
|
|
|
+ pkt.type = type;
|
|
|
+ pkt.sub_type = sub_type;
|
|
|
+ pkt.id = id;
|
|
|
+ //pkt.data.m_bManaged = true;
|
|
|
+ pkt.data = data;
|
|
|
+ //data.m_bManaged = false;
|
|
|
+ pos->ctx->SendMessage(pkt);
|
|
|
+ //break;
|
|
|
}
|
|
|
}
|
|
|
- void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
|
|
|
- {
|
|
|
- if (!error) {
|
|
|
- if (m_eState == eChannelState_Connecting) {
|
|
|
- CSimpleStringA strValue;
|
|
|
- ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
|
|
|
- if (Error == Error_Succeed) {
|
|
|
- int local_view_x;
|
|
|
- int local_view_y;
|
|
|
- int local_view_cx;
|
|
|
- int local_view_cy;
|
|
|
- int remote_view_x;
|
|
|
- int remote_view_y;
|
|
|
- int remote_view_cx;
|
|
|
- int remote_view_cy;
|
|
|
- int remote_video_width = 0;
|
|
|
- int remote_video_height = 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
|
|
|
+{
|
|
|
+ if (!error) {
|
|
|
+ if (m_eState == eChannelState_Connecting) {
|
|
|
+ CSimpleStringA strValue;
|
|
|
+ ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
|
|
|
+ if (Error == Error_Succeed) {
|
|
|
+ int local_view_x;
|
|
|
+ int local_view_y;
|
|
|
+ int local_view_cx;
|
|
|
+ int local_view_cy;
|
|
|
+ int remote_view_x;
|
|
|
+ int remote_view_y;
|
|
|
+ int remote_view_cx;
|
|
|
+ int remote_view_cy;
|
|
|
+ int remote_video_width = 0;
|
|
|
+ int remote_video_height = 0;
|
|
|
+ {
|
|
|
+ CSystemStaticInfo Info;
|
|
|
+ GetFunction()->GetSystemStaticInfo(Info);
|
|
|
+ if (Info.eScreen == 1)
|
|
|
{
|
|
|
- CSystemStaticInfo Info;
|
|
|
- GetFunction()->GetSystemStaticInfo(Info);
|
|
|
- if (Info.eScreen == 1)
|
|
|
- {
|
|
|
- remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
|
|
|
- remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
|
|
|
- remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
|
|
|
- }
|
|
|
+ remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
|
|
|
+ remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
|
|
|
+ remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
+ ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
+ remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
+ //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get Video Window Initialize Param:%d,%d,%d,%d %d,%d,%d,%d",local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
+ //remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
+ CSimpleStringA param;
|
|
|
+ if (eMobilePadType == m_eDeviceType)
|
|
|
+ {
|
|
|
+ param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
+ REC_COMMON_VIDEO_FPS_MOBILE_AGENT, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
- //Dbg("Get Video Window Initialize Param:%d,%d,%d,%d %d,%d,%d,%d",local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
- // remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
- CSimpleStringA param;
|
|
|
- if (eMobilePadType == m_eDeviceType)
|
|
|
- {
|
|
|
- param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
- REC_COMMON_VIDEO_FPS_MOBILE_AGENT, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
- remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
- }
|
|
|
- else if((ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
|
|
|
- {
|
|
|
- param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
- REC_COMMON_VIDEO_FPS_MOBILE, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
- remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
- REC_COMMON_VIDEO_FPS, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
- remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
- }
|
|
|
-
|
|
|
- ChangeState(eChannelState_Connected, (LPCSTR)param);
|
|
|
- } else {
|
|
|
- Dbg("get VideoWindowInitializeParam failed!");
|
|
|
- bizchan_start_close(m_pChan);
|
|
|
}
|
|
|
+ else if((ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
|
|
|
+ {
|
|
|
+ param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
+ REC_COMMON_VIDEO_FPS_MOBILE, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
+ remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
|
|
|
+ REC_COMMON_VIDEO_FPS, local_view_x, local_view_y, local_view_cx, local_view_cy,
|
|
|
+ remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
|
|
|
+ }
|
|
|
+
|
|
|
+ ChangeState(eChannelState_Connected, (LPCSTR)param);
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get VideoWindowInitializeParam failed!");
|
|
|
+ bizchan_start_close(m_pChan);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (m_pChan) {
|
|
|
- bizchan_close(m_pChan);
|
|
|
- bizchan_destroy(m_pChan);
|
|
|
- m_pChan = NULL;
|
|
|
- }
|
|
|
- ChangeState(eChannelState_Idle);
|
|
|
}
|
|
|
- }
|
|
|
- void CBizChannelEntity::on_close()
|
|
|
- {
|
|
|
+ } else {
|
|
|
if (m_pChan) {
|
|
|
bizchan_close(m_pChan);
|
|
|
bizchan_destroy(m_pChan);
|
|
@@ -387,42 +446,59 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
|
|
|
}
|
|
|
ChangeState(eChannelState_Idle);
|
|
|
}
|
|
|
- void CBizChannelEntity::_on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size)
|
|
|
- {
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("_on rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", pkt_size, type, sub_type, id, hash32_buf(pkt, pkt_size, 0));
|
|
|
- NotifyOnRecvPkt *task = new NotifyOnRecvPkt();
|
|
|
- task->m_pEntity = this;
|
|
|
- task->type = type;
|
|
|
- task->sub_type = sub_type;
|
|
|
- task->id = id;
|
|
|
- task->data.m_bManaged = true;
|
|
|
- task->data.m_iLength = pkt_size;
|
|
|
- if (pkt_size)
|
|
|
- {
|
|
|
- task->data.m_pData = new char[pkt_size];
|
|
|
- memcpy(task->data.m_pData, pkt, pkt_size);
|
|
|
- } else {
|
|
|
- task->data.m_pData = NULL;
|
|
|
- }
|
|
|
- GetFunction()->PostEntityTaskFIFO(task);
|
|
|
- }
|
|
|
- void CBizChannelEntity::_on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
|
|
|
- {
|
|
|
- NotifyOnConnect *task = new NotifyOnConnect();
|
|
|
- task->m_pEntity = this;
|
|
|
- task->error = error;
|
|
|
- task->remote_rtp_ip = remote_ip;
|
|
|
- task->remote_video_port = remote_video_rtp;
|
|
|
- task->remote_video_desc = remote_video_desc;
|
|
|
- GetFunction()->PostEntityTaskFIFO(task);
|
|
|
+}
|
|
|
+
|
|
|
+void CBizChannelEntity::on_close()
|
|
|
+{
|
|
|
+ if (m_pChan) {
|
|
|
+ bizchan_close(m_pChan);
|
|
|
+ bizchan_destroy(m_pChan);
|
|
|
+ m_pChan = NULL;
|
|
|
}
|
|
|
+ ChangeState(eChannelState_Idle);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- void CBizChannelEntity::_on_close()
|
|
|
+void CBizChannelEntity::_on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size)
|
|
|
+{
|
|
|
+ //LOG_TRACE("_on rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", pkt_size, type, sub_type, id, hash32_buf(pkt, pkt_size, 0));
|
|
|
+ NotifyOnRecvPkt *task = new NotifyOnRecvPkt();
|
|
|
+ task->m_pEntity = this;
|
|
|
+ task->type = type;
|
|
|
+ task->sub_type = sub_type;
|
|
|
+ task->id = id;
|
|
|
+ task->data.m_bManaged = true;
|
|
|
+ task->data.m_iLength = pkt_size;
|
|
|
+ if (pkt_size)
|
|
|
{
|
|
|
- NotifyOnClose * task = new NotifyOnClose();
|
|
|
- task->m_pEntity = this;
|
|
|
- GetFunction()->PostEntityTaskFIFO(task);
|
|
|
+ task->data.m_pData = new char[pkt_size];
|
|
|
+ memcpy(task->data.m_pData, pkt, pkt_size);
|
|
|
+ } else {
|
|
|
+ task->data.m_pData = NULL;
|
|
|
}
|
|
|
+ GetFunction()->PostEntityTaskFIFO(task);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CBizChannelEntity::_on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
|
|
|
+{
|
|
|
+ NotifyOnConnect *task = new NotifyOnConnect();
|
|
|
+ task->m_pEntity = this;
|
|
|
+ task->error = error;
|
|
|
+ task->remote_rtp_ip = remote_ip;
|
|
|
+ task->remote_video_port = remote_video_rtp;
|
|
|
+ task->remote_video_desc = remote_video_desc;
|
|
|
+ GetFunction()->PostEntityTaskFIFO(task);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CBizChannelEntity::_on_close()
|
|
|
+{
|
|
|
+ NotifyOnClose *task = new NotifyOnClose();
|
|
|
+ task->m_pEntity = this;
|
|
|
+ GetFunction()->PostEntityTaskFIFO(task);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx )
|
|
@@ -477,6 +553,7 @@ void ChannelServiceSession::OnClose( ErrorCodeEnum eErrorCode )
|
|
|
m_pEntity->UnregisterState(m_id);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
SP_ENTITY(CBizChannelEntity)
|
|
|
SP_END_ENTITY_MAP()
|