OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import os | 5 import os |
6 import signal | 6 import signal |
7 import tempfile | 7 import tempfile |
8 import time | |
9 | 8 |
10 from pylib import cmd_helper | 9 from pylib import cmd_helper |
11 | 10 |
12 # TODO(jbudorick) Remove once telemetry gets switched over. | 11 # TODO(jbudorick) Remove once telemetry gets switched over. |
13 import pylib.android_commands | 12 import pylib.android_commands |
14 import pylib.device.device_utils | 13 import pylib.device.device_utils |
15 | 14 |
16 | 15 |
17 class VideoRecorder(object): | 16 class VideoRecorder(object): |
18 """Records a screen capture video from an Android Device (KitKat or newer). | 17 """Records a screen capture video from an Android Device (KitKat or newer). |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 self._recorder.wait() | 75 self._recorder.wait() |
77 | 76 |
78 def Pull(self, host_file=None): | 77 def Pull(self, host_file=None): |
79 """Pull resulting video file from the device. | 78 """Pull resulting video file from the device. |
80 | 79 |
81 Args: | 80 Args: |
82 host_file: Path to the video file to store on the host. | 81 host_file: Path to the video file to store on the host. |
83 Returns: | 82 Returns: |
84 Output video file name on the host. | 83 Output video file name on the host. |
85 """ | 84 """ |
86 # TODO(jbudorick): Merge filename generation with the logic for doing so in | 85 host_file_name = host_file or ('screen-recording-%s.mp4' % |
87 # DeviceUtils. | 86 self._device.old_interface.GetTimestamp()) |
88 host_file_name = ( | |
89 host_file | |
90 or 'screen-recording-%s.mp4' % time.strftime('%Y%m%dT%H%M%S', | |
91 time.localtime())) | |
92 host_file_name = os.path.abspath(host_file_name) | 87 host_file_name = os.path.abspath(host_file_name) |
| 88 self._device.old_interface.EnsureHostDirectory(host_file_name) |
93 self._device.PullFile(self._device_file, host_file_name) | 89 self._device.PullFile(self._device_file, host_file_name) |
94 self._device.RunShellCommand('rm -f "%s"' % self._device_file) | 90 self._device.RunShellCommand('rm -f "%s"' % self._device_file) |
95 return host_file_name | 91 return host_file_name |
OLD | NEW |