Harness::Harness()
    : mInitCheck(NO_INIT) {
    mInitCheck = initOMX();
}
Example #2
0
OMXCAM_ERROR OMXCAM_startVideo (OMXCAM_VIDEO_SETTINGS* settings, uint32_t ms){
  OMXCAM_trace ("Starting video");
  
  if (!settings->bufferCallback){
    OMXCAM_error ("The 'bufferCallback' field must be defined");
    return OMXCAM_ErrorBadParameter;
  }
  if (running){
    OMXCAM_error ("Video capture is already running");
    return OMXCAM_ErrorVideo;
  }
  
  bgError = 0;
  OMXCAM_ERROR error;
  
  if ((error = OMXCAM_init ())) return error;
  
  if ((error = initOMX (settings))) return error;
  
  //Start the background thread
  OMXCAM_trace ("Creating background thread");
  
  if (pthread_mutex_init (&mutex, 0)){
    OMXCAM_error ("pthread_mutex_init");
    return OMXCAM_ErrorVideo;
  }
  
  running = 1;
  
  if (pthread_create (&bgThread, 0, captureVideo, &threadArg)){
    OMXCAM_error ("pthread_create");
    return OMXCAM_ErrorVideo;
  }
  
  //Block the main thread
  if (ms){
    if (sleepThread (ms)) return OMXCAM_ErrorSleep;
  }else{
    if (lockThread ()) return OMXCAM_ErrorLock;
  }
  
  if (bgError){
    //The video was already stopped due to an error
    OMXCAM_trace ("Video stopped due to an error");
    
    int err = bgError;
    bgError = 0;
    
    if (pthread_join (bgThread, 0)){
      OMXCAM_error ("pthread_join");
      return OMXCAM_ErrorVideo;
    }
    
    return err;
  }
  
  if (!running){
    //The video was already stopped by the client
    OMXCAM_trace ("Video stopped by the client");
    
    if (pthread_join (bgThread, 0)){
      OMXCAM_error ("pthread_join");
      return OMXCAM_ErrorVideo;
    }
    
    return OMXCAM_ErrorNone;
  }
  
  return OMXCAM_stopVideo ();
}