feat: Add support for AES-encrypted video offline playback#127
feat: Add support for AES-encrypted video offline playback#127Balamurugan-Testpress merged 11 commits intomainfrom
Conversation
Balamurugan-Testpress
commented
Feb 20, 2026
- Offline playback failed for AES-protected videos because the player did not fetch, persist, or serve encryption keys when offline.
- Added AES content-protection support with secure key storage during download and key cleanup on video deletion.
- Persisted protection type in offline schema for proper key resolution.
Summary of ChangesHello @Balamurugan-Testpress, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the video playback capabilities by introducing robust support for AES-encrypted videos in offline mode. It resolves a critical issue where such videos could not be played without an internet connection, by implementing secure storage and retrieval mechanisms for encryption keys. The changes ensure a seamless and secure offline viewing experience for users of AES-protected content. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for AES content protection alongside existing DRM, involving the addition of a ContentProtectionType enum and related constants. The LocalOfflineAsset model is updated to store the contentProtectionType, though a reviewer suggested a more robust storage type than an optional string. A new EncryptionKeyRepository is implemented to securely save and retrieve AES encryption keys from the Keychain. The TPStreamsDownloadManager is enhanced to pre-fetch and manage these AES keys for offline content, including their deletion when assets are removed, with a reviewer questioning the dual saving of keys for assetId and videoId. The ResourceLoaderDelegate is refactored to handle both online and offline key requests, utilizing a new ContentProtectionAPI for online fetching and the EncryptionKeyRepository for offline keys. A new VideoURLParser is introduced to extract video IDs from URLs, but reviewers noted potential brittleness in its heuristic and the reliance on url.lastPathComponent for offline key identification. Additionally, the Video model and API parsers are updated to incorporate the new content protection type, and the Realm database schema version is incremented.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request successfully adds support for offline playback of AES-encrypted videos. The changes are well-structured, introducing secure key storage using Keychain, updating the data models, and creating a new API for fetching keys. I've made a few suggestions to improve code clarity and performance, such as removing an unused parameter and using a lazy sequence for key lookups. Overall, this is a great enhancement.
1294e7e to
b455198
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for offline playback of AES-encrypted videos. The changes are comprehensive, introducing logic to fetch, securely store in the Keychain, and serve encryption keys. New components like EncryptionKeyRepository and ContentProtectionAPI are well-designed. My review highlights a critical issue regarding a mismatch in key identifiers that could prevent the feature from working as intended, along with a couple of medium-severity suggestions to enhance error handling in the new Keychain repository.
91ae475 to
e605844
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces significant functionality for AES-encrypted video offline playback. The changes are comprehensive, touching data models, download management, network layers, and the player itself. The implementation of key fetching, secure storage in the Keychain, and manifest hardening for offline playback is well-thought-out. I've identified a few areas for improvement regarding error handling, code clarity, and redundancy, which are detailed in the specific comments. Overall, this is a solid implementation of a complex feature.
…g logic into `EncryptionKeyRepository` and remove `AESKeyManager`.
828407c to
2651c56
Compare
| private let serviceId = "com.tpstreams.iOSPlayerSDK.encryption.keys" | ||
| private let keyPrefix = "VIDEO_ENCRYPTION_KEY_" | ||
|
|
||
| public final class EncryptionKeyRepository { |
There was a problem hiding this comment.
I think we can extract the keychain manipulation logic into a separate util class.
| final class EncryptionKeyService { | ||
| static let shared = EncryptionKeyService() | ||
|
|
||
| private let repository = EncryptionKeyRepository.shared |
There was a problem hiding this comment.
If we extract the keychain into separte util class, we don't need the repository class i think.
We could handle the repository logic in this class itself.