Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: build/android/pylib/screenshot.py

Issue 1522313002: [Android] Move screenshot and video_recorder into devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix video_recorder timing Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/android/tools/video_recorder.py ('k') | build/android/screenshot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/screenshot.py
diff --git a/build/android/pylib/screenshot.py b/build/android/pylib/screenshot.py
deleted file mode 100644
index b3d17e2e00afefc6f25acf6bdfb0ec2a3a285e87..0000000000000000000000000000000000000000
--- a/build/android/pylib/screenshot.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import os
-import tempfile
-import time
-
-from devil.android import device_signal
-from devil.utils import cmd_helper
-
-
-class VideoRecorder(object):
- """Records a screen capture video from an Android Device (KitKat or newer).
-
- Args:
- device: DeviceUtils instance.
- host_file: Path to the video file to store on the host.
- megabits_per_second: Video bitrate in megabits per second. Allowed range
- from 0.1 to 100 mbps.
- size: Video frame size tuple (width, height) or None to use the device
- default.
- rotate: If True, the video will be rotated 90 degrees.
- """
- def __init__(self, device, megabits_per_second=4, size=None,
- rotate=False):
- self._device = device
- self._device_file = (
- '%s/screen-recording.mp4' % device.GetExternalStoragePath())
- self._recorder = None
- self._recorder_stdout = None
- self._is_started = False
-
- self._args = ['adb']
- if str(self._device):
- self._args += ['-s', str(self._device)]
- self._args += ['shell', 'screenrecord', '--verbose']
- self._args += ['--bit-rate', str(megabits_per_second * 1000 * 1000)]
- if size:
- self._args += ['--size', '%dx%d' % size]
- if rotate:
- self._args += ['--rotate']
- self._args += [self._device_file]
-
- def Start(self):
- """Start recording video."""
- self._recorder_stdout = tempfile.mkstemp()[1]
- self._recorder = cmd_helper.Popen(
- self._args, stdout=open(self._recorder_stdout, 'w'))
- if not self._device.GetPids('screenrecord'):
- raise RuntimeError('Recording failed. Is your device running Android '
- 'KitKat or later?')
-
- def IsStarted(self):
- if not self._is_started:
- for line in open(self._recorder_stdout):
- self._is_started = line.startswith('Content area is ')
- if self._is_started:
- break
- return self._is_started
-
- def Stop(self):
- """Stop recording video."""
- os.remove(self._recorder_stdout)
- self._is_started = False
- if not self._recorder:
- return
- if not self._device.KillAll('screenrecord', signum=device_signal.SIGINT,
- quiet=True):
- logging.warning('Nothing to kill: screenrecord was not running')
- self._recorder.wait()
-
- def Pull(self, host_file=None):
- """Pull resulting video file from the device.
-
- Args:
- host_file: Path to the video file to store on the host.
- Returns:
- Output video file name on the host.
- """
- # TODO(jbudorick): Merge filename generation with the logic for doing so in
- # DeviceUtils.
- host_file_name = (
- host_file
- or 'screen-recording-%s.mp4' % time.strftime('%Y%m%dT%H%M%S',
- time.localtime()))
- host_file_name = os.path.abspath(host_file_name)
- self._device.PullFile(self._device_file, host_file_name)
- self._device.RunShellCommand('rm -f "%s"' % self._device_file)
- return host_file_name
« no previous file with comments | « build/android/devil/android/tools/video_recorder.py ('k') | build/android/screenshot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698