Library rewrite - #3
Conversation
…ts from the p2pcam alias
indykoning
left a comment
There was a problem hiding this comment.
I was able to first rewrite the p2pcam library to make it more reliable and robust. Although I’m not a big fan of AI, I have to admit that it really helped me, especially when analyzing packets with Wireshark.
Honestly this is quite impressive either way, i don't mind AI usage personally so long as you understand the code that has been written.
I'm seeing some imports which may not be installed by default, could you create a requirements.txt with those dependencies?
And a nice future stability improvement, could you add the ruff formatting tool?
It'll do quite some quality improvements, but could also do some code changes which i cannot test myself anymore so i cannot add it myself.
| # Continue-packet state machine (ported faithfully from the original | ||
| # reverse-engineered client.py, lines 490-641). |
There was a problem hiding this comment.
| # Continue-packet state machine (ported faithfully from the original | |
| # reverse-engineered client.py, lines 490-641). | |
| # Continue-packet state machine. |
| setuptools.setup( | ||
| name="p2pcam", | ||
| version="0.0.3", | ||
| version="0.0.4", |
There was a problem hiding this comment.
| version="0.0.4", | |
| version="1.0.0", |
|
This is some ruff configuration i have for another project The github action name: Ruff
on:
- push
- pull_request
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
src: "./p2pcam"
version: "0.15.16"
# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml
target-version = "py313"
[lint]
select = [
"ALL",
]
ignore = [
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"ANN001",
"ANN201",
"ANN202",
"D203", # no-blank-line-before-class (incompatible with formatter)
"D212", # multi-line-summary-first-line (incompatible with formatter)
"COM812", # incompatible with formatter
"ISC001", # incompatible with formatter
"E501", # Line length is not important
"EM101",
"TRY003", # Allow exception messages to be used directly
"ERA001", # Commented out code is allowed for examples
"T201", # Prints are allowed in examples
"PLR0913",
"FBT001", # Boolean positional args are part of the existing public API
"FBT002",
"N999",
]
[lint.flake8-pytest-style]
fixture-parentheses = false
[lint.pyupgrade]
keep-runtime-typing = true
[lint.mccabe]
max-complexity = 25 |
After spending a few days digging around the web, decompiling APKs, DLLs, and SO libraries, and sniffing and analyzing packets with Wireshark, I finally managed to rewrite the p2pcam library to make it more reliable and robust.
Here are the new features:
LanScannerclass for automatic camera discovery on the LANLanVideoClientclass which is based on my own observations and reverse engineering of the network protocol, as well as on part of @jheyman's video surveillance script.MJPEGServerclass for serving an MJPEG HTTP stream with thread-safe frame updates, supporting multiple clients.example.pyscript replacement) that allows users to easily discover cameras, stream video, save frames, serve MJPEG streams over HTTP, and apply image transformations (flip, timestamp)With these changes, I was able to get a video stream without interruptions and as smooth as the one from the original app!
Note: I bumped the package version to 0.0.4 in
setup.pyto reflect these significant improvements, but you can set it as you want.