Skip to content
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

Remove opencv #79

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
matrix:
# Should match the python versions in pyproject.toml and publish.yml
python-version: ["3.10"]
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [windows-latest, ubuntu-latest, macos-latest]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
# Should match the python versions in pyproject.toml and ci.yml
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [windows-latest, ubuntu-latest, macos-latest]
env:
OS: ${{ matrix.os }}
Expand Down
176 changes: 55 additions & 121 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ py-scrcpy = "scrcpy_ui:main"

[tool.poetry.dependencies]
# Should match the python versions in .github/workflows/ci.yml and publish.yml
python = ">=3.8.1,<3.13"
python = ">=3.9,<3.13"
av = "^12"
opencv-python = "^4.5.0"
adbutils = "^1.0.8"
numpy = "^2"
adbutils = "^2"

# Optional dependencies for ui
PySide6 = { version = "^6.0.0", optional = true }

[tool.poetry.extras]
ui = ["PySide6"]

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
flake8 = "^7"
isort = "*"
black = "^22.3.0"
Expand Down
6 changes: 5 additions & 1 deletion scrcpy/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def text(self, text: str) -> bytes:

@inject(const.TYPE_INJECT_TOUCH_EVENT)
def touch(
self, x: int, y: int, action: int = const.ACTION_DOWN, touch_id: int = 0x1234567887654321
self,
x: int,
y: int,
action: int = const.ACTION_DOWN,
touch_id: int = 0x1234567887654321,
) -> bytes:
"""
Touch screen
Expand Down
12 changes: 4 additions & 8 deletions scrcpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ def __init__(
"c2.qti.avc.encoder",
"c2.android.avc.encoder",
]
assert codec_name in [
None,
"h264",
"h265",
"av1"
]
assert codec_name in [None, "h264", "h265", "av1"]

# Params
self.flip = flip
Expand Down Expand Up @@ -163,7 +158,9 @@ def __deploy_server(self) -> None:
f"max_size={self.max_width}",
f"max_fps={self.max_fps}",
f"video_bit_rate={self.bitrate}",
f"video_encoder={self.encoder_name}" if self.encoder_name else "video_encoder=OMX.google.h264.encoder",
f"video_encoder={self.encoder_name}"
if self.encoder_name
else "video_encoder=OMX.google.h264.encoder",
f"video_codec={self.codec_name}" if self.codec_name else "video_codec=h264",
"tunnel_forward=true",
"send_frame_meta=false",
Expand All @@ -174,7 +171,6 @@ def __deploy_server(self) -> None:
"power_off_on_close=false",
"clipboard_autosync=false",
]
print(commands)

self.__server_stream: AdbConnection = self.device.shell(
commands,
Expand Down
5 changes: 2 additions & 3 deletions scrcpy_ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
from adbutils import adb
from PySide6.QtGui import QImage, QKeyEvent, QMouseEvent, QPixmap, Qt
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox
from ui_main import Ui_MainWindow

import scrcpy

from ui_main import Ui_MainWindow

if not QApplication.instance():
app = QApplication([])
else:
Expand Down Expand Up @@ -40,7 +39,7 @@ def __init__(
flip=self.ui.flip.isChecked(),
bitrate=1000000000,
encoder_name=encoder_name,
max_fps=60
max_fps=60,
)
self.client.add_listener(scrcpy.EVENT_INIT, self.on_init)
self.client.add_listener(scrcpy.EVENT_FRAME, self.on_frame)
Expand Down
13 changes: 11 additions & 2 deletions tests/test_control.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""Tests adapted from https://github.com/Genymobile/scrcpy/blob/v2.4/app/tests/test_control_msg_serialize.c

make sure to compare to the version we are targeting ^^^^

See https://github.com/Genymobile/scrcpy/issues/673#issuecomment-516360374
"""


import threading

import scrcpy
Expand Down Expand Up @@ -34,12 +42,13 @@ def test_control_touch():
assert control.touch(100, 200, scrcpy.ACTION_DOWN) == (
b"\x02" # TYPE_INJECT_TOUCH_EVENT
+ b"\x00" # ACTION_DOWN
+ b"\xff\xff\xff\xff\xff\xff\xff\xff" # Virtual touch id
+ b"\x12\x34\x56\x78\x87\x65\x43\x21" # pointer id
+ b"\x00\x00\x00\x64" # X: 100
+ b"\x00\x00\x00\xc8" # Y: 200
+ b"\x07\x80\x04\x38" # Resolution: (1920, 1080)
+ b"\xff\xff" # Pressure: 100%
+ b"\x00\x00\x00\x01" # Primary button
+ b"\x00\x00\x00\x01" # AMOTION_EVENT_BUTTON_PRIMARY (action button)
+ b"\x00\x00\x00\x01" # AMOTION_EVENT_BUTTON_PRIMARY (buttons)
)


Expand Down
Loading