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

Prep work for PTP #49

Open
systemcrash opened this issue Jul 30, 2021 · 7 comments
Open

Prep work for PTP #49

systemcrash opened this issue Jul 30, 2021 · 7 comments

Comments

@systemcrash
Copy link
Member

@glmnet @LewdNeko

First question: what happens on your systems when you run PTP on port 319+320?

Do you need root privileges/run sudo? Or does it work OK to say, bind to '0.0.0.0' / '::'

I've not found a way that airplay sends PTP to any other port. I think the ports are baked in.

@systemcrash
Copy link
Member Author

It seems that Python 3.7 might be necessary for PTP. Example:

    def time_monotonic_ns(self):
        # From PEP 564: Linux 1MHz. Win 10MHz. my macOS 88ns, ~11.3MHz
        # The following if/else is nearly twice as slow as a direct call...
        if sys.hexversion >= 0x3070000:
            #Needs Python >= 3.7
            return time.monotonic_ns()
        else:
            return int(time.monotonic() * 1e9)

We could structure this as a try: call, and try time.monotonicc_ns() first. Then fall back to older versions. Python 3.7 seems to guarantee much more accurate ns timestamping than int(time.monotonic() * 1e9).

@glmnet
Copy link
Contributor

glmnet commented Aug 26, 2021

@glmnet @LewdNeko

First question: what happens on your systems when you run PTP on port 319+320?

Do you need root privileges/run sudo? Or does it work OK to say, bind to '0.0.0.0' / '::'

I've not found a way that airplay sends PTP to any other port. I think the ports are baked in.

ahh sorry not replying before. I'm testing this on Windows only, and have not run into any issue regarding port permissions

@glmnet
Copy link
Contributor

glmnet commented Aug 26, 2021

It seems that Python 3.7 might be necessary for PTP. Example:

I would just drop support for Python < 3.7. E.g. 3.6 is quite old and not receiving security security updates in just a few months https://en.wikipedia.org/wiki/History_of_Python#Table_of_versions

@systemcrash
Copy link
Member Author

systemcrash commented Aug 26, 2021 via email

@systemcrash
Copy link
Member Author

systemcrash commented Aug 26, 2021 via email

@TheSpookyCat
Copy link
Contributor

I'm for dropping Python 3.6 support :)

@systemcrash
Copy link
Member Author

I ended up doing this in the head of the PTP module:

if sys.hexversion >= 0x3070000:
    # Needs Python >= 3.7 - define only once at startup.
    def time_monotonic_ns():
        # TODO: calibrate a timing loop at startup to precalculate avg call time
        # From PEP 564: Linux 1MHz. Win 10MHz. my macOS 88ns, ~11.3MHz
        return time.monotonic_ns()
else:
    def time_monotonic_ns():
        return int(time.monotonic() * 1e9)

This means we can have both. Win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants