-
Notifications
You must be signed in to change notification settings - Fork 509
Chromium recording #9174
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
Merged
Merged
Chromium recording #9174
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # | ||
| # @copyright Copyright (c) 2023, Daniel Calviño Sánchez ([email protected]) | ||
| # @copyright Copyright (c) 2023, Elmer Miroslav Mosher Golovin ([email protected]) | ||
| # | ||
| # @license GNU AGPL version 3 or any later version | ||
| # | ||
|
|
@@ -236,4 +237,12 @@ def getFfmpegExtensionVideo(self): | |
| """ | ||
| return self._configParser.get('ffmpeg', 'extensionvideo', fallback='.webm') | ||
|
|
||
| def getBrowserForRecording(self): | ||
| """ | ||
| Returns the browser identifier that will be used for recordings. | ||
|
|
||
| Defaults to "firefox". | ||
| """ | ||
| return self._configParser.get('recording', 'browser', fallback='firefox') | ||
|
|
||
| config = Config() | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # | ||
| # @copyright Copyright (c) 2023, Daniel Calviño Sánchez ([email protected]) | ||
| # @copyright Copyright (c) 2023, Elmer Miroslav Mosher Golovin ([email protected]) | ||
| # | ||
| # @license GNU AGPL version 3 or any later version | ||
| # | ||
|
|
@@ -33,7 +34,12 @@ | |
| from secrets import token_urlsafe | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| from selenium.webdriver.chrome.options import Options as ChromeOptions | ||
| from selenium.webdriver.chrome.service import Service as ChromeService | ||
| from selenium.webdriver.chrome.webdriver import WebDriver as ChromeDriver | ||
| from selenium.webdriver.firefox.options import Options as FirefoxOptions | ||
| from selenium.webdriver.firefox.service import Service as FirefoxService | ||
| from selenium.webdriver.firefox.webdriver import WebDriver as FirefoxDriver | ||
| from selenium.webdriver.support.wait import WebDriverWait | ||
| from shutil import disk_usage | ||
| from time import sleep | ||
|
|
@@ -202,6 +208,51 @@ def __del__(self): | |
| # created in "/tmp". | ||
| self.driver.quit() | ||
|
|
||
| def startChrome(self, width, height, env): | ||
| """ | ||
| Starts a Chrome instance. | ||
|
|
||
| Will use Chromium if Google Chrome is not installed. | ||
|
|
||
| :param width: the width of the browser window. | ||
| :param height: the height of the browser window. | ||
| :param env: the environment variables, including the display to start | ||
| the browser in. | ||
| """ | ||
|
|
||
| options = ChromeOptions() | ||
|
|
||
| # "webSocketUrl" is needed for BiDi. | ||
| options.set_capability('webSocketUrl', True) | ||
|
|
||
| options.add_argument('--use-fake-ui-for-media-stream') | ||
|
|
||
| # Allow to play media without user interaction. | ||
| options.add_argument('--autoplay-policy=no-user-gesture-required') | ||
|
|
||
| options.add_argument('--kiosk') | ||
| options.add_argument(f'--window-size={width},{height}') | ||
| options.add_argument('--disable-infobars') | ||
danxuliu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| options.add_experimental_option("excludeSwitches", ["enable-automation"]) | ||
|
|
||
| if disk_usage('/dev/shm').free < 2147483648: | ||
| self._logger.info('Less than 2 GiB available in "/dev/shm", usage disabled') | ||
| options.add_argument("--disable-dev-shm-usage") | ||
|
|
||
| if disk_usage('/tmp').free < 134217728: | ||
| self._logger.warning('Less than 128 MiB available in "/tmp", strange failures may occur') | ||
|
|
||
| service = ChromeService( | ||
| env=env, | ||
| ) | ||
|
|
||
| self.driver = ChromeDriver( | ||
| options=options, | ||
| service=service, | ||
| ) | ||
|
|
||
| self.bidiLogsHelper = BiDiLogsHelper(self.driver, self._parentLogger) | ||
danxuliu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def startFirefox(self, width, height, env): | ||
| """ | ||
| Starts a Firefox instance. | ||
|
|
@@ -212,7 +263,7 @@ def startFirefox(self, width, height, env): | |
| the browser in. | ||
| """ | ||
|
|
||
| options = webdriver.FirefoxOptions() | ||
| options = FirefoxOptions() | ||
|
|
||
| # "webSocketUrl" is needed for BiDi; this should be set already by | ||
| # default, but just in case. | ||
|
|
@@ -239,7 +290,7 @@ def startFirefox(self, width, height, env): | |
| env=env, | ||
| ) | ||
|
|
||
| self.driver = webdriver.Firefox( | ||
| self.driver = FirefoxDriver( | ||
| options=options, | ||
| service=service, | ||
| ) | ||
|
|
@@ -418,7 +469,9 @@ def __init__(self, browser, nextcloudUrl, width, height, env, parentLogger): | |
|
|
||
| self.seleniumHelper = SeleniumHelper(parentLogger) | ||
|
|
||
| if browser == 'firefox': | ||
| if browser == 'chrome': | ||
| self.seleniumHelper.startChrome(width, height, env) | ||
| elif browser == 'firefox': | ||
| self.seleniumHelper.startFirefox(width, height, env) | ||
| else: | ||
| raise Exception('Invalid browser: ' + browser) | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # | ||
| # @copyright Copyright (c) 2023, Daniel Calviño Sánchez ([email protected]) | ||
| # @copyright Copyright (c) 2023, Elmer Miroslav Mosher Golovin ([email protected]) | ||
| # | ||
| # @license GNU AGPL version 3 or any later version | ||
| # | ||
|
|
@@ -188,8 +189,10 @@ def start(self, actorType, actorId): | |
| env = self._display.env() | ||
| env['PULSE_SINK'] = audioSinkIndex | ||
|
|
||
| browser = config.getBrowserForRecording() | ||
|
|
||
| self._logger.debug("Starting participant") | ||
| self._participant = Participant('firefox', self.backend, width, height, env, self._logger) | ||
| self._participant = Participant(browser, self.backend, width, height, env, self._logger) | ||
|
|
||
| self._logger.debug("Joining call") | ||
| self._participant.joinCall(self.token) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.