feat(live): add ZIP_STORED media frame pack and unpack helpers - #7152
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
copybara/982888971
branch
6 times, most recently
from
September 18, 2026 19:17
759ecb3 to
57755cc
Compare
copybara-service
Bot
force-pushed
the
copybara/982888971
branch
5 times, most recently
from
September 19, 2026 02:33
8b99875 to
04e6b33
Compare
Realtime live sessions produce streams of `image/*` and `video/*` frames alongside `audio/*` chunks. Persisting each frame as a separate artifact creates `O(F)` storage operations per turn, while adding a batch method to `BaseArtifactService` expands the abstract storage interface across every backend. This change adds `google.adk.live._media_frames` with standalone helpers to pack and unpack sequences of `MediaFrame` entries as a single uncompressed (`zipfile.ZIP_STORED`) `.zip` archive (`application/zip`) that can be saved and loaded through the existing `BaseArtifactService.save_artifact()` / `load_artifact()` methods: - `MediaFrame`: Pydantic model pairing a `types.Blob` frame payload with its capture timestamp. - `pack_media_frames()`: validates non-empty frames and non-decreasing capture timestamps, writes `frames/frame_NNNN.<ext>` members and a `metadata.json` timing manifest into an uncompressed (`zipfile.ZIP_STORED`) ZIP archive, and returns `(archive_bytes, manifest)`. - `unpack_media_frames()`: full round-trip inverse that restores `(list[MediaFrame], manifest)` from archive bytes. - `read_manifest()`, `extract_frame()`, `extract_preview_frame()`, and `summarize_manifest()`: `O(1)` central-directory helpers to inspect the manifest or read individual keyframes (such as `frames/frame_0000.jpeg`) without inflating the full archive or storing a separate preview artifact. Testing: - `pytest tests/unittests/live/test_media_frames.py`: 68 passed. PiperOrigin-RevId: 982888971
copybara-service
Bot
force-pushed
the
copybara/982888971
branch
from
September 19, 2026 02:51
04e6b33 to
7e2d617
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(live): add ZIP_STORED media frame pack and unpack helpers
Realtime live sessions produce streams of
image/*andvideo/*frames alongsideaudio/*chunks. Persisting each frame as a separate artifact createsO(F)storage operations per turn, while adding a batch method to
BaseArtifactServiceexpands the abstract storage interface across every backend.
This change adds
google.adk.live._media_frameswith standalone helpers topack and unpack sequences of
MediaFrameentries as a single uncompressed(
zipfile.ZIP_STORED).ziparchive (application/zip) that can be saved andloaded through the existing
BaseArtifactService.save_artifact()/load_artifact()methods:MediaFrame: Pydantic model pairing atypes.Blobframe payload with itscapture timestamp.
pack_media_frames(): validates non-empty frames and non-decreasing capturetimestamps, writes
frames/frame_NNNN.<ext>members and ametadata.jsontiming manifest into an uncompressed (
zipfile.ZIP_STORED) ZIP archive, andreturns
(archive_bytes, manifest).unpack_media_frames(): full round-trip inverse that restores(list[MediaFrame], manifest)from archive bytes.
read_manifest(),extract_frame(),extract_preview_frame(), andsummarize_manifest():O(1)central-directory helpers to inspect themanifest or read individual keyframes (such as
frames/frame_0000.jpeg)without inflating the full archive or storing a separate preview artifact.
Testing:
pytest tests/unittests/live/test_media_frames.py: 68 passed.