XILOutputAssistor::XILOutputAssistor(int type,const char*fn,struct deviceattributes *devattr) : Renderer(type) { char *cisname; XilDevice device; filename_ = strdup(fn); memcpy(&deviceattributes_,devattr,sizeof(deviceattributes_)); cisname=NULL; switch (type) { case FT_JPEG|FT_HW: cisname = "Jpeg"; memcpy(jfif_header1,jfif_header1_,sizeof(jfif_header1_)); memcpy(jfif_header2,jfif_header2_,sizeof(jfif_header2_)); break; case FT_H261: cisname = "H261"; break; case FT_CELLB: cisname = "CellB"; break; default: fprintf(stderr," unknown cis %d???\n",type&~FT_HW); break; } type_ = type; imageYCC = NULL; xil_ = xil_open(); if (xil_ == 0) { fprintf(stderr,"couldn't open xil.\n"); return;//FIXME } device = xil_device_create(xil_,deviceattributes_.name); if (device == 0) { fprintf(stderr,"couldn't open %s\n",deviceattributes_.name); return; } xil_device_set_value(device,"DEVICE_NAME",(void*)filename_); //fprintf(stderr,"VIDEO_OUT\n"); xil_device_set_value(device,"VIDEO_OUT",(void*)TRUE); o1kimage = xil_create_from_device(xil_,deviceattributes_.name,device); int arg; xil_get_device_attribute(o1kimage,"VIDEO_OUT",(void**)&arg); //fprintf(stderr,"VIDEO_OUT-> %d\n",arg); cis_ = xil_cis_create(xil_ , cisname); if (cis_ == 0) { fprintf(stderr,"couldn't create CIS for %s\n",cisname); return; } xil_cis_set_keep_frames(cis_, 3); xil_cis_set_max_frames(cis_, 3); //fprintf(stderr,"HW_DECOMPRESS_CIS\n"); // use _THIS_ cis_ for HW decompression xil_set_attribute(o1kimage,"HW_DECOMPRESS_CIS",cis_); }
/* * Class: com_sun_media_protocol_sunvideo_XILCapture * Method: xilConnect * Signature: (II)Z */ JNIEXPORT jboolean JNICALL Java_com_sun_media_protocol_sunvideo_XILCapture_xilConnect(JNIEnv *env, jobject jxil, jint devnum, jint port) { XilDevice device; char *devname = NULL; char devnamestr[256]; /* Allocate a new structure */ InstanceState * inst = (InstanceState *) malloc(sizeof(InstanceState)); /* Store the pointer to the instance state in the java variable "peer" */ SetLongField(env, jxil, "peer", (int) inst); /* Debug message */ PRINT("In xilConnect\n"); /* Copy the parameters */ inst->port = (int) port; inst->xil_state = NULL; inst->rtvc_image = NULL; inst->scaled_image = NULL; inst->colored_image = NULL; inst->xil_cis = NULL; inst->scale = 1; inst->quality = 0; inst->do_cis = RAW; inst->cis_type = "Raw"; inst->skip = 0; inst->inWidth = 0; inst->inHeight = 0; inst->outWidth = 0; inst->outHeight = 0; inst->inStrideX = 0; inst->started = 0; inst->firstRawRead = 1; /* inst->xil_state = xil_open(); */ createXilState(); inst->xil_state = *jmf_xil_state; if (inst->xil_state == NULL) { fprintf(stderr, "SunVideo Capture unable to open xil library\n"); freeXilState(env, jxil, inst); return 0; } /* Debug Message */ PRINT("XILCapture open_xil() succeeded \n"); if (devnum > 0) { sprintf(devnamestr, "/dev/rtvc%d", devnum); devname = devnamestr; /* Debug Message */ PRINT("Attempting to open xil device "); PRINT(devname); PRINT("\n"); } if (! (device = xil_device_create(inst->xil_state, "SUNWrtvc"))) { /* Debug Message */ PRINT("Unable to create a xil device object\n"); freeXilState(env, jxil, inst); return 0; } /* Debug Message */ PRINT("XILCapture xil_device_create() succeeded \n"); xil_device_set_value(device, "DEVICE_NAME", devname); /* Debug Message */ PRINT("XILCapture xil_device_set_value() succeeded \n"); inst->rtvc_image = xil_create_from_device(inst->xil_state, "SUNWrtvc", device); /* Debug Message */ PRINT("XILCapture xil_create_from_device() completed \n"); xil_device_destroy(device); /* Debug Message */ PRINT("XILCapture xil_device_destroy() completed \n"); if (inst->rtvc_image == NULL) { /* Debug Message */ PRINT("Unable to open xil device\n"); freeXilState(env, jxil, inst); return 0; } tryPort(env, jxil, inst); return 1; }