tv-app: select media device type at runtime (advertised + declared) (backport #73895) - #74070
tv-app: select media device type at runtime (advertised + declared) (backport #73895)#74070mergify[bot] wants to merge 1 commit into
Conversation
…73895) * platform: allow overriding the advertised device type id at runtime GetDeviceTypeId() returned CHIP_DEVICE_CONFIG_DEVICE_TYPE unconditionally, so the DNS-SD "_T<id>" commissioning subtype was fixed at compile time. Add a SetDeviceTypeId() setter on ConfigurationManager, backed by a non-persistent in-RAM override in GenericConfigurationManagerImpl, so an application can change the advertised device type at boot. This mirrors the existing Get/SetFirmwareBuildChipEpochTime override: the interface method defaults to CHIP_ERROR_NOT_IMPLEMENTED so no platform implementation is forced to change, and GetDeviceTypeId() falls back to the compile-time value when no override is set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * tv-app: add --device-type flag to select media device type at runtime tv-app is built as a Casting Video Player (0x0023), with endpoint 1 hosting a superset of clusters that also covers the mandatory set of the other three media player device types. Add a `--device-type` flag (casting-video|basic-video|casting-audio|streaming-audio) that presents the app as any of the four without a rebuild: - during argument parsing (before the server starts advertising), it overrides the DNS-SD "_T<id>" commissioning subtype via ConfigurationMgr().SetDeviceTypeId; - in ApplicationInit, it rewrites endpoint 1's Descriptor DeviceTypeList via emberAfSetDeviceTypeList. The commissioner role and cluster set are as compiled; document both the runtime flag and that caveat, plus the build-time variant path for a fully faithful data model, in a new examples/tv-app/README.md linked from linux/README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * tv-app: address review feedback on --device-type - Use the generated devices/Types.h entries (kCastingVideoPlayer, kBasicVideoPlayer) instead of hardcoded ids for the video player types, so they track the data model. The two audio player types are not yet emitted there (absent from matter-devices.xml) and remain spelled out. - Fix the docs build: add the top-level tv-app README to the Sphinx toctree (the tv-app/**/README glob only matches nested READMEs). - Fix the spellcheck: add "superset" to the CI wordlist. - Fix markdownlint MD040: tag the fenced command block as sh. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * platform: honor device-type override in ESP32/android GetDeviceTypeId The runtime device-type override (SetDeviceTypeId) was only consulted by the generic GetDeviceTypeId used on Linux/darwin. ESP32 and android provide their own GetDeviceTypeId that reads persisted config, so they ignored the override: after SetDeviceTypeId() the getter still returned the stored/compile-time value. This surfaced as a TestConfigurationMgr.DeviceTypeId failure on the ESP32 QEMU test (returned 0 instead of the value just set). Have those platform getters consult the override first via a small GetDeviceTypeIdOverride() accessor, and move the override storage from a file-static in the .ipp to a static data member of the template. A static data member is a single external-linkage instance per specialization, so the setter and every platform getter observe the same object regardless of which translation unit instantiates them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * tv-app: only record device-type override after SetDeviceTypeId succeeds Set gMediaDeviceTypeList/gMediaDeviceTypeOverridden only once SetDeviceTypeId() has succeeded, and fail the option otherwise, so a failed advertised-type override does not leave the app claiming an override (and rewriting the Descriptor DeviceTypeList in ApplicationInit) that never took effect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit 4592828)
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.7-branch #74070 +/- ##
============================================
Coverage 56.42% 56.42%
============================================
Files 1862 1862
Lines 121963 121967 +4
Branches 14352 14352
============================================
+ Hits 68816 68819 +3
- Misses 53147 53148 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
tv-appis hard-wired to the Casting Video Player (0x0023) device type in two independent places that must be kept in agreement by hand — the compile-timeCHIP_DEVICE_CONFIG_DEVICE_TYPE(DNS-SD advertising) and endpoint 1's declaration intv-app.zap/tv-app.matter(DescriptorDeviceTypeList). There is no supported, documented way to run it as any of the other media player device types, even though the spec now defines four: Basic Video Player (0x0028), Casting Video Player (0x0023), Casting Audio Player (0x0021) and Streaming Audio Player (0x0020).Change
Two commits:
1.
platform: allow overriding the advertised device type id at runtime.GetDeviceTypeId()returnedCHIP_DEVICE_CONFIG_DEVICE_TYPEunconditionally, fixing the DNS-SD_T<id>subtype at compile time. Add aSetDeviceTypeId()setter onConfigurationManager, backed by a non-persistent in-RAM override inGenericConfigurationManagerImpl. This mirrors the existingGet/SetFirmwareBuildChipEpochTimeoverride: the interface method defaults toCHIP_ERROR_NOT_IMPLEMENTED(no platform impl is forced to change), andGetDeviceTypeId()falls back to the compile-time value when unset.Dnssd.cppalready sources the advertised type fromGetDeviceTypeId(), so advertising follows automatically. Unit test added inTestConfigurationMgr.2.
tv-app: add--device-typeflag. Endpoint 1 already hosts a superset of clusters that satisfies the mandatory set of all four media player device types. The flag--device-type <casting-video|basic-video|casting-audio|streaming-audio>presents the app as any of the four without a rebuild:_Tsubtype viaConfigurationMgr().SetDeviceTypeId;ApplicationInit, it rewrites endpoint 1's DescriptorDeviceTypeListviaemberAfSetDeviceTypeList.Default behavior (Casting Video Player) is unchanged.
Scope / caveats (documented, not worked around)
The flag changes the advertised and declared device type. It intentionally does not change the commissioner role (Casting players are Commissioners; Basic/Streaming are commissionable-only — that machinery is compiled in) or trim the cluster set. A new
examples/tv-app/README.mddocuments the flag and these caveats, and describes the build-time variant path (per-type ZAP/.matter) for a fully faithful data model;examples/tv-app/linux/README.mdlinks to it.Testing
tv-appbuilds clean (darwin-arm64-tv-app-clang).TestConfigurationMgr.DeviceTypeIdcovering the Set→Get override and the compile-time fallback. (This test suite is Mac-excluded inBUILD.gn, so it runs in CI on Linux.)This is an automatic backport of pull request tv-app: select media device type at runtime (advertised + declared) #73895 done by Mergify.