VMWithDirectShowMultiVideo

This tutorial is very similar to the previous one. The only difference is that in the InitializeVideoman we initialize a number of inputs coming from video files stored in the directory that is passed as argument to the program.

bool InitializeVideoMan()
{
   if ( !dirPath )
      return false;
   vector< string > files;
   loadFiles( dirPath, files ); //Load the files name of the videos in the directory

   VideoManInputFormat format;
   inputIdentification device;

   for ( size_t v = 0; v < files.size() && videoInputIDs.size() < maxVideos; ++v )
   {
      //Initialize one input from a video file
      device.fileName = new char[files[v].length() + 1];
      strcpy( device.fileName, files[v].c_str() );
      device.identifier = "DSHOW_VIDEO_FILE"; //using VMDirectShow module  
      //play in real-time
      format.clock = true;
      format.dropFrames = true;
      format.renderAudio = renderAudio;
      int inputID;
      if ( ( inputID = videoMan.addVideoInput( device, &format ) ) != -1 )
      {
         videoInputIDs.push_back( inputID );
      }
      delete device.fileName;
   }
   for ( size_t v = 0; v < videoInputIDs.size(); ++v )
      videoMan.playVideo( videoInputIDs[v] );
   //We want to display all the intialized video inputs
   videoMan.activateAllVideoInputs();
   return ( videoInputIDs.size() > 0);
}