Copyright © 2010 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This is the a Last Call Working Draft of the API for Media Resource 1.0 specification. It has been produced by the Media Annotations Working Group, which is part of the W3C Video on the Web Activity.
The W3C Membership and other interested parties are invited to review the document and send comments through 11 July 2010. Comments must be sent to to public-media-annotation@w3.org mailing list (public archive). Use "[LC Comment API]" in the subject line of your email.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
MediaResource
interface
MetadataSource
interface
Language
interface
MAObject
interface
This section is non-normative.
This specification defines a client-side API to access metadata information related to media resources on the Web. The overall purpose of the API is to provide developers with a convenient access to metadata information stored in different metadata formats. Thereby, the Media Ontology Core Properties will be used as a pivot vocabulary in the API. The description of relations between these core properties and the metadata formats in scope (1.2 Formats in scope) are stored in the Media Ontology in order to provide cross-community data integration. The API is described using the interface definition language [WEBIDL]. The decision to use Web IDL, which offers bindings for ECMAScript and Java, can be based on the Use Cases and Requirements for Ontology and API for Media Resource 1.0 [MEDIA-ANNOT-REQS]. This document clearly states that the focus for this API lies on multimedia services on the Web.
The API serves as a mediator between a developer and the underlying Ontology for Media Resource 1.0 [MEDIA-ANNOT-ONTOLOGY] with the goal to support interoperability between metadata formats. It offers operations to retrieve particular metadata informations represented in a certain metadata format related to media resources on the Web.
This document is being published with the aspiration to gather wide feedback on the yet available API design.
Refers to the formats in scope of Ontology for Media Resource 1.0.
Refers to the Formats out of scope of Ontology for Media Resource 1.0.
In this document the terms "Media Resource", "Property", "Mapping" and "Property value type" are to be interpreted as defined in Section 2 of Ontology for Media Resource 1.0.
We consider two scenarios where the API could be implemented: either in a user agent (scenario 1) or as a web service (scenario 2). The two scenarios are shown in the figure.
In both scenarios, the access to the metadata properties needs the following stack of components:
An implementation of the API for Media Resource (as defined in this document), which providers the actual getter methods for the properties.
An implementation of the mappings from a specific source format to the properties of the media ontology (as defined in Ontology for Media Resource 1.0).
A format specific API to access the metadata. This can be an API for accessing a metadata document describing a media resource (e.g. an XML parser and a set of XPath statements) or an extractor to read metadata embedded in the media resource (e.g. a library to read EXIF information from JPEG images). In order to define the context on which the API for Media Resource is working, it is assumed that there is at least a unidirectional reference from the media resource to the metadata document or vice versa. If this is not the case such a reference needs to be provided by the web application (scenario 1), web service (scenario 2) or media repository (scenario 2).
The JavaScript examples in this document will only work if the API is implemented by the browser.
The API exists of a number of interfaces, described using Web IDL. Implementations of the API should
provide objects implementing the different interfaces. The entire description
can be found in Appendix A. The API is contained
within the MediaResource
interface within the mawg
module. Objects implementing this interface provide the necessary methods to
access metadata properties of a Media Resource. The object holds methods to
identify the actual Media Resource and the metadata sources. All properties can
be accessed through a specific operation getProperty
. When an
attempt to read a property fails, diagnostics information can be obtained using
a diagnosis operation. Subtypes in the API are relevant for those properties
mentioned in 4.1.3 Core
properties of Ontology for
Media Resource 1.0. Lastly, methods are available that allow to iterate
through the available metadata. Next, the different interfaces and exposed
methods are discussed. Finally, examples of the usage of the API can be found
in section 4.
MediaResource
interfaceThe MediaResource
interface offers a number of operations that
allow accessing the metadata of a Media Resource.
Example on how to introduce this in HTML5 by making the HTMLMediaElement
inherit from the MediaResource
interface:
interface HTMLMediaElement : MediaResource, HTMLElement {...}
Example of usage in JavaScript:
mediaResource = document.getElementsByTagName("video")[0]; //mediaResource implements the HTMLMediaElement interface and the MediaResource interface title = mediaResource.getProperty("title"); ...
As shown, the getElementsByTagName
returns a
HTMLMediaElement
which inherits from the
MediaResource
interface. The getProperty
method is
part of this interface so the returned element has an implementation of this
method. By calling the getProperty
method with the argument
"title" we can retrieve the title of the corresponding media resource.
The JavaScript examples in this section all assume that getElementsByTagName() returns an object implementing the MediaResource interface.
Next, we give the Web IDL description of the MediaResource
interface and describe the different operations that are part of it.
[NoInterfaceObject]
interface MediaResource {
boolean selectMAResource (in DOMString mediaResource, in optional MetadataSource
[] metadataSources);
MAObject
[] getProperty (in DOMString propertyName, in optional DOMString fragment, in optional DOMString sourceFormat, in optional DOMString subtype, in optional DOMString language);
DOMString[] getPropertyNamesWithValues (in optional DOMString sourceFormat, in optional DOMString language, in optional DOMString fragment);
DOMString[] getSourceFormatsWithValues (in optional DOMString language);
DOMString getDiagnosis ();
DOMString[] getOriginalData (in DOMString sourceFormat);
};
getDiagnosis
This operation allows to retrieve the status code(e.g., the getProperty operation returning a null value). See Section 4 for details.
DOMString
getOriginalData
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
sourceFormat | DOMString |
✘ | ✘ | This argument identifies a specific metadata format. If a metadata format is defined, only the metadata available in the corresponding metadata format are retrieved. This parameter is optional. |
DOMString[]
getProperty
MAObject
interface, described in (MAObject interface). Depending on
the requested property, the returned objects implement a different
sub-interface (inheriting from the MAObject
interface).
Requesting for the title gives back an array of MAObjects implementing
the Title
interface, requesting the creator results in
MAObjects implementing the Creator
interface and so on.
These interfaces are described in section 3.5 to 3.12.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
propertyName | DOMString |
✘ | ✘ | This argument identifies the property for which the values need to be retrieved. Optional arguments allow to refine the request |
fragment | DOMString |
✘ | ✔ | This argument allows to identify the specific media fragment for which the metadata is requested. This parameter is optional. |
sourceFormat | DOMString |
✘ | ✔ | This argument identifies a specific metadata format. If a metadata format is defined, only the metadata available in the corresponding metadata format are retrieved. This parameter is optional. |
subtype | DOMString |
✘ | ✔ | This argument identifies a subtype. Some properties can be filtered on subtypes. This parameter is optional. |
language | DOMString |
✘ | ✔ | This argument allows to identify the language of the metadata. Only if the metadata is available in the specified language, the values are returned. This parameter is optional. |
MAObject
[]
getPropertyNamesWithValues
getProperty
operation with the corresponding
property name will return at least one object.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
sourceFormat | DOMString |
✘ | ✔ | This argument identifies a specific metadata format. If a metadata format is defined, only the metadata available in the corresponding metadata format are retrieved. This parameter is optional. |
language | DOMString |
✘ | ✔ | This argument allows to identify the language of the metadata. Only if the metadata is available in the specified language, the values are returned. This parameter is optional. |
fragment | DOMString |
✘ | ✔ | This argument allows to identify the specific media fragment for which the metadata is requested. This parameter is optional. |
DOMString[]
getSourceFormatsWithValues
getProperty
operation with the corresponding
source format will return at least one object.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
language | DOMString |
✘ | ✔ | This argument allows to identify the language of the metadata. Only if the metadata is available in the specified language, the values are returned. This parameter is optional. |
DOMString[]
selectMAResource
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
mediaResource | DOMString |
✘ | ✘ | The mediaResource argument identifies the Media Resource. The implementation of the API should try to find relevant metadata sources for this Media Resource |
metadataSources |
|
✘ | ✔ | This argument is an array of objects, each implementing the MetadataSource interface. This interface holds an uri identifying the metadata source (metadataSource) and the name of the actual metadata format (sourceFormat). This parameter is optional. |
boolean
MetadataSource
interfaceMetadataSource
interface is used to identify other metadata
sources.
[NoInterfaceObject]
interface MetadataSource {
attribute DOMString metadataSource;
attribute DOMString sourceFormat;
};
Language
interfaceLanguage
interface is used to identify the language of the
metadata.
[NoInterfaceObject]
interface Language {
attribute DOMString language;
};
language
of type DOMStringMAObject
interfaceMAObject
interface is used as the return type of
MediaResource.getProperty
method. This is used to hold the values
of the requested property. Depending on the requested property, these objects
implement a different interface.
[NoInterfaceObject]
interface MAObject {
attribute DOMString unstructuredValue;
attribute DOMString uri;
attribute DOMString sourceFormat;
attribute DOMString fragmentIdentifier;
attribute DOMString mappingType;
};
fragmentIdentifier
of
type DOMStringmappingType
of type DOMStringsourceFormat
of type DOMStringunstructuredValue
of
type DOMStringuri
of type DOMStringIdentifier
interfaceIdentifier
interface is used as the specific return type of
MediaResource.getProperty
method which has "Identifier" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Identifier : MAObject
{
attribute DOMString value;
attribute DOMString type;
};
Example in JavaScript is as below:
image = document.getElementsByTagName("img")[0]; id = image.getProperty("identifier"); /*Resulting in: id[0].value = "http://www.w3c.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626.JPG" id[0].type = "URI" id[1].value= "ISAN 0000-3BAB-9352-0000-G-0000-0000-Q" id[1].type="ISAN" id[2].value= "urn:uuid:36a87260-1102-11df-8a39-0800200c9a66" id[2].type="UUID" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=identifier
Response (JSON format): { "identifier" : [ {"value" : "http://www.w3c.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626.JPG", "type" : "URI" } , { "value" : "ISAN 0000-3BAB-9352-0000-G-0000-0000-Q", "type" : "ISAN" }, { "value" : "urn:uuid:36a87260-1102-11df-8a39-0800200c9a66", "type" : "UUID" } ] }
Title
interfaceTitle
interface is used as the specific return type of
MediaResource.getProperty
method which has "Title" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Title : MAObject
, Language
{
attribute DOMString value;
attribute DOMString type;
};
Example in JavaScript is as below:
song = document.getElementsByTagName("audio")[0]; title = song.getProperty("title"); /*Resulting in: title[0].value = "Artificial Horizon" title[0].type = "Album title" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=title
Response (JSON format): { "title" : { "value" : "Artificial Horizon" , "type" : "Album title" } }
Language
interfaceLanguage
interface is used as the specific return type of
MediaResource.getProperty
method which has "Language" as a value
of propertyName
parameter. Recommended best practice is to use BCP
47 [BCP-47].
[NoInterfaceObject]
interface Language : MAObject
{
attribute DOMString value;
};
value
of type DOMStringExample in JavaScript is as below:
video = document.getElementsByTagName("video")[0]; language = video.getProperty("language"); /*Resulting in: language[0].value = "en-us" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=language
Response (JSON format): { "language" : { "value" : "en-us" } }
Locator
interfaceLocator
interface is used as the specific return type of
MediaResource.getProperty
method which has "Locator" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Locator : MAObject
{
attribute DOMString value;
};
value
of type DOMStringExample in JavaScript is as below:
image = document.getElementsByTagName("img")[0]; locator = image.getProperty("locator"); /*Resulting in: locator[0].value = "http://www.w3.org/2008/WebVideo/Annotations/wiki/images/9/93/MAWG-Stockholm-20090626.JPG" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=locator
Response (JSON format): { "locator" : { "value" : "http://www.w3.org/2008/WebVideo/Annotations/wiki/images/9/93/MAWG-Stockholm-20090626.JPG" } }
Contributor
interfaceContributor
interface is used as the specific return type of
MediaResource.getProperty
method which has "Contributor" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface Contributor : MAObject
{
attribute DOMString id;
attribute DOMString role;
};
id
of type DOMStringrole
of type DOMStringgetProperty
operation. For the latter a number of suggested
terms are defined:
editor (EBU 11.1)
actor (EBU 25.9)
composer
featured_in
cinematographer
director
musicproducer
producer
screenplayer
writer
distributor (company)
production company
Example in JavaScript is as below:
video = document.getElementsByTagName("video")[0]; contributor = video.getProperty("contributor"); /*Resulting in: contributor[0].id = "http://individuals.example.com/Contributor1" contributor[0].role = "editor" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=contributors
Response (JSON format): { "contributors" : { "id" : "http://individuals.example.com/Contributor1", "role" : "editor" } }
Creator
interfaceCreator
interface is used as the specific return type of
MediaResource.getProperty
method which has "Creator" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Creator : MAObject
{
attribute DOMString value;
};
value
of type DOMStringExample in JavaScript is as below:
video = document.getElementsByTagName("video")[0]; creator = video.getProperty("creator"); /*Resulting in: creator[0].value = "http://individuals.example.com/Author1" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=creator
Response (JSON format): { "creator" : { "value" : "http://individuals.example.com/Author1" } }
CreateDate
interfaceCreateDate
interface is used as the specific return type of
MediaResource.getProperty
method which has "CreateDate" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Date : MAObject
{
attribute DOMString date;
attribute DOMString type;
};
date
of type DOMStringtype
of type DOMStringgetProperty
operation.
Example in JavaScript is as below:
video = document.getElementsByTagName("video")[0]; createdate = video.getProperty("createdate"); /*Resulting in: createdate[0].date = "2009-06-26T15:30:00" createdate[0].type = "date recorded" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=createDate
Response (JSON format): { "createDate" : { "date": "2009-06-26T15:30:00", "type" : "date recorded" } }
Location
interfaceLocation
interface is used as the specific return type of
MediaResource.getProperty
method which has "Location" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Location : MAObject
, Language
{
attribute DOMString name;
attribute Float longitude;
attribute Float latitude;
attribute Float altitude;
attribute DOMString system;
};
altitude
of type Floatsystem
.
latitude
of type Floatsystem
.
longitude
of type Floatsystem
.
name
of type DOMStringsystem
of type DOMStringExample in JavaScript is as below:
video = document.getElementsByTagName("video")[0]; location = video.getProperty("location"); /*Resulting in: location[0].name = "San Jose" location[0].longitude = 37.33986481118008 location[0].latitude = -121.88507080078125 location[0].altitude = 0 location[0].system = "GPS" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=location
Response (JSON format): { "location" : { "name" : "San Jose", "longitude" : 37.33986481118008, "latitude" : -121.88507080078125, "altitude" : 0, system : "GPS" } }
Description
interfaceDescription
interface is used as the specific return type of
MediaResource.getProperty
method which has "Description" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface Description : MAObject
, Language
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; description = image.getProperty("description"); /*Resulting in: description[0].value = "Group picture of the W3C Media Annotations WG at the face-to-face meeting in Stockholm." */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=description
Response (JSON format): { "description" : { "value" : "Group picture of the W3C Media Annotations WG at the face-to-face meeting in Stockholm." } }
Keyword
interfaceKeyword
interface is used as the specific return type of
MediaResource.getProperty
method which has "Keyword" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Keyword : MAObject
, Language
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; keyword = image.getProperty("keyword"); /*Resulting in: keyword[0].value = "W3C Media Annotations WG" keyword[1].value = "meeting" keyword[2].value = "group picture" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=keyword
Response (JSON format): { "keyword" : [ { "value" : "W3C Media Annotations WG" }, { "value" : "meeting" }, { "value" : "group picture" } ] }
Genre
interfaceGenre
interface is used as the specific return type of
MediaResource.getProperty
method which has "Genre" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Genre : MAObject
, Language
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; genre = image.getProperty("genre"); /*Resulting in: genre[0].value = "Work" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=genre
Response (JSON format): { "genre" : { "value" : "Work" } }
Rating
interfaceRating
interface is used as the specific return type of
MediaResource.getProperty
method which has "Rating" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Rating : MAObject
, Language
{
attribute DOMString issuer;
attribute short value;
attribute short minimum;
attribute short maximum;
attribute DOMString type;
};
issuer
of type DOMStringmaximum
of type shortminimum
of type shorttype
of type DOMStringgetProperty
operation. Examples are "Review
Rating", "MPAA", "Personal Rating".
value
of type shortimage = document.getElementsByTagName("img")[0]; rating = image.getProperty("rating"); /*Resulting in: rating[0].issuer = "http://individuals.example.com/ChrisPoppe" rating[0].value = 10.0 rating[0].minimum = 0 rating[0].maximum = 10.0 rating[0].type = "Personal Rating" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=rating
Response (JSON format): "rating" : { "rating" : { "issuer" : "http://individuals.example.com/ChrisPoppe", "value" : 10.0, "minimum" : 0, "maximum" : 10.0, "type" : "Personal Rating" } }
Relation
interfaceRelation
interface is used as the specific return type of
MediaResource.getProperty
method which has "Relation" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Relation : MAObject
{
attribute DOMString id;
attribute DOMString relationship;
};
image = document.getElementsByTagName("img")[0]; relation = image.getProperty("relation"); /*Resulting in: relation[0].id = "http://www.w3.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626_thumb.JPG" relation[0].relationship = "re-edit" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=relation
Response (JSON format): { "relation" : { "id" : "http://www.w3.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626_thumb.JPG" , "relationship" : "re-edit" } }
Collection
interfaceCollection
interface is used as the specific return type of
MediaResource.getProperty
method which has "Collection" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Collection : MAObject
, Language
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; collection = image.getProperty("collection"); /*Resulting in: collection[0].value = "My Work Pictures" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=collection
Response (JSON format): { "collection" : { "value" : "My Work Pictures" } }
Copyright
interfaceCopyright
interface is used as the specific return type of
MediaResource.getProperty
method which has "Copyright" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Copyright : MAObject
, Language
{
attribute DOMString statement;
attribute DOMString[] holder;
};
image = document.getElementsByTagName("img")[0]; copyright = image.getProperty("copyright"); /*Resulting in: copyright[0].statement = "All images in the collection are copyrighted by John Doe" copyright[0].holder[0] = "http://individuals.example.com/JohnDoe" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=rights-properties
Response (JSON format): { "rights-properties" : { "statement" : "All images in the collection are copyrighted by John Doe", "holder" : "http://individuals.example.com/JohnDoe" } }
Policy
interfacePolicy
interface is used as the specific return type of
MediaResource.getProperty
method which has "Policy" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Policy : MAObject
, Language
{
attribute DOMString value;
attribute DOMString link;
attribute DOMString organization;
attribute DOMString type;
};
link
of type DOMStringorganization
of type DOMStringtype
of type DOMStringgetProperty
operation. Examples are
"license", "access", and "privacy".
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; policy = image.getProperty("policy"); /*Resulting in: policy[0].value = "Attribution 2.5" policy[0].organization = "http://creativecommons.org/licenses/by/2.5" policy[0].type = "license" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=policy
Response (JSON format): { "policy" : { "value": "Attribution 2.5 ", "organization" : "http://creativecommons.org/licenses/by/2.5", "type": "license" } }
Publisher
interfacePublisher
interface is used as the specific return type of
MediaResource.getProperty
method which has "Publisher" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Publisher : MAObject
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; publisher = image.getProperty("publisher"); /*Resulting in: publisher[0].value = "http://individuals.example.com/JohnDoe" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=publisher
Response (JSON format): { "publisher" : { "value" : "http://individuals.example.com/JohnDoe" } }
TargetAudience
interfaceTargetAudience
interface is used as the specific return type of
MediaResource.getProperty
method which has "TargetAudience" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface TargetAudience : MAObject
, Language
{
attribute DOMString issuer;
attribute DOMString classification;
attribute DOMString type;
};
classification
of
type DOMStringissuer
of type DOMStringtype
of type DOMStringgetProperty
operation. Examples are "Age
group" and "Geographical".
image = document.getElementsByTagName("img")[0]; targetAudience = image.getProperty("targetaudience"); /*Resulting in: targetAudience[0].issuer = "http://www.fosi.org/icra" targetAudience[0].classification = "no nudity" targetAudience[0].type = "Age Group" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=targetaudience
Response (JSON format): { "targetaudience" : { "issuer" : "http://www.fosi.org/icra", "classification" : "no nudity", "type" : "Age Group" } }
Fragments
interfaceFragments
interface is used as the specific return type of
MediaResource.getProperty
method which has "Fragments" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Fragments : MAObject
{
attribute DOMString role;
attribute DOMString id;
};
movie = document.getElementsByTagName("movie")[0]; fragments = movie.getProperty("fragments"); /*Resulting in: fragments[0].role = "Person" fragments[0].id = "http://www.example.com/movie.mov#xywh=320,320,40,100" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=fragments
Response (JSON format): { "fragments" : { "role" : "Person", "identifier" : "http://www.example.com/movie.mov#xywh=320,320,40,100" } }
NamedFragments
interfaceNamedFragments
interface is used as the specific return type of
MediaResource.getProperty
method which has "NamedFragments" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface NamedFragments : MAObject
{
attribute DOMString name;
attribute DOMString id;
};
image = document.getElementsByTagName("img")[0]; namedFragments = image.getProperty("NamedFragments"); /*Resulting in: namedFragments[0].name = "Joakim Söderberg" namedFragments[0].id = "http://www.w3.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626.JPG#xywh=1600,550,80,150" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=namedFragments
Response (JSON format): { "namedfragments" : { "name" : "Joakim Söderberg", "identifier" : "http://www.w3.org/2008/WebVideo/Annotations/wiki/Image:MAWG-Stockholm-20090626.JPG#xywh=1600,550,80,150" } }
FrameSize
interfaceFrameSize
interface is used as the specific return type of
MediaResource.getProperty
method which has "FrameSize" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface FrameSize : MAObject
{
attribute unsigned long width;
attribute unsigned long height;
attribute DOMString unit;
};
height
of type unsigned longunit
of type DOMStringwidth
of type unsigned longimage = document.getElementsByTagName("img")[0]; frameSize = image.getProperty("framesize"); /*Resulting in: frameSize[0].width = 3.072 frameSize[0].height = 2.304 */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=frameSize
Response (JSON format): { "framesize" : { "width" : 3.072, "height" : 2.304 } }
Compression
interfaceCompression
interface is used as the specific return type of
MediaResource.getProperty
method which has "Compression" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface Compression : MAObject
, Language
{
attribute DOMString value;
};
value
of type DOMStringvideo = document.getElementsByTagName("video")[0]; compression = video.getProperty("compression"); /*Resulting in: compression[0].value = "H.264/AVC" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=compression
Response (JSON format): { "compression" : { "value" : "H.264/AVC" } }
Duration
interfaceDuration
interface is used as the specific return type of
MediaResource.getProperty
method which has "Duration" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Duration : MAObject
{
attribute unsigned long value;
};
value
of type unsigned longvideo = document.getElementsByTagName("video")[0]; duration = video.getProperty("duration"); /*Resulting in: duration[0].value = 3600 */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=duration
Response (JSON format): { "duration" : { "value" : 3600 } }
Format
interfaceFormat
interface is used as the specific return type of
MediaResource.getProperty
method which has "Format" as a value of
propertyName
parameter.
[NoInterfaceObject]
interface Format : MAObject
{
attribute DOMString value;
};
value
of type DOMStringimage = document.getElementsByTagName("img")[0]; format = image.getProperty("format"); /*Resulting in: format[0].value = "image/jpeg" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=format
Response (JSON format): { "format" : { "value" : "image/jpeg" } }
Samplingrate
interfaceSamplingrate
interface is used as the specific return type of
MediaResource.getProperty
method which has "Samplingrate" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface Samplingrate : MAObject
{
attribute unsigned long value;
};
value
of type unsigned longaudio = document.getElementsByTagName("audio")[0]; samplingrate = audio.getProperty("samplingrate"); /*Resulting in: samplingrate[0].value = 44100 */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=samplingrate
Response (JSON format): { "samplingrate" : { "value" : 44100 } }
Framerate
interfaceFramerate
interface is used as the specific return type of
MediaResource.getProperty
method which has "Framerate" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface Framerate : MAObject
{
attribute float value;
};
value
of type floatvideo = document.getElementsByTagName("video")[0]; framerate = video.getProperty("framerate"); /*Resulting in: framerate[0].value = 30 */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=framerate
Response (JSON format): { "framerate" : { "value" : 30 } }
AverageBitrate
interfaceAverageBitrate
interface is used as the specific return type of
MediaResource.getProperty
method which has "AverageBitrate" as a
value of propertyName
parameter.
[NoInterfaceObject]
interface AverageBitrate : MAObject
{
attribute float value;
};
value
of type floatExample is as below:
video = document.getElementsByTagName("video")[0]; bitrate = video.getProperty("averagebitrate"); /*Resulting in: bitrate[0].value = 45.06 */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=averageBitrate
Response (JSON format): { "bitrate" : { "value" : 45.06 } }
NumTracks
interfaceNumTracks
interface is used as the specific return type of
MediaResource.getProperty
method which has "NumTracks" as a value
of propertyName
parameter.
[NoInterfaceObject]
interface NumTracks : MAObject
{
attribute unsigned short value;
attribute DOMString type;
};
type
of type DOMStringvalue
of type unsigned shortvideo = document.getElementsByTagName("video")[0]; numTracks = video.getProperty("NumTracks"); /*Resulting in: numTracks[0].value = 2 numTracks[0].type = "Data streams" */
Usage as a service:
Request: http://example.com/my-media-resource/?ma-query=numtracks
Response (JSON format): { "numtracks" : { "value" : 2 } }
This part illustrates some examples to show how to use the API using
JavaScript in actual implementations. The examples assume that the methods
getElementsByTagName() and getElementsById() return an element that implements
the MediaResource
interface. Moreover, in these examples it is
assumed that the implementation of the API knows where to find the metadata
that corresponds to a specific media resource (if necessary the location of the
metadata can be configured using the selectMAResource
method). The
implementation should provide the mappings of different metadata formats to the
core properties.
//assume that the video elements in HTML5 inherit from the MediaResource interface video = document.getElementsByTagName("video"); //search the video's for the one with title "Apocalypse now" for(i=0; i<video.length; i++) { //request for the titles of the video titles = video[i].getProperty("title"); for(j = 0; j<titles.length; j++) { //check if the title matches if(titles[j].value == "Apocalypse Now") { //request for the director of the video director = video[i].getProperty("contributor","","","director"); /*Resulting in: director[0].id = "Francis Ford Coppola"; */ } } }
//somehow get the mediaResource object that represents the corresponding album album = document.getElementById("JosuhaTree_U2"); //get the id of the second song using the fragments property trackid = album.getProperty("Fragments","","","Song")[1].id; //use this identifier to get the mediaResource object that represents the track mediaResource = new MediaResource(); mediaResource.selectMediaResource(trackid); //get the title of the track title = mediaResource.getProperty("Title")[0].value;
//somehow get the mediaResource object that represents the movie (e.g., see first example) movie = document.getElementById("Planet_of_the_apes_id"); copyright = movie.getProperty("copyright","","","","en-us")[0].statement;
//somehow get the mediaResource object that represents the movie (e.g., see first example) movie = document.getElementById("Apocalypse_Now_id"); genre = movie.getProperty("genre","","","","en-us"); /*Resulting in: genre[0].value = "Action"; genre[1].value = "Drama"; */
This section introduces a set of status codes for the defined API to
indicate the system behaviour. It uses a subset of the HTML/1.1 [HTTP11] status
codes for general informations (e.g., bad request), but also system
specific ones (e.g., property not defined in source format). The specific
status codes have been arranged in the HTML/1.1 [HTTP11] status codes categories.
These codes can be retrieved by calling the getDiagnosis
method.
The set of status codes my be enlarged or changed in later versions of this document. The numerical code range for the system specific status codes start with x62 (x = number of HTML/1.1 [HTTP11] status codes category and 62 = MA).
Numerical Code | Textual Description | Example |
200 | Ok | property delivered correctly |
204 | No Content | property retrieved without content |
206 | Partial Content | only a subset of the available data stored in the result set |
262 | Syntactic Mapping | retrieval used a syntactic mapping |
263 | Semantic Mapping | retrieval used a semantic mapping |
264 | Structured Return Value | result is structured |
265 | Unstructured Return Value | result is unstructured |
400 | Bad Request | syntactical error with respect to the GET method used |
404 | Not Found | the queries resource is not found |
415 | Unsupported Media Type | get duration call on an image data store |
462 | Property not defined in Source Format | location is not defined in MediaRSS |
500 | Internal Server Error | internal library (e.g., extractor) crashes |
501 | Not Implemented | only a subset of GET methods for properties implemented |
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].
This section is non-normative.
This specification defines a client-side API to access metadata information related to media resources on the Web. These APIs will provide the methods for getting metadata information which can be in one of different formats, either as separate document or embedded in media resources.
There are related activity and technical documents in W3C such as Policy Requirements [POLICY-REQS] in DAP WG, ODRL 1.1 [ODRL11], P3P 1.1 [P3P11] and PLING Wiki [PLING-WIKI].
module mawg { interface MediaResource { //Media Resource context boolean selectMAResource(in DOMString mediaResource, in optional MetadataSource[] metadataSources ); // Property Access MAObject[] getProperty(in DOMString propertyName, in optional DOMString fragment, in optional DOMString sourceFormat, in optional DOMString subtype, in optional DOMString language ); //Iterating DOMString[] getPropertyNamesWithValues(in optional DOMString sourceFormat, in optional DOMString language, in optional DOMString fragment); DOMString[] getSourceFormatsWithValues(in optional DOMString language); DOMString getOriginalData(in DOMString sourceFormat); //Operation for retrieval of the reason of an error DOMString getDiagnosis(); }; interface MetadataSource { attribute DOMString metadataSource; attribute DOMString sourceFormat; }; module returnValues { interface MAObject { attribute DOMString unstructuredValue; attribute DOMString uri; attribute DOMString sourceFormat; attribute DOMString fragmentIdentifier; attribute DOMString mappingType; }; interface Language { attribute DOMString language; }; interface UnsignedLongObject: MAObject { attribute unsigned long value; }; interface UnsignedShortObject: MAObject { attribute unsigned short value; }; interface FloatObject: MAObject { attribute float value; }; interface Identifier: MAObject { attribute DOMString value; attribute DOMString type; }; interface Title: MAObject, Language { attribute DOMString value; attribute DOMString type; }; interface Language : MAObject { attribute DOMString value; }; interface Locator : MAObject { attribute DOMString value; }; interface Contributor: MAObject { attribute DOMString id; attribute DOMString role; }; interface Creator : MAObject { attribute DOMString value; }; interface Date: MAObject { attribute DOMString date; attribute DOMString type; }; interface Location: MAObject, Language { attribute DOMString name; attribute Float longitude; attribute Float latitude; attribute Float altitiude; attribute DOMString system; }; interface Description : MAObject, Language { attribute DOMString value; }; interface Keyword : MAObject, Language { attribute DOMString value; }; interface Genre : MAObject, Language { attribute DOMString value; }; interface Rating: MAObject, Language { attribute DOMString issuer; attribute short value; attribute short minimum; attribute short maximum; attribute DOMString context; attribute DOMString type; }; interface Relation: MAObject, Language { attribute DOMString id; attribute DOMString relationship; }; interface Copyright: MAObject, Language { attribute DOMString statement; attribute DOMString[] holder; }; interface Policy: MAObject, Language { attribute DOMString statement; attribute DOMString link; attribute DOMString organization; attribute DOMString type; }; interface Publisher: MAObject { attribute DOMString value; }; interface TargetAudience: MAObject, Language { attribute DOMString issuer; attribute DOMString classification; }; interface Fragment: MAObject, Language { attribute DOMString role; attribute DOMString id; }; interface NamedFragment: MAObject, Language { attribute DOMString name; attribute DOMString id; }; interface FrameSize: MAObject { attribute unsigned long width; attribute unsigned long height; attribute DOMString unit; }; interface Compression : MAObject, Language { attribute DOMString value; }; interface Duration : MAObject { attribute unsigned long value; }; interface Format : MAObject { attribute DOMString value; }; interface Samplingrate : MAObject { attribute unsigned long value; }; interface Framerate : MAObject { attribute float value; }; interface AverageBitrate : MAObject { attribute float value; }; interface NumTracks : MAObject { attribute unsigned short value; attribute DOMString type; }; }; };
This document is the work of the W3C Media Annotations Working Group.
Members of the Working Group are (at the time of writing, and by alphabetical order): Members of the Working Group are (at the time of writing, and by alphabetical order): Werner Bailer (JOANNEUM RESEARCH), Tobias B체rger (University of Innsbruck), Eric Carlson (Apple, Inc.), Pierre-Antoine Champin ((public) Invited expert), Ashish Chawla ((public) Invited expert), Jaime Delgado (Universitat Polit챔cnica de Catalunya), Jean-Pierre EVAIN ((public) Invited expert), Philip J채genstedt (Opera Software), Ralf Klamma ((public) Invited expert), WonSuk Lee (Electronics and Telecommunications Research Institute (ETRI)), V챕ronique Malais챕 (Vrije Universiteit), Erik Mannens (IBBT), Hui Miao (Samsung Electronics Co., Ltd.), Thierry Michel (W3C/ERCIM), Frank Nack (University of Amsterdam), Soohong Daniel Park (Samsung Electronics Co., Ltd.), Silvia Pfeiffer (W3C Invited Experts), Chris Poppe (IBBT), V챠ctor Rodr챠guez (Universitat Polit챔cnica de Catalunya), Felix Sasaki (Potsdam University of Applied Sciences), David Singer (Apple, Inc.), Florian Stegmaier ((public) Invited expert), John Strassner ((public) Invited expert), Joakim S철derberg (ERICSSON), Thai Wey Then (Apple, Inc.), Ruben Tous (Universitat Polit챔cnica de Catalunya), Rapha챘l Troncy (CWI), Vassilis Tzouvaras (K-Space), Davy Van Deursen (IBBT).
The people who have contributed to discussions on public-media-annotation@w3.org are also gratefully acknowledged.