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 tempfile | 6 import tempfile |
7 | 7 |
8 from pylib import cmd_helper | 8 from pylib import cmd_helper |
9 | 9 |
10 # TODO(jbudorick) Remove once telemetry gets switched over. | 10 # TODO(jbudorick) Remove once telemetry gets switched over. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 self._args += ['--size', '%dx%d' % size] | 46 self._args += ['--size', '%dx%d' % size] |
47 if rotate: | 47 if rotate: |
48 self._args += ['--rotate'] | 48 self._args += ['--rotate'] |
49 self._args += [self._device_file] | 49 self._args += [self._device_file] |
50 | 50 |
51 def Start(self): | 51 def Start(self): |
52 """Start recording video.""" | 52 """Start recording video.""" |
53 self._recorder_stdout = tempfile.mkstemp()[1] | 53 self._recorder_stdout = tempfile.mkstemp()[1] |
54 self._recorder = cmd_helper.Popen( | 54 self._recorder = cmd_helper.Popen( |
55 self._args, stdout=open(self._recorder_stdout, 'w')) | 55 self._args, stdout=open(self._recorder_stdout, 'w')) |
56 self._recorder_pids = self._device.old_interface.ExtractPid('screenrecord') | 56 self._recorder_pids = self._device.GetPid('screenrecord') |
57 if not self._recorder_pids: | 57 if not self._recorder_pids: |
58 raise RuntimeError('Recording failed. Is your device running Android ' | 58 raise RuntimeError('Recording failed. Is your device running Android ' |
59 'KitKat or later?') | 59 'KitKat or later?') |
60 | 60 |
61 def IsStarted(self): | 61 def IsStarted(self): |
62 if not self._is_started: | 62 if not self._is_started: |
63 for line in open(self._recorder_stdout): | 63 for line in open(self._recorder_stdout): |
64 self._is_started = line.startswith('Content area is ') | 64 self._is_started = line.startswith('Content area is ') |
65 if self._is_started: | 65 if self._is_started: |
66 break | 66 break |
(...skipping 14 matching lines...) Expand all Loading... |
81 | 81 |
82 Args: | 82 Args: |
83 host_file: Path to the video file to store on the host. | 83 host_file: Path to the video file to store on the host. |
84 """ | 84 """ |
85 host_file_name = host_file or ('screen-recording-%s.mp4' % | 85 host_file_name = host_file or ('screen-recording-%s.mp4' % |
86 self._device.old_interface.GetTimestamp()) | 86 self._device.old_interface.GetTimestamp()) |
87 host_file = os.path.abspath(host_file_name) | 87 host_file = os.path.abspath(host_file_name) |
88 self._device.old_interface.EnsureHostDirectory(self._host_file) | 88 self._device.old_interface.EnsureHostDirectory(self._host_file) |
89 self._device.PullFile(self._device_file, host_file_name) | 89 self._device.PullFile(self._device_file, host_file_name) |
90 self._device.RunShellCommand('rm -f "%s"' % self._device_file) | 90 self._device.RunShellCommand('rm -f "%s"' % self._device_file) |
OLD | NEW |