2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ANDROID_MEDIA_METADATA_H__
18 #define ANDROID_MEDIA_METADATA_H__
20 #include <sys/types.h>
21 #include <utils/Errors.h>
22 #include <utils/RefBase.h>
23 #include <utils/SortedVector.h>
30 // Metadata is a class to build/serialize a set of metadata in a Parcel.
32 // This class should be kept in sync with android/media/Metadata.java.
33 // It provides all the metadata ids available and methods to build the
34 // header, add records and adjust the set size header field.
39 // media::Metadata data(&p);
41 // data.appendHeader();
42 // data.appendBool(Metadata::kPauseAvailable, true);
43 // ... more append ...
44 // data.updateLength();
50 typedef SortedVector<Type> Filter;
52 static const Type kAny = 0;
54 // Keep in sync with android/media/Metadata.java
55 static const Type kTitle = 1; // String
56 static const Type kComment = 2; // String
57 static const Type kCopyright = 3; // String
58 static const Type kAlbum = 4; // String
59 static const Type kArtist = 5; // String
60 static const Type kAuthor = 6; // String
61 static const Type kComposer = 7; // String
62 static const Type kGenre = 8; // String
63 static const Type kDate = 9; // Date
64 static const Type kDuration = 10; // Integer(millisec)
65 static const Type kCdTrackNum = 11; // Integer 1-based
66 static const Type kCdTrackMax = 12; // Integer
67 static const Type kRating = 13; // String
68 static const Type kAlbumArt = 14; // byte[]
69 static const Type kVideoFrame = 15; // Bitmap
70 static const Type kCaption = 16; // TimedText
72 static const Type kBitRate = 17; // Integer, Aggregate rate of
73 // all the streams in bps.
75 static const Type kAudioBitRate = 18; // Integer, bps
76 static const Type kVideoBitRate = 19; // Integer, bps
77 static const Type kAudioSampleRate = 20; // Integer, Hz
78 static const Type kVideoframeRate = 21; // Integer, Hz
80 // See RFC2046 and RFC4281.
81 static const Type kMimeType = 22; // String
82 static const Type kAudioCodec = 23; // String
83 static const Type kVideoCodec = 24; // String
85 static const Type kVideoHeight = 25; // Integer
86 static const Type kVideoWidth = 26; // Integer
87 static const Type kNumTracks = 27; // Integer
88 static const Type kDrmCrippled = 28; // Boolean
90 // Playback capabilities.
91 static const Type kPauseAvailable = 29; // Boolean
92 static const Type kSeekBackwardAvailable = 30; // Boolean
93 static const Type kSeekForwardAvailable = 31; // Boolean
94 static const Type kSeekAvailable = 32; // Boolean
96 // @param p[inout] The parcel to append the metadata records
97 // to. The global metadata header should have been set already.
98 explicit Metadata(Parcel *p);
101 // Rewind the underlying parcel, undoing all the changes.
104 // Append the size and 'META' marker.
107 // Once all the records have been added, call this to update the
108 // lenght field in the header.
111 // append* are methods to append metadata.
112 // @param key Is the metadata Id.
113 // @param val Is the value of the metadata.
114 // @return true if successful, false otherwise.
115 // TODO: add more as needed to handle other types.
116 bool appendBool(Type key, bool val);
117 bool appendInt32(Type key, int32_t val);
120 Metadata(const Metadata&);
121 Metadata& operator=(const Metadata&);
124 // Checks the key is valid and not already present.
125 bool checkKey(Type key);
131 } // namespace android::media
132 } // namespace android
134 #endif // ANDROID_MEDIA_METADATA_H__