mirror of
git://f0xx.org/android_cast
synced 2026-07-29 02:59:00 +03:00
3.7 KiB
3.7 KiB
Pro / OSS split (cast-core + cast-pro AAR)
Design notes for a commercial build without forking the cast protocol. Not implemented yet — complements COMMERCIAL.md (dev-gated Play Billing placeholders).
Goals
- OSS (
cast-core) — protocol, UDP/TCP transport, receiver, sender engine, crash reporter client, settings model. Publishable repo for trust and forks. - Closed (
cast-proAAR) — entitlements, license check, optional premium codecs/UI, Play Billing glue. Distributed via private Maven or Play App Bundle module (not on public Maven). - Single APK on Play:
appdepends oncast-core+cast-proat compile time; F-Droid / OSS build usescast-coreonly with stub entitlements.
Entitlements API (in core)
Keep a thin interface in core so free code never imports Play Billing:
public interface CastEntitlements {
boolean isPro(Context ctx);
int maxReceivers();
boolean allowsResolution(CastSettings.Resolution r);
boolean allowsStreamProtection();
}
- Default (OSS):
FreeCastEntitlements— e.g. max 1 receiver, cap outgoing long edge at 480 unless dev override, FEC/NACK off or dev-only. - Pro:
ProCastEntitlementsin AAR — reads signed license / Play purchase cache, returns higher limits.
Call sites (minimal first pass):
| Area | Gate |
|---|---|
CastTuningEngine / sender encode |
allowsResolution() |
| Multi-receiver connect | maxReceivers() |
| Stream protection UI | allowsStreamProtection() |
| Developer resolution UI modes | Always allowed when BuildConfig.DEBUG or AppPreferences dev flags |
CommercialFeatures stays developer toggles for ads/IAP/Play review; pro entitlement is runtime product state from Billing + AAR.
Module layout (Gradle)
cast-core/ # android library, published OSS
cast-pro/ # android library, proprietary, implementation project OR maven coords
app/ # application
app/build.gradle:
implementation project(':cast-core')implementation 'com.foxx.androidcast:cast-pro:…'(release) orimplementation project(':cast-pro')(internal)- Optional
ossReleaseflavor:implementation project(':cast-core')only +FreeCastEntitlements
ServiceLoader or manifest meta-data to bind CastEntitlements implementation avoids compileOnly reflection hacks.
Play Billing flow
- User buys SKU (see
InAppPurchaseCoordinator.SKU_PREMIUM). - Pro AAR verifies purchase token, caches entitlement locally (encrypted prefs or Play Library
BillingClient+ acknowledge). CastEntitlementsrefreshes; UI shows unlocked resolutions / receivers.- Offline grace period (e.g. 7 days) documented in product terms.
Build & release
- Version cast-core and cast-pro independently; app pins both in
gradle/libs.versions.toml. - CI: OSS job builds
cast-core+ F-Droid APK; private job signscast-proand release APK. - Do not embed license secrets in OSS; pro AAR may contain obfuscated verification only.
Migration steps (suggested order)
- Extract
CastEntitlements+FreeCastEntitlementsin app (no module split yet). - Wire gates at encode + multi-receiver (behind dev “simulate free tier” toggle).
- Create
:cast-corelibrary — movenetwork/,cast/, shared settings (large refactor). - Add
:cast-prowithProCastEntitlements+ Billing bridge. - Play Console product + privacy policy (COMMERCIAL.md).
Relation to sender resolution test
Developer Sender resolution UI mode (SenderResolutionUi) is for UX experiments only. Production free tier should still enforce caps in CastTuningEngine via entitlements, not by hiding spinner entries alone.