@@ -0,0 +1,2372 @@
+#!/usr/bin/env python%0A#  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.%0A#%0A#  Use of this source code is governed by a BSD-style license%0A#  that can be found in the LICENSE file in the root of the source%0A#  tree. An additional intellectual property rights grant can be found%0A#  in the file PATENTS.  All contributing project authors may%0A#  be found in the AUTHORS file in the root of the source tree.%0A%0A%22%22%22Checks if a virtual webcam is running and starts it if not.%0A%0AReturns a non-zero return code if the webcam could not be started.%0A%0APrerequisites:%0A* Python must have the psutil package installed.%0A* Windows: a scheduled task named 'ManyCam' must exist and be configured to%0A  launch ManyCam preconfigured to auto-play the test clip.%0A* Mac: ManyCam must be installed in the default location and be preconfigured%0A  to auto-play the test clip.%0A* Linux: The v4l2loopback must be loaded to the kernel already (with the%0A  devices=2 argument) and the v4l2_file_player application must be compiled and%0A  put in the location specified below.%0A%22%22%22%0A%0Aimport psutil%0Aimport subprocess%0Aimport sys%0A%0A%0AWEBCAM_WIN = %5B'schtasks', '/run', '/tn', 'ManyCam'%5D%0AWEBCAM_MAC = %5B'open', '/Applications/ManyCam/ManyCam.app'%5D%0AWEBCAM_LINUX = (%0A    '$HOME/fake-webcam-driver/linux/v4l2_file_player/v4l2_file_player '%0A    '$HOME/webrtc_video_quality/reference_video.yuv 640 480 /dev/video1 &')%0A%0A%0Adef IsWebCamRunning():%0A  if sys.platform == 'win32':%0A    process_name = 'ManyCam.exe'%0A  elif sys.platform.startswith('darwin'):%0A    process_name = 'ManyCam'%0A  elif sys.platform.startswith('linux'):%0A    process_name = 'v4l2_file_player'%0A  else:%0A    raise Exception('Unsupported platform: %25s' %25 sys.platform)%0A  for p in psutil.get_process_list():%0A    if process_name == p.name:%0A      print 'Found a running virtual webcam (%25s with PID %25s)' %25 (p.name, p.pid)%0A      return True%0A  return False%0A%0A%0Adef Main():%0A  if IsWebCamRunning():%0A    return 0%0A%0A  try:%0A    if sys.platform == 'win32':%0A      subprocess.check_call(WEBCAM_WIN)%0A    elif sys.platform.startswith('darwin'):%0A      subprocess.check_call(WEBCAM_MAC)%0A    elif sys.platform.startswith('linux'):%0A      subprocess.check_call(WEBCAM_LINUX, shell=True)%0A%0A    print 'Successfully launched virtual webcam.'%0A    return 0%0A%0A  except Exception as e:%0A    print 'Failed to launch virtual webcam: %25s' %25 e%0A%0A%0Aif __name__ == '__main__':%0A  sys.exit(Main())%0A

Add script to ensure virtual webcam is running.