/* decode w/ buffering * this will fork another process * child process does decoding * parent process does playing audio */ void decode() { OutputBuffer * cb; PlayerControl * pc; DecoderControl * dc; // fprintf(stderr,"In decode.c decode func :\r\n"); cb = &(getPlayerData()->buffer); clearAllMetaChunkSets(cb); cb->begin = 0; cb->end = 0; pc = &(getPlayerData()->playerControl); dc = &(getPlayerData()->decoderControl); dc->error = 0; dc->seek = 0; dc->stop = 0; dc->start = 1; if(mpm_get_id(MPM_DECODE)<=0) { if(decoderInit(pc,cb,dc)<0) return; } decodeParent(pc, dc, cb); // fprintf(stderr,"Exiting In decode.c decode func :\r\n"); }
JNIEXPORT jint JNICALL Java_com_example_enzocamtest_CamView_startCamera(JNIEnv* env, jobject thiz, jstring deviceName, jint width, jint height) { int ret = 0; const char* dev_name = (*env)->GetStringUTFChars(env, deviceName, 0); /* Initialize all the structures we will be using */ mjpgDec = (struct decoderInstance *)calloc(1, sizeof(struct decoderInstance)); usbCam = (struct cameraInstance *)calloc(1, sizeof(struct cameraInstance)); camData = (struct mediaBuffer *)calloc(1, sizeof(struct mediaBuffer)); yuvData = (struct mediaBuffer *)calloc(1, sizeof(struct mediaBuffer)); y422_buf = (struct g2d_buf *)calloc(1, sizeof(struct g2d_buf)); /* Set properties for H264 AVC decoder */ mjpgDec->type = MJPEG; /* Set properties for USB camera */ usbCam->type = MJPEG; usbCam->width = width; usbCam->height = height; usbCam->fps = FPS; strcpy(usbCam->deviceName, dev_name); /* Init the VPU. This must be done before a codec can be used. If this fails, we need to bail. */ ret = vpuInit(); if (ret < 0) return -1; if (cameraInit(usbCam) < 0) ret = -1; /* In order to init mjpg decoder, it must be supplied with bitstream parse */ ret = cameraGetFrame(usbCam, camData); if (ret < 0) { err_msg("Could not get camera frame\n"); ret = -1; } if (decoderInit(mjpgDec, camData) < 0) { err_msg("Could not init MJPG decoder\n"); ret = -1; } y420_buf = g2d_alloc(width * height * 2, 0); rgb_buf = g2d_alloc(width * height * 2, 0); rgb_surf.planes[0] = rgb_buf->buf_paddr; rgb_surf.left = 0; rgb_surf.top = 0; rgb_surf.right = width; rgb_surf.bottom = height; rgb_surf.stride = width; rgb_surf.width = width; rgb_surf.height = height; rgb_surf.rot = G2D_ROTATION_0; rgb_surf.format = G2D_RGB565; y420_surf.planes[0] = y420_buf->buf_paddr; y420_surf.planes[1] = y420_surf.planes[0] + width*height; y420_surf.planes[2] = y420_surf.planes[1] + width*height/4; y420_surf.left = 0; y420_surf.top = 0; y420_surf.right = width; y420_surf.bottom = height; y420_surf.stride = width; y420_surf.width = width; y420_surf.height = height; y420_surf.rot = G2D_ROTATION_0; y420_surf.format = G2D_I420; info_msg("Finished setting up JNI codec and camera!\n"); return ret; }