Skip to content

Fix SRTCP handling in camera talkback receiver - #587

Merged
ikalchev merged 1 commit into
ikalchev:devfrom
Naka-Masa19:fix-talkback-rtcp
Dec 1, 2026
Merged

ikalchev merged 1 commit into
ikalchev:devfrom
Naka-Masa19:fix-talkback-rtcp

Conversation

@Naka-Masa19

@Naka-Masa19 Naka-Masa19 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

There was a recurring authentication error when processing incoming talkback audio packets:

ERROR:pyhap.camera_talkback:Failed to process incoming talkback audio packet
Traceback (most recent call last):
  File "/home/USER/.local/lib/python3.15/site-packages/pyhap/camera_talkback.py", line 228, in _run
    rtp_plain = self._session.unprotect(data)
  File "/home/USER/.local/lib/python3.15/site-packages/pylibsrtp/__init__.py", line 254, in unprotect
    return self.__process(packet, lib.srtp_unprotect)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.15/site-packages/pylibsrtp/__init__.py", line 274, in __process
    _srtp_assert(func(self._srtp[0], self._cdata, len_p))
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.15/site-packages/pylibsrtp/__init__.py", line 59, in _srtp_assert
    raise Error(ERRORS[rc])
pylibsrtp.Error: authentication failure

I found that some incoming packets caused an authentication failure when processed with unprotect(), but were successfully decrypted with unprotect_rtcp().

Solution

Identify potential RTCP packets using the packet type range defined in RFC 5761 and process them with unprotect_rtcp() instead of unprotect().

RTCP packets are skipped to prevent them from being processed as audio data.

Note: I have not confirmed whether HAP Talkback explicitly follows the RTP/RTCP multiplexing rules defined in RFC 5761. However, this change eliminated the recurring errors in my testing.

Use of AI

AI-assisted (debugging / technical research, including RTP/RTCP specifications, and PR text). Code authored and verified by me.

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.42%. Comparing base (9b4f079) to head (5953aee).

Files with missing lines Patch % Lines
pyhap/camera_talkback.py 0.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #587      +/-   ##
==========================================
- Coverage   92.45%   92.42%   -0.04%     
==========================================
  Files          56       56              
  Lines       11347    11351       +4     
  Branches     1457     1458       +1     
==========================================
  Hits        10491    10491              
- Misses        570      573       +3     
- Partials      286      287       +1     
Files with missing lines Coverage Δ
pyhap/camera_talkback.py 77.57% <0.00%> (-3.02%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ikalchev
ikalchev merged commit e150ca7 into ikalchev:dev Dec 1, 2026
7 of 8 checks passed
@Naka-Masa19
Naka-Masa19 deleted the fix-talkback-rtcp branch December 1, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants