Skip to content

Commit

Permalink
Screen recording
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Oct 20, 2023
1 parent 5d02aa6 commit 2b3db4d
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import multiprocessing
import os

from mobly.utils import stop_standing_subprocess
from capture.utils.artifact import create_standard_log_name
from typing import TYPE_CHECKING
from ..base import AndroidStream
Expand All @@ -35,6 +34,8 @@
class ScreenRecorder(AndroidStream):

def __init__(self, platform: "Android"):
self.screen_artifact = None
self.screen_phone_out_path = None
self.screen_command = None
self.screen_proc = None
self.logger = logger
Expand Down Expand Up @@ -64,12 +65,12 @@ async def prepare_screen_recording(self) -> None:
return

def update_commands(self) -> None:
screen_artifact = create_standard_log_name("screencast"+self.file_counter,
"mp4",
parent=self.platform.artifact_dir)
screen_phone_out_path = f"/sdcard/Movies/{os.path.basename(self.screen_artifact)}"
self.screen_artifact = create_standard_log_name("screencast" + str(self.file_counter),
"mp4",
parent=self.platform.artifact_dir)
self.screen_phone_out_path = f"/sdcard/Movies/{os.path.basename(self.screen_artifact)}"
self.screen_command = f"shell screenrecord --bugreport {self.screen_phone_out_path}"
screen_pull_command = f"pull {screen_phone_out_path} {screen_artifact}"
screen_pull_command = f"pull {self.screen_phone_out_path} {self.screen_artifact}"
self.pull_commands.append(screen_pull_command)
self.file_counter += 1

Expand All @@ -81,9 +82,10 @@ def run_recorder(self) -> None:

async def start(self):
await self.prepare_screen_recording()
if self.check_screen():
if self.check_screen() and not self.screen_pull:
self.screen_pull = True
self.screen_proc = multiprocessing.Process(target=self.run_recorder)
self.screen_proc.start()

async def pull_screen_recording(self) -> None:
if self.screen_pull:
Expand All @@ -96,8 +98,6 @@ async def pull_screen_recording(self) -> None:
async def stop(self):
self.logger.info("Stopping screen proc")
if self.screen_proc is not None:
print(self.screen_proc)
import sys
sys.exit(1)
self.screen_proc.kill()
await self.pull_screen_recording()
# TODO stitch together

0 comments on commit 2b3db4d

Please sign in to comment.