|
@@ -1,6 +1,6 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "mod_assistantchannel.h"
|
|
|
-#include "../include/EventCode.h"
|
|
|
+#include "EventCode.h"
|
|
|
|
|
|
static const char *__states[] = {
|
|
|
"Idle", "Connecting", "Connected", "Closing"
|
|
@@ -31,7 +31,7 @@ static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
|
|
|
ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILE,
|
|
|
ACM_VIDEO_MODE_QVGA, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILEAGENT);
|
|
|
}
|
|
|
- else if((ePadtype == eDevicetype)||(eDesk2SType == eDevicetype))
|
|
|
+ else if((ePadtype == eDevicetype)||(eDesk2SType == eDevicetype)||(eDesk1SType == eDevicetype)||(eDesk2SIntegratedType == eDevicetype))
|
|
|
{
|
|
|
return media_desc_encode(
|
|
|
ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILE,
|
|
@@ -84,7 +84,11 @@ static void __on_destroy(bizchan_t *chan, void *user_data)
|
|
|
static void __dbg(void *user_data, const char *fmt, va_list arg)
|
|
|
{
|
|
|
//vDbg(fmt, arg);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ int n = _vscprintf(fmt, arg);
|
|
|
+#else
|
|
|
int n = _scprintf(fmt, arg);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
if (n >= MAX_PATH) {
|
|
|
char* buf = (char*)malloc((size_t)(n + 1));
|
|
|
vsnprintf(buf, n + 1, fmt, arg);
|
|
@@ -93,7 +97,11 @@ static void __dbg(void *user_data, const char *fmt, va_list arg)
|
|
|
}
|
|
|
else {
|
|
|
char strlog[MAX_PATH] = { 0 };
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ _vsnprintf(strlog, MAX_PATH, fmt, arg);
|
|
|
+#else
|
|
|
vsnprintf(strlog, MAX_PATH, fmt, arg);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
|
|
|
}
|
|
|
}
|
|
@@ -163,6 +171,9 @@ DeviceTypeEnum CBizChannelEntity::RvcGetDeviceType()
|
|
|
else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk1S")==0){
|
|
|
eType = eDesk1SType;
|
|
|
}
|
|
|
+ else if (stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
|
|
|
+ eType = eCardStore;
|
|
|
+ }
|
|
|
else{
|
|
|
eType = eStand2sType;
|
|
|
}
|
|
@@ -185,8 +196,7 @@ ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
|
|
|
|
|
|
CServerSessionBase* CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
|
|
|
return new ChannelServiceSession(this, m_id_seq++);
|
|
|
}
|
|
|
|
|
@@ -214,14 +224,16 @@ ErrorCodeEnum CBizChannelEntity::Connect(const char *ip, int port, const char *c
|
|
|
cb.on_recv_pkt = &__on_recv_pkt;
|
|
|
cb.dbg = &__dbg;
|
|
|
int rc = bizchan_create(&config, &cb, &m_pChan);
|
|
|
- if (rc == 0)
|
|
|
- {
|
|
|
+ if (rc == 0) {
|
|
|
rc = bizchan_start_connect(m_pChan);
|
|
|
}
|
|
|
- if (rc != 0)
|
|
|
+
|
|
|
+ if (rc != 0) {
|
|
|
Error = Error_Unexpect;
|
|
|
- else
|
|
|
+ }
|
|
|
+ else {
|
|
|
ChangeState(eChannelState_Connecting);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -276,7 +288,6 @@ ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<Channe
|
|
|
return Error_AlreadyExist;
|
|
|
}
|
|
|
}
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RegisterRxPkt id = %d",id);
|
|
|
pos = new rxpkt_entry();
|
|
|
pos->id = id;
|
|
|
pos->ctx = ctx;
|
|
@@ -328,6 +339,15 @@ ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int
|
|
|
}
|
|
|
|
|
|
|
|
|
+void CBizChannelEntity::GetIpByDomain(char* poutput, size_t ulen, const char *pinput)
|
|
|
+{
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ bizchan_getip_bydomain(m_pChan, poutput, ulen, pinput);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
void CBizChannelEntity::ChangeState(int new_state, const char *param)
|
|
|
{
|
|
|
if (m_eState != new_state) {
|
|
@@ -347,7 +367,7 @@ void CBizChannelEntity::ChangeState(int new_state, const char *param)
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+//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));
|
|
@@ -414,7 +434,7 @@ void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_
|
|
|
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))
|
|
|
+ else if((ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType)||(eDesk1SType == m_eDeviceType) || (eDesk2SIntegratedType == 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,
|
|
@@ -433,7 +453,7 @@ void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_
|
|
|
bizchan_start_close(m_pChan);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
else {
|
|
|
if (m_pChan) {
|
|
|
bizchan_close(m_pChan);
|
|
@@ -499,6 +519,7 @@ void CBizChannelEntity::_on_close()
|
|
|
|
|
|
void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start connect, %s:%d [%s]", (LPCSTR)ctx->Req.ip, ctx->Req.port, (LPCSTR)ctx->Req.callno);
|
|
|
ErrorCodeEnum Error = m_pEntity->Connect(ctx->Req.ip, ctx->Req.port, ctx->Req.callno, (CallingTypeEnum)ctx->Req.etype);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect Error = %d", Error);
|
|
@@ -507,6 +528,7 @@ void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Conne
|
|
|
|
|
|
void ChannelServiceSession::Handle_Close( SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect close!");
|
|
|
ErrorCodeEnum Error = m_pEntity->Close();
|
|
|
ctx->Answer(Error);
|
|
@@ -514,6 +536,7 @@ void ChannelServiceSession::Handle_Close( SpReqAnsContext<ChannelService_Close_R
|
|
|
|
|
|
void ChannelServiceSession::Handle_GetState( SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
ctx->Ans.status = state2str(m_pEntity->GetState());
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|
|
@@ -525,24 +548,37 @@ void ChannelServiceSession::Handle_BeginState( SpSubscribeContext<ChannelService
|
|
|
|
|
|
void ChannelServiceSession::Handle_EndState( SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->UnregisterState(m_id);
|
|
|
}
|
|
|
|
|
|
void ChannelServiceSession::Handle_Send( SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->Send(ctx->Info.type, ctx->Info.compress, ctx->Info.encrypt, ctx->Info.sub_type, ctx->Info.id, ctx->Info.data);
|
|
|
}
|
|
|
|
|
|
void ChannelServiceSession::Handle_BeginRecv( SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx )
|
|
|
{
|
|
|
+
|
|
|
m_pEntity->RegisterRxPkt(m_id, ctx);
|
|
|
}
|
|
|
|
|
|
void ChannelServiceSession::Handle_EndRecv( SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx )
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->UnregisterRxpkt(m_id);
|
|
|
}
|
|
|
|
|
|
+void ChannelServiceSession::Handle_GetIpByDomain(SpReqAnsContext<ChannelService_GetIpByDomain_Req, ChannelService_GetIpByDomain_Ans>::Pointer ctx)
|
|
|
+{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
+ char strip[MAX_PATH] = {0};
|
|
|
+ m_pEntity->GetIpByDomain(strip, MAX_PATH, ctx->Req.strdomain);
|
|
|
+ ctx->Ans.strip = strip;
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+}
|
|
|
+
|
|
|
void ChannelServiceSession::OnClose( ErrorCodeEnum eErrorCode )
|
|
|
{
|
|
|
m_pEntity->UnregisterRxpkt(m_id);
|