Exemple #1
0
jint
Java_ch_nuicell_ecam_CameraPreview_prepareCamera( JNIEnv* env,jobject thiz, jint videoid) {

    int ret;

    if(camerabase<0) {
        camerabase = checkCamerabase();
    }

    ret = opendevice(camerabase + videoid);

    if(ret != ERROR_LOCAL) {
        ret = initdevice();
    }
    if(ret != ERROR_LOCAL) {
        ret = startcapturing();

        if(ret != SUCCESS_LOCAL) {
            stopcapturing();
            uninitdevice ();
            closedevice ();
            LOGE("device resetted");
        }

    }

    if(ret != ERROR_LOCAL) {
        rgb = (int *)malloc(sizeof(int) * (IMG_WIDTH*IMG_HEIGHT));
        ybuf = (int *)malloc(sizeof(int) * (IMG_WIDTH*IMG_HEIGHT));
    }
    return ret;
}
Exemple #2
0
jint 
Java_dk_itu_eyedroid_io_protocols_InputStreamUSBCamera_prepareCamera( JNIEnv* env,jobject thiz, jint videoid){

	int ret;

	if(camerabase<0){
		camerabase = checkCamerabase();
	}

	ret = opendevice(camerabase + videoid);

	if(ret != ERROR_LOCAL){
		ret = initdevice();
	}
	if(ret != ERROR_LOCAL){
		ret = startcapturing();

		if(ret != SUCCESS_LOCAL){
			stopcapturing();
			uninitdevice ();
			closedevice ();
			LOGE("device resetted");	
		}

	}

	if(ret != ERROR_LOCAL){
		rgb = (int *)malloc(sizeof(int) * (IMG_WIDTH*IMG_HEIGHT));
		ybuf = (int *)malloc(sizeof(int) * (IMG_WIDTH*IMG_HEIGHT));
	}
	return ret;
}	
Exemple #3
0
jint Java_com_camera_simpledoublewebcams2_CameraPreview_prepareCamera(JNIEnv* env,jobject thiz, jint videoid){

	int ret[CAMERANUM];
	int i;
		
	if(camerabase<0){
		camerabase = checkCamerabase();
	}
		
	for(i=0 ; i<CAMERANUM ; i++){
		ret[i] = opendevice(i, camerabase+videoid+i);

		if(ret[i]  != ERROR_LOCAL){
			ret[i]  = initdevice(i);
		}
		if(ret[i]  != ERROR_LOCAL){
			ret[i] = startcapturing(i);
		}

		if(ret[i]  != ERROR_LOCAL){
			rgb[i] = (int *)malloc(sizeof(int) * (IMG_WIDTH*IMG_HEIGHT));
		}
	}
		
	if(ret[0]==ERROR_LOCAL || ret[1]==ERROR_LOCAL ){
		return ret[1]*2+ret[0];
	}else{
		return SUCCESS_LOCAL ;
	}
}	
void MainWindow::createActions()
{
    pt_openDeviceAct = new QAction(tr("Device"),this);
    pt_openDeviceAct->setStatusTip(tr("Try to open available video capture device"));
    connect(pt_openDeviceAct, SIGNAL(triggered()), this, SLOT(opendevice()));

    pt_openVideoAct = new QAction(tr("File"),this);
    pt_openVideoAct->setStatusTip(tr("Try to open available video file"));
    connect(pt_openVideoAct, SIGNAL(triggered()), this, SLOT(openvideofile()));

    pt_pauseAct = new QAction(tr("&Pause"), this);
    pt_pauseAct->setStatusTip(tr("Stop a processing session"));
    connect(pt_pauseAct, SIGNAL(triggered()), pt_videoCapture, SLOT(pause()));

    pt_resumeAct = new QAction(tr("&Resume"), this);
    pt_resumeAct->setStatusTip(tr("Resume a processing session"));
    connect(pt_resumeAct, SIGNAL(triggered()), pt_videoCapture, SLOT(resume()));

    pt_exitAct = new QAction(tr("E&xit"), this);
    pt_exitAct->setStatusTip(tr("Application exit"));
    connect(pt_exitAct, SIGNAL(triggered()), this, SLOT(close()));

    pt_aboutAct = new QAction(tr("&About"), this);
    pt_aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(pt_aboutAct, SIGNAL(triggered()), this, SLOT(show_about()));

    pt_helpAct = new QAction(tr("&Help"), this);
    pt_helpAct->setStatusTip(tr("Show the application's Help"));
    connect(pt_helpAct, SIGNAL(triggered()), this, SLOT(show_help()));

    pt_deviceResAct = new QAction(tr("&CamResolution"), this);
    pt_deviceResAct->setStatusTip(tr("Open a video device resolution dialog"));
    connect(pt_deviceResAct, SIGNAL(triggered()), this, SLOT(opendeviceresolutiondialog()));

    pt_deviceSetAct = new QAction(tr("&CamSettings"), this);
    pt_deviceSetAct->setStatusTip(tr("Open a video device settings dialog"));
    connect(pt_deviceSetAct, SIGNAL(triggered()), this, SLOT(opendevicesettingsdialog()));

    pt_DirectShowAct = new QAction(tr("&DS_dialog"), this);
    pt_DirectShowAct->setStatusTip(tr("Try to open a device-driver embedded settings dialog"));
    connect(pt_DirectShowAct, SIGNAL(triggered()), this, SLOT(callDirectShowSdialog()));
}
Exemple #5
0
cVFDStatus::cVFDStatus() {
	opendevice();
}
DWORD WINAPI DumpThreadProc( LPVOID lpParameter)
{
	unsigned int i,j,k,m,n,ret;
	int l;
	FD_SCAN_PARAMS sp;
	FD_SCAN_RESULT *sr;
	FD_READ_WRITE_PARAMS rwp;
	FD_CMD_RESULT cmdr;
	SECTORCONFIG* sectorconfig;
	floppydumperparams * params;
	unsigned char * tempstr;
	unsigned char * trackbuffer;
	unsigned char b;
	int tracksize,retry,gap3len,trackformat;
	unsigned long rotationtime,rpm,bitrate,tracklen;
	unsigned long total_size,numberofsector_read,number_of_bad_sector;
	
	CYLINDER* currentcylinder;
	SIDE* currentside;
	
	
	params=(floppydumperparams*)lpParameter;
	
	params->flopemu->hxc_printf(MSG_DEBUG,"Starting Floppy dump...");
	
	tempstr=(char*)malloc(1024);
	
	trackbuffer=0;
	tracksize=0;
	
	if(checkversion())
	{
		if(opendevice(params->drive))
		{

			total_size=0;
			numberofsector_read=0;
			number_of_bad_sector=0;

			sr=malloc(sizeof(FD_ID_HEADER)*256 + 1);
			
			params->floppydisk->floppyBitRate=VARIABLEBITRATE;
			
			params->floppydisk->floppyNumberOfSide=params->number_of_side;
			params->floppydisk->floppyNumberOfTrack=params->number_of_track;
			params->floppydisk->floppySectorPerTrack=-1;

			seek(0, 0);

			sprintf(tempstr,"Checking drive RPM...");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
					
			rotationtime=200000;
			if (!DeviceIoControl(h, IOCTL_FD_GET_TRACK_TIME, 0, 0, &rotationtime, sizeof(rotationtime), &ret, NULL))
			{
				sprintf(tempstr,"Error during RPM checking :%d ",GetLastError());
				SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
				params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump: IOCTL_FD_GET_TRACK_TIME error %d...",GetLastError());
				closedevice();
				free(tempstr);

				params->status=0;
				return 0;
			}
			
			params->floppydisk->tracks=(CYLINDER**)malloc(sizeof(CYLINDER*)*params->floppydisk->floppyNumberOfTrack);
			
			rpm=60000/(rotationtime/1000);
			
			params->flopemu->hxc_printf(MSG_DEBUG,"Drive RPM: %d",rpm);
			sprintf(tempstr,"Drive RPM: %d",rpm);
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			
			if(rpm>280 && rpm<320) rpm=300;
			if(rpm>340 && rpm<380) rpm=360;
			
			bitrate=500000;
			
			sprintf(tempstr,"Starting reading disk...");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			
			for(i=0;i<params->floppydisk->floppyNumberOfTrack;i++)
			{
				params->floppydisk->tracks[i]=(CYLINDER*)malloc(sizeof(CYLINDER));
				currentcylinder=params->floppydisk->tracks[i];
				currentcylinder->number_of_side=params->floppydisk->floppyNumberOfSide;
				currentcylinder->sides=(SIDE**)malloc(sizeof(SIDE*)*currentcylinder->number_of_side);
				memset(currentcylinder->sides,0,sizeof(SIDE*)*currentcylinder->number_of_side);
				
				for(j=0;j<params->floppydisk->floppyNumberOfSide;j++)
				{
					
					currentcylinder->floppyRPM=rpm;
					currentcylinder->sides[j]=malloc(sizeof(SIDE));
					memset(currentcylinder->sides[j],0,sizeof(SIDE));
					currentside=currentcylinder->sides[j];
					
					seek(i*params->double_step, j);
					
					l=0;
					do
					{
						m=0;
						while(tm[m].index!=l)
						{
							m++;
						}
						
						memset(sr,0,sizeof(FD_ID_HEADER)*256 + 1);
						
						if(tm[m].encoding_mode)
						{
							sp.flags=FD_OPTION_MFM;
							trackformat=ISOFORMAT_DD;
						}
						else
						{
							sp.flags=0x00;
							trackformat=ISOFORMAT_SD;
						}
						
						sp.head=j;
						
						bitrate=tm[m].bitrate;
						b = tm[m].bitrate_code;
						if (!DeviceIoControl(h, IOCTL_FD_SET_DATA_RATE, &b, sizeof b, NULL, 0, &ret, NULL)) 
						{
							printf("IOCTL_FD_SET_DATA_RATE=%d failed err=%d\n", b, GetLastError());
							closedevice();
							params->status=0;
							return 0;
						}
						
						if (!DeviceIoControl(h, IOCTL_FD_SCAN_TRACK, &sp, sizeof sp, sr, sizeof(FD_ID_HEADER)*256 + 1, &ret, NULL))
						{
							params->flopemu->hxc_printf(MSG_DEBUG,"IOCTL_FD_SCAN_TRACK error %d ...",GetLastError());
						}
						
						if(sr->count)
						{
							n=0;
							while(tm[n].index)
							{
								n++;
							}
							
							k=tm[n].index;
							tm[n].index=tm[m].index;		
							tm[m].index=k;
						}
						else
						{
							DeviceIoControl(h, IOCTL_FD_RESET, NULL, 0, NULL, 0, &ret, NULL);
						}
						
						l++;
					}while(l<8 && !sr->count);
					
					sectorconfig=(SECTORCONFIG*)malloc(sizeof(SECTORCONFIG)*sr->count);
					memset(sectorconfig,0,sizeof(SECTORCONFIG)*sr->count);
					
					params->flopemu->hxc_printf(MSG_DEBUG,"Track %d side %d: %d sectors found : ",i,j,sr->count);
					
					seek(i*params->double_step, j);
					
					if( sr->Header[0].cyl==sr->Header[sr->count-1].cyl && 
						sr->Header[0].head==sr->Header[sr->count-1].head && 
						sr->Header[0].sector==sr->Header[sr->count-1].sector && 
						sr->Header[0].size==sr->Header[sr->count-1].size 
						)
					{
						sr->count--;
					}

					for(k=0;k<sr->count;k++)
					{
						params->flopemu->hxc_printf(MSG_DEBUG,"Sector %.2d, Track ID: %.3d, Head ID:%d, Size: %d bytes, Bitrate:%dkbits/s, %s",sr->Header[k].sector,sr->Header[k].cyl,sr->Header[k].head,128<<sr->Header[k].size,bitrate/1000,trackformat==ISOFORMAT_SD?"FM":"MFM");
						
						
						if(tm[m].encoding_mode)
						{
							rwp.flags=FD_OPTION_MFM;
						}
						else
						{
							rwp.flags=0x00;
						}
						rwp.cyl=sr->Header[k].cyl;
						rwp.phead=j;
						rwp.head=sr->Header[k].head;
						rwp.sector=sr->Header[k].sector;
						rwp.size=sr->Header[k].size;
						rwp.eot=sr->Header[k].sector+1;
						rwp.gap=10;
						if((128<<sr->Header[k].size)>128)
						{
							rwp.datalen=255;
						}
						else
						{
							rwp.datalen=128;
						}
						
						retry=5;
						trackbuffer=realloc(trackbuffer,tracksize+(128<<sr->Header[k].size));
						do
						{
							retry--;
						}while(!DeviceIoControl(h, IOCTL_FDCMD_READ_DATA, &rwp, sizeof rwp, &trackbuffer[tracksize], 128<<sr->Header[k].size, &ret, NULL) && retry);
						if(!retry)
						{	
							DeviceIoControl(h, IOCTL_FD_GET_RESULT,0, 0, &cmdr, sizeof(FD_CMD_RESULT), &ret, NULL);
							params->flopemu->hxc_printf(MSG_DEBUG,"Read Error ! ST0: %.2x, ST1: %.2x, ST2: %.2x",cmdr.st0,cmdr.st1,cmdr.st2);
							number_of_bad_sector++;
						}
					
						
						total_size=total_size+(128<<sr->Header[k].size);
						numberofsector_read++;

						sectorconfig[k].cylinder=sr->Header[k].cyl;
						sectorconfig[k].head=sr->Header[k].head;
						sectorconfig[k].sector=sr->Header[k].sector;
						sectorconfig[k].sectorsize=(128<<sr->Header[k].size);
						
						
						tracksize=tracksize+(128<<sr->Header[k].size);

						sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",numberofsector_read,total_size,number_of_bad_sector);
						SetDlgItemText(params->windowshwd,IDC_EDIT2,tempstr);

					}
					
					currentside->number_of_sector=sr->count;
					currentside->bitrate=bitrate;
					
					tracklen=(bitrate/(rpm/60))/4;

					currentside->tracklen=tracklen;
					
					currentside->databuffer=malloc(currentside->tracklen);
					memset(currentside->databuffer,0,currentside->tracklen);
					
					currentside->flakybitsbuffer=0;
					
					currentside->timingbuffer=0;
					currentside->indexbuffer=malloc(currentside->tracklen);
					memset(currentside->indexbuffer,0,currentside->tracklen);						
					fillindex(currentside->tracklen-1,currentside,2500,TRUE,1);
					
					gap3len=20;
					
					BuildISOTrack(params->flopemu,trackformat,currentside->number_of_sector,1,512,j,i,gap3len,trackbuffer,currentside->databuffer,&currentside->tracklen,0,0,sectorconfig);
					
					sprintf(tempstr,"Track %d side %d: %d sectors, %dkbits/s, %s",i,j,sr->count,bitrate/1000,trackformat==ISOFORMAT_SD?"FM":"MFM");
					SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
					
					free(sectorconfig);
					free(trackbuffer);
					trackbuffer=0;
					tracksize=0;
				}
			}
			
			closedevice();

			sprintf(tempstr,"Done !");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",numberofsector_read,total_size,number_of_bad_sector);
			SetDlgItemText(params->windowshwd,IDC_EDIT2,tempstr);
					
			params->flopemu->hxc_printf(MSG_DEBUG,"Done ! %d sectors read, %d bad sector(s), %d bytes read",numberofsector_read,number_of_bad_sector,total_size);
		
			loadfloppy("Floppy Dump",params->floppydisk,0);


			free(tempstr);
			

			
			params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump...");
			
			params->status=0;
			return 0;

		}
	
	}

	sprintf(tempstr,"Error while opening fdrawcmd, see: http://simonowen.com/fdrawcmd");
	SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
	
	free(tempstr);

	params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump...");
	
	params->status=0;
	return 0;
	
}