FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Proposal: low-level SmartCam two-way audio / media transport · Issue #1763 · python-kasa/python-kasa · GitHub

Repository navigation

Proposal: low-level SmartCam two-way audio / media transport #1763

Open

Description

I have been experimenting with local two-way audio on a physical Tapo C200 (HW 1.0, FW 1.3.17) and I think there is a reasonably small, self-contained media protocol layer that could fit in python-kasa.

The goal would not be to add media-player, TTS, transcoding or WebRTC support to python-kasa, but only to expose the low-level local Tapo media primitives required for microphone/talkback.

What I verified

On the C200, the media protocol is separate from the regular management API:

management: HTTPS :443
media:      HTTP  :8800 /stream

Talkback works locally using:

HTTP Digest authentication
→ open `talk` session (`mode: aec`)
→ receive a session id
→ G.711 A-law / PCMA, 8 kHz mono
→ minimal MPEG-TS
→ multipart stream with X-Session-Id
→ camera speaker

I validated this with a standalone Python POC against the physical camera:

  • audible generated tones played successfully through the speaker;
  • 8/8 loopback checks captured the expected tone through the camera microphone;
  • a talk session remained stable for 30 seconds;
  • reopening sessions repeatedly works;
  • talkback works while preview is active;
  • talkback also works while the Tapo app live view is open;
  • no FFmpeg or other media framework is required for the speaker path.

The speaker path can be implemented using standard Python networking plus a small MPEG-TS muxer.

Relationship with existing python-kasa support

python-kasa already exposes or queries useful SmartCam information such as:

  • getAudioConfig;
  • audio_capability.device_speaker;
  • audio_capability.device_microphone;
  • getMediaEncrypt;
  • vhttpd;
  • the existing SmartCam credentials / SHA-256 credential hashing logic.

The existing SslAesTransport itself is not reusable because the media protocol is different, but some authentication/capability primitives can be shared.

Reference implementation

go2rtc already implements the same Tapo media protocol:

https://github.com/AlexxIT/go2rtc/tree/master/pkg/tapo

I used it as a protocol reference, but the proposed implementation would not depend on or embed go2rtc.

The relevant protocol-specific parts are small compared with the rest of go2rtc's media stack.

Proposed scope

I suggest starting with speaker talkback only.

Conceptually:

async with await camera.open_talk() as talk:
    await talk.write_pcma(data)

Where data is already PCMA / G.711 A-law at the codec/rate advertised by the camera.

Internally, python-kasa would handle:

  • media connection on port 8800;
  • Digest authentication;
  • talk session lifecycle;
  • multipart framing;
  • minimal MPEG-TS encapsulation;
  • real-time pacing;
  • reconnect / timeout errors.

It would deliberately not handle:

  • MP3/AAC decoding;
  • generic resampling;
  • TTS;
  • WebRTC;
  • Home Assistant / Music Assistant concepts;
  • video streaming.

Possible internal structure

Something along these lines:

SmartCamDevice
├── management transport (:443)
└── media client (:8800)
    └── TalkSession
        └── write_pcma(...)

The exact public API should of course follow the project's existing conventions.

Microphone / preview

I also validated microphone capture:

preview
→ encrypted multipart video/mp2t
→ AES-CBC decrypt
→ MPEG-TS demux
→ PCMA 8 kHz

That works on the same C200, but I would prefer to keep it out of the first PR because it adds considerably more complexity and firmware/codec variations.

A second PR could add a low-level preview/audio iterator once the talkback transport is accepted.

Open questions

Before turning the POC into a proper PR, I would like feedback on:

  1. Is a low-level SmartCam media transport within python-kasa's intended scope?
  2. Would a speaker-only first PR be preferable?
  3. Should the public API accept only encoded PCMA frames initially, or would a small PCM16 → G.711 helper also be appropriate?
  4. Is there a preferred place for this transport/session layer in the current SmartCam architecture?

If this direction is acceptable, I can prepare a focused first PR with unit tests for authentication, session setup, multipart framing and deterministic MPEG-TS output, plus validation against the physical C200.

Activity

  1. juherr commented on Sep 18, 2026

    ContributorAuthor
  2. freeKC commented on Sep 27, 2026

    Contributor

    In case it helps with the design: the same port 8800 session also carries the recording side (SD card clip download, per clip thumbnails, live snapshot), and I wrote that part up in detail after getting it working from scratch on a C510W: https://github.com/freeKC/tapo-v4-protocol/blob/main/PROTOCOL.md (section 7, media port).

    A few things from that work that may matter for the layer you propose:

    • the digest realm is shared by all media requests, but the password hash depends on the encrypt_type the camera advertises in WWW-Authenticate ("3" means SHA-256 upper of the cloud password, older firmware wants MD5);
    • one connection is bound to the media type of its first request, so talk, video and thumbnails need separate connections;
    • the camera only keeps one video session at a time and answers -52405 / -52407 / -52417 / -52435 when another one is active, so the layer needs an explicit stop and a short pause between sessions;
    • the multipart parts are AES-128-CBC with a key derived from the digest nonce, and the reader has to ack every 25 parts within a window of 50 or the camera stalls.

    Happy to test a draft against my cameras (C510W on the new login, C410 on the old one) if that is useful.

  3. rytilahti commented on Oct 4, 2026

    Member

    Hey @juherr and thanks for the detailed proposal. I am not that familiar on details how av transports work, so I am just leaving a coupe of quick notes on high-level:

    • Exposing low-level interfaces through some API sounds good to me. We should try avoid doing any encoding/decoding etc. if feasible.
    • Speaker-only would definitely be preferred as there might be several moving parts, so the simpler the initial implementation the better. Having a way to output will also make funny demos possible (or using it as a speaker/doorbell, I guess). I have a TC65, so I can help with testing.
    • We should not add any dependencies or transcoding/encoding, the first step would be to accept a raw audio file and stream it to the device.

    It would make sense to check how homeassistant handles such transports and what primitives are necessary, as that could be a candidate for this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL