utils: improve debug
[platform/upstream/gstreamer.git] / docs / design / draft-metadata.txt
1 Metadata
2 --------
3
4 This draft recaps the current metadata handling in GStreamer and proposes some
5 additions.
6
7
8 Supported Metadata standards
9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
11 The paragraphs below list supported native metadata standards sorted by type and
12 then in alphabetical order. Some standards have been extended to support
13 additional metadata. GStreamer already supports all of those to some extend. 
14 This is showns in the table below as either [--], [r-], [-w] or [rw] depending on
15 read/write support (08.Feb.2010).
16
17 Audio
18 - mp3
19   ID3v2: [rw]
20     http://www.id3.org/Developer_Information
21   ID3v1: [rw] 
22     http://www.id3.org/ID3v1
23   XMP: [--] (inside ID3v2 PRIV tag of owner XMP)
24     http://www.adobe.com/devnet/xmp/
25 - ogg/vorbis
26   vorbiscomment: [rw] 
27     http://www.xiph.org/vorbis/doc/v-comment.html
28     http://wiki.xiph.org/VorbisComment
29 - wav
30   LIST/INFO chunk: [rw]
31     http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info
32     http://www.kk.iij4u.or.jp/~kondo/wave/mpidata.txt
33   XMP: [--]
34     http://www.adobe.com/devnet/xmp/
35
36 Video
37 - 3gp
38   {moov,trak}.udta:  [rw]
39      http://www.3gpp.org/ftp/Specs/html-info/26244.htm 
40   ID3V2: [--]
41      http://www.3gpp.org/ftp/Specs/html-info/26244.htm 
42      http://www.mp4ra.org/specs.html#id3v2
43 - avi
44   LIST/INFO chunk: [rw]
45     http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info
46     http://www.kk.iij4u.or.jp/~kondo/wave/mpidata.txt
47   XMP: [--] (inside "_PMX" chunk)
48     http://www.adobe.com/devnet/xmp/
49 - asf
50   ??: 
51   XMP: [--]
52     http://www.adobe.com/devnet/xmp/
53 - flv [--]
54   XMP: (inside onXMPData script data tag)
55     http://www.adobe.com/devnet/xmp/
56 - mkv
57   tags: [rw]
58     http://www.matroska.org/technical/specs/tagging/index.html
59 - mov
60   XMP: [--] (inside moov.udta.XMP_ box)
61     http://www.adobe.com/devnet/xmp/
62 - mp4
63   {moov,trak}.udta: [rw]
64     http://standards.iso.org/ittf/PubliclyAvailableStandards/c051533_ISO_IEC_14496-12_2008.zip
65   moov.udta.meta.ilst: [rw]
66     http://atomicparsley.sourceforge.net/
67     http://atomicparsley.sourceforge.net/mpeg-4files.html
68   ID3v2: [--]
69     http://www.mp4ra.org/specs.html#id3v2
70   XMP: [--] (inside UUID box)
71     http://www.adobe.com/devnet/xmp/
72 - mxf
73   ??
74
75 Images
76 - gif
77   XMP: [--]
78     http://www.adobe.com/devnet/xmp/
79 - jpg
80   jif: [rw] (only comments)
81   EXIF: [rw] (via metadata plugin)
82     http://www.exif.org/specifications.html
83   IPTC: [rw] (via metadata plugin)
84     http://www.iptc.org/IPTC4XMP/
85   XMP: [rw] (via metadata plugin)
86     http://www.adobe.com/devnet/xmp/
87 - png
88   XMP: [--]
89     http://www.adobe.com/devnet/xmp/
90
91 further Links:
92 http://age.hobba.nl/audio/tag_frame_reference.html
93 http://wiki.creativecommons.org/Tracker_CC_Indexing
94
95
96 Current Metadata handling
97 ~~~~~~~~~~~~~~~~~~~~~~~~~
98
99 When reading files, demuxers or parsers extract the metadata. It will be sent 
100 a GST_EVENT_TAG to downstream elements. When a sink element receives a tag
101 event, it will post a GST_MESSAGE_TAG message on the bus with the contents of
102 the tag event.
103
104 Elements receiving GST_EVENT_TAG events can mangle them, mux them into the 
105 buffers they send or just pass them through. Usually is muxers that will format
106 the tag data into the form required by the format they mux. Such elements would
107 also implement the GstTagSetter interface to receive tags from the application.
108
109   +----------+
110   | demux    |
111  sink       src --> GstEvent(tag) over GstPad to downstream element
112   +----------+
113
114            method call over GstTagSetter interface from application
115                                                           |
116                                                           v
117                                                     +----------+
118                                                     | mux      |
119 GstEvent(tag) over GstPad from upstream element --> sink       src
120                                                     +----------+
121
122 The data used in all those interfaces is GstTagList. It is based on a 
123 GstStructure which is like a hash table with differently typed entries. The key
124 is always a string/GQuark. Many keys are predefined in GStreamer core. More keys
125 are defined in gst-plugins-base/gst-libs/gst/tag/tag.h.
126 If elements and applications use predefined types, it is possible to transcode a
127 file from one format into another while preserving all known and mapped
128 metadata.
129
130
131 Issues
132 ~~~~~~
133
134 Unknown/Unmapped metadata
135 ^^^^^^^^^^^^^^^^^^^^^^^^^
136
137 Right now GStreamer can lose metadata when transcoding, remuxing content. This
138 can happend as we don't map all metadata fields to generic ones.
139
140 We should probably also add the whole metadata blob to the GstTagList. We would
141 need a GST_TAG_SYSTEM_xxx define (e.g. GST_TAG_SYSTEM_ID3V2) for each standard.
142 The content is not printable and should be treated as binary if not known. The
143 tag is not mergeable - call gst_tag_register() with GstTagMergeFunc=NULL. Also
144 the tag data is only useful for upstream elements, not for the application. 
145
146 A muxer would first scan a taglist for known system tags. Unknown tags are
147 ignored as already. It would first populate its own metadata store with the
148 entries from the system tag and the update the entries with the data in normal
149 tags.
150
151 Below is an initial list of tag systems:
152 ID3V1           - GST_TAG_SYSTEM_ID3V1
153 ID3V2           - GST_TAG_SYSTEM_ID3V2
154 RIFF_INFO       - GST_TAG_SYSTEM_RIFF_INFO
155 XMP             - GST_TAG_SYSTEM_XMP
156
157 We would basically need this for each container format.
158
159 See also https://bugzilla.gnome.org/show_bug.cgi?id=345352
160
161 Lost metadata
162 ^^^^^^^^^^^^^
163
164 A case slighly different from the previous is that when an application sets a
165 GstTagList on a pipeline. Right elements consuming tags do not report which tags
166 have been consumed.  Especially when using elements that make metadata 
167 persistent, we have no means of knowing which of the tags made it into the 
168 target stream and which were not serialized. Ideally the application would like
169 to know which kind of metadata is accepted by a pipleine to reflect that in the
170 UI.
171
172 Although it is in practise so that elements implementing GstTagSetter are the
173 ones that serialize, this does not have to be so. Otherwise we could add a
174 means to that interface, where elements add the tags they have serialized. The
175 application could build one list from all the tag messages and then query all
176 the serialized tags from tag-setters. The delta tells what has not been
177 serialized.
178
179 A different approach would be to query the list of supported tags in advance.
180 This could be a query (GST_QUERY_TAG_SUPPORT). The query result could be a list
181 of elements and their tags. As a convenience we could flatten the list of tags
182 for the top-level element (if the query was sent to a bin) and add that.
183
184 Tags are per Element
185 ^^^^^^^^^^^^^^^^^^^^
186
187 In many cases we want tags per stream. Even metadata standards like mp4/3gp
188 metadata supports that. Right now GST_MESSAGE_SRC(tags) is the element. We tried
189 changing that to the pad, but that broke applications.
190 Also we miss the symmetric functionality in GstTagSetter. This interface is
191 usually implemented by elements.
192
193 Open bugs
194 ^^^^^^^^^
195
196 https://bugzilla.gnome.org/buglist.cgi?query_format=advanced;short_desc=tag;bug_status=UNCONFIRMED;bug_status=NEW;bug_status=ASSIGNED;bug_status=REOPENED;bug_status=NEEDINFO;short_desc_type=allwordssubstr;product=GStreamer
197
198 Add GST_TAG_MERGE_REMOVE
199 https://bugzilla.gnome.org/show_bug.cgi?id=560302
200
201