feat(media): model image, video, and 3D variants - #690
Open
igrigorik wants to merge 1 commit into
Open
Conversation
The existing Media shape is image-oriented: one URL and one pair of dimensions cannot describe alternate video resolutions and codecs, adaptive streaming manifests, device-specific 3D formats, poster images, or an externally hosted player's embed URL. Model Media as an open type discriminator with image, video, and model_3d variants. Keep `url` as the primary resource, add `sources` as the complete set of negotiable renditions, and represent externally hosted playback as a video with `embed_url` rather than a separate media type. Optional `preview` and `name` fields provide a poster and human-readable label; source metadata covers media type, format, dimensions, and byte size. The shape follows the schema.org MediaObject family while using scalar seconds for duration and bytes for file size. REST and MCP examples demonstrate self-hosted video, 3D models, and embedded video without vendor-specific hosts. This is additive and preserves generated-source compatibility: the base keeps `required: [type, url]` plus `width` and `height`, shared constraints are defined once on the base, and unknown media types remain valid but MUST be ignored by Platforms. Follow-up: teach the Schema Reference macro to merge inherited base constraints when rendering description-only variant refinements.
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.
The existing
Mediashape is image-oriented: one URL and one pair of dimensions cannot faithfully describe alternate video resolutions and codecs, adaptive-streaming manifests, device-specific 3D formats, poster images, or an externally hosted player. This update extendsMediaas an open type discriminator with well-knownimage,video, andmodel_3dvariants. It follows the schema.orgMediaObjectfamily while preserving UCP's existing wire contract and generated-source APIs.if/thencomposition.sourcesfor the complete set of available video renditions or 3D encodings.previewfor a poster or thumbnail still.name, distinct from accessibility-orientedalt_text.durationin seconds.type: "video"plusembed_url, rather than introducing a redundantexternal_videotype.Media.typeopen: a Platform must ignore media types it does not recognize.When
sourcesis present andurlidentifies a rendition, the Business should include a source whoseurlmatches the media item'surl. The exception is an externally hosted video, whereurlidentifies a watch page rather than a playable rendition.Self-hosted video
The primary rendition appears in both
urland the completesourcesset:{ "type": "video", "url": "https://cdn.example.com/video-720.mp4", "name": "Product demonstration", "duration": 24, "preview": { "url": "https://cdn.example.com/video-poster.jpg", "width": 1280, "height": 720 }, "sources": [ { "url": "https://cdn.example.com/video-720.mp4", "mime_type": "video/mp4", "width": 1280, "height": 720 }, { "url": "https://cdn.example.com/video.m3u8", "mime_type": "application/vnd.apple.mpegurl" } ] }3D model
A single logical model can advertise the formats supported by different devices:
{ "type": "model_3d", "url": "https://cdn.example.com/product.glb", "preview": { "url": "https://cdn.example.com/product-poster.jpg" }, "sources": [ { "url": "https://cdn.example.com/product.glb", "mime_type": "model/gltf-binary" }, { "url": "https://cdn.example.com/product.usdz", "mime_type": "model/vnd.usdz+zip" } ] }Externally hosted video
The watch page remains the primary URL while
embed_urlidentifies third-party active player content:{ "type": "video", "url": "https://videos.example.com/watch/123", "embed_url": "https://videos.example.com/embed/123", "preview": { "url": "https://cdn.example.com/video-poster.jpg", "width": 1280, "height": 720 } }A Platform may decline to load third-party active content under its security, privacy, or presentation policy and use the watch-page URL instead.
Backward compatibility
This is backward compatible for conforming uses of the released
Mediacontract:typeandurl;widthandheightremain on baseMediafor generated-source compatibility;Checklist