Ejemplo n.º 1
0
int main(int /*argc*/, char* /*argv*/ [])
{
  rtLogSetLevel(RT_LOG_INFO);

  rtError e;
  rtRemoteEnvironment* env = rtEnvironmentGetGlobal();
  e = rtRemoteInit(env);
  if (e != RT_OK)
  {
    rtLogError("rtRemoteInit:%s", rtStrError(e));
    exit(1);
  }

  rtObjectRef obj(new ContinuousVideoRecorder());
  e = rtRemoteRegisterObject(env, "some_name", obj);
  if (e != RT_OK)
  {
    rtLogError("rtRemoteRegisterObject:%s", rtStrError(e));
    exit(2);
  }

  while (true)
  {
    // process incoming messages
    e = rtRemoteRunUntil(env, 1000);
    rtLogInfo("rtRemoteRunUntil: %s", rtStrError(e));

    // ((ContinuousVideoRecorder *)obj.getPtr())->fireOnUploadComplete();
  }

  return 0;
}
Ejemplo n.º 2
0
int main( int argc, const char **argv )
{
   rtError rc;
   rtRemoteEnvironment *env= 0;
   const char* srcName= 0;
   const char* fileName= 0;
   const char* endpointName= 0;
   bool toFile= false;
   bool toEndpoint= false;
   int duration= -1;
   int len;

   printf("mediacapture-test v1.0\n");

   if ( argc > 4 )
   {
      showUsage();
   }
   else
   {
      if ( argc > 1 )
      {
         len= strlen(argv[1]);
         if ( (len == 4) && !strncmp( argv[1], "file", len) )
         {
            toFile= true;
         }
         else if ( (len == 8) && !strncmp( argv[1], "endpoint", len) )
         {
            toEndpoint= true;
         }
      }
      if ( argc > 2 )
      {
         if ( toFile )
         {
            fileName= argv[2];
         }
         else
         if ( toEndpoint )
         {
            endpointName= argv[2];
         }
      }
      if ( argc > 3 )
      {
         duration= atoi(argv[3]);
      }
      if ( !toFile && !toEndpoint )
      {
         showUsage();
         exit(0);
      }
      if ( duration < 0 )
      {
         duration= 30000;
      }

      printf("will capture to %s (%s)\n", (toFile?"file":"endpoint"), (toFile?fileName:endpointName));

      env= rtEnvironmentGetGlobal();

      rc= rtRemoteInit(env);
      if ( rc == RT_OK )
      {
         rtObjectRef registry;
         struct sigaction sigint;

         rc= rtRemoteLocateObject(env, "mediacaptureregistry", registry);
         if ( rc == RT_OK )
         {
            sigint.sa_handler= signalHandler;
            sigemptyset(&sigint.sa_mask);
	         sigint.sa_flags= SA_RESETHAND;
            sigaction(SIGINT, &sigint, NULL);

            setBlockingMode(NON_BLOCKING_ENABLED);

            listActions();
            gRunning= true;
            while( gRunning )
            {
               rtRemoteProcessSingleItem( env );
               if ( isKeyHit() )
               {
                  int src= -1;
                  int c= fgetc(stdin);
                  switch( c )
                  {
                     case '0':
                     case '1':
                     case '2':
                     case '3':
                     case '4':
                     case '5':
                     case '6':
                     case '7':
                     case '8':
                     case '9':
                        src= c-'0';
                        getAvailablePipelines(env, registry);
                        if ( toFile )
                        {
                           captureSourceToFile( src, fileName, duration, env );
                        }
                        else
                        {
                           startCaptureSourceToEndpoint( src, endpointName, duration, env );
                        }
                        break;
                     case 's':
                        if ( !toFile )
                        {
                           if ( gSrcActive != -1 )
                           {
                              stopCaptureSourceToEndpoint( gSrcActive, env );
                           }
                        }
                        break;
                     case 'l':
                        displayPipelineList(env, registry);
                        break;
                     case 'i':
                        displayMediaConsumptionInfo(env, registry);
                        break;
                     case 'c':
                        clearMediaConsumptionInfo(env, registry);
                        break;
                     case 'q':
                        gRunning= false;
                        break;
                     default:
                        listActions();
                        break;
                  }
               }
               usleep( 10000 );
            }

            setBlockingMode(NON_BLOCKING_DISABLED);
         }
         else
         {
            printf("error: unable to locate registry: %d", rc);
         }

      }
      else
      {
         printf("error: rtRemoteInit rc %d\n", rc);
      }

   }

   return 0;
}