예제 #1
0
파일: ghost.cpp 프로젝트: Laxa/ddnet
void CGhost::OnMessage(int MsgType, void *pRawMsg)
{
	// check for messages from server
	if(MsgType == NETMSGTYPE_SV_KILLMSG)
	{
		CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
		if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalClientID)
		{
			if(m_Recording)
				StopRecord();
			StopRender();
			m_LastDeathTick = Client()->GameTick();
		}
	}
	else if(MsgType == NETMSGTYPE_SV_CHAT)
	{
		CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
		if(pMsg->m_ClientID == -1 && m_Recording)
		{
			char aName[MAX_NAME_LENGTH];
			int Time = CRaceHelper::TimeFromFinishMessage(pMsg->m_pMessage, aName, sizeof(aName));
			if(Time > 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0)
			{
				StopRecord(Time);
				StopRender();
			}
		}
	}
}
예제 #2
0
int CWaveRecord::WriteToFile(PBYTE pByData, DWORD dwSize)
{
	int nPickup = SplitStereo2Mono(m_format, pByData, dwSize);
	int nRecBytes[2] = {dwSize, dwSize};
	char* pRecData[2] = {(char*)pByData, (char*)pByData};	
	
	if(m_nChs != eCH_MONO && m_nChs != eCH_STEREO)
	{
		pRecData[0] = (char*)m_pByInDataL;
		pRecData[1] = (char*)m_pByInDataR;
		nRecBytes[0] = nPickup;
		nRecBytes[1] = nPickup;
	}
	
	for(int nCh = 0; nCh < 2; nCh++)
	{
		if(m_hWaveFile[nCh])
		{
			int length = mmioWrite(m_hWaveFile[nCh], pRecData[nCh], nRecBytes[nCh]);
			if(nRecBytes[nCh] != length)
			{
				m_dwBufNumInQueue--;
				StopRecord();
				return -1;
			}
		}
	}

	return nPickup;
}	
예제 #3
0
파일: ghost.cpp 프로젝트: Laxa/ddnet
void CGhost::OnReset()
{
	StopRecord();
	StopRender();
	m_LastDeathTick = -1;
	m_LastRaceTick = -1;
}
예제 #4
0
파일: Main.cpp 프로젝트: GaryJin/Demo
int main()
{
	// Set wave format when sampling the audio
	WAVEFORMATEX wf;
	SetWaveFormat(&wf,1,1,12000,1,8,0);
	
	// Open wave input channel
	HWAVEIN hWaveIn;
	OpenWaveIn(&hWaveIn,&wf);

	// Prepare Wave In Header and allocate memory
	WAVEHDR waveHdr;
	DWORD dataSize = 240000L;
	PrepareWaveIn(&hWaveIn, &waveHdr, dataSize);

	// Start recording
	StartRecord(&hWaveIn);
	
	Sleep(10000);

	// Stop recording
	MMTIME mmt;
	StopRecord(&hWaveIn, &mmt);

	SaveRecordtoFile("test//myTest.wav",&wf,&hWaveIn,&waveHdr,&mmt);

	ReleaseWaveIn(&hWaveIn, &waveHdr);
	CloseWaveIn(&hWaveIn);

	system("pause");
	return 0;
}
예제 #5
0
파일: replay.cpp 프로젝트: meesokim/p6001v
////////////////////////////////////////////////////////////////
// デストラクタ
////////////////////////////////////////////////////////////////
REPLAY::~REPLAY( void )
{
	switch( RepST ){
	case REP_RECORD:	StopRecord(); break;
	case REP_REPLAY:	StopReplay(); break;
	}
	if( Matrix ) delete [] Matrix;
	if( Ini ) delete Ini;
}
예제 #6
0
파일: DLGscreen.cpp 프로젝트: dulton/brpj
//录像定时事件
void CDLGscreen::RecordTimerEvent()
{
	for(int i=0;i<MAX_DEVICE_NUM;i++)
	{
		if(m_videoInfo[i].isRecord == true)
		{
			CTime nowtime=CTime::GetTickCount();
			CTimeSpan ts = nowtime - m_videoInfo[i].startTime;
			int recMinutes = ts.GetMinutes();
			if(recMinutes >= DlgSetSystem.m_record_cuttime)
			{
				StopRecord(i);
				DlgMain->DlgTabVideo.DlgNormal.OpenRecord(i);
			}
		}
#if OPEN_RECORD
		//定时录制
		if(DlgMain->DlgTabVideo.DlgSetRecord.NeedRecord(m_videoInfo[i].camID))
		{
			if(m_videoInfo[i].isRecord == false)
			{
				m_videoInfo[i].planRecord = true;
				DlgMain->DlgTabVideo.DlgNormal.OpenRecord(i);	//开始录制
			}
		}
		else
		{
			if(m_videoInfo[i].planRecord == true)
			{
				m_videoInfo[i].planRecord = false;
				if(m_videoInfo[i].isRecord == true)
				{
					DlgMain->DlgTabVideo.DlgNormal.CloseRecord(i);	//停止录制
				}
			}
		}
#endif
	}

	//定时录像放这里ZOG
	//FOR N个摄像头
#if OPEN_RECORD
	if(DlgMain->DlgTabVideo.DlgSetRecord.NeedRecord(CAMID) )
	{
		if(m_videoInfo[i].isRecord)
		//不做事情
		else
		//开始录制
	
	}
	else
	{
		if(m_videoInfo[i].isRecord)
예제 #7
0
파일: DLGscreen.cpp 프로젝트: dulton/brpj
//停止播放
void CDLGscreen::StopPlay(int screenNo)
{
	if(m_videoInfo[screenNo].isRecord == true)
	{
		StopRecord(screenNo);
	}
	
	m_videoInfo[screenNo].enableCarDetect = false;
	m_videoInfo[screenNo].enableFaceDetect=false;
	Sleep(100);

	if(m_videoInfo[screenNo].isplay == true)
	{
		m_videoInfo[screenNo].isplay = false;
		m_video.StopPlay(m_videoInfo[screenNo].venderID,screenNo);
		DlgMain->ShowCameraMessage(m_videoInfo[screenNo].name.GetBuffer(0),"连接停止",FALSE);
		DlgMain->DlgTabVideo.DlgDeviceTree.ChangeTreeItemIcon(m_videoInfo[screenNo].camID,false);
	}



#if OPEN_LC_CARDETECT_CODE 
	//停止识别
	if(false == m_videoInfo[screenNo].enableCarDetect)
		CarDetect[screenNo].Stop();
	
		CarAdd[screenNo]=0;
#endif

#if OPEN_HYZJ_CARDETECT_CODE 
		//停止识别
		if(false == m_videoInfo[screenNo].enableCarDetect)
			HYZJCarDetect[screenNo].Stop();

		CarAdd[screenNo]=0;
#endif

#if OPEN_FACEDETECT_CODE 	
	//停止识别
	if(false == m_videoInfo[screenNo].enableFaceDetect)
		FaceDetect[screenNo].Stop();
	FaceAdd[screenNo]=0;
#endif


	CWnd* pWnd = m_screenPannel.GetPage(screenNo);
	if (pWnd)
	{
		pWnd->PostMessage(VIDEO_REPAINT);
	}

}
예제 #8
0
파일: TestPage.cpp 프로젝트: jerlich/rt-fsm
void CTestPage::OnRecord() 
/////////////////////////////////////////////////////////////////////////////
{
	static char BASED_CODE szFilter[] = "Wave Files(*.wav)|*.wav|All Files(*.*)|*.*||";
	char	szInitialDir[ _MAX_PATH ];
	char	szFileName[ _MAX_PATH ];

	UpdateData( TRUE );	// Get data from the controls

	if( !m_pHalAdapter->IsOpen() )
	{
		MessageBox( "Must Open Adapter First!" );
		return;
	}

 	if( m_nRecordMode == MODE_STOP )
	{
		// Pop up the file dialog box
		CFileDialog	dlg( TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, szFilter, this );

		if( m_szFileName[0] )
		{
			char	szDrive[ _MAX_DRIVE ];
			char	szDir[ _MAX_DIR ];
			char	szBaseName[ _MAX_FNAME ];
			char	szExt[ _MAX_EXT ];

			_splitpath( m_szFileName, szDrive, szDir, szBaseName, szExt );
			sprintf( szInitialDir, "%s%s", szDrive, szDir );
			sprintf( szFileName, "%s%s", szBaseName, szExt );
			
			dlg.m_ofn.lpstrInitialDir = szInitialDir;
			dlg.m_ofn.lpstrFile = szFileName;
		}
		else
			dlg.m_ofn.lpstrInitialDir = "D:\\Audio";

		if( dlg.DoModal() == IDCANCEL )
			return;

		CString	PathName;
		PathName = dlg.GetPathName();
		strcpy( m_szFileName, PathName.GetBuffer( _MAX_PATH - 1 ) );
		PathName.ReleaseBuffer();
		
		StartRecord();
	}
	else
	{
		StopRecord();
	}
}
예제 #9
0
void CWaveFile::WriteRecData2File(char* pszData, DWORD dwBufSize)
{
	int nRecBytes = dwBufSize;

	if(m_hWaveFileRec)
	{
		int nLength = mmioWrite(m_hWaveFileRec, pszData, dwBufSize);
		if(nRecBytes != nLength)
		{
			StopRecord();
		}
	}
}
예제 #10
0
inline BOOL StorFactory::StopRecordAll()
{
	Lock();
	CameraParamMap CameraMap = m_CameraParamMap;
	UnLock();
	CameraParamMap::iterator it = CameraMap.begin(); 
	for(; it!=CameraMap.end(); ++it)
	{
	    StopRecord((*it).second.m_Conf.data.conf.nId);
	}

	return TRUE;
}
예제 #11
0
inline BOOL Factory::StopRecordAll()
{
	Lock();
	DeviceParamMap DeviceMap = m_DeviceParamMap;
	UnLock();
	DeviceParamMap::iterator it = DeviceMap.begin(); 
	for(; it!=DeviceMap.end(); ++it)
	{
	    StopRecord((*it).second.m_Conf.data.conf.nId);
	}

	return TRUE;
}
예제 #12
0
파일: DLGPlaywin.cpp 프로젝트: dulton/brpj
void CDLGPlaywin::StopPlay()
{
	if(GetCurWndRecordState())
	{
		StopRecord();
	}

	m_video.StopPlay(m_curScreen);

	CWnd* pWnd = m_screenPannel.GetPage(m_curScreen);
	if (pWnd)
	{
		pWnd->PostMessage(VIDEO_REPAINT);
	}
}
예제 #13
0
bool VideoCam::PushFrame(RGB24Pixel* data)
{

    if(!recording || log_error)
        return !log_error;

    VCFrameHdr hdr;

    timespec t_now;
    clock_gettime(CLOCK_MONOTONIC,&t_now);

    //timespec t_frame;
    //t_frame.tv_sec=tstamp->tv_sec;
    //t_frame.tv_nsec=((long int)tstamp->tv_usec)*1000;

    //double dt=Util::dift(&t_now,&t_frame);

    hdr.n=sec;
    hdr.time=GlobalTimer.GetTimer();

//    printf("\nPushF: %f\n",dt);

    fwrite(&hdr,sizeof(hdr),1,fd);

    fwrite(data,sizeof(RGB24Pixel),frm_size.w*frm_size.h,fd);

    if(rec_n_frames>=0){
        if((--rec_n_frames)<=0)
            StopRecord();

        //printf("\nVideoCam: %d frames left\n",rec_n_frames);
    }

    return true;

}
예제 #14
0
LRESULT CWaveRecord::OnMM_WIM_DATA(WPARAM wParam, LPARAM lParam)
{
	int nPickup = 0;
	MMRESULT mmResult = 0;
	LPWAVEHDR pHdr = (LPWAVEHDR)lParam;

	if(!m_bRecording)
	{
		return 0L;
	}

	mmResult = waveInUnprepareHeader(m_hWaveIn, pHdr, sizeof(WAVEHDR));
	if(mmResult)
	{
		MyMessageBox(_T("waveInUnprepareHeader failed"), eERR_ERROR);
		return -1L;
	}

	if(m_bRecording)
	{	
		nPickup = WriteToFile((PBYTE)pHdr->lpData, pHdr->dwBytesRecorded);
		if(nPickup == -1)
		{
			MyMessageBox(_T("Write file failed"), eERR_ERROR);
			return FALSE;
		}

		if(m_mp3_hIn) // Save to mp3 file
		{
			int nRecBytes[2] = {pHdr->dwBytesRecorded, pHdr->dwBytesRecorded};
			char *pRecData[2] = {pHdr->lpData, pHdr->lpData};
			DWORD dwSamplesBytes = m_dwSamplesEnMp3Block * (m_format.wBitsPerSample / 8);
			
			for(int nCh = 0; nCh < 2; nCh++ )
			{
				if(m_mp3_File[nCh].m_hFile)
				{
					int nRemainSize = m_mp3_dwWavBufferSize - m_dwWaveDataBytes[nCh];
					int nCopyBytes = (nRemainSize < nRecBytes[nCh]) ? nRemainSize : nRecBytes[nCh];
					memcpy(m_mp3_pByWavBuffer[nCh] + m_dwWaveDataBytes[nCh], pRecData[nCh], nCopyBytes);
					m_dwWaveDataBytes[nCh] += nCopyBytes;
					
					// Compress mp3
					for(; m_dwWaveDataBytes[nCh] > dwSamplesBytes; m_dwWaveDataBytes[nCh] -= dwSamplesBytes)
					{
						EncodeMp3(m_mp3_pByWavBuffer[nCh], dwSamplesBytes, nCh);
						memmove(m_mp3_pByWavBuffer[nCh], m_mp3_pByWavBuffer[nCh] + 
							dwSamplesBytes, m_dwWaveDataBytes[nCh] - dwSamplesBytes);
					}
					
					char *pUnCopyData = pRecData[nCh] + nCopyBytes;
					int nUnCopyDataBytes = nRecBytes[nCh] - nCopyBytes;
					nRemainSize = m_mp3_dwWavBufferSize - m_dwWaveDataBytes[nCh];
					nCopyBytes = (nRemainSize < nUnCopyDataBytes) ? nRemainSize : nUnCopyDataBytes;
					memcpy(m_mp3_pByWavBuffer[nCh] + m_dwWaveDataBytes[nCh], pUnCopyData, nCopyBytes );
				}	
			}
		}

		// Prepares a buffer for waveform-audio input
		mmResult = waveInPrepareHeader(m_hWaveIn, pHdr, sizeof(WAVEHDR));
		if(mmResult)
		{
			MyMessageBox(_T("waveInPrepareHeader failed"), eERR_ERROR);
			return -1L;
		}
		else
		{
			mmResult = waveInAddBuffer(m_hWaveIn, pHdr, sizeof(WAVEHDR));
			if(mmResult)
			{
				MyMessageBox(_T("waveInAddBuffer failed"), eERR_ERROR);
				return -1L;
			}
			else
			{
				if(m_hParentWnd)
				{
					DrawWave((DWORD)nPickup);
				}
			}
		}
	}
	else
	{
		if(m_dwBufNumInQueue <= 1)
		{
			StopRecord();
		}
		else
		{
			m_dwBufNumInQueue--;
		}
	}
	
	return 0L;
}
예제 #15
0
void DAXAudio::Stop()
{
	StopRecord();
	StopPlay();
}
예제 #16
0
void VideoAndSound() {
	VideoCapture capture;
	//capture.open("rtsp://*****:*****@192.168.1.65/Streaming/Channels/1");	//����ͷ1
	capture.open("rtsp://*****:*****@192.168.1.141:554/axis-media/media.amp");		//	����ͷ2
																					//capture.open("rtsp://service:@10.153.33.11/?line=1$camera");					//�˴�ΰ	����
																					//capture.open(0);																//open ���ݱ�Ŵ�����ͷ
																					//AVI or ASF
																					// MPEG4 CV_FOURCC('D', 'I', 'V', 'X')
																					// MJPG  CV_FOURCC('M', 'J', 'P', 'G')
	VideoWriter writer("VideoTestDemo.avi", CV_FOURCC('M', 'J', 'P', 'G'), 30.0, Size(640, 480));

	std::cout << "-------------" << std::endl;
	if (!capture.isOpened())
	{
		std::cout << "Read video Failed !" << std::endl;
		return;
	}

	//cv::VideoCapture capture;

	cv::Mat frame;
	cv::namedWindow("video test");

	int frame_num = 800;

	//��ʼ¼��
	StartRecord();

	//for (;;) {
	//	if (!capture.read(frame)) {
	//		std::cout << "No frame" << std::endl;
	//		cv::waitKey();
	//	}
	//	writer << frame;
	//	cv::imshow("Output Window", frame);
	//	if (cv::waitKey(1) >= 0) break;
	//}

	for (int i = 0; i < frame_num - 1; ++i)
	{
		capture >> frame;
		capture.read(frame);

		//���۽���ǰ
		imshow("video test", frame);
		writer << frame;

		//���۽����� ��Ƶ�洢��¼����������
		//writer << fisheye2pano2(frame);
		//frame = fisheye2pano2(frame);
		//imshow("fisheyevideo test", frame);

		if (cv::waitKey(30) == 'q')
		{
			break;
		}
	}

	//������Ƶ
	StopRecord();
	SaveRecord();

	cv::destroyWindow("video test");
	//cv::destroyAllWindows();
	capture.release();

	Encode();
}
예제 #17
0
//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_CREATE:
		{
			g_hWndMain = hWnd;
			CreateControlButtons(hWnd);
			UpdateButtonStatus();
		}
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case START_CAPTURE_ID:
			StartRecord();
			break;
		case STOP_CAPTURE_ID:
			StopRecord();
			break;
		case START_PLAY_ID:
			StartPlay();
			break;
		case STOP_PLAY_ID:
			StopPlay();
			break;
		case START_EXTRACT_ID:
			StartExtract();
			break;
		case STOP_EXTRACT_ID:
			StopExtract();
			break;
		case ADD_SCALE_ID:
			AddScale();
			break;
		case SUB_SCALE_ID:
			SubScale();
			break;
		case PAINT_RECORD_ID:
			PaintRecorder();
			break;
		case PAINT_EXTRACT_ID:
			PaintExtractor();
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 在此添加任意绘图代码...

		if (g_pAudioPainter->IsEnable())
		{
			RECT rect;
			::GetWindowRect(hWnd, &rect);

			rect.right = rect.right - rect.left - 20;
			rect.left = 10;
			rect.bottom = (rect.bottom - rect.top) / 2;
			rect.top = 200;

			g_pAudioPainter->Paint(hWnd, hdc, rect, 10.0f);
		}

		wchar_t buf[20];
		wsprintf(buf, L"Scale: %d%%", (int)(g_pAudioPainter->GetScale() * 100));
		::TextOut(hdc, 0, 0, buf, ::wcslen(buf));

		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case WM_TIMER:
		if (g_pAudioPainter->IsEnable())
		{
			RECT rect = { 0, 0,  WINDOW_WIDTH, WINDOW_HEIGHT };
			::InvalidateRect(hWnd, &rect, true);
		}
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
예제 #18
0
Replay::~Replay()
{
    StopRecord();
}
예제 #19
0
void MultiPlayer::StopRecord(shared_ptr<OnePlayer> onePlayer)
{
	StopRecord(onePlayer->mid);
}