#ifndef __MEMORY_SERVER__
#define __MEMORY_SERVER__

#pragma once

#include "MemoryDef.h"
#include "MemoryComm.h"

class CMemoryServer:public CMemoryComm
{
public:
	CMemoryServer(void);
	~CMemoryServer(void);

	BOOL StartApp(LPCTSTR lpAppDir);
	BOOL StopApp();
	BOOL ShowApp();
	BOOL HideApp();
	BOOL ConnectDevice();
	BOOL DisconnectDevice();
	BOOL StreamOpt(BOOL bStartStreaming = TRUE);
	BOOL CaptureImageByCount(		
		int nKeepTime,						// 持续时间;
		LPCTSTR lpszSaveDir,				// 保存路径;
		LPCTSTR lpszPrefix,					// 文件前缀;
		unsigned short dwImageType = 2		// 相片格式;
		);
	BOOL CaptureSingleImage(		
		LPCTSTR lpszSaveDir,				// 保存路径;
		unsigned short dwImageType = 2,		// 相片格式;
		BOOL IsAutoName = FALSE
		);
	BOOL CaptureImageByTime(
		int nKeepTime,						// 持续时间;
		int nCaputerCount,					// 每秒抓取张数;
		LPCTSTR lpszSaveDir,				// 保存路径;
		LPCTSTR lpszPrefix,					// 文件前缀;
		unsigned short dwImageType = 2		// 相片格式;
		);
	BOOL StopCaptureImage();
	BOOL SynCaptureAudio(LPCTSTR lpszSaveDir);
	BOOL AsyCaptureAudio(DWORD dwDuration, LPCTSTR lpszSaveDir);
	BOOL StopCaptureAudio();

	BOOL GetResult();
	inline void Replacepath2(char *p){
		while( *p != '\0' )
		{
			if (*p == '/') *p = '\\';
			p++;
		}
	}

	inline void Replacepath(char *p){
		int i = 0;
		char *pold = p;
		char szpath[MAX_PATH] = {'\0'};
		while( *p != '\0' )
		{
			if (szpath[i-1] == '\\' && ('\\' == *p || '/' == *p))
			{
				if (i == 1)
				{// 如果是共享目录;
					if (*p == '/') 
						*p = '\\';
					szpath[i] = *p;
					i++;
				}
				p++;
				continue;
			}

			if (*p == '/') 
				*p = '\\';
			szpath[i] = *p;
			p++;i++;
		}

		memcpy(pold, szpath, i);
		pold += i;
		*pold = '\0';
	}

};

#endif