| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 # | 4 # |
| 5 # This module is handler for incoming data to the pywebsocket standalone server | 5 # This module is handler for incoming data to the pywebsocket standalone server |
| 6 # (source is in http://code.google.com/p/pywebsocket/source/browse/trunk/src/). | 6 # (source is in http://code.google.com/p/pywebsocket/source/browse/trunk/src/). |
| 7 # It follows the conventions of the pywebsocket server and in our case receives | 7 # It follows the conventions of the pywebsocket server and in our case receives |
| 8 # and stores incoming frames to disk. | 8 # and stores incoming frames to disk. |
| 9 | 9 |
| 10 import Queue | 10 import Queue |
| 11 import os | 11 import os |
| 12 import sys | 12 import sys |
| 13 import threading | 13 import threading |
| 14 | 14 |
| 15 _NUMBER_OF_WRITER_THREADS = 10 | 15 _NUMBER_OF_WRITER_THREADS = 10 |
| 16 | 16 |
| 17 _HOME_ENV_NAME = 'HOMEPATH' if 'win32' == sys.platform else 'HOME' | 17 _HOME_ENV_NAME = 'USERPROFILE' if 'win32' == sys.platform else 'HOME' |
| 18 _WORKING_DIR = os.path.join(os.environ[_HOME_ENV_NAME], 'webrtc_video_quality') | 18 _WORKING_DIR = os.path.join(os.environ[_HOME_ENV_NAME], 'webrtc_video_quality') |
| 19 | 19 |
| 20 # I couldn't think of other way to handle this but through a global variable | 20 # I couldn't think of other way to handle this but through a global variable |
| 21 g_frame_number_counter = 0 | 21 g_frame_number_counter = 0 |
| 22 g_frames_queue = Queue.Queue() | 22 g_frames_queue = Queue.Queue() |
| 23 | 23 |
| 24 | 24 |
| 25 def web_socket_do_extra_handshake(request): | 25 def web_socket_do_extra_handshake(request): |
| 26 pass # Always accept. | 26 pass # Always accept. |
| 27 | 27 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 t = FrameWriterThread(g_frames_queue) | 66 t = FrameWriterThread(g_frames_queue) |
| 67 t.setDaemon(True) | 67 t.setDaemon(True) |
| 68 t.start() | 68 t.start() |
| 69 g_frames_queue.join() | 69 g_frames_queue.join() |
| 70 | 70 |
| 71 | 71 |
| 72 # This handler's entire code is imported as 'it is' and then incorporated in the | 72 # This handler's entire code is imported as 'it is' and then incorporated in the |
| 73 # code of the standalone pywebsocket server. If we put this start_threads() call | 73 # code of the standalone pywebsocket server. If we put this start_threads() call |
| 74 # inside a if __name__ == '__main__' clause it wouldn't run this code at all | 74 # inside a if __name__ == '__main__' clause it wouldn't run this code at all |
| 75 # (tested). | 75 # (tested). |
| 76 start_threads() | 76 start_threads() |
| OLD | NEW |