예제 #1
0
파일: Clipboard.c 프로젝트: embassy/AkelPad
//Plugin extern function
void __declspec(dllexport) Capture(PLUGINDATA *pd)
{
  pd->dwSupport|=PDS_SUPPORTALL;
  if (pd->dwSupport & PDS_GETSUPPORT)
    return;

  if (!bInitCommon)
    InitCommon(pd);
  else if (!bInitCapture)
    ReadOptions(OF_CAPTURE);

  if (bInitCapture)
  {
    DestroyDock(hWndCaptureDlg, DKT_KEEPAUTOLOAD);

    //Stay in memory and show as non-active
    pd->nUnload=UD_NONUNLOAD_NONACTIVE;
  }
  else
  {
    InitMain();
    InitCapture();

    pfCapture=pd->lpPluginFunction;
    bCaptureDockWaitResize=pd->bOnStart;
    CreateDock(&hWndCaptureDlg, &dkCaptureDlg, !bCaptureDockWaitResize);

    //Stay in memory, and show as active
    pd->nUnload=UD_NONUNLOAD_ACTIVE;
  }
}
예제 #2
0
BOOL CCapVideoApp::InitInstance(){
  InitCommonControls();
  CWinApp::InitInstance();
  SetRegistryKey(_T("6BEE NETWORKS PTE LTD"));
  CWinThread::InitInstance();
  CCapVideoDlg dlg;//main thread start dialog frame
  if(!InitCapture()){
    return FALSE;
  }
  dlg.m_caprawvideo = m_caprawvideo;
  if (m_caprawvideo){//derive a thread to capture video
    m_caprawvideo->PostThreadMessage(WM_STARTPREVIEW,(WPARAM)&(dlg.m_cappreview),(LPARAM)0);
  }
  INT_PTR nResponse = dlg.DoModal();
  if (nResponse == IDCANCEL && strlen(m_caprawvideo->getavfilename())!=0){
    /// @todo temp comment out this -  can use a function in 6beecommond.dll to replace it.
    ///////////////////////////// start to upload /////////////////////////////////
    /*
    USES_CONVERSION;
    CString videopath;
    videopath.Format(_T("%s%s"),_6beed_util::Get6BEEPath(_6bees_const::kVideoDir,true),A2CW(m_caprawvideo->getavfilename()));
    HWND hwndTo = ::FindWindow(0,_6bees_const::kUploader_WndTitle);
    if(!hwndTo){
      CString UploaderCmd = _6beed_util::Get6BEEPath(_6bees_const::kUploaderName);
      UploaderCmd += _T(" -m upload -f \"") + videopath + _T("\"");
      STARTUPINFO si = {sizeof(si)};
      PROCESS_INFORMATION pi;
      if (!CreateProcessW(NULL,const_cast<LPWSTR>(UploaderCmd.GetString()),NULL,NULL,false,0,NULL,NULL,&si,&pi)){
        ::AfxMessageBox(_T("ERROR: Cannot Start 6BeeUpLoader!"));
      }
    }else{
      _6beed_util::SendMsgToUploader(hwndTo,W2CA(videopath),CPYDATA_UPLOAD_2_UPLOAD_DIRECT);
    }
    */
    /////////////////////////////////////////////////////////////////////////////
  }
  return FALSE;
}
예제 #3
0
int main( int argc, char** argv )
{

#ifdef USE_CVCAM
	bool cvcam=true;
#else 
	bool cvcam=false;
#endif

	
	if (cmdLine.SplitLine(argc, argv) < 1)
	{
      // no switches were given on the command line, abort
      //ShowHelp();
      //exit(-1);
	}

	std::string infile="../../../stip_online/video/walk-complex.avi";
	std::string tmp;
	int cam=-1;
	try
	{
		if( cmdLine.HasSwitch("-h") || 
			cmdLine.HasSwitch("-help") ||
			cmdLine.HasSwitch("--help"))
		{
			ShowHelp();
			exit(0);
		}

		if( cmdLine.HasSwitch("-f") && cmdLine.HasSwitch("-cam") )
		{
			std::cout<<"You can't specify both file and camera as input!"<<std::endl;
			ShowHelp();
			exit(-1);
		}

	

		if( !(cmdLine.HasSwitch("-f") || cmdLine.HasSwitch("-cam") ))
		{
			std::cout<<"no input..."<<std::endl;
			ShowHelp();
			exit(-1);
		}

		//*** input/output options
		if(cmdLine.GetArgumentCount("-f")>0) 
			infile = cmdLine.GetArgument("-f", 0);
		if(cmdLine.GetArgumentCount("-o")>0) 
			outfile = cmdLine.GetArgument("-o", 0);
	
		if(cmdLine.HasSwitch("-cam"))
			if(cmdLine.GetArgumentCount("-cam")>0)
				cam =  atoi(cmdLine.GetArgument("-cam", 0).c_str());
			else
				cam = -1;

		if(cmdLine.GetArgumentCount("-res")>0) resid =  atoi(cmdLine.GetArgument( "-res", 0 ).c_str());
		if(resid<0 || resid>4) resid=1;

		if(cmdLine.GetArgumentCount("-vis")>0) show = cmdLine.GetArgument("-vis", 0)=="yes"?true:false;
		
		//*** descriptor options
		if(cmdLine.GetArgumentCount("-dscr")>0) mshb.descriptortype = cmdLine.GetArgument("-dscr", 0);
		if(cmdLine.GetArgumentCount("-szf")>0) mshb.patchsizefactor = atof(cmdLine.GetArgument("-szf", 0).c_str());

		//*** detection options
		if(cmdLine.GetArgumentCount("-nplev")>0) mshb.nxplev=atoi(cmdLine.GetArgument("-nplev", 0).c_str());
		if(cmdLine.GetArgumentCount("-plev0")>0) mshb.initpyrlevel=atoi(cmdLine.GetArgument("-plev0", 0).c_str());
		//if(cmdLine.GetArgumentCount("-sigma")>0) hb.sig2 =  atof(cmdLine.GetArgument( "-sigma", 0 ).c_str());
		//if(cmdLine.GetArgumentCount("-tau")>0) hb.tau2 =  atof(cmdLine.GetArgument( "-tau", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-kparam")>0) mshb.kparam =  atof(cmdLine.GetArgument( "-kparam", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-thresh")>0) mshb.SignificantPointThresh =  atof(cmdLine.GetArgument( "-thresh", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-border")>0) mshb.Border =  atoi(cmdLine.GetArgument( "-border", 0 ).c_str());

		//*** video capture options
		mshb.framemax = 100000000;
		if(cmdLine.GetArgumentCount("-framemax")>0) mshb.framemax =  atoi(cmdLine.GetArgument( "-framemax", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-ff")>0) frame_begin =  atoi(cmdLine.GetArgument( "-ff", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-lf")>0) frame_end =  atoi(cmdLine.GetArgument( "-lf", 0 ).c_str());
		
		
	}
	catch (...)
	{
		ShowHelp();
		exit(-1);
	}


	if(infile=="")  //prb:both can handle cam and file
	{
		if(!InitCVCAM(cam))
			return -2;
		// initialize source name string
        sourcename="CameraStream";
	} else {
		cvcam=false;
		if(!InitCapture(infile.c_str()))
			return -2;	
		// initialize source name string
        sourcename=infile;
		std::cout<<"Options summary: "<<std::endl;
		std::cout<<"  video input:     "<<sourcename<<std::endl;
		std::cout<<"  frame interval:  "<<frame_begin<<"-"<<frame_end<<std::endl;
		std::cout<<"  output file:     "<<outfile<<std::endl;
		std::cout<<"  #pyr.levels:     "<<mshb.nxplev<<std::endl;
		std::cout<<"  init.pyr.level:  "<<mshb.initpyrlevel<<std::endl;
		std::cout<<"  patch size fct.: "<<mshb.patchsizefactor<<std::endl;
		std::cout<<"  descriptor type: "<<mshb.descriptortype<<std::endl;
	}

		
        
	if(show)
	{
		//cvNamedWindow( win1,  CV_WINDOW_AUTOSIZE  );
		cvNamedWindow( win2, 0 );
	}


	//cvNamedWindow("Original");

	if(capture)
	{
    int fn=0;
    for(;;)
    {
        if (fn>=mshb.framemax) break;
        if (fn>=frame_end-frame_begin) break;

        fn++;
		frame = cvQueryFrame( capture );
			
        if( !frame )
            break;

		//CVUtil::DrawCircleFeature(frame,cvPoint(10,10),4.0);
		//CapProperties(capture);		
		//cvShowImage("Original",frame);

		dostuff(frame);
		if(show)
		{
			dovisstuff();
			//cvWaitKey();
			cvWaitKey(10);
			//if(cvWaitKey(10) >= 0 )
			//    break;
		}  
    }
	}
	std::cout<<"-> detected "<<TotalIPs<<" points"<<std::endl;

#ifdef USE_CVCAM
	if(cvcam)
	{
		cvWaitKey(0);
		cvcamExit();
	}
#endif
	
	if(capture)
		cvReleaseCapture( &capture );
	

	if(show)
	{
		cvDestroyWindow(win1);
	}

	if(gray) cvReleaseImage(&gray);
	if(vis)  cvReleaseImage(&vis);
	if(vis2)	cvReleaseImage(&vis2);
	if(vis3)	cvReleaseImage(&vis3);
	if(camimg) cvReleaseImage(&camimg);
    return 0;
}
예제 #4
0
int main()
{
	int ret = -1;
	unsigned long long lastTime = 0 ;
	FILE * pEncFile = NULL;
	char saveFile[128] = "h264.buf";
	int bFirstFrame = 1;

	ret = cedarx_hardware_init();
	if (ret < 0)
	{
		printf("cedarx_hardware_init failed\n");
	}

	ret = InitCapture();
	if(ret != 0)
	{
		printf("InitCapture failed\n");
		return -1;
	}

	ret = CedarvEncInit();
	if (ret != 0)
	{
		printf("CedarvEncInit failed\n");
		return -1;
	}

	pEncFile = fopen(saveFile, "wb+");
	if (pEncFile == NULL)
	{
		printf("open %s failed\n", saveFile);
		return -1;
	}

	printf("to stream on\n");
	StartStreaming();

	lastTime = gettimeofday_curr();
	while(1)
	{
		__vbv_data_ctrl_info_t data_info;
		unsigned long long curTime = gettimeofday_curr();

		printf("cru: %lld, last: %lld, %lld\n", curTime, lastTime, curTime - lastTime);
		if ((curTime - lastTime) > 1000*1000*5)	// 30s
		{
			ReleaseFrame(g_cur_id);
			goto EXIT;
		}

		ret = g_pCedarV->encode(g_pCedarV);
		if (ret != 0)
		{
			usleep(10000);
			printf("not encode, ret: %d\n", ret);
		}

		ReleaseFrame(g_cur_id);

		memset(&data_info, 0 , sizeof(__vbv_data_ctrl_info_t));
		ret = g_pCedarV->GetBitStreamInfo(g_pCedarV, &data_info);
		if(ret == 0)
		{
			if (1 == bFirstFrame)
			{
				bFirstFrame = 0;
				fwrite(data_info.privateData, data_info.privateDataLen, 1, pEncFile);
			}

			if (data_info.uSize0 != 0)
			{
				fwrite(data_info.pData0, data_info.uSize0, 1, pEncFile);
			}

			if (data_info.uSize1 != 0)
			{
				fwrite(data_info.pData1, data_info.uSize1, 1, pEncFile);
			}
			printf("v GetBS OK\n");
		}

		g_pCedarV->ReleaseBitStreamInfo(g_pCedarV, data_info.idx);
	}

EXIT:
	DeInitCapture();

	if (pEncFile != NULL)
	{
		fclose(pEncFile);
		pEncFile = 0;
	}

	if (g_pCedarV != NULL)
	{
		g_pCedarV->close(g_pCedarV);
		H264EncExit(g_pCedarV);
		g_pCedarV = NULL;
	}

	cedarx_hardware_exit();

	return 0;
}
예제 #5
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;
}
예제 #6
0
파일: Clipboard.c 프로젝트: embassy/AkelPad
BOOL CALLBACK SetupDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static HICON hPluginIcon;
  static HWND hWndCaptureTitle;
  static HWND hWndSeparator;
  static HWND hWndPasteSerialTitle;
  static HWND hWndHotkeyDelimSkip;
  static HWND hWndHotkeyDelimAsTab;
  static HWND hWndHotkeyDelimAsIs;

  if (uMsg == WM_INITDIALOG)
  {
    //Load plugin icon
    hPluginIcon=LoadIconA(hInstanceDLL, MAKEINTRESOURCEA(IDI_ICON_PLUGIN));
    SendMessage(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hPluginIcon);

    hWndCaptureTitle=GetDlgItem(hDlg, IDC_SETUP_CAPTURE_TITLE);
    hWndSeparator=GetDlgItem(hDlg, IDC_SETUP_CAPTURE_SEPARATOR);
    hWndPasteSerialTitle=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_TITLE);
    hWndHotkeyDelimSkip=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMSKIP);
    hWndHotkeyDelimAsTab=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMASTAB);
    hWndHotkeyDelimAsIs=GetDlgItem(hDlg, IDC_SETUP_PASTESERIAL_DELIMASIS);

    SetWindowTextWide(hDlg, wszPluginTitle);
    SetDlgItemTextWide(hDlg, IDC_SETUP_CAPTURE_SEPARATOR_LABEL, GetLangStringW(wLangModule, STRID_SEPARATOR));
    SetDlgItemTextWide(hDlg, IDC_SETUP_CAPTURE_SEPARATOR_LEGEND, GetLangStringW(wLangModule, STRID_LEGEND));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_GROUP, GetLangStringW(wLangModule, STRID_GLOBALHOTKEYS));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMSKIP_LABEL, GetLangStringW(wLangModule, STRID_DELIMSKIP));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMASTAB_LABEL, GetLangStringW(wLangModule, STRID_DELIMASTAB));
    SetDlgItemTextWide(hDlg, IDC_SETUP_PASTESERIAL_DELIMASIS_LABEL, GetLangStringW(wLangModule, STRID_DELIMASIS));
    SetDlgItemTextWide(hDlg, IDOK, GetLangStringW(wLangModule, STRID_OK));
    SetDlgItemTextWide(hDlg, IDCANCEL, GetLangStringW(wLangModule, STRID_CANCEL));

    if (!bInitCapture) EnableWindow(hWndCaptureTitle, FALSE);
    if (!bInitPasteSerial) EnableWindow(hWndPasteSerialTitle, FALSE);
    SendMessage(hWndSeparator, EM_LIMITTEXT, MAX_PATH, 0);
    EscapeDataToEscapeString(wszCaptureSeparator, wszBuffer);
    SetWindowTextWide(hWndSeparator, wszBuffer);

    SendMessage(hWndHotkeyDelimSkip, HKM_SETHOTKEY, dwHotkeyDelimSkip, 0);
    SendMessage(hWndHotkeyDelimAsTab, HKM_SETHOTKEY, dwHotkeyDelimAsTab, 0);
    SendMessage(hWndHotkeyDelimAsIs, HKM_SETHOTKEY, dwHotkeyDelimAsIs, 0);
  }
  else if (uMsg == WM_COMMAND)
  {
    if (LOWORD(wParam) == IDOK)
    {
      GetWindowTextWide(hWndSeparator, wszBuffer, MAX_PATH);
      EscapeStringToEscapeData(wszBuffer, wszCaptureSeparator);

      dwHotkeyDelimSkip=(DWORD)SendMessage(hWndHotkeyDelimSkip, HKM_GETHOTKEY, 0, 0);
      dwHotkeyDelimAsTab=(DWORD)SendMessage(hWndHotkeyDelimAsTab, HKM_GETHOTKEY, 0, 0);
      dwHotkeyDelimAsIs=(DWORD)SendMessage(hWndHotkeyDelimAsIs, HKM_GETHOTKEY, 0, 0);

      if (nInitMain)
      {
        if (bInitCapture)
        {
          UninitCapture();
          InitCapture();
        }
        if (bInitPasteSerial)
        {
          UninitPasteSerial();
          InitPasteSerial();
        }
        if (bInitSelAutoCopy)
        {
          UninitSelAutoCopy();
          InitSelAutoCopy();
        }
      }
      dwSaveFlags|=OF_CAPTURE_SETTINGS|OF_PASTESERIAL_SETTINGS;

      if (dwSaveFlags)
      {
        SaveOptions(dwSaveFlags);
        dwSaveFlags=0;
      }

      EndDialog(hDlg, 0);
      return TRUE;
    }
    else if (LOWORD(wParam) == IDCANCEL)
    {
      EndDialog(hDlg, 0);
      return TRUE;
    }
  }
  else if (uMsg == WM_CLOSE)
  {
    PostMessage(hDlg, WM_COMMAND, IDCANCEL, 0);
    return TRUE;
  }
  else if (uMsg == WM_DESTROY)
  {
    //Destroy plugin icon
    DestroyIcon(hPluginIcon);
  }
  return FALSE;
}
예제 #7
0
// 工作线程
void GrabThread::run()
{
	int ret = -1;
#ifdef ZQSENDER
	ZqSenderTcpCtx *sender = 0;

	ret = zqsnd_open_tcp_server(&sender, 4000, 0);
	if (ret < 0) {
		fprintf(stderr, "can't open zqsender for port %d\n", 4000);
		::exit(-1);
	}
	fprintf(stderr, "start tcp srv port 4000\n");
#endif // zqsender
	
	ret = cedarx_hardware_init();
	if (ret < 0) {
		printf("cedarx_hardware_init failed\n");
		::exit(-1);
	}
	
	ret = InitCapture(_cap);
	if(ret != 0) {
		printf("InitCapture failed\n");
		::exit(-1);
	}

	ret = CedarvEncInit(_cap->width_, _cap->height_, _cap->fps_, _cap->kbits_);
	if (ret != 0) {
		printf("CedarvEncInit failed\n");
		::exit(-1);
	}

	printf("to stream on\n");
	StartStreaming(_cap);

	while (!quit_) {
		__vbv_data_ctrl_info_t data_info;

		// FIXME: encode 需要消耗一定时间,这里不准确
		usleep(1000 * 1000 / _cap->fps_);	// 25fps
	
		ret = g_pCedarV->encode(g_pCedarV);
		if (ret != 0) {
			usleep(10000);
			printf("not encode, ret: %d\n", ret);
			::exit(-1);
		}

		ReleaseFrame(_cap, g_cur_id);

		memset(&data_info, 0 , sizeof(__vbv_data_ctrl_info_t));
		ret = g_pCedarV->GetBitStreamInfo(g_pCedarV, &data_info);
		if(ret == 0) {
			// 有数据
#ifdef ZQSENDER
			send_data(sender, &data_info);
#endif // zqsender

			if (data_info.privateDataLen > 0) {
				if (_cap->priv)
					slice_free(_cap->priv);
				_cap->priv = slice_alloc(data_info.privateData, data_info.privateDataLen, 0);
				fprintf(stderr, "save priv: len=%d\n", data_info.privateDataLen);

				//ost::MutexLock al(_cap->cs_fifo_);
				//_cap->fifo_.push_back(slice_alloc(data_info.privateData, data_info.privateDataLen, 0));
			}

			if (data_info.uSize0 > 0) {
				ost::MutexLock al(_cap->cs_fifo_);

				unsigned char *p = data_info.pData0;

				if (_cap->fifo_.size() > 100 && p[4] == 0x65) {
					fprintf(stderr, "fifo overflow ...\n");
					// 当积累的太多,并且收到关键帧清空
					while (!_cap->fifo_.empty()) {
						slice_t *s = _cap->fifo_.front();
						_cap->fifo_.pop_front();
						slice_free(s);
						fprintf(stderr, "E");
					}
				}

				// 为每个关键帧之前保存 sps. pps
				if (p[4] == 0x65) {
					fprintf(stderr, "patch pps/sps\n");
					_cap->fifo_.push_back(slice_alloc(_cap->priv->data_, _cap->priv->len_,
								data_info.pData0, data_info.uSize0, data_info.pts));
				}
				else {
					_cap->fifo_.push_back(slice_alloc(data_info.pData0, data_info.uSize0, data_info.pts));
				}

				_cap->sem_fifo_.post();
			}

			if (data_info.uSize1 > 0) {
				ost::MutexLock al(_cap->cs_fifo_);

				unsigned char *p = data_info.pData1;

				if (_cap->fifo_.size() > 100 && p[4] == 0x65) {
					fprintf(stderr, "fifo overflow ...\n");
					// 当积累的太多,并且收到关键帧清空
					while (!_cap->fifo_.empty()) {
						slice_t *s = _cap->fifo_.front();
						_cap->fifo_.pop_front();
						slice_free(s);
						fprintf(stderr, "E");
					}
				}

				// 为每个关键帧之前保存 sps. pps
				if (p[4] == 0x65) {
					fprintf(stderr, "patch pps/sps\n");
					_cap->fifo_.push_back(slice_alloc(_cap->priv->data_, _cap->priv->len_,
								data_info.pData1, data_info.uSize1, data_info.pts));
				}
				else {
					_cap->fifo_.push_back(slice_alloc(data_info.pData1, data_info.uSize1, data_info.pts));
				}

				_cap->sem_fifo_.post();
			}
		}

		g_pCedarV->ReleaseBitStreamInfo(g_pCedarV, data_info.idx);
	}
	
	DeInitCapture(_cap);

	if (g_pCedarV != NULL) {
		g_pCedarV->close(g_pCedarV);
		H264EncExit(g_pCedarV);
		g_pCedarV = NULL;
	}

	cedarx_hardware_exit();
}
예제 #8
0
////////////////////////////////////////////////////////////
/// Point d'entr�e du programme
///
/// \return Code d'erreur de l'application
///
////////////////////////////////////////////////////////////
int main_capture()
{
    int time_left = 0;

    // Initialisation d'OpenAL avec le device par d�faut
    if (!InitOpenAL_capture(NULL))
        return EXIT_FAILURE;

    // Initialisation de la capture
    if (!InitCapture(NULL))
        return EXIT_FAILURE;

    // Lancement de la capture
    alcCaptureStart(CaptureDevice);

    // On va stocker les �chantillons captur�s dans un tableau d'entiers sign�s 16 bits
    std::vector<ALshort> Samples;

    // ...Et c'est parti pour 5 secondes de capture
    time_t Start = time(NULL);

    while ((time_left = time(NULL) - Start) <= 5) // si x passe � 1, on stop la capture
    {
	std::cout << "\rSpeech capture in progress... " << std::fixed << std::setprecision(2) << 5-time_left << " sec left";
        // On r�cup�re le nombre d'�chantillons disponibles
        ALCint SamplesAvailable;
        alcGetIntegerv(CaptureDevice, ALC_CAPTURE_SAMPLES, 1, &SamplesAvailable);

        // On lit les �chantillons et on les ajoute au tableau
        if (SamplesAvailable > 0)
        {
            std::size_t Start = Samples.size();
            Samples.resize(Start + SamplesAvailable);
            alcCaptureSamples(CaptureDevice, &Samples[Start], SamplesAvailable);
        }
    }

    // On stoppe la capture
    alcCaptureStop(CaptureDevice);

    // On n'oublie pas les �ventuels �chantillons qu'il reste � r�cup�rer
    ALCint SamplesAvailable;
    alcGetIntegerv(CaptureDevice, ALC_CAPTURE_SAMPLES, 1, &SamplesAvailable);
    if (SamplesAvailable > 0)
    {
        std::size_t Start = Samples.size();
        Samples.resize(Start + SamplesAvailable);
        alcCaptureSamples(CaptureDevice, &Samples[Start], SamplesAvailable);
    }

	std::cout << "\rSpeech capture complete                   " << std::endl;

    // On sauvegarde les �chantillons captur�s dans un fichier
    SaveSound("vocal.wav", Samples);

    // Fermeture de la capture
    ShutdownCapture();

    // Fermeture d'OpenAL
    ShutdownOpenAL_capture();

    return EXIT_SUCCESS;
}