|
@@ -1,5 +1,5 @@
|
|
|
#include "stdafx.h"
|
|
|
-#include <io.h>
|
|
|
+
|
|
|
#include "SpBase.h"
|
|
|
#include "video_session.h"
|
|
|
#include "../../Other/libvideoframework/videoframework.h"
|
|
@@ -14,10 +14,20 @@
|
|
|
#include "../../Other/libvideoframework/videocap.h"
|
|
|
#include "../../Other/libvideoframework/videortp.h"
|
|
|
#include "../../Other/libvideoframework/videoclock.h"
|
|
|
+#include "fileutil.h"
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
#include <ipp.h>
|
|
|
+#include <io.h>
|
|
|
+#include <DbgHelp.h>
|
|
|
+#pragma comment(lib, "dbghelp.lib")
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-#include "../../Other/libvideohorflip/videohorflip.h"
|
|
|
+//#include "../../Other/libvideohorflip/videohorflip.h"
|
|
|
|
|
|
#include "cv.h"
|
|
|
#include "highgui.h"
|
|
@@ -41,15 +51,18 @@ extern "C"
|
|
|
}
|
|
|
#include "../../Other/libvideoframework/video_common/ffmpeg_api_cpp_adapter.h"
|
|
|
|
|
|
-#include <DbgHelp.h>
|
|
|
-#pragma comment(lib, "dbghelp.lib")
|
|
|
-
|
|
|
|
|
|
BOOL g_bIsSalesRecord = FALSE;
|
|
|
BOOL g_bEwsRecord = FALSE; // add by ly@2019/04/18
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
HWND pg_local_hwnd = NULL; // preview window
|
|
|
HWND pg_remote_hwnd = NULL; // remote window
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+
|
|
|
video_session_t* pg_last_session = NULL; // last used session
|
|
|
|
|
|
#define WNDCLS_NAME "sipmedia_video"
|
|
@@ -68,8 +81,13 @@ video_session_t* pg_last_session = NULL; // last used session
|
|
|
|
|
|
|
|
|
typedef struct picture_record_s{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
HANDLE evt;
|
|
|
HANDLE work_thread;
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
video_session_t* session;
|
|
|
video_frame* show_frame;
|
|
|
video_frame* record_frame;
|
|
@@ -93,10 +111,17 @@ struct video_session_t
|
|
|
IplImage*personmask;
|
|
|
IplImage*recordareaimage;
|
|
|
IplImage*recordareamask;
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
HANDLE ui_thread;
|
|
|
HANDLE ui_event;
|
|
|
HWND local_hwnd; // preview window
|
|
|
HWND remote_hwnd; // remote window
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+
|
|
|
picture_record_t* pic_record;
|
|
|
};
|
|
|
|
|
@@ -316,10 +341,16 @@ static void local_put_frame(void *user_data, video_frame *frame)
|
|
|
int offset = (REC_COMMON_VIDEO_RTP_WIDTH - REC_COMMON_VIDEO_RTP_OPT_WIDTH) / 2;
|
|
|
unsigned char *dst_data[4] = {tt.data[0], 0, 0, 0};
|
|
|
dst_data[0] += offset * 3;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
IppiSize size;
|
|
|
size.width = frame->width;
|
|
|
size.height = frame->height;
|
|
|
ippiCopy_8u_C3R(frame->data[0], frame->linesize[0], tt.data[0] + offset * 3, tt.linesize[0], size);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
sws_scale(session->local_encode_sws_ctx_opt, tt.data, tt.linesize, 0, tt.height, tmp_frame_encode->data, tmp_frame_encode->linesize);
|
|
|
video_frame_free(&tt);
|
|
@@ -408,32 +439,37 @@ static int on_rx_frame(video_frame *frame, void *user_data)
|
|
|
return used;
|
|
|
}
|
|
|
|
|
|
-int GetCurrentRunPath(char *pPath)
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+int GetCurrentRunPath(char* pPath)
|
|
|
{
|
|
|
- char *pBuf = new char[MAX_PATH_SIZE];
|
|
|
+ char* pBuf = new char[MAX_PATH_SIZE];
|
|
|
if (pBuf == NULL)
|
|
|
return -1;
|
|
|
- ZeroMemory(pBuf,MAX_PATH_SIZE);
|
|
|
- GetModuleFileName(NULL,pBuf,MAX_PATH_SIZE);
|
|
|
- int len = strnlen_s(pBuf,MAX_PATH_SIZE);
|
|
|
+ ZeroMemory(pBuf, MAX_PATH_SIZE);
|
|
|
+ GetModuleFileName(NULL, pBuf, MAX_PATH_SIZE);
|
|
|
+ int len = strnlen_s(pBuf, MAX_PATH_SIZE);
|
|
|
if (len <= 0)
|
|
|
{
|
|
|
- delete []pBuf;
|
|
|
+ delete[]pBuf;
|
|
|
return -2;
|
|
|
}
|
|
|
- char *pch;
|
|
|
- pch = strstr (pBuf,"bin");
|
|
|
+ char* pch;
|
|
|
+ pch = strstr(pBuf, "bin");
|
|
|
if (pch == NULL)
|
|
|
return -3;
|
|
|
- int lenDel = strnlen_s(pch,MAX_PATH_SIZE);
|
|
|
+ int lenDel = strnlen_s(pch, MAX_PATH_SIZE);
|
|
|
if (len <= 0)
|
|
|
{
|
|
|
- delete []pBuf;
|
|
|
+ delete[]pBuf;
|
|
|
return -3;
|
|
|
}
|
|
|
- strncpy_s(pPath,MAX_PATH_SIZE,pBuf,len-lenDel);
|
|
|
- delete []pBuf; return strnlen_s(pPath,MAX_PATH_SIZE);
|
|
|
+ strncpy_s(pPath, MAX_PATH_SIZE, pBuf, len - lenDel);
|
|
|
+ delete[]pBuf; return strnlen_s(pPath, MAX_PATH_SIZE);
|
|
|
}
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+
|
|
|
//远端视频窗口状态回调
|
|
|
static int on_remoteWinstate(videoplayer_t *player, void *user_data, video_frame **frame)
|
|
|
{
|
|
@@ -494,10 +530,14 @@ static int on_pull(videoplayer_t *player, void *user_data, video_frame **frame)
|
|
|
video_frame_fill_black(tmp_frame_preview);
|
|
|
if (session->video_error == NULL)
|
|
|
{
|
|
|
- char strPath[MAX_PATH_SIZE];
|
|
|
+ char strPath[MAX_PATH_SIZE] = {0};
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
GetCurrentRunPath(strPath);
|
|
|
- sprintf(strPath,"%s\\bin\\looklowerscreen.jpg",strPath);
|
|
|
- if (_access(strPath,0)!=-1)
|
|
|
+ sprintf(strPath, "%s\\bin\\looklowerscreen.jpg", strPath);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+ if (ExistsFile(strPath))
|
|
|
{
|
|
|
IplImage*img = cvLoadImage(strPath,1);
|
|
|
if (img != NULL)
|
|
@@ -648,7 +688,8 @@ int show_agent_picture_proc(void *arg)
|
|
|
Dbg("show_agent_picture_proc param valid.");
|
|
|
return -1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
|
|
|
|
|
|
for (;;) {
|
|
@@ -680,34 +721,37 @@ int show_agent_picture_proc(void *arg)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+#else
|
|
|
+
|
|
|
+#endif
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void showagentpicdump_exception(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
-{
|
|
|
- char tmp[MAX_PATH];
|
|
|
- HANDLE hDumpFile;
|
|
|
- sprintf(tmp, ".\\showagnetpic_%d.dmp", GetCurrentProcessId());
|
|
|
- hDumpFile = CreateFileA( tmp, GENERIC_READ | GENERIC_WRITE,
|
|
|
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
- if( ( hDumpFile != NULL ) && ( hDumpFile != INVALID_HANDLE_VALUE ) )
|
|
|
- {
|
|
|
- MINIDUMP_EXCEPTION_INFORMATION mdei;
|
|
|
- MINIDUMP_TYPE mdt;
|
|
|
-
|
|
|
- mdei.ThreadId = GetCurrentThreadId();
|
|
|
- mdei.ExceptionPointers = ExceptionInfo;
|
|
|
- mdei.ClientPointers = FALSE;
|
|
|
-
|
|
|
- mdt = MiniDumpWithFullMemory;
|
|
|
-
|
|
|
- MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
|
|
|
- hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0 );
|
|
|
-
|
|
|
- CloseHandle( hDumpFile );
|
|
|
- }
|
|
|
-}
|
|
|
+//static void showagentpicdump_exception(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
+//{
|
|
|
+// char tmp[MAX_PATH];
|
|
|
+// HANDLE hDumpFile;
|
|
|
+// sprintf(tmp, ".\\showagnetpic_%d.dmp", GetCurrentProcessId());
|
|
|
+// hDumpFile = CreateFileA( tmp, GENERIC_READ | GENERIC_WRITE,
|
|
|
+// 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
+// if( ( hDumpFile != NULL ) && ( hDumpFile != INVALID_HANDLE_VALUE ) )
|
|
|
+// {
|
|
|
+// MINIDUMP_EXCEPTION_INFORMATION mdei;
|
|
|
+// MINIDUMP_TYPE mdt;
|
|
|
+//
|
|
|
+// mdei.ThreadId = GetCurrentThreadId();
|
|
|
+// mdei.ExceptionPointers = ExceptionInfo;
|
|
|
+// mdei.ClientPointers = FALSE;
|
|
|
+//
|
|
|
+// mdt = MiniDumpWithFullMemory;
|
|
|
+//
|
|
|
+// MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
|
|
|
+// hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0 );
|
|
|
+//
|
|
|
+// CloseHandle( hDumpFile );
|
|
|
+// }
|
|
|
+//}
|
|
|
|
|
|
|
|
|
//坐席端图像显示线程
|
|
@@ -727,15 +771,20 @@ static unsigned int __stdcall agent_picture_show_thread(void *arg)
|
|
|
static int agent_picture_video_start(picture_record_t* t_record)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
t_record->evt = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
t_record->work_thread = (HANDLE)_beginthreadex(NULL, 0, &agent_picture_show_thread, t_record, 0, NULL);
|
|
|
+#else
|
|
|
|
|
|
+#endif // RVC_OS_WIN
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
static int agent_picture_video_stop(picture_record_t* t_record)
|
|
|
{
|
|
|
Dbg("agent picture video stop called, stop static picture show thread.");
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
if (t_record->evt) {
|
|
|
SetEvent(t_record->evt);
|
|
|
if (t_record->work_thread) {
|
|
@@ -747,6 +796,9 @@ static int agent_picture_video_stop(picture_record_t* t_record)
|
|
|
t_record->evt = NULL;
|
|
|
}
|
|
|
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
if (t_record->record_frame){
|
|
|
video_frame_delete(t_record->record_frame);
|
|
|
t_record->record_frame = NULL;
|
|
@@ -815,13 +867,17 @@ static void show_remote_agnet_picture(video_session_t *t_session)
|
|
|
irecord_video_frame_heigt = /*REC_COMMON_VIDEO_DSM_AGENT_HEIGHT*/REC_COMMON_VIDEO_SNAPSHOT_PREVIEW_HEIGHT;
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
GetCurrentRunPath(strPath);
|
|
|
- sprintf(strImgPath,"%s\\bin\\agent.jpg",strPath);
|
|
|
+ sprintf(strImgPath, "%s\\bin\\agent.jpg", strPath);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
video_frame* remote_frame = video_frame_new(irecord_video_frame_width, irecord_video_frame_heigt, VIDEO_FORMAT_RGB24);
|
|
|
video_frame_fill_black(remote_frame);
|
|
|
|
|
|
- if (_access(strImgPath,0)!=-1)
|
|
|
+ if (ExistsFile(strImgPath))
|
|
|
{
|
|
|
IplImage*img = cvLoadImage(strImgPath,1);
|
|
|
videoq_frame* vframe = new videoq_frame;
|
|
@@ -885,8 +941,9 @@ static void show_remote_agnet_picture(video_session_t *t_session)
|
|
|
static int start_video(video_session_t *session)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
+ int rc = -1;
|
|
|
|
|
|
- int rc;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
if (session->video_shm_q_env)
|
|
|
{
|
|
|
session->local_encode_sws_ctx_env = sws_getContext(
|
|
@@ -1223,6 +1280,10 @@ static int start_video(video_session_t *session)
|
|
|
}
|
|
|
|
|
|
on_error:
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
@@ -1230,8 +1291,10 @@ on_error:
|
|
|
static void stop_video(video_session_t *session)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
Dbg("stop_video param video_session %0x, session->local_clock is %0x, session->remote_hwnd is %0x.", session, session->local_clock, session->remote_hwnd);
|
|
|
- if (session->local_clock&&session->remote_hwnd)
|
|
|
+ if (session->local_clock && session->remote_hwnd)
|
|
|
{
|
|
|
Dbg("videoclock_stop local_clock addr is %0x", session->local_clock);
|
|
|
videoclock_stop(session->local_clock);
|
|
@@ -1241,14 +1304,14 @@ static void stop_video(video_session_t *session)
|
|
|
pg_local_hwnd = NULL;
|
|
|
}
|
|
|
|
|
|
- if (session->rtp/*&&session->remote_hwnd*/)
|
|
|
+ if (session->rtp/*&&session->remote_hwnd*/)
|
|
|
{
|
|
|
Dbg("begin stop video rtp.");
|
|
|
videortp_stop(session->rtp);
|
|
|
videortp_destroy(session->rtp);
|
|
|
session->rtp = NULL;
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
Dbg("session->rtp == null");
|
|
|
}
|
|
|
|
|
@@ -1258,7 +1321,7 @@ static void stop_video(video_session_t *session)
|
|
|
Dbg("local video player destroy.");
|
|
|
}
|
|
|
|
|
|
- if (session->remote_player&&session->remote_hwnd)
|
|
|
+ if (session->remote_player && session->remote_hwnd)
|
|
|
{
|
|
|
videoplayer_destroy(session->remote_player);
|
|
|
session->remote_player = NULL;
|
|
@@ -1273,8 +1336,13 @@ static void stop_video(video_session_t *session)
|
|
|
sws_freeContext(session->local_encode_sws_ctx_opt);
|
|
|
session->local_encode_sws_ctx_opt = NULL;
|
|
|
}
|
|
|
+#else
|
|
|
+
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
static bool ReMoveOutOfScreenVideoWindow(HWND hWnd, RECT rect)
|
|
|
{
|
|
|
bool bret = false;
|
|
@@ -1286,28 +1354,28 @@ static bool ReMoveOutOfScreenVideoWindow(HWND hWnd, RECT rect)
|
|
|
int iVideoWidth = rect.right - rect.left;
|
|
|
int iVideoHight = rect.bottom - rect.top;
|
|
|
|
|
|
- if (rect.left < 0){
|
|
|
- if (rect.bottom <= iScreenHight){
|
|
|
+ if (rect.left < 0) {
|
|
|
+ if (rect.bottom <= iScreenHight) {
|
|
|
MoveWindow(hWnd, 0, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
- }
|
|
|
- else{
|
|
|
+ }
|
|
|
+ else {
|
|
|
MoveWindow(hWnd, 0, iScreenHight - iVideoHight, iVideoWidth, iVideoHight, TRUE);
|
|
|
}
|
|
|
bret = true;
|
|
|
}
|
|
|
|
|
|
- if (rect.right > iScreenWidth){
|
|
|
- if (rect.bottom <= iScreenHight){
|
|
|
+ if (rect.right > iScreenWidth) {
|
|
|
+ if (rect.bottom <= iScreenHight) {
|
|
|
MoveWindow(hWnd, iScreenWidth - iVideoWidth, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
- }
|
|
|
- else{
|
|
|
+ }
|
|
|
+ else {
|
|
|
MoveWindow(hWnd, iScreenWidth - iVideoWidth, iScreenHight - iVideoHight, iVideoWidth, iVideoHight, TRUE);
|
|
|
}
|
|
|
bret = true;
|
|
|
}
|
|
|
|
|
|
- if (rect.bottom > iScreenHight){
|
|
|
- if (rect.left >= 0 && rect.right <= iScreenWidth){
|
|
|
+ if (rect.bottom > iScreenHight) {
|
|
|
+ if (rect.left >= 0 && rect.right <= iScreenWidth) {
|
|
|
MoveWindow(hWnd, rect.left, iScreenHight - iVideoHight, iVideoWidth, iVideoHight, TRUE);
|
|
|
bret = true;
|
|
|
}
|
|
@@ -1327,28 +1395,28 @@ static bool ReMoveCenterOtherVideoWindow(HWND hWnd, RECT rect, RECT otherect)
|
|
|
int iOtherVideoWidth = otherect.right - otherect.left;
|
|
|
int iOtherVideoHight = otherect.bottom - otherect.top;
|
|
|
|
|
|
- if (iVideoWidth > iOtherVideoHight || iVideoHight > iOtherVideoHight){
|
|
|
+ if (iVideoWidth > iOtherVideoHight || iVideoHight > iOtherVideoHight) {
|
|
|
return bret;
|
|
|
}
|
|
|
|
|
|
- if (rect.left > otherect.left + iVideoWidth && rect.right < otherect.right){
|
|
|
- if (rect.top > otherect.top && rect.bottom < otherect.bottom){
|
|
|
- if (otherect.right - rect.right <= rect.left - otherect.left){
|
|
|
+ if (rect.left > otherect.left + iVideoWidth && rect.right < otherect.right) {
|
|
|
+ if (rect.top > otherect.top && rect.bottom < otherect.bottom) {
|
|
|
+ if (otherect.right - rect.right <= rect.left - otherect.left) {
|
|
|
MoveWindow(hWnd, otherect.right - iVideoWidth, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
- }
|
|
|
- else{
|
|
|
+ }
|
|
|
+ else {
|
|
|
MoveWindow(hWnd, otherect.left, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
}
|
|
|
bret = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (rect.right < otherect.right - iVideoWidth && rect.left > otherect.left){
|
|
|
- if (rect.top > otherect.top && rect.bottom < otherect.bottom){
|
|
|
- if (otherect.right - rect.right <= rect.left - otherect.left){
|
|
|
+ if (rect.right < otherect.right - iVideoWidth && rect.left > otherect.left) {
|
|
|
+ if (rect.top > otherect.top && rect.bottom < otherect.bottom) {
|
|
|
+ if (otherect.right - rect.right <= rect.left - otherect.left) {
|
|
|
MoveWindow(hWnd, otherect.right - iVideoWidth, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
- }
|
|
|
- else{
|
|
|
+ }
|
|
|
+ else {
|
|
|
MoveWindow(hWnd, otherect.left, rect.top, iVideoWidth, iVideoHight, TRUE);
|
|
|
}
|
|
|
bret = true;
|
|
@@ -1363,7 +1431,7 @@ static bool ReMoveVideoWindow(HWND hWnd, RECT rect, RECT otherect)
|
|
|
LOG_FUNCTION();
|
|
|
|
|
|
bool bret = false;
|
|
|
-
|
|
|
+
|
|
|
bret = ReMoveOutOfScreenVideoWindow(hWnd, rect);
|
|
|
bret = ReMoveCenterOtherVideoWindow(hWnd, rect, otherect);
|
|
|
|
|
@@ -1371,57 +1439,62 @@ static bool ReMoveVideoWindow(HWND hWnd, RECT rect, RECT otherect)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static int HandleVideoMoveEvent(int iMessageType, HWND hWnd, video_session_t *pSession)
|
|
|
+static int HandleVideoMoveEvent(int iMessageType, HWND hWnd, video_session_t* pSession)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
int iRet = -1;
|
|
|
- if (NULL == pSession || NULL == hWnd){
|
|
|
+ if (NULL == pSession || NULL == hWnd) {
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
HWND hOtherWnd = NULL;
|
|
|
//本地和远端标识 1为本地,2为远端
|
|
|
int iVideoType = 2;
|
|
|
- if (hWnd == pSession->local_hwnd){
|
|
|
+ if (hWnd == pSession->local_hwnd) {
|
|
|
iVideoType = 1;
|
|
|
hOtherWnd = pSession->remote_hwnd;
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
hOtherWnd = pSession->local_hwnd;
|
|
|
}
|
|
|
|
|
|
- if (NULL == hOtherWnd){
|
|
|
+ if (NULL == hOtherWnd) {
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
bool bMoved = false;
|
|
|
RECT rect;
|
|
|
GetWindowRect(hWnd, &rect);
|
|
|
- Dbg("MessageType = %d, VideoType = %d, rect.left = %d, rect.right = %d, rect.bottom = %d, rect.top = %d",iMessageType, iVideoType, rect.left, rect.right, rect.bottom, rect.top);
|
|
|
-
|
|
|
+ Dbg("MessageType = %d, VideoType = %d, rect.left = %d, rect.right = %d, rect.bottom = %d, rect.top = %d", iMessageType, iVideoType, rect.left, rect.right, rect.bottom, rect.top);
|
|
|
+
|
|
|
RECT otherect;
|
|
|
GetWindowRect(hOtherWnd, &otherect);
|
|
|
Dbg("other video Window left = %d, right = %d, bottom = %d, top = %d", otherect.left, otherect.right, otherect.bottom, otherect.top);
|
|
|
|
|
|
bMoved = ReMoveVideoWindow(hWnd, rect, otherect);
|
|
|
-
|
|
|
- if (bMoved){
|
|
|
+
|
|
|
+ if (bMoved) {
|
|
|
Dbg("has removed video window.");
|
|
|
GetWindowRect(hWnd, &rect);
|
|
|
}
|
|
|
-
|
|
|
- if (NULL != pSession->conf.video_echo_cb && NULL != pSession->conf.video_echo_cb->on_video_box_move){
|
|
|
+
|
|
|
+ if (NULL != pSession->conf.video_echo_cb && NULL != pSession->conf.video_echo_cb->on_video_box_move) {
|
|
|
pSession->conf.video_echo_cb->on_video_box_move(iMessageType, iVideoType, rect.left, rect.bottom, pSession->conf.video_echo_cb->user_data);
|
|
|
iRet = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
{
|
|
|
- video_session_t *session = (video_session_t*)GetWindowLongPtrA(hWnd, GWLP_USERDATA);
|
|
|
+ video_session_t* session = (video_session_t*)GetWindowLongPtrA(hWnd, GWLP_USERDATA);
|
|
|
|
|
|
switch (msg) {
|
|
|
case WM_DESTROY:
|
|
@@ -1429,7 +1502,8 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
if (session->local_hwnd == hWnd) {
|
|
|
Dbg("session->local_hwnd = 0");
|
|
|
session->local_hwnd = 0;
|
|
|
- } else if (session->remote_hwnd == hWnd) {
|
|
|
+ }
|
|
|
+ else if (session->remote_hwnd == hWnd) {
|
|
|
Dbg("session->remote_hwnd = 0");
|
|
|
session->remote_hwnd = 0;
|
|
|
}
|
|
@@ -1439,10 +1513,10 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
}
|
|
|
return 0;
|
|
|
case WM_NCHITTEST:
|
|
|
- if (((session->local_hwnd == hWnd)&&(0 != session->conf.local_move)) || ((session->remote_hwnd == hWnd)&&(0 != session->conf.remote_move))){
|
|
|
+ if (((session->local_hwnd == hWnd) && (0 != session->conf.local_move)) || ((session->remote_hwnd == hWnd) && (0 != session->conf.remote_move))) {
|
|
|
return HTCAPTION;
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
break;
|
|
|
}
|
|
|
case WM_ACTIVATE:
|
|
@@ -1452,17 +1526,18 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
return 0;
|
|
|
#if 1
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
- {
|
|
|
- LPWINDOWPOS pPos = (LPWINDOWPOS)lParam;
|
|
|
- if (pPos->hwndInsertAfter != HWND_TOPMOST && pPos->hwndInsertAfter != HWND_TOP) {
|
|
|
- //BringWindowToTop(hWnd);
|
|
|
- SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
|
|
- } else {
|
|
|
- return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
- }
|
|
|
+ {
|
|
|
+ LPWINDOWPOS pPos = (LPWINDOWPOS)lParam;
|
|
|
+ if (pPos->hwndInsertAfter != HWND_TOPMOST && pPos->hwndInsertAfter != HWND_TOP) {
|
|
|
+ //BringWindowToTop(hWnd);
|
|
|
+ SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
|
|
}
|
|
|
- return 0;
|
|
|
- //return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
+ else {
|
|
|
+ return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ //return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
#endif
|
|
|
case WM_MBUTTONDOWN:
|
|
|
case WM_MBUTTONUP:
|
|
@@ -1490,29 +1565,34 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
break;
|
|
|
|
|
|
case WM_ENTERSIZEMOVE:
|
|
|
- {
|
|
|
- Dbg("***WM_ENTERSIZEMOVE***");
|
|
|
- HandleVideoMoveEvent(0, hWnd, session);
|
|
|
- }
|
|
|
- break;
|
|
|
+ {
|
|
|
+ Dbg("***WM_ENTERSIZEMOVE***");
|
|
|
+ HandleVideoMoveEvent(0, hWnd, session);
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
case WM_EXITSIZEMOVE:
|
|
|
- {
|
|
|
- Dbg("***WM_EXITSIZEMOVE***");
|
|
|
- HandleVideoMoveEvent(1, hWnd, session);
|
|
|
- }
|
|
|
- break;
|
|
|
+ {
|
|
|
+ Dbg("***WM_EXITSIZEMOVE***");
|
|
|
+ HandleVideoMoveEvent(1, hWnd, session);
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#endif //
|
|
|
+
|
|
|
+
|
|
|
static unsigned int __stdcall ui_proc(void *arg)
|
|
|
{
|
|
|
video_session_t *session = (video_session_t*)arg;
|
|
|
Dbg("ui_proc session addr is %0x", session);
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+
|
|
|
WNDCLASSA wc = {0};
|
|
|
ATOM a = 0;
|
|
|
HWND hWnd = NULL;
|
|
@@ -1651,6 +1731,10 @@ static unsigned int __stdcall ui_proc(void *arg)
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1658,6 +1742,8 @@ static int start_ui(video_session_t *session)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
Dbg("start ui session addr is 0x%8x", session);
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
session->ui_event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
|
|
if (!session->ui_event) {
|
|
|
Dbg("phonemedia_start create ui event failed!");
|
|
@@ -1696,6 +1782,9 @@ static int start_ui(video_session_t *session)
|
|
|
return Error_Resource;
|
|
|
}
|
|
|
}
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1703,8 +1792,10 @@ static void stop_ui(video_session_t *session)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
Dbg("stop ui session addr is %0x.", session);
|
|
|
- if (DOUBLERECORD_CALLTYPE == session->conf.nCallType){
|
|
|
- if (NULL != pg_last_session){
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ if (DOUBLERECORD_CALLTYPE == session->conf.nCallType) {
|
|
|
+ if (NULL != pg_last_session) {
|
|
|
pg_last_session->rtp = session->rtp;
|
|
|
pg_last_session->local_clock = session->local_clock;
|
|
|
|
|
@@ -1714,10 +1805,10 @@ static void stop_ui(video_session_t *session)
|
|
|
session->ui_event = NULL;
|
|
|
session = pg_last_session;
|
|
|
}
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
- if (NULL != session->pic_record){
|
|
|
- if (NULL != session->pic_record->work_thread){
|
|
|
+ if (NULL != session->pic_record) {
|
|
|
+ if (NULL != session->pic_record->work_thread) {
|
|
|
SetEvent(session->pic_record->evt);
|
|
|
|
|
|
Dbg("CloseHandle pic_record ui_thread %0x", session->pic_record->work_thread);
|
|
@@ -1732,11 +1823,11 @@ static void stop_ui(video_session_t *session)
|
|
|
|
|
|
if (session->local_hwnd) {
|
|
|
Dbg("PostMessageA WM_CLOSE session addr is %0x, session->local_hwnd = %0x", session, session->local_hwnd);
|
|
|
-
|
|
|
+
|
|
|
BOOL bRet = PostMessageA(session->local_hwnd, WM_CLOSE, 0, 0);
|
|
|
Dbg("WaitForSingleObject session addr is %8x, and session->ui_thread is %8x.", session, session->ui_thread);
|
|
|
DWORD dCode = WaitForSingleObject(session->ui_thread, INFINITE);
|
|
|
- Dbg("After WaitForSingleObject (session->ui_thread, INFINITE) session addr is %8x, and session->ui_thread = %0x.",session, session->ui_thread);
|
|
|
+ Dbg("After WaitForSingleObject (session->ui_thread, INFINITE) session addr is %8x, and session->ui_thread = %0x.", session, session->ui_thread);
|
|
|
|
|
|
Dbg("CloseHandle ui_thread %0x", session->ui_thread);
|
|
|
CloseHandle(session->ui_thread);
|
|
@@ -1750,6 +1841,10 @@ static void stop_ui(video_session_t *session)
|
|
|
pg_local_hwnd = NULL;
|
|
|
pg_remote_hwnd = NULL;
|
|
|
Dbg("set pg_last_session to null.");
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
static int load_record_area_png(video_session_t *session)
|
|
@@ -1761,10 +1856,16 @@ static int load_record_area_png(video_session_t *session)
|
|
|
|
|
|
//加载双录人形背景框
|
|
|
char strPath[MAX_PATH_SIZE]={0};
|
|
|
+ char strRecordAreaPath[MAX_PATH_SIZE] = { 0 };
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
GetCurrentRunPath(strPath);
|
|
|
- char strRecordAreaPath[MAX_PATH_SIZE]={0} ;
|
|
|
- sprintf(strRecordAreaPath,"%s\\bin\\recordarea.png",strPath);
|
|
|
- if (_access(strRecordAreaPath,0)!=-1)
|
|
|
+ sprintf(strRecordAreaPath, "%s\\bin\\recordarea.png", strPath);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+ if (ExistsFile(strRecordAreaPath))
|
|
|
{
|
|
|
if (session->recordareaimage == NULL)
|
|
|
{
|
|
@@ -1915,9 +2016,13 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
|
|
|
|
|
|
char strPath[MAX_PATH_SIZE]={0};
|
|
|
char strImgPath[MAX_PATH_SIZE]={0};
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
GetCurrentRunPath(strPath);
|
|
|
- sprintf(strImgPath,"%s\\bin\\error.jpg",strPath);
|
|
|
- if (_access(strImgPath,0)!=-1)
|
|
|
+ sprintf(strImgPath, "%s\\bin\\error.jpg", strPath);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+ if (ExistsFile(strImgPath))
|
|
|
{
|
|
|
IplImage*img = cvLoadImage(strImgPath,1);
|
|
|
if (img != NULL)
|
|
@@ -1939,9 +2044,14 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
|
|
|
session->video_error = NULL;
|
|
|
}
|
|
|
//加载人形背景框
|
|
|
- char strPersonPath[MAX_PATH_SIZE] ;
|
|
|
- sprintf(strPersonPath,"%s\\bin\\rxk.png",strPath);
|
|
|
- if (_access(strPersonPath,0)!=-1)
|
|
|
+ char strPersonPath[MAX_PATH_SIZE] = {0};
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ sprintf(strPersonPath, "%s\\bin\\rxk.png", strPath);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+ if (ExistsFile(strPersonPath))
|
|
|
{
|
|
|
if (session->personimage == NULL)
|
|
|
{
|
|
@@ -2029,6 +2139,8 @@ void video_session_stop(video_session_t *session)
|
|
|
void double_record_broadcast_video_session_stop()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+
|
|
|
if (NULL != pg_last_session){
|
|
|
if (NULL != pg_last_session->pic_record){
|
|
|
if (NULL != pg_last_session->pic_record->work_thread){
|
|
@@ -2066,15 +2178,20 @@ void double_record_broadcast_video_session_stop()
|
|
|
pg_local_hwnd = NULL;
|
|
|
pg_remote_hwnd = NULL;
|
|
|
Dbg("set pg_last_session, pg_local_hwnd, pg_remote_hwnd to null.");
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
void video_session_destroy(video_session_t *session)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
|
|
|
- if (NULL != session){
|
|
|
- if (NULL != session->pic_record){
|
|
|
- if (NULL != session->pic_record->work_thread){
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ if (NULL != session) {
|
|
|
+ if (NULL != session->pic_record) {
|
|
|
+ if (NULL != session->pic_record->work_thread) {
|
|
|
SetEvent(session->pic_record->evt);
|
|
|
|
|
|
Dbg("CloseHandle pic_record ui_thread %0x", session->pic_record->work_thread);
|
|
@@ -2086,7 +2203,10 @@ void video_session_destroy(video_session_t *session)
|
|
|
session->pic_record->evt = NULL;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
|
|
|
if (session->video_shm_q_env) {
|
|
|
delete session->video_shm_q_env;
|
|
@@ -2135,8 +2255,8 @@ static void av_log_cb(void*ptr, int level, const char*fmt, va_list list)
|
|
|
|
|
|
int video_lib_init()
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
CoInitialize(NULL);
|
|
|
-
|
|
|
{
|
|
|
int i, n;
|
|
|
|
|
@@ -2155,13 +2275,21 @@ int video_lib_init()
|
|
|
av_log_set_callback(&av_log_cb);
|
|
|
//av_log_set_level(AV_LOG_DEBUG);
|
|
|
av_log_set_level(AV_LOG_QUIET);
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
void video_lib_deinit()
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
CoUninitialize();
|
|
|
+#else
|
|
|
+
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
videoframework_term();
|
|
|
}
|
|
|
|