-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] trace: Add android screenrecord collector #172
Open
valschneider
wants to merge
1
commit into
ARM-software:master
Choose a base branch
from
valschneider:trace/screen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import os | ||
import signal | ||
|
||
from devlib.trace import TraceCollector | ||
from devlib.host import kill_children | ||
|
||
DEFAULT_MAX_DURATION = 180 | ||
|
||
class ScreenrecordCollector(TraceCollector): | ||
|
||
def __init__(self, target, | ||
verbose=False, | ||
size=None, | ||
bit_rate=None, | ||
time_limit_s=None, | ||
debug=False, | ||
rotate=False, | ||
output_format=None, | ||
): | ||
super(ScreenrecordCollector, self).__init__(target) | ||
|
||
self.verbose = verbose | ||
self.size = size | ||
self.bit_rate = bit_rate | ||
self.time_limit_s = time_limit_s | ||
self.debug = debug | ||
self.rotate = rotate | ||
self.output_format = output_format | ||
|
||
self.screenrecord = None | ||
|
||
args = [] | ||
if self.verbose: | ||
args.append('--verbose') | ||
if self.size: | ||
args.append('--size {}'.format(self.size)) | ||
if self.bit_rate: | ||
args.append('--bit-rate {}'.format(self.bit_rate)) | ||
if self.time_limit_s and self.time_limit_s < DEFAULT_MAX_DURATION: | ||
args.append('--time-limit {}'.self.time_limit_s) | ||
if self.debug: | ||
args.append('--bugreport') | ||
if self.rotate: | ||
args.append('--rotate') | ||
if self.output_format: | ||
args.append('--output-format {}'.format(self.output_format)) | ||
|
||
self._cmd = 'screenrecord {}'.format(' '.join(args)) | ||
|
||
def reset(self): | ||
""" | ||
|
||
""" | ||
# Remove file(s) | ||
target.remove(self._remote_file) | ||
|
||
def start(self): | ||
""" | ||
Start the video recording | ||
""" | ||
# We'd need a set of e.g. numbered tmp files | ||
self._remote_file = self.target.path.join( | ||
self.target.working_directory, | ||
'screenrecord_tmp' | ||
) | ||
|
||
cmd = '{} {}'.format(self._cmd, self._remote_file) | ||
|
||
self._screenrecord = self.target.background(cmd) | ||
|
||
def stop(self): | ||
""" | ||
Stop the video recording | ||
""" | ||
if not self._screenrecord: | ||
raise RuntimeError('Logcat monitor not running, nothing to stop') | ||
|
||
kill_children(self._screenrecord.pid, signal.SIGINT) | ||
self._screenrecord.terminate() | ||
|
||
def get_trace(self, outfile): | ||
""" | ||
Output collected video recording to designated file | ||
""" | ||
# Files would be pulled and concat'd here | ||
self.target.pull(self._remote_file, outfile) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's valid to call
reset
prior to the first invocation ofstart
, so do not assume thatself._remote_file
will exist on target.