void glutKeyboard (unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27:
		CleanupExit();
	case'p':
		g_bPause = !g_bPause;
		break;
	case 'l':
		g_bPause = false;
		g_bStep = true;
		break;
	case 'c':
		g_bDrawCoM = !g_bDrawCoM;
		break;
	case 'f':
		g_bPrintFrameID = !g_bPrintFrameID;
		break;
	case 'k':
		if (g_pRecorder == NULL)
			StartCapture();
		else
			StopCapture();
		printf("Record turned %s\n", g_pRecorder ? "on" : "off");
		break;
	}
}
Example #2
0
void
Controller::ToggleCapture(bool start)
{
	BAutolock _(this);
	if (fCaptureThread < 0 && start)
		StartCapture();
	else
		EndCapture();
}
Example #3
0
    void CaptureTestStart() {
        if (not initialized or capture or doingCaptureTest) {
            return;
        }

        audioLogs.Notice("Starting the sound capture test");
        StartCapture(16000);
        doingCaptureTest = true;
    }
void CUsbtestDlg::OnRButtonUp(UINT_PTR id, CPoint pt)
{
    static unsigned int i = 1;
    if (i % 2)
        StartCapture(devID);
    else
        StopCapture(devID);

    i++;
}
void VisionCapture::InitCapture(int cam,bool start)
{

    if (!m_videoCapture)
        m_videoCapture.reset(new cv::VideoCapture(cam));
    if (m_videoCapture->isOpened()) {
        m_videoCapture->set(CV_CAP_PROP_FRAME_WIDTH,640);
        m_videoCapture->set(CV_CAP_PROP_FRAME_HEIGHT,480);
        //m_videoCapture->set(CV_CAP_PROP_FRAME_WIDTH,960);
        //m_videoCapture->set(CV_CAP_PROP_FRAME_HEIGHT,720);

        m_videoCapture->set(CV_CAP_PROP_FPS,15);
     if(start)
        StartCapture();

    }
}
Example #6
0
void glutKeyboard (unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27:
		CleanupExit();
	case'p':
		g_bPause = !g_bPause;
		break;
	case 'k':
		if (g_pRecorder == NULL)
			StartCapture();
		else
			StopCapture();
		printf("Record turned %s\n", g_pRecorder ? "on" : "off");
		break;
	}
}
Example #7
0
BOOL CReportCameraWorker::SetConfig(CReportCameraConfig& ReportCameraConfig, BOOL bAutoStartCapture)
{
	TRACE(_T("CReportCameraWorker::SetConfig\n"));

	BOOL bCaptureStarted = m_bCaptureStarted;

	if (bCaptureStarted)
	{
		StopCapture();	
	}

	m_ReportCameraConfig = ReportCameraConfig;

	if (bAutoStartCapture)
	{
		StartCapture();	
	}
	
	return TRUE;
}
Example #8
0
void CSiriusView::OnCommandStart() 
{
	// get selected adapter
	char szAdapter[512], szMutexName[512];
	szAdapter[0] = 0;
	g_pwndAdapter->GetWindowText(szAdapter, 512);
	if (0 == szAdapter[0])
		return;
	// remove ip and mask
	char *pszIpMask = strstr(szAdapter, " (ip:");
	if (pszIpMask)
		*pszIpMask = 0;
	// check if we have such adapter already started
	CreateMutexName(szAdapter, szMutexName);
	m_hAdapterMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, szMutexName);
	if (m_hAdapterMutex != NULL) {
		MessageBox("This adapter is already opened\n\rin other instance of Show Traffic", 
			g_szError, MB_OK | MB_ICONSTOP);
		CloseHandle(m_hAdapterMutex);
		return;
	}
	m_hAdapterMutex = CreateMutex(NULL, FALSE, szMutexName);
	
	if (0 != StartCapture(szAdapter))
		return;	

	g_bStarted = TRUE;
	g_pwndTraffic->Invalidate();

	::SetTimer(m_hWnd, TIMER_ID, 1000, &(CSiriusView::MyTimerProc)); // init statistics timer

	// update application title
	g_pwndAdapter->GetWindowText(szAdapter, 512);
	CString sTitle;
	sTitle.LoadString(AFX_IDS_APP_TITLE);
	sTitle += " - [";
	sTitle += szAdapter;
	sTitle += "]";
	GetParentFrame()->SetWindowText(sTitle);
}
Example #9
0
bool AudioRecorder::Start()
{
	Clear();

	if (!StartCapture())
		return false;

	SetDone(false);

	m_hThreadCapture = (HANDLE)::_beginthreadex(NULL, 0, &CaptureTheadProc, this, 0, NULL);
	if (m_hThreadCapture == NULL)
		return false;

	//HANDLE arWaits[1] = { m_hThreadCapture };
	//DWORD dwWaitResult = WaitForMultipleObjects(sizeof(arWaits) / sizeof(arWaits[0]), arWaits, FALSE, INFINITE);
	//if (dwWaitResult != WAIT_OBJECT_0)
	//{
	//	StopRecord();
	//	return false;
	//}

	return true;
}
Example #10
0
CAviApp::Initialize(PDATA2COMPRESS_ROUTINE pRoutineAddress,LPVOID	pParam)
{
	//Stop read and send thread
	if(!m_htReadThread)
		StartCapture();

	Stop();

	m_pCompressRoutine = pRoutineAddress;					//set pointer to compress routine
	m_pParent = pParam;										//set sender pointer

	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	COptionsDialog	* dlgOptions = new COptionsDialog(this);

	if(dlgOptions->DoModal()!=IDOK)
	{
		delete dlgOptions;
		return TRUE;
	}

	delete dlgOptions;
	return FALSE;
}
Example #11
0
HRESULT CAudio::InitializeCapture(IAnalyzed* analyzed)
{
	ENTER_SECTION(this);

	m_Analyzed = analyzed;

	// Get the address of the create function
	LPDIRECTSOUNDCAPTURECREATE8 DirectSoundCaptureCreate8 = (LPDIRECTSOUNDCAPTURECREATE8)GetProcAddress(m_DS,"DirectSoundCaptureCreate8");
	if(!DirectSoundCaptureCreate8)
	{
		TRACE("Failed to find \"DirectSoundCaptureCreate8\" in \"%s\".\n",DSDLL);
		return E_FAIL;
	}

	// Create our main capture object
	HRESULT hr = DirectSoundCaptureCreate8(&DSDEVID_DefaultCapture, &m_SoundCapture, NULL);
	if(FAILED(hr))
	{
		TRACE("Failed to load create direct sound capture.\n",DSDLL);
		return E_FAIL;
	}

	// Create the wave format description
	WAVEFORMATEX waveform;
	ZeroMemory(&waveform,sizeof(waveform));
	waveform.cbSize = sizeof(waveform);
	waveform.nChannels = AUDIO_CHANNELS;
	waveform.nSamplesPerSec = AUDIO_FREQUENCY;
	waveform.wBitsPerSample = AUDIO_BITS;
	waveform.nBlockAlign = (waveform.nChannels * waveform.wBitsPerSample) / 8;
	waveform.nAvgBytesPerSec = waveform.nSamplesPerSec * waveform.nBlockAlign;
	waveform.wFormatTag = WAVE_FORMAT_PCM;

	// Create the record buffer format description
	DSCBUFFERDESC bufferdesc;
	ZeroMemory(&bufferdesc,sizeof(bufferdesc));
	bufferdesc.dwSize = sizeof(bufferdesc);
	bufferdesc.dwFlags = 0;
	bufferdesc.dwBufferBytes = AUDIO_BUFFERSIZE;
	bufferdesc.dwFXCount = 0;
	bufferdesc.lpDSCFXDesc = 0;
	bufferdesc.lpwfxFormat = &waveform;

	// Create the capture buffer
	hr = m_SoundCapture->CreateCaptureBuffer(&bufferdesc, &m_CaptureBuffer, NULL);
	if(FAILED(hr))
	{
		TRACE("Failed to create direct sound capture buffer.");
		return E_FAIL;
	}

	if(FAILED(StartCapture()))
	{
		TRACE("Failed to start capture.\n");
		return E_FAIL;
	}

	// Create the renderer thread
	m_Capture = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)CaptureThread,this,NULL,&m_CaptureId);
	if(!m_Capture)
		return E_FAIL;

	return S_OK;
}
Example #12
0
void USBCamera::UpdateSettings() {
    std::lock_guard<priority_recursive_mutex> lock(m_mutex);
    bool wasActive = m_active;

    if (wasActive) StopCapture();
    if (m_open) CloseCamera();
    OpenCamera();

    uInt32 count = 0;
    uInt32 currentMode = 0;
    SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, nullptr, &count, &currentMode);
    auto modes = std::make_unique<IMAQdxVideoMode[]>(count);
    SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, modes.get(), &count, &currentMode);

    // Groups are:
    //   0 - width
    //   1 - height
    //   2 - format
    //   3 - fps
    std::regex reMode("([0-9]+)\\s*x\\s*([0-9]+)\\s+(.*?)\\s+([0-9.]+)\\s*fps");
    IMAQdxVideoMode* foundMode = nullptr;
    IMAQdxVideoMode* currentModePtr = &modes[currentMode];
    double foundFps = 1000.0;

    // Loop through the modes, and find the match with the lowest fps
    for (unsigned int i = 0; i < count; i++) {
        std::cmatch m;
        if (!std::regex_match(modes[i].Name, m, reMode)) continue;
        unsigned int width = (unsigned int)std::stoul(m[1].str());
        unsigned int height = (unsigned int)std::stoul(m[2].str());
        if (width != m_width) continue;
        if (height != m_height) continue;
        double fps = atof(m[4].str().c_str());
        if (fps < m_fps) continue;
        if (fps > foundFps) continue;
        bool isJpeg =
            m[3].str().compare("jpeg") == 0 || m[3].str().compare("JPEG") == 0;
        if ((m_useJpeg && !isJpeg) || (!m_useJpeg && isJpeg)) continue;
        foundMode = &modes[i];
        foundFps = fps;
    }
    if (foundMode != nullptr) {
        if (foundMode->Value != currentModePtr->Value) {
            SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, IMAQdxAttributeVideoMode,
                           IMAQdxValueTypeU32, foundMode->Value);
        }
    }

    if (m_whiteBalance.compare(AUTO) == 0) {
        SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_MODE,
                       IMAQdxValueTypeString, AUTO);
    } else {
        SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_MODE,
                       IMAQdxValueTypeString, MANUAL);
        if (m_whiteBalanceValuePresent)
            SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_VALUE,
                           IMAQdxValueTypeU32, m_whiteBalanceValue);
    }

    if (m_exposure.compare(AUTO) == 0) {
        SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_MODE,
                       IMAQdxValueTypeString,
                       std::string("AutoAperaturePriority").c_str());
    } else {
        SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_MODE,
                       IMAQdxValueTypeString, MANUAL);
        if (m_exposureValuePresent) {
            double minv = 0.0;
            double maxv = 0.0;
            SAFE_IMAQ_CALL(IMAQdxGetAttributeMinimum, m_id, ATTR_EX_VALUE,
                           IMAQdxValueTypeF64, &minv);
            SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_EX_VALUE,
                           IMAQdxValueTypeF64, &maxv);
            double val = minv + ((maxv - minv) * ((double)m_exposureValue / 100.0));
            SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_VALUE,
                           IMAQdxValueTypeF64, val);
        }
    }

    SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_BR_MODE, IMAQdxValueTypeString,
                   MANUAL);
    double minv = 0.0;
    double maxv = 0.0;
    SAFE_IMAQ_CALL(IMAQdxGetAttributeMinimum, m_id, ATTR_BR_VALUE,
                   IMAQdxValueTypeF64, &minv);
    SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_BR_VALUE,
                   IMAQdxValueTypeF64, &maxv);
    double val = minv + ((maxv - minv) * ((double)m_brightness / 100.0));
    SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_BR_VALUE, IMAQdxValueTypeF64,
                   val);

    if (wasActive) StartCapture();
}
Example #13
0
void
FireWireDVNode::HandleStart(bigtime_t performance_time)
{
	CALLED();
	StartCapture();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::CaptureThink( void )
{
	SetNextThink( gpGlobals->curtime + AREA_THINK_TIME );

	// make sure this point is in the round being played (if we're playing one)
	CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
	if ( pMaster && m_hPoint )
	{
		if ( !pMaster->IsInRound( m_hPoint ) )
		{
			return;
		}
	}

	if ( !TeamplayGameRules()->PointsMayBeCaptured() )
	{
		// Points aren't allowed to be captured. If we were 
		// being captured, we need to clean up and reset.
		if ( m_bCapturing )
		{
			BreakCapture( false );
			UpdateNumPlayers();
		}
		return;
	}

	// go through our list of players
	Assert( GetNumberOfTeams() <= MAX_CAPTURE_TEAMS );
	int iNumPlayers[MAX_CAPTURE_TEAMS];
	int iNumBlockablePlayers[MAX_CAPTURE_TEAMS]; // Players in the zone who can't cap, but can block / pause caps
	CBaseMultiplayerPlayer *pFirstPlayerTouching[MAX_CAPTURE_TEAMS];
	for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
	{
		iNumPlayers[i] = 0;
		iNumBlockablePlayers[i] = 0;
		pFirstPlayerTouching[i] = NULL;
	}

	if ( m_hPoint )
	{
		// Loop through the entities we're touching, and find players
		for ( int i = 0; i < m_hTouchingEntities.Count(); i++ )
		{
			CBaseEntity *ent = m_hTouchingEntities[i];
			if ( ent && ent->IsPlayer() )
			{
				CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer(ent);
				if ( pPlayer->IsAlive() )
				{	
					int iTeam = pPlayer->GetTeamNumber();

					// If a team's not allowed to cap a point, don't count players in it at all
					if ( !TeamplayGameRules()->TeamMayCapturePoint( iTeam, m_hPoint->GetPointIndex() ) )
						continue;

					if ( !TeamplayGameRules()->PlayerMayCapturePoint( pPlayer, m_hPoint->GetPointIndex() ) )
					{
						if ( TeamplayGameRules()->PlayerMayBlockPoint( pPlayer, m_hPoint->GetPointIndex() ) )
						{
							if ( iNumPlayers[iTeam] == 0 && iNumBlockablePlayers[iTeam] == 0 )
							{
								pFirstPlayerTouching[iTeam] = pPlayer;
							}

							iNumBlockablePlayers[iTeam] += TeamplayGameRules()->GetCaptureValueForPlayer( pPlayer );
						}
						continue;
					}

					if ( iTeam >= FIRST_GAME_TEAM )
					{
						if ( iNumPlayers[iTeam] == 0 && iNumBlockablePlayers[iTeam] == 0 )
						{
							pFirstPlayerTouching[iTeam] = pPlayer;
						}

						iNumPlayers[iTeam] += TeamplayGameRules()->GetCaptureValueForPlayer( pPlayer );
					}
				}
			}
		}
	}

	int iTeamsInZone = 0;
	bool bUpdatePlayers = false;
	m_nTeamInZone = TEAM_UNASSIGNED;
	for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
	{
		iNumPlayers[i] *= mp_simulatemultiplecappers.GetInt();

		if ( m_TeamData[i].iNumTouching != iNumPlayers[i] )
		{
			m_TeamData[i].iNumTouching = iNumPlayers[i];
			bUpdatePlayers = true;
		}
		m_TeamData[i].iBlockedTouching = m_TeamData[i].iNumTouching;

		if ( m_TeamData[i].iNumTouching )
		{
			iTeamsInZone++;

			m_nTeamInZone = i;
		}
	}

	if ( iTeamsInZone > 1 )
	{
		m_nTeamInZone = TEAM_UNASSIGNED;
	}
	else
	{
		// If we've got non-cappable, yet blockable players here for the team that's defending, they 
		// need to block the cap. This catches cases like the TF invulnerability, which needs to block
		// caps, but isn't allowed to contribute to a cap.
		for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
		{
			if ( !iNumBlockablePlayers[i] || m_nTeamInZone == i )
				continue;

			iTeamsInZone++;
		}
	}

	UpdateTeamInZone();

	bool bBlocked = false;

	// If the cap is being blocked, reset the number of players so the client
	// knows to stop the capture as well.
	if ( mp_blockstyle.GetInt() == 1 )
	{
		if ( m_bCapturing && iTeamsInZone > 1 )
		{
			bBlocked = true;

			for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
			{
				iNumPlayers[i] = 0;
				if ( m_TeamData[i].iNumTouching != iNumPlayers[i] )
				{
					m_TeamData[i].iNumTouching = iNumPlayers[i];
					bUpdatePlayers = true;
				}
			}
		}
	}

	if ( bUpdatePlayers )
	{
		UpdateNumPlayers( bBlocked );
	}

	// When a player blocks, tell them the cap index and attempt number
	// only give successive blocks to them if the attempt number is different
	if ( m_bCapturing )
	{
		if ( m_hPoint )
		{
			m_hPoint->SetLastContestedAt( gpGlobals->curtime );
		}

		// Calculate the amount of modification to the cap time
		float flTimeDelta = gpGlobals->curtime - m_flLastReductionTime;

		float flReduction = flTimeDelta;
		if ( CaptureModeScalesWithPlayers() )
		{
			// Diminishing returns for successive players.
			for ( int i = 1; i < m_TeamData[m_nTeamInZone].iNumTouching; i++ )
			{
				flReduction += (flTimeDelta / (float)(i+1));
			}
		}
		m_flLastReductionTime = gpGlobals->curtime;

		//if more than one team is in the zone
		if( iTeamsInZone > 1 )
		{
			if ( !m_bBlocked )
			{
				m_bBlocked = true;
				UpdateBlocked();
			}

			// See if anyone gets credit for the block
			float flPercentToGo = m_fTimeRemaining / m_flCapTime;
			if ( CaptureModeScalesWithPlayers() )
			{
				flPercentToGo = m_fTimeRemaining / ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
			}

			if ( ( flPercentToGo <= 0.5 || TeamplayGameRules()->PointsMayAlwaysBeBlocked() ) && m_hPoint )
			{
				// find the first player that is not on the capturing team
				// they have just broken a cap and should be rewarded		
				// tell the player the capture attempt number, for checking later
				CBaseMultiplayerPlayer *pBlockingPlayer = NULL;
				for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
				{
					if ( m_nCapturingTeam == i )
						continue;

					if ( pFirstPlayerTouching[i] )
					{
						pBlockingPlayer = pFirstPlayerTouching[i];
						break;
					}
				}
				Assert( pBlockingPlayer );

				if ( pBlockingPlayer )
				{
					bool bRepeatBlocker = false;
					for ( int i = m_Blockers.Count()-1; i >= 0; i-- )
					{
						if ( m_Blockers[i].hPlayer != pBlockingPlayer )
							continue;

						// If this guy's was a blocker, but not valid now, remove him from the list
						if ( m_Blockers[i].iCapAttemptNumber != m_iCapAttemptNumber || !IsTouching(m_Blockers[i].hPlayer) ||
							 ( TeamplayGameRules()->PointsMayAlwaysBeBlocked() && m_Blockers[i].flNextBlockTime < gpGlobals->curtime && m_bStartTouch ) )
						{
							m_Blockers.Remove(i);
							continue;
						}

						bRepeatBlocker = true;
						break;
					}

					if ( !bRepeatBlocker )
					{
                        m_hPoint->CaptureBlocked( pBlockingPlayer );

						// Add this guy to our blocker list
						int iNew = m_Blockers.AddToTail();
						m_Blockers[iNew].hPlayer = pBlockingPlayer;
						m_Blockers[iNew].iCapAttemptNumber = m_iCapAttemptNumber;
						m_Blockers[iNew].flNextBlockTime = gpGlobals->curtime + 10.0f;
					}
				}
			}

			if ( mp_blockstyle.GetInt() == 0 )
			{
				BreakCapture( false );
			}
			return;
		}

		if ( m_bBlocked )
		{
			m_bBlocked = false;
			UpdateBlocked();
		}

		float flTotalTimeToCap = m_flCapTime;
		if ( CaptureModeScalesWithPlayers() )
		{
			flTotalTimeToCap = ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
		}

		// Now remove the reduction amount after we've determined there's only 1 team in the area
		if ( m_nCapturingTeam == m_nTeamInZone )
		{
			SetCapTimeRemaining( m_fTimeRemaining - flReduction );
		}
		else if ( m_nOwningTeam == TEAM_UNASSIGNED && m_nTeamInZone != TEAM_UNASSIGNED )
		{
			SetCapTimeRemaining( m_fTimeRemaining + flReduction );
		}
		else
		{
			// Caps deteriorate over time
			if ( TeamplayRoundBasedRules() && m_hPoint && TeamplayRoundBasedRules()->TeamMayCapturePoint(m_nCapturingTeam,m_hPoint->GetPointIndex()) )
			{
				float flDecreaseScale = CaptureModeScalesWithPlayers() ? mp_capdeteriorate_time.GetFloat() : flTotalTimeToCap;
				float flDecrease = (flTotalTimeToCap / flDecreaseScale) * flTimeDelta;
				if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->InOvertime() )
				{
					flDecrease *= 6;
				}
				SetCapTimeRemaining( m_fTimeRemaining + flDecrease );
			}
			else
			{
				SetCapTimeRemaining( flTotalTimeToCap );
			}
		}

		/*
		//if no-one is in the area
		if( iTeamsInZone == 0 )
		{
			BreakCapture( true );
			return;
		}
		
		//if they've lost the number of players needed to cap
		int iTeamMembersHere = m_TeamData[m_nCapturingTeam].iNumTouching + iNumBlockablePlayers[m_nCapturingTeam];
		if ( (iTeamMembersHere == 0 ) || (mp_capstyle.GetInt() == 0 && iTeamMembersHere < m_TeamData[m_nCapturingTeam].iNumRequiredToCap) )
		{
			BreakCapture( true );
			return;
		}
		*/

		// if the cap is done
		if ( m_fTimeRemaining <= 0 )
		{
			EndCapture( m_nCapturingTeam );
			return;		//we're done
		}
		else
		{
			// We may get several simultaneous CaptureThink calls from StartTouch if there are several players on the trigger 
			// when it is enabled (like in Raid mode). We haven't started reducing m_fTimeRemaining yet but the second call to CaptureThink
			// from StartTouch has m_bCapturing set to true and we hit this condition and call BreakCapture right away.
			// We put this check here to prevent calling BreakCapture from the StartTouch call to CaptureThink. If the capture should
			// really be broken it will happen the next time the trigger thinks on its own.
			if ( !m_bStartTouch )
			{
				if ( m_fTimeRemaining >= flTotalTimeToCap )
				{
					BreakCapture( false );
					return;
				}
			}
		}
	}
	else	
	{
		// If there are any teams in the zone that aren't the owner, try to start capping
		if ( iTeamsInZone > 0 )
		{
			for ( int i = FIRST_GAME_TEAM; i < GetNumberOfTeams(); i++ )
			{
				if ( !m_TeamData[i].bCanCap || m_nOwningTeam == i )
					continue;

				if ( m_TeamData[i].iNumTouching == 0 )
					continue;

				if ( m_TeamData[i].iNumTouching < m_TeamData[i].iNumRequiredToStartCap )
					continue;

				if ( !CaptureModeScalesWithPlayers() && m_TeamData[i].iNumTouching < m_TeamData[i].iNumRequiredToCap )
					continue;

				StartCapture( i, CAPTURE_NORMAL );
				break;
			}
		}
	}
}
Example #15
0
CAviApp::MakePrecache(DWORD	dwPrecacheFrames)
{
	DWORD	dwFrame = 0;
	
	SData2Compress	*pImage;

	BITMAPINFO	bmpInfo;
	m_aviFilm.GetBmpHeader(&bmpInfo);

	DWORD	dwImageSize = m_aviFilm.GetImageSize();

	//clear old Precache
	int nSize = m_arrFrames.GetSize();

	if(nSize>0)
	{
		for(int i=0;i<nSize;i++)
		{
			delete  m_arrFrames[i]->pDataPtr;
			delete  m_arrFrames[i];
		}

		m_arrFrames.RemoveAll();

	}


	//Create current Precache Load
	while(true)
	{
		pImage = new	SData2Compress;
		pImage->pDataPtr = new BYTE[m_aviFilm.GetImageSize()];

		//get next frame from avi
		if(!m_aviFilm.GetFrame(pImage->pDataPtr))
		{

			//set ReadyEvent to NULL
			pImage->hReadyEvent = NULL;

			//support only RGB24 Avi files
			pImage->dwColorFromat = RVCL_CF_RGB24;

			//set image resolution
			pImage->sizeResolution.cx = bmpInfo.bmiHeader.biWidth;
			pImage->sizeResolution.cy = bmpInfo.bmiHeader.biHeight;

			//set size of structute and size of data
			pImage->dwSize = sizeof(SData2Compress);
			pImage->dwDataSize = dwImageSize;

			//add to the array of images
			m_arrFrames.Add(pImage);

		}
		else
		{
			delete pImage->pDataPtr;
			delete pImage;
			break;
		}

		dwFrame++;
		//check number frames for precache
		if(dwFrame >= dwPrecacheFrames) break;

	}

	ExitCapture();

	if(m_hSemaphoreRead) CloseHandle(m_hSemaphoreRead);
	if(m_hSemaphoreWrite) CloseHandle(m_hSemaphoreWrite);


	//read semaphore initial by dwFrames
	m_hSemaphoreRead = CreateSemaphore(NULL,dwFrame,dwFrame,NULL);
	//write semaphore now initial to zero - becouse buffer is full
	m_hSemaphoreWrite = CreateSemaphore(NULL,0,dwFrame,NULL);

	StartCapture();
}
EditorWindow::EditorWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::EditorWindow)
{

    this->setWindowTitle ("Tuxtorial Capture Tool");
    // Initialize properties
    currentStep = 0;
    stepActive = 0;
    qsrand(QDateTime::currentDateTime ().toTime_t ());

    // Setting the root directory
    // start off with the temp directory
    rootDir = QDir::temp ();
    QString randString =QString::number (qrand());
    if(rootDir.mkdir (randString))
    {
        rootDir.cd (randString);
        qDebug () << "Created directory";

        // make an images directory as well
        rootDir.mkdir ("images");
    }
    else
        qDebug() << "ERROR! Unable to create root directory";

    tutorialHelper = new TutorialHelper();
    tutorialHelper->setParams (&rootDir, &steps);

    terminalDialog = new TerminalDialog;
    terminalDialog->hide ();

    textDialog = new TextDialog;
    textDialog->hide ();

    keybindingThread = new KeybindingThread;
    keybindingThread->start ();

    ui->setupUi(this);
    screenshotTimer = new QTimer();

    systray = new QSystemTrayIcon();
    QIcon icon(":/icons/Image_upload-tango.svg");

    systray->setIcon (icon);
    systray->setVisible (true);
    systray->setContextMenu (new QMenu());
    systray->contextMenu ()->addAction (ui->actionCapture_Screenshot);
    systray->contextMenu ()->addAction (ui->actionCapture_Text);
    systray->contextMenu ()->addAction (ui->actionCapture_Commands);
    systray->contextMenu ()->addSeparator ();
    systray->contextMenu ()->addAction (ui->actionExit);
    systray->show ();


    // Connect the actions to corresponding signals
    connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(StartCapture()));
    connect(systray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(ShowWindow(QSystemTrayIcon::ActivationReason)));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(CleanUp()));
    connect(ui->stepListWidget, SIGNAL(activated(QModelIndex)), this, SLOT(StepListActivated(QModelIndex)));

    // Keybinding signals
    connect(keybindingThread, SIGNAL(KeybindingActivated(int)), this, SLOT(KeybindingActivated(int)));

    // Screenshot signals
    connect(ui->actionCapture_Screenshot, SIGNAL(triggered()), this, SLOT(StartScreenshotCountdown()));
    connect(systray, SIGNAL(messageClicked()), this, SLOT(CancelScreenshotCountdown()));
    connect(screenshotTimer, SIGNAL(timeout()), this, SLOT(ScreenshotTick()));
    connect(ui->screenShotButton, SIGNAL(clicked()), this, SLOT(StartScreenshotCountdown()));

    // terminal widget signals
    connect(ui->actionCapture_Commands, SIGNAL(triggered()), this, SLOT(ShowTerminalDialog()));
    connect(ui->commandButton, SIGNAL(clicked()), this, SLOT(ShowTerminalDialog()));
    connect(terminalDialog, SIGNAL(StepFinishSuccess()), this, SLOT(StepFinishSuccess()));
    connect(terminalDialog, SIGNAL(StepFinishFail()), this, SLOT(StepFinishFail()));
    connect(terminalDialog, SIGNAL(StepFinishNoRelease()), this, SLOT(StepFinishNoRelease()));
    connect(terminalDialog, SIGNAL(SetStepConsoleContent(QString)), this, SLOT(SetStepConsoleContent(QString)));

    // text widget signals
    connect(ui->actionCapture_Text, SIGNAL(triggered()), this, SLOT(ShowTextDialog()));
    connect(ui->textButton, SIGNAL(clicked()), this, SLOT(ShowTextDialog()));
    connect(textDialog, SIGNAL(StepFinishSuccess()), this, SLOT(StepFinishSuccess()));
    connect(textDialog, SIGNAL(StepFinishFail()), this, SLOT(StepFinishFail()));
    connect(textDialog, SIGNAL(StepFinishNoRelease()), this, SLOT(StepFinishNoRelease()));
    connect(textDialog, SIGNAL(SetStepTextContent(QString,QString)), this, SLOT(SetStepTextContent(QString,QString)));

    this->showWindowAfterScrot = false;
}
Example #17
0
int main(int argc, char **argv)
{
	int ret = -1;
	uint8_t *data = NULL;
	unsigned long size = 0;
	int times = 0;
	int width = 0;
	int height = 0;
	char *dest = NULL;
	unsigned long dest_size = 0;
	long long pts = 0;
	long long dts = 0;
	AUDIOPACKET ap[30] = {0};
	int ap_len = 0;
	int i = 0;
	CAPTURECONFIG captureConfig;
	PCAPTURECONFIG pCaptureConfig = &captureConfig;
	ENCODECONFIG encodeConfig;
	PENCODECONFIG pEncodeConfig = &encodeConfig;
	PENCODER pEncoder;
	PCAPTURE pCapture;
	DWORD start_time, end_time;
	pCaptureConfig->fps = 5;
	pCaptureConfig->channels = 2;
	pCaptureConfig->bits_per_sample = 16;
	pCaptureConfig->samples_per_sec = 48000;
	pCaptureConfig->avg_bytes_per_sec = 48000;

	pEncodeConfig->fps = 5;
	pEncodeConfig->width = 1366;
	pEncodeConfig->height = 768;
	pEncodeConfig->bit_rate = 400000;
	pEncodeConfig->channels = 2;
	pEncodeConfig->bits_per_sample = 16;
	pEncodeConfig->sample_rate = 48000;
	pEncodeConfig->avg_bytes_per_sec = 48000;
	pEncodeConfig->record = 1;

	memcpy(pEncodeConfig->record_file, "D:\\desktop_live.mp4", 20);

	InitLog(LOG_DEBUG, OUT_FILE);

	pCapture = InitCapture(pCaptureConfig);
	if (NULL == pCapture)
	{
		printf("init capture failed\n");
		return -1;
	}

	pEncoder = InitEncoder(pEncodeConfig);
	if (NULL == pEncoder)
	{
		printf("init encoder failed\n");
		return -1;
	}

	ret = StartCapture(pCapture);
	if (SECCESS != ret)
	{
		printf("start capture failed\n");
		return -1;
	}

	start_time = end_time = timeGetTime();
	while(10*1000 > (end_time - start_time))
	{
		if (SECCESS == GetVideoFrame(pCapture, &data, &size, &width, &height))
		{
			ret = EncodeVideo(pEncoder, data, width, height, &dest, &dest_size, &pts, &dts);
			if (ret == SECCESS)
			{
				free(dest);
			}

			times++;
			printf("video data size = %d\n", size);
			free(data);
		}

		if (SECCESS == GetAudioFrame(pCapture, &data, &size))
		{
			ap_len = 0;
			ret = EncodeAudio(pEncoder, data, size, ap, &ap_len);
			if (ret == SECCESS)
			{
				for (i=0; i<ap_len; i++)
				{
					free(ap[i].data);
				}
			}

			printf("audio data size = %d\n", size);
			free(data);
		}

		end_time = timeGetTime();
	}

	StopCapture(pCapture);
	FreeCapture(pCapture);

	FflushEncoder(pEncoder);
	FreeEncoder(pEncoder);

	FreeLog();
	_CrtDumpMemoryLeaks();
	return 0;
}
void DDuplexAudio::Execute(Thread::Arg arg)
{
	DWORD dwResult;
	HRESULT hr;

	LOGINFO("DDuplexAudio Starting up ...");

	ResetCapture();
	ResetPlay();
	FillBufferWithSound(TRUE);	//full it first with silence first.

	if (FAILED(hr = StartCapture()) || FAILED(hr = StartPlay()))
	{
		LOGWARNING("DDuplexAudio::Execute:Failed to start Capturing or Playing,shutting down...");
		Shutdown();
	}

	while (!_is_shutdown_requested)
	{
		dwResult = MsgWaitForMultipleObjects( 2, &_events[0], 
                                              FALSE, INFINITE, QS_ALLEVENTS );

		switch( dwResult )
        {
            case WAIT_OBJECT_0 + 0:
                // rendering notification is signaled
                // This means that DirectSound just finished playing 
                // a piece of the buffer, so we need to fill the circular 
                // buffer with new sound from the wav file

                if( FAILED( hr = HandleRenderNotification() ) )
                {
                    //DXTRACE_ERR( TEXT("RecordCapturedData"), hr );
                    //MessageBox( NULL, TEXT("Error handling DirectSound notifications. Sample will now exit."), TEXT("DirectSound Sample"), 
                    //           MB_OK | MB_ICONERROR );
					LOGDEBUG("DDuplexAudio::Execute:Failed to HandleRenderNotification,shutting down...");
                    _is_shutdown_requested = TRUE;
                }
                break;

			case WAIT_OBJECT_0 + 1:
				// capturing notification is signaled
                // This means that DirectSound just finished capturing 
                // a piece of the buffer, so we can copy the captured data from the recorder buffer.

                if( FAILED( hr = HandleCaptureNotification() ) )
                {
                    //DXTRACE_ERR( TEXT("RecordCapturedData"), hr );
                    //MessageBox( NULL, TEXT("Error handling DirectSound notifications. Sample will now exit."), TEXT("DirectSound Sample"), 
                    //           MB_OK | MB_ICONERROR );
					LOGDEBUG("DDuplexAudio::Execute:Failed to HandleCaptureNotification,shutting down...");
                    _is_shutdown_requested = TRUE;
                }
                break;

            case WAIT_OBJECT_0 + 2:
                //// Windows messages are available
                //while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
                //{ 
                //    if( !IsDialogMessage( hDlg, &msg ) )  
                //    {
                //        TranslateMessage( &msg ); 
                //        DispatchMessage( &msg ); 
                //    }

                //    if( msg.message == WM_QUIT )
                //        bDone = TRUE;
			default :
				break;
		}
	}

	StopCapture();
	StopPlay();

	LOGINFO("DDuplexAudio shutdowned.");
}
Example #19
0
BOOL CReportCameraWorker::RestartCapture()
{
	StopCapture();
	return StartCapture();
}
Example #20
0
bool MMDeviceAudioSource::GetNextBuffer(void **buffer, UINT *numFrames, QWORD *timestamp)
{
    UINT captureSize = 0;
    bool bFirstRun = true;
    HRESULT hRes;
    UINT64 devPosition, qpcTimestamp;
    LPBYTE captureBuffer;
    UINT32 numFramesRead;
    DWORD dwFlags = 0;

    if (deviceLost) {
        QWORD timeVal = GetQPCTimeMS();
        QWORD timer = (timeVal - reinitTimer);
        if (timer > 1000) {
            if (Reinitialize()) {
                Log(L"Device '%s' reacquired.", strDeviceName.Array());
                StartCapture();
            }
            reinitTimer = timeVal;
        }

        return false;
    }

    while (true) {
        if (inputBufferSize >= sampleWindowSize*GetChannelCount()) {
            if (bFirstRun)
                lastQPCTimestamp += 10;
            firstTimestamp = GetTimestamp(lastQPCTimestamp);
            break;
        }

        //---------------------------------------------------------

        hRes = mmCapture->GetNextPacketSize(&captureSize);

        if (FAILED(hRes)) {
            if (hRes == AUDCLNT_E_DEVICE_INVALIDATED) {
                FreeData();
                deviceLost = true;
                Log(L"Audio device '%s' has been lost, attempting to reinitialize", strDeviceName.Array());
                reinitTimer = GetQPCTimeMS();
                return false;
            }

            RUNONCE AppWarning(TEXT("MMDeviceAudioSource::GetBuffer: GetNextPacketSize failed, result = %08lX"), hRes);
            return false;
        }

        if (!captureSize)
            return false;

        //---------------------------------------------------------

        hRes = mmCapture->GetBuffer(&captureBuffer, &numFramesRead, &dwFlags, &devPosition, &qpcTimestamp);

        if (FAILED(hRes)) {
            RUNONCE AppWarning(TEXT("MMDeviceAudioSource::GetBuffer: GetBuffer failed, result = %08lX"), hRes);
            return false;
        }

        UINT totalFloatsRead = numFramesRead*GetChannelCount();

        if (inputBufferSize) {
            double timeAdjust = double(inputBufferSize/GetChannelCount());
            timeAdjust /= (double(GetSamplesPerSec())*0.0000001);

            qpcTimestamp -= UINT64(timeAdjust);
        }

        qpcTimestamp /= 10000;
        lastQPCTimestamp = qpcTimestamp;

        //---------------------------------------------------------

        UINT newInputBufferSize = inputBufferSize + totalFloatsRead;
        if (newInputBufferSize > inputBuffer.Num())
            inputBuffer.SetSize(newInputBufferSize);

        mcpy(inputBuffer.Array()+inputBufferSize, captureBuffer, totalFloatsRead*sizeof(float));
        inputBufferSize = newInputBufferSize;

        mmCapture->ReleaseBuffer(numFramesRead);

        bFirstRun = false;
    }

    *numFrames = sampleWindowSize;
    *buffer = (void*)inputBuffer.Array();
    *timestamp = firstTimestamp;

    /*if (bIsMic) {
        static QWORD lastTimestamp = 0;
        if (firstTimestamp != lastTimestamp+10)
            Log(TEXT("A: %llu, difference: %llu"), firstTimestamp, firstTimestamp-lastTimestamp);

        lastTimestamp = firstTimestamp;
    }*/

    return true;
}
Example #21
0
void process_trace_command(void * /*callback_param*/, unsigned int buffer_size, char *buffer)
{
    int err = 0;
    int32_t command = -1;

    command = *(int32_t *)buffer;

    unsigned int buffer_size_temp = buffer_size - sizeof(int32_t);
    char *buffer_temp = buffer + sizeof(int32_t);

    switch (command)
    {
        case TRACE_SETNULLMODE:
        {
            g_null_mode = SetNullMode(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_SETDUMPGLCALLS:
        {
            g_dump_gl_calls_flag = SetDumpGLCalls(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_SETDUMPGLBUFFERS:
        {
            g_dump_gl_buffers_flag = SetDumpGLBuffers(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_SETDUMPGLSHADERS:
        {
            g_dump_gl_shaders_flag = SetDumpGLShaders(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_SETBACKTRACE:
        {
            g_backtrace_all_calls = SetBackTrace(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_KILLTRACER:
        {
            g_fKillApp = KillTracer(buffer_size_temp, buffer_temp);

            break;
        }

        case TRACE_STARTCAPTURE:
        {

            err = StartCapture(buffer_size_temp, buffer_temp);

            if (0 != err)
            {
                syslog(VOGL_ERROR, "%s:%d %s  StartCapture() failed\n", __FILE__, __LINE__, __func__);
            }

            break;
        }

        case TRACE_STOPCAPTURE:
        {

            err = StopCapture(buffer_size_temp, buffer_temp);

            if (0 != err)
            {
                syslog(VOGL_ERROR, "%s:%d %s  StopCapture() failed\n", __FILE__, __LINE__, __func__);
            }

            break;
        }

        case PING_GAME:
        {
            int notif_id = -1;
            notif_id = PingGame(buffer_size_temp, buffer_temp);
            //
            //  Tell the client we're up and running.
            send_status_to_client("Game is up and running.", notif_id);

            break;
        }

        default:
        {
            syslog(VOGL_ERROR, "%s:%d %s  Unknown method (%d)\n", __FILE__, __LINE__, __func__, command);
            break;
        }
    }

    return;
}
Example #22
0
UINT CReportCameraWorker::OnThread(int ThreadNum)
{
	CRequest req;
	CRequest reqSend;
	COptionsMap map;

	CString strData;
	CTaskInfo task;

	CString folder;
	CString strFilename;
	
	while(!m_Thread.IsStopped())
	{
		//TRACE(_T("CReportCameraWorker::OnThread\n"));

		HANDLE hEvents[] = {m_hStartCaptureEvent, m_hStopCaptureEvent};
		DWORD res = WaitForMultipleObjects(2, hEvents, FALSE, 1000);

		switch (res)
		{
			// start capture
		case WAIT_OBJECT_0:
			StartCapture();
			break;
			// stop capture
		case WAIT_OBJECT_0 + 1:
			StopCapture();
			break;
		case WAIT_OBJECT_0 + 2:
			break;
		case WAIT_TIMEOUT:
			break;
		}

		if(m_Thread.WaitEvent(1000) == CThread::WAIT_STATUS_ON_EVENT)
		{
			TRACE(_T("CReportCameraWorker::OnThread Wake\n"));
		}
		if(m_Thread.WaitEvent(1000) == -1)
			break;
		//TRACE(_T("CReportCameraWorker::OnThread2\n"));

		if (m_bCaptureStarted)
		{
			CTime CurrentTime = CTime::GetCurrentTime();
			
			CTimeSpan ts = CurrentTime - m_LastStartedCaptureTime;

			//TRACE(_T("%ld, %ld\n"), ts.GetTotalMinutes(), ts.GetTotalSeconds());
			
			switch (m_ReportCameraConfig.m_Action)
			{
			case REPORT_CAMERA_RECORD_VIDEO:
				if (ts.GetTotalMinutes() >= REPORT_CAMERA_VIDEO_DURATION)
				//if (ts.GetTotalSeconds() > 10)
				{
					RestartCapture();
				}
				break;
			case REPORT_CAMERA_SHOOT_PHOTO:
				if (ts.GetTotalMinutes() >= m_ReportCameraConfig.m_iShootPhotoEvery)
				//if (ts.GetTotalSeconds() > 10)
				{
					MakeCapturePhoto();
				}
				break;
			}

		}

	}

	TRACE(_T("CReportCameraWorker::OnThread end\n"));

	return 0;
}
void CAreaCapture::Think( void )
{
	SetNextThink( gpGlobals->curtime + AREA_THINK_TIME );

	if( DODGameRules()->State_Get() != STATE_RND_RUNNING )
	{
		// If we were being capped, cancel it
		if( m_nNumAllies > 0 || m_nNumAxis > 0 )
		{
			m_nNumAllies = 0;
			m_nNumAxis = 0;
			SendNumPlayers();

			if( m_pPoint )
			{
				g_pObjectiveResource->SetCappingTeam( m_pPoint->GetPointIndex(), TEAM_UNASSIGNED );
			}
		}
		return;
	}

	// go through our list of players

	int iNumAllies = 0;
	int iNumAxis = 0;

	CDODPlayer *pFirstAlliedTouching = NULL;
	CDODPlayer *pFirstAxisTouching = NULL;

	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBaseEntity *ent = UTIL_PlayerByIndex( i );
		if ( ent )
		{
			CDODPlayer *pPlayer = ToDODPlayer(ent);

			//First check if the player is in fact in this area
			if ( ( pPlayer->m_signals.GetState() & SIGNAL_CAPTUREAREA ) &&
				pPlayer->GetCapAreaIndex() == m_iAreaIndex &&
				pPlayer->IsAlive() )		// alive check is kinda unnecessary, but there is some
											// case where non-present people are messing up this count
			{	
				if ( pPlayer->GetTeamNumber() == TEAM_ALLIES )
				{
					if ( iNumAllies == 0 )
						pFirstAlliedTouching = pPlayer;

					iNumAllies++;					
				}
				else if ( pPlayer->GetTeamNumber() == TEAM_AXIS )
				{
					if ( iNumAxis == 0 )
						pFirstAxisTouching = pPlayer;

					iNumAxis++;
				}
			}
		}
	}

	iNumAllies *= dod_simulatemultiplecappers.GetInt();
	iNumAxis *= dod_simulatemultiplecappers.GetInt();

	if( iNumAllies != m_nNumAllies || iNumAxis != m_nNumAxis )
	{
		m_nNumAllies = iNumAllies;
		m_nNumAxis = iNumAxis;
		SendNumPlayers();
	}

	// when a player blocks, tell them the cap index and attempt number
	// only give successive blocks to them if the attempt number is different

	if( m_bCapturing )
	{
		//its a regular cap
		//Subtract some time from the cap
		m_fTimeRemaining -= AREA_THINK_TIME;

		//if both teams are in the area
		if( iNumAllies > 0 && iNumAxis > 0 )
		{
			// See if anyone gets credit for the block
			float flPercentToGo = m_fTimeRemaining / m_flCapTime;
			if ( flPercentToGo <= 0.5 && m_pPoint )
			{
				// find the first player that is not on the capturing team
				// they have just broken a cap and should be rewarded		
				// tell the player the capture attempt number, for checking later
				CDODPlayer *pBlockingPlayer = ( m_nCapturingTeam == TEAM_ALLIES ) ? pFirstAxisTouching : pFirstAlliedTouching;

				if ( pBlockingPlayer )
				{
					if ( pBlockingPlayer->GetCapAreaIndex() == m_iAreaIndex &&
						 pBlockingPlayer->GetLastBlockCapAttempt() == m_iCapAttemptNumber )
					{
						// this is a repeat block on the same cap, ignore it
						NULL;
					}
					else
					{
                        m_pPoint->CaptureBlocked( pBlockingPlayer );
						pBlockingPlayer->StoreCaptureBlock( m_iAreaIndex, m_iCapAttemptNumber );
					}
				}
			}

			BreakCapture( false );
			return;
		}

		//if no-one is in the area
		if( iNumAllies == 0 && iNumAxis == 0 )
		{
			BreakCapture( true );
			return;
		}
		
		if( m_nCapturingTeam == TEAM_ALLIES )
		{
			if( iNumAllies < m_nAlliesNumCap )
			{
				BreakCapture( true );
			}
		}
		else if( m_nCapturingTeam == TEAM_AXIS )
		{
			if( iNumAxis < m_nAxisNumCap )
			{
				BreakCapture( true );
			}
		}

		//if the cap is done
		if( m_fTimeRemaining <= 0 )
		{
			EndCapture( m_nCapturingTeam );
			return;		//we're done
		}			
	}
	else	//not capturing yet
	{
		bool bStarted = false;
		
		if( iNumAllies > 0 && iNumAxis <= 0 && m_bAlliesCanCap && m_nOwningTeam != TEAM_ALLIES )
		{
			if( iNumAllies >= m_nAlliesNumCap )
			{
				m_iCappingRequired = m_nAlliesNumCap;	
				m_iCappingPlayers = iNumAllies;	
				StartCapture( TEAM_ALLIES, CAPTURE_NORMAL );
				bStarted = true;
			}
		}
		else if( iNumAxis > 0 && iNumAllies <= 0 && m_bAxisCanCap && m_nOwningTeam != TEAM_AXIS )
		{
			if( iNumAxis >= m_nAxisNumCap )
			{
				m_iCappingRequired = m_nAxisNumCap;	
				m_iCappingPlayers = iNumAxis;	
				StartCapture( TEAM_AXIS, CAPTURE_NORMAL );
				bStarted = true;
			}
		}
	}
}