Esempio n. 1
0
CStreamClientSDK::~CStreamClientSDK()
{
	for(int i=0;i<MAX_DEVICE_NUM;i++)
		StopPlay(i);

	PtzStopPlay();
	StreamClient_FiniLib();
}
Esempio n. 2
0
CHaikangSDK::~CHaikangSDK()
{
	for(int i=0;i<MAX_DEVICE_NUM;i++)
		StopPlay(i);

	PtzStopPlay();
	NET_DVR_Cleanup();
}
Esempio n. 3
0
//释放Master所占相关资源
void CSourceManager::RealseManager()
{
	StopPlay();
	StopPush();
	StopCapture();
	RealseScreenCapture();
	UnInitSource();
}
Esempio n. 4
0
void Cce152::ComputeKey(void)
{
    BYTE k = pKEYB->LastKey;
    switch (k) {
    case K_PLAY : if (mode == LOAD) { Play();
        }
                    break;
    case K_EJECT:
        switch (mode) {
            case EJECT:
            case STOP : LoadTape(); break;
            case LOAD : LoadTape(); break;
            case PLAY : StopPlay(); break;
            case RECORD : StopPlay(); break;
		}
        break;
    case K_RECORD: RecTape(); break;
    }
}
Esempio n. 5
0
VSCVWidget::~VSCVWidget()
{
    VDC_DEBUG( "%s ~VSCVWidget id %d\n",__FUNCTION__,
            m_nId);
    StopPlay();
    if (m_pStarted != TRUE)
    {
        m_pStarted = TRUE;
    }
}
Esempio n. 6
0
bool CHaikangSDK::StartPlay(int screenNo,char *name,char *sip,int nPort,int channel,
							char *user,char *psw,HWND hWnd,int subtype,int Direction)
{
	if(m_LoginHandle[screenNo] != -1)
	{
		StopPlay(screenNo);
	}
	//---------------------------------------
	// 注册设备
	m_direction[screenNo]=Direction;
	NET_DVR_DEVICEINFO_V30 struDeviceInfo;
	m_LoginHandle[screenNo] = NET_DVR_Login_V30(sip, nPort, user, psw, &struDeviceInfo);
	if (m_LoginHandle[screenNo] < 0)
	{
		DlgMain->ShowCameraMessage(name,"Login error!",FALSE);
		printf("Login error, %d\n", NET_DVR_GetLastError());
		//NET_DVR_Cleanup();
		return false;
	}

	//---------------------------------------
	//设置异常消息回调函数
	NET_DVR_SetExceptionCallBack_V30(0, NULL,g_ExceptionCallBack, NULL);

	//---------------------------------------
	//启动预览并设置回调数据流
	NET_DVR_CLIENTINFO ClientInfo = {0};
	//需要SDK解码时句柄设为有效值,仅取流不解码时可设为空
	ClientInfo.hPlayWnd = NULL;
	ClientInfo.lChannel = channel;		//预览通道号
	//最高位(31)为0表示主码流,为1表示子码流0~30位表示连接方式:0-TCP方式;1-UDP方式;2-多播方式;3-RTP方式;
	if(subtype == 0)
		ClientInfo.lLinkMode = 0;
	else
		ClientInfo.lLinkMode = 0x80000000;
	ClientInfo.sMultiCastIP = NULL;	//多播地址,需要多播预览时配置
  
	BOOL bPreviewBlock = false;       //请求码流过程是否阻塞,0:否,1:是
	m_RealHandle[screenNo] = NET_DVR_RealPlay_V30(m_LoginHandle[screenNo], &ClientInfo, g_RealDataCallBack_V30, this, 0);
	if (m_RealHandle[screenNo] < 0)
	{
		DlgMain->ShowCameraMessage(name,"Play error!",FALSE);
		printf("NET_DVR_RealPlay_V30 error\n");
		NET_DVR_Logout(m_LoginHandle[screenNo]);
	//	NET_DVR_Cleanup();
		m_LoginHandle[screenNo] = -1;
		return false;
	}

	DlgMain->ShowCameraMessage(name,"连接成功",FALSE);
	return true;
}
Esempio n. 7
0
int	Cce152::EjectTape(void)
{
	if (info.ptrFd)
	{
        StopPlay();
		AddLog(LOG_TAPE,"Stop Play");
		fclose(info.ptrFd);
		info.ptrFd=0;
		TapeCounter = 0;
	}
	mode = EJECT;
	return 1;
}
Esempio n. 8
0
void WINAPI duAnimation::Play()
 {
	duImage *pImage = (duImage *)GetResObj(m_szAnimation, DU_RES_IMAGE);
	if (pImage == NULL)
		return;

	StopPlay();

	DWORD dwThreadId = 0;

	m_hTimerEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	m_hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	m_hThread = CreateThread(NULL, 0, AnimationThread, this, 0, &dwThreadId);
}
Esempio n. 9
0
void CAudioCtrl::StopAndFreeAll()
{
	if (m_hRecord)
	{
		StopRec();
	}
	
	if (m_hPlay)
	{
		StopPlay();
	}

	FreeBuffer();
}
Esempio n. 10
0
void CAudioCtrl::OnTimer(UINT nIDEvent) 
{
	switch ( nIDEvent )
	{
	case TIMER_EVENT_STOPREC:
		KillTimer ( nIDEvent );
		StopRec ();
		break;
	case TIMER_EVENT_STOPPLAY:
		KillTimer ( nIDEvent );
		StopPlay ();
		break;
	}	
	CWnd::OnTimer(nIDEvent);
}
Esempio n. 11
0
void ErrorHandler(LPTSTR Info, LPTSTR Extra)
// Purpose: Close open handles and display message box for error
// Args: String with information to display in message box
// Globals Used: hHeap, TimerID, hFile
{
  char TempString[300];

  StopPlay();
  strcpy(TempString,"Colorize.dll:");
  strcat(TempString,Info);
  if (Extra != NULL)
  {
    strcat(TempString,"\r\n");
    strcat(TempString,Extra);
  }
  MessageBox(NULL,TempString,DEFTITLE,MB_OK|MB_SETFOREGROUND);
}
void CLHTMLActiveDocument::FinalRelease()
{
	ATLTRACE("CLHTMLActiveDocument::FinalRelease()\n");

	StopPlay();	// TODO, do somewhere else

	if (m_cwnd.m_hWnd)
	{
		m_cwnd.DestroyWindow();
	}

	if (m_pWindow)
	{
#if 0
		m_pWindow->Free();
#endif
		m_pWindow->Release();
		m_pWindow = NULL;
	}

	DeleteCriticalSection(&m_paintCriticalSection);

	if (m_element)
	{
		m_element.Release();
	}

	if (m_document)
	{
		m_document.p->AddRef();
		int refcount = m_document.p->Release();

		m_document.Release();
	}

	if (m_errorHandler)
	{
		m_errorHandler.p->AddRef();
		int refcount = m_errorHandler.p->Release();

		m_errorHandler.Release();
	}

	m_curMoniker.Release();
}
Esempio n. 13
0
bool CMusicPlayer::PlayDocument(CScoreDocument *pSDoc)
{
//	if(m_pSDoc) return false;
	di.doc = pSDoc;
	StopPlay();
	di.Runnalbe = true;
	if(di.Puased) {
		ReleaseSemaphore(di.hSemaphore, 1, NULL);
		di.Puased = false;
	}

	m_hThread = ::CreateThread (
		NULL,		// 默认安全属性
		NULL,		// 默认堆栈大小
		PlayProc,	// 线程入口地址(执行线程的函数)
		&di,		// 传给函数的参数
		0,		// 指定线程立即运行
		&m_dwThreadId);	// 返回线程的ID号

	return true;
}
Esempio n. 14
0
CVlcRtspSDK::~CVlcRtspSDK()
{
	StopPlay();

	/* Free the media_player */
	if (m_pLibvlc_Inst != NULL)
		libvlc_release(m_pLibvlc_Inst);

	if (RGBdata != NULL)
	{
		free(RGBdata);
		RGBdata = NULL;
	}
	if (YUVdata != NULL)
	{
		free(YUVdata);
		YUVdata = NULL;
	}

	DeleteCriticalSection(&lockflag);

}
Esempio n. 15
0
//删除设备
void CDLGscreen::DeleteDevice(long camID)
{
	for(int i=0;i<MAX_DEVICE_NUM;i++)
	{
		if(m_videoInfo[i].camID == camID)
		{
			StopPlay(i);
			DlgMain->DlgTabVideo.DlgNormal.UpdateNormalWnd();

			m_videoInfo[i].subtype = 0;		//主码流
			m_videoInfo[i].isplay = false;
			m_videoInfo[i].area = "";
			m_videoInfo[i].name = "";
			m_videoInfo[i].user = "";
			m_videoInfo[i].psw = "";
			m_videoInfo[i].enableCarDetect = false;
			m_videoInfo[i].enableFaceDetect = false;
			m_videoInfo[i].playHandle = -1;

		}
	}
}
Esempio n. 16
0
//---------------------------------------------------------------------------
__fastcall TLinkDetailForm::TLinkDetailForm(TComponent* Owner)
	: TForm(Owner)
{
	StopPlay();

	FReader = NULL;
	FMagnify = 0;
	FManager = NULL;
	LinkNum = 0;

	Dragging = false;
	BeforeOrAfter = false;
	FirstMouseDownPos = 0;
	FirstMouseDownX = 0;

	WaveAreaHasFocus = true;

	WaveAreaPanel->DoubleBuffered = true;
	PlayBeforePaintBoxPanel->DoubleBuffered = true;

	PlayBeforeLength = 0;
	PlayStartPos = 0;

	EditLinkAttribFrame->OnInfoChanged = EditLinkAttribFrameInfoChanged;
	EditLinkAttribFrame->OnEraseRedo   = EditLinkAttribFrameEraseRedo;

	BeforeLinkLabel->Font->Color = C_WAVE_B_FG_BASE;
	AfterLinkLabel ->Font->Color = C_WAVE_A_FG_BASE;

	UpdateLayout();
	UpdateDisplay();

	
	// window position and size
	ReadWindowBasicInformationFromIniFile("LinkDetail", this);

	// assign mainwindow's icon
	Icon->Assign(((TForm*)Owner)->Icon);
}
Esempio n. 17
0
//
// 播放对应当数据缓冲读完后触发的消息
//
LRESULT CAudioCtrl::OnMM_WOM_DONE (WPARAM wParam, LPARAM lParam)
{
	//TRACE("OnMM_WOM_DONE!\r\n");

	MMRESULT mmReturn = 0;
	
	LPWAVEHDR pHdr = (LPWAVEHDR)lParam;
	mmReturn = ::waveOutUnprepareHeader(m_hPlay, pHdr, sizeof(WAVEHDR));
	if ( mmReturn )
	{
		TRACE("waveOutUnprepareHeader() failed!\r\n" );
		return -1L;
	}
	
	m_nDataQueueNum--;

	if ( m_eStatus == ENUM_STATUS_PLAYING )
	{		
		
		int nSize = m_dwQueuBufferSize;
		if ( ReadSoundDataFromFile ( pHdr->lpData, nSize ) )
		{
			AddOutputBufferToQueue ( (int)pHdr->dwUser, nSize );			
			return 0L;
		}
		else
		{
			Stop();
		}
	}

	if ( m_nDataQueueNum == 0 && m_eStatus != ENUM_STATUS_PLAYING )
	{
		StopPlay ();
	}

	return S_OK;
}
Esempio n. 18
0
void VSCVWidget::dropEvent(QDropEvent *event)
{
    VDC_DEBUG( "%s Enter in dropEvent id %d\n",__FUNCTION__, m_nId);
    if (event->mimeData()->hasText() == false)
    {
    	return;
    }

    s32 nPlayId = atoi(event->mimeData()->text().toLatin1().data());
    if (nPlayId < VWIDGET_ID_OFFSET)
    {
       if (m_pStarted == TRUE)
       {
            return;
       }
       m_nPlayId = nPlayId;
        StopPlay();
        StartPlay("fake");
        return;
    }
    

    VDC_DEBUG( "%s Enter in dropEvent Play %d\n",__FUNCTION__, nPlayId);

    nPlayId = nPlayId - VWIDGET_ID_OFFSET;

    if (nPlayId == m_nId)
    {
        VDC_DEBUG( "%s Enter in dropEvent Same with me %d\n", 
            __FUNCTION__, nPlayId);
        return;
    }
    emit VideoSwitchWith(m_nId, nPlayId);
    VDC_DEBUG( "%s Enter in dropEvent  me %d switch with %d\n", 
            __FUNCTION__, m_nId, nPlayId);
}
Esempio n. 19
0
// MP3 decode player
void MP3Player(void)
{
    FRESULT res;
    uint8_t *ReadStart;
    uint8_t *GuardPtr;
    volatile uint8_t u8PCMBufferTargetIdx = 0;
    volatile uint32_t pcmbuf_idx, i;
    volatile unsigned int Mp3FileOffset=0;
    uint16_t sampleL, sampleR;

    pcmbuf_idx = 0;
    memset((void *)&audioInfo, 0, sizeof(audioInfo));

    /* Parse MP3 header */
    MP3_ParseHeaderInfo(MP3_FILE);

    /* First the structures used by libmad must be initialized. */
    mad_stream_init(&Stream);
    mad_frame_init(&Frame);
    mad_synth_init(&Synth);

    /* Open MP3 file */
    res = f_open(&mp3FileObject, MP3_FILE, FA_OPEN_EXISTING | FA_READ);
    if (res != FR_OK) {
        printf("Open file error \r\n");
        return;
    }

    /* Open I2S1 interface and set to slave mode, stereo channel, I2S format */
    I2S_Open(I2S1, I2S_MODE_SLAVE, 16000, I2S_DATABIT_16, I2S_STEREO, I2S_FORMAT_I2S, I2S_I2S);

    /* Initialize WAU8822 codec */
    WAU8822_Setup();

    /* Configure wau8822 for specific sampling rate */
    WAU8822_ConfigSampleRate(audioInfo.mp3SampleRate);

    /* Set MCLK and enable MCLK */
    I2S_EnableMCLK(I2S1, 12000000);

    while(1) {
        if(Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN) {
            if(Stream.next_frame != NULL) {
                /* Get the remaining frame */
                Remaining = Stream.bufend - Stream.next_frame;
                memmove(MadInputBuffer, Stream.next_frame, Remaining);
                ReadStart = MadInputBuffer + Remaining;
                ReadSize = FILE_IO_BUFFER_SIZE - Remaining;
            } else {
                ReadSize = FILE_IO_BUFFER_SIZE,
                ReadStart = MadInputBuffer,
                Remaining = 0;
            }

            /* read the file from SDCard */
            res = f_read(&mp3FileObject, ReadStart, ReadSize, &ReturnSize);
            if((res != FR_OK) || f_eof(&mp3FileObject)) {
                printf("Stop !(%x)\n\r", res);
                goto stop;
            }

            /* if the file is over */
            if (ReadSize > ReturnSize) {
                GuardPtr=ReadStart+ReadSize;
                memset(GuardPtr,0,MAD_BUFFER_GUARD);
                ReadSize+=MAD_BUFFER_GUARD;
            }

            Mp3FileOffset = Mp3FileOffset + ReturnSize;
            /* Pipe the new buffer content to libmad's stream decoder
                     * facility.
            */
            mad_stream_buffer(&Stream,MadInputBuffer,ReadSize+Remaining);
            Stream.error=(enum  mad_error)0;
        }

        /* decode a frame from the mp3 stream data */
        if(mad_frame_decode(&Frame,&Stream)) {
            if(MAD_RECOVERABLE(Stream.error)) {
                /*if(Stream.error!=MAD_ERROR_LOSTSYNC ||
                   Stream.this_frame!=GuardPtr)
                {
                }*/
                continue;
            } else {
                /* the current frame is not full, need to read the remaining part */
                if(Stream.error==MAD_ERROR_BUFLEN) {
                    continue;
                } else {
                    printf("Something error!!\n");

                    /* play the next file */
                    audioInfo.mp3FileEndFlag = 1;
                    goto stop;
                }
            }
        }

        /* Once decoded the frame is synthesized to PCM samples. No errors
        * are reported by mad_synth_frame();
        */
        mad_synth_frame(&Synth,&Frame);

        //
        // decode finished, try to copy pcm data to audio buffer
        //

        if(audioInfo.mp3Playing) {
            //if next buffer is still full (playing), wait until it's empty
            if(aPCMBuffer_Full[u8PCMBufferTargetIdx] == 1)
                while(aPCMBuffer_Full[u8PCMBufferTargetIdx]);
        } else {

            if((aPCMBuffer_Full[0] == 1) && (aPCMBuffer_Full[1] == 1 )) {       //all buffers are full, wait
                StartPlay();
            }
        }

        for(i=0; i<(int)Synth.pcm.length; i++) {
            /* Get the left/right samples */
            sampleL = Synth.pcm.samples[0][i];
            sampleR = Synth.pcm.samples[1][i];

            /* Fill PCM data to I2S(PDMA) buffer */
            aPCMBuffer[u8PCMBufferTargetIdx][pcmbuf_idx++] = sampleR | (sampleL << 16);

            /* Need change buffer ? */
            if(pcmbuf_idx == PCM_BUFFER_SIZE) {
                aPCMBuffer_Full[u8PCMBufferTargetIdx] = 1;      //set full flag
                u8PCMBufferTargetIdx ^= 1;

                pcmbuf_idx = 0;
//               printf("change to ==>%d ..\n", u8PCMBufferTargetIdx);
                /* if next buffer is still full (playing), wait until it's empty */
                if((aPCMBuffer_Full[u8PCMBufferTargetIdx] == 1) && (audioInfo.mp3Playing))
                    while(aPCMBuffer_Full[u8PCMBufferTargetIdx]);
            }
        }
    }

stop:

    printf("Exit MP3\r\n");

    mad_synth_finish(&Synth);
    mad_frame_finish(&Frame);
    mad_stream_finish(&Stream);

    f_close(&mp3FileObject);
    StopPlay();
}
Esempio n. 20
0
bool CStreamClientSDK::StartPlay(int screenNo,char *name,char *sip,
								 char *user,char *psw,HWND hWnd,int subtype,
								 char *Rtspurl,int RTP,int DecodeTag)
{
	if(m_RealHandle[screenNo] >=0)
	{
		StopPlay(screenNo);
	}
	int i;
	int transmethod;

	m_RealHandle[screenNo]=StreamClient_CreateSession();
	if(m_RealHandle[screenNo]>=0)
	{

		i=StreamClient_SetMsgCallBack(m_RealHandle[screenNo],StreamClientSDKMsgFunc,NULL);
		if(i)
		{
			DlgMain->ShowCameraMessage(name,(char*)StreamClient_GetErrMsgByErrCode(i),FALSE);
			StreamClient_DestroySession(m_RealHandle[screenNo]);
			m_RealHandle[screenNo]=-1;
			return false;
		}

		//解码
		if(DecodeTag==DECODETAG_PS)
		{
			i=StreamClient_SetPsDataCallBack(m_RealHandle[screenNo],StreamClientSDKDataFunc,this);
		}
		else if(DecodeTag==DECODETAG_SRC)
		{
			i=StreamClient_SetDataCallBack(m_RealHandle[screenNo],StreamClientSDKDataFunc,this);
		}

		if(i)
		{
			DlgMain->ShowCameraMessage(name,(char*)StreamClient_GetErrMsgByErrCode(i),FALSE);
			StreamClient_DestroySession(m_RealHandle[screenNo]);
			m_RealHandle[screenNo]=-1;
			return false;
		}

		if(0==RTP)
			transmethod=RTPRTSP_TRANSMODE;
		else	if(1==RTP)
			transmethod=RTPUDP_TRANSMODE;
		else	if(2==RTP)
			transmethod=RTPMCAST_TRANSMODE;
		else
		{
			DlgMain->ShowCameraMessage(name,"RTP选择错误",FALSE);
			StreamClient_DestroySession(m_RealHandle[screenNo]);
			m_RealHandle[screenNo]=-1;
			return false;
		}

		i=StreamClient_Start(m_RealHandle[screenNo], NULL, Rtspurl, "StreamClient",  transmethod, user, psw);
		if(i)
		{
			DlgMain->ShowCameraMessage(name,(char*)StreamClient_GetErrMsgByErrCode(i),FALSE);
			StreamClient_DestroySession(m_RealHandle[screenNo]);
			m_RealHandle[screenNo]=-1;
			return false;
		}
	}
	else
	{
		if(-3 == m_RealHandle[screenNo])
			DlgMain->ShowCameraMessage(name,"STREAM_CLIENT_NO_RTSP_SESSION流媒体客户端会话已用尽!",FALSE);
		else	if(-2 == m_RealHandle[screenNo])
			DlgMain->ShowCameraMessage(name,"STREAM_CLIENT_NO_INIT 流媒体客户端未初始化!",FALSE);

		return false;
	}
	DlgMain->ShowCameraMessage(name,"连接成功",FALSE);
	return true;
}
Esempio n. 21
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;
}
Esempio n. 22
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.");
}
Esempio n. 23
0
int StartLocalFilePlay(Tcl_Interp *interp)
{
  DWORD dwFileSizeHigh;
  DWORD dwFileSize;

  pDTS_Color->bStart = false; // Do this to prevent reentrant call
                              // from DoOneEvent
  bPaused = false;

  if (pDTS_Color->Filename != NULL && pDTS_Color->Channel != NULL)
  {
    StopPlay(); // Stop any play in-progress

    // Open file
    if ((hFile = CreateFile(pDTS_Color->Filename,
            GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL,NULL)) == INVALID_HANDLE_VALUE)
    {
      ErrorHandler("Could not open file.",pDTS_Color->Filename);
    	return TCL_ERROR;
    }

    // Determine file's size
    dwFileSize = GetFileSize(hFile,&dwFileSizeHigh);
    if (dwFileSizeHigh)
    {
      ErrorHandler("File is too big!");
    	return TCL_ERROR;
    }

    if (dwFileSize == 0)
    {
      ErrorHandler("Play file is empty!");
    	return TCL_ERROR;
    }

    // Create a heap in virtual memory
    if ((hHeap = HeapCreate(0,dwFileSize,0)) == INVALID_HANDLE_VALUE)
    {
      ErrorHandler("Cannot create heap!");
    	return TCL_ERROR;
    }

    // Allocate space for the file
    if ((lpHeap = HeapAlloc(hHeap,0,dwFileSize)) == NULL)
    {
      ErrorHandler("Insufficient heap space!");
    	return TCL_ERROR;
    }

    // Read the entire file into virtual memory
    (void)ReadFile(hFile, lpHeap, dwFileSize, &dwBytesRead, NULL);
    if (dwBytesRead != dwFileSize)
    {
      ErrorHandler("Could not read entire file!");
    	return TCL_ERROR;
    }

    // Finished with the file
    CloseHandle(hFile);

    // Initialize vars and flags
    bDataReady = bEndOfFile = bPaused = false;
    dwByteCount = 0; // Counts total bytes processed from heap buffer

    // Go ahead and queue first line
    QueueNextLineForTransmit();

    // Begin timer thread
    TimerID = SetTimer(NULL,      // no main window handle in a DLL
          0,                      // timer identifier
          pDTS_Color->PlayTime,   // delay in ms
          (TIMERPROC) OnTimer1);  // timer callback

    // Fetch and send text lines on timer event, yielding to XiRC
    // XiRC only calls our polling routine once per second,
    // but we can send data to a chat window much faster, so this
    // code gates data to XiRC at a programmable rate set in Colorizer.exe
    // while still allowing other XiRC scripts to run.
    if (!pDTS_Color->bUseDDE && interp != NULL)
    {
      // Run loop for XiRCON
      while((!bEndOfFile || bDataReady) && !pDTS_Color->bStop)
      {
        if (bDataReady) // bDataDeady triggered by timer callback event
        {
          Sendtcl(interp, GlobalString);
          bDataReady = false;
        }
        else if (!pDTS_Color->bUseDDE) // Yield to other TCL processes
          (void)Tcl_DoOneEvent(TCL_DONT_WAIT);
      }

      if (pDTS_Color->bStop)
        Sendtcl(interp, "echo \"Playback Stopped!\" status");
      else
        Sendtcl(interp, "echo \"Playback Ended!\" status");

      StopPlay();
    }
  }

  return TCL_OK;
}
Esempio n. 24
0
//开始播放
bool CDLGscreen::StartPlay(int id,char *area,char *name,char *ip,int port,int channel,
						   char *user,char *psw,int screenNo,int subtype,int venderID,
						   char *Rtspurl,int RTP,int DecodeTag,int Direction)
{
	CWnd* pWnd = m_screenPannel.GetPage(screenNo);
	if (!pWnd)
	{
		return false;
	}

	//只能有一个视频在播放
	for(int i=0;i<MAX_DEVICE_NUM;i++)
	{
		if(true == m_videoInfo[i].isplay)
		{
			if(id == m_videoInfo[i].camID)
			{

				//非服务器执行
				MessageBox("正在其他窗口播放中",MESSAGEBOX_TITLE);
				return false;
			}
		}
	}
	//路数限制
	int j=0;
	for(int i=0;i<MAX_DEVICE_NUM;i++)
	{
		if(true == m_videoInfo[i].isplay)
		{
			j++;
		}
	}
	char str[64];
	sprintf(str,"本版本最大支持%d路设备\n",MAX_CAMERA);
	if(j>=MAX_CAMERA)
	{
		//非服务器执行
		MessageBox(str,MESSAGEBOX_TITLE);
		return false;
	}

	if(m_videoInfo[screenNo].isplay == true)
	{
		StopPlay(screenNo);
	}

	FaceAdd[screenNo]=0;
	CarAdd[screenNo]=0;

	bool ret = m_video.StartPlay(venderID,screenNo,name, ip, port, 
		channel, user, psw, pWnd->m_hWnd, subtype,Rtspurl,RTP,DecodeTag,Direction);

	if(ret)
	{
		m_videoInfo[screenNo].subtype = subtype;		//主码流
		m_videoInfo[screenNo].isplay = true;
		m_videoInfo[screenNo].area = area;
		m_videoInfo[screenNo].name = name;
		m_videoInfo[screenNo].ip = ip;
		m_videoInfo[screenNo].user = user;
		m_videoInfo[screenNo].psw = psw;
		m_videoInfo[screenNo].port = port;
		m_videoInfo[screenNo].channel = channel;
		m_videoInfo[screenNo].camID = id;
		m_videoInfo[screenNo].playHandle = m_video.m_RealHandle[screenNo];
		m_videoInfo[screenNo].venderID = venderID;
		m_videoInfo[screenNo].Rtspurl = Rtspurl;
		m_videoInfo[screenNo].RTP = RTP;
		m_videoInfo[screenNo].DecodeTag = DecodeTag;
		m_videoInfo[screenNo].Direction = Direction;

		DlgMain->DlgTabVideo.DlgDeviceTree.ChangeTreeItemIcon(id,true);
//服务器不能更新图标
		DlgMain->DlgTabVideo.DlgNormal.UpdateNormalWnd();

	}

	return ret;

}
Esempio n. 25
0
void VSCVWidget::stopAction()
{
    StopPlay();
}
Esempio n. 26
0
void DAXAudio::Stop()
{
	StopRecord();
	StopPlay();
}
Esempio n. 27
0
bool CVlcRtspSDK::StartPlay(int screenNum,char *name,HWND inhWnd,char *Rtspurl,int Direction)
{
	StopPlay();

	screenNo=screenNum;
	m_direction=Direction;

	hWnd=inhWnd;
	hDC   =   ::GetDC(hWnd); 
	pDc   =   CDC::FromHandle(hDC);   
	pDc->SetStretchBltMode(COLORONCOLOR);

	wchar_t wbuff[1024];
	char utf8[1024];
	MultiByteToWideChar(CP_ACP, 0, Rtspurl, -1, wbuff, 1024);  
	// buffLen = WideCharToMultiByte(CP_UTF8, 0, wbuff, -1, NULL, 0, 0, 0);  
	//  utf8 = new char[buffLen+1];  
	WideCharToMultiByte(CP_UTF8, 0, wbuff, -1, (LPSTR)utf8, 1024, 0, 0);  
	const char *p=NULL;

	// 判断rtsp地址是否可以连接
	// 使用url去创建一个CYuanRtspClient对象
#if !TEST_DEBUG
	CYuanRtspClient YuanRtsp(Rtspurl);
	ERTSPERROR eRet = YuanRtsp.InitSocket();
	if (eRet == E_RTSP_SUCCESS)
	{
		eRet = YuanRtsp.JudgeCorrect();
		if (eRet != E_RTSP_SUCCESS)
		{
			DlgMain->ShowCameraMessage(name,"RTSP连接失败 socket不通",FALSE);
			return false;
		}
	}
	else
	{
		DlgMain->ShowCameraMessage(name,"RTSP连接失败 socket不通",FALSE);
		return false;
	}
#endif


#if TEST_DEBUG
	m_pLibvlc_m =	libvlc_media_new_path(m_pLibvlc_Inst,utf8);
#else
	m_pLibvlc_m = libvlc_media_new_location(m_pLibvlc_Inst, utf8);
#endif

	//libvlc_media_new_path
	m_pLibvlc_Mp = libvlc_media_player_new_from_media(m_pLibvlc_m);

	libvlc_media_release(m_pLibvlc_m);

	//libvlc_media_player_set_hwnd(m_pLibvlc_Mp, hWnd);

	libvlc_video_set_callbacks(m_pLibvlc_Mp, Libvlc_Video_Lock_Callback, Libvlc_Video_UnLock_Callback,
		Libvlc_Video_Display_Callback, (void *)this);

	libvlc_video_set_format_callbacks(m_pLibvlc_Mp, Libvlc_Video_Format_Callback, Libvlc_Video_Cleanup_Callback);


	if(0==libvlc_media_player_play(m_pLibvlc_Mp)) 
	{	

		DlgMain->ShowCameraMessage(name,"连接成功",FALSE);
	}
	else
	{	

		DlgMain->ShowCameraMessage(name,"RTSP连接失败",FALSE);
		return false;
	}

	return true;
}
Esempio n. 28
0
CMusicPlayer::~CMusicPlayer()
{
	StopPlay();
}
Esempio n. 29
0
//---------------------------------------------------------------------------
void __fastcall TLinkDetailForm::FormDestroy(TObject *Sender)
{
	StopPlay();
	if(FManager) delete FManager, FManager = NULL;
}
Esempio n. 30
0
void QueueNextLineForTransmit(void)
// Purpose: Format data from virtual memory buffer into GlobalString
// Globals Used: bEndOfFile, bDataReady, lpHeap, dwByteCount, dwBytesRead,
//               GlobalString
// Custom Functions Called: PrintString()
{
  if (dwBytesRead == 0)
  {
    StopPlay();
    return;
  }

  // immediate stop-play for mIRC if detaching or user-stop
  if (pDTS_Color->bUseDDE && pDTS_Color->bStop)
  {
    StopPlay();

//    if (IsPirchVortec())
//      Senddde("/display \"Playback Stopped!\"");
//    else
//      Senddde("/echo -s \"Playback Stopped!\"");

    return;
  }

  DWORD dwStringCount;
  char* lpBuf;

  // Queue data for Eval
  if (!bEndOfFile && !bDataReady)
  {
    // Read through the file (now in virtual memory)
    lpBuf = (char*)lpHeap; // Point to start of heap

    dwStringCount = 0;

    for(; dwByteCount < dwBytesRead ; dwByteCount++)
    {
      if (lpBuf[dwByteCount] != '\r' && lpBuf[dwByteCount] != '\n' &&
                   dwStringCount < GLOBALSTRINGSIZ-1)
        GlobalString[dwStringCount++] = lpBuf[dwByteCount];
      else if (lpBuf[dwByteCount] == '\n')
      {
        // Add a terminating CTRL_K if space(s) at end of line to prevent
        // them from being trimmed off by some clients
        if (dwStringCount && GlobalString[dwStringCount-1] == ' ')
          GlobalString[dwStringCount++] = CTRL_K;
        GlobalString[dwStringCount] = NULLCHAR;
//        PrintString(pDTS_Color->PlayTime);
        PrintString(0); // play file with no delay!
        bDataReady = true;
        dwByteCount++;
        break;
      }
    }

    // Finished reading the file?
    if (dwByteCount >= dwBytesRead)
    {
      if (!bDataReady)
      {
        // Add a terminating CTRL_K if space(s) at end of line to prevent
        // them from being trimmed off by some clients
        if (dwStringCount && GlobalString[dwStringCount-1] == ' ')
          GlobalString[dwStringCount++] = CTRL_K;
        GlobalString[dwStringCount] = NULLCHAR;

        if (dwStringCount)
        {
//          PrintString(pDTS_Color->PlayTime);
          PrintString(0); // play file with no delay!
          bDataReady = true;
        }
      }

      bEndOfFile = true;
    }
  }

  // pump data directly via DDE if this is mIRC
  if (pDTS_Color->bUseDDE)
  {
    //Start a DDE transaction
    if (bDataReady)
    {
      Senddde(GlobalString);
      bDataReady = false;
    }

    if (bEndOfFile)
    {
      StopPlay();

//      if (IsPirchVortec())
//        Senddde("/display \"Playback Ended!\"");
//      else
//        Senddde("/echo -s \"Playback Ended!\"");
    }
  }
}