1aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber/* 2aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * Copyright (C) 2010 The Android Open Source Project 3aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * 4aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * you may not use this file except in compliance with the License. 6aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * You may obtain a copy of the License at 7aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * 8aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * 10aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * Unless required by applicable law or agreed to in writing, software 11aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * See the License for the specific language governing permissions and 14aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber * limitations under the License. 15aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber */ 16aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 17aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber#ifndef ID3_H_ 18aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 19aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber#define ID3_H_ 20aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 21aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber#include <utils/RefBase.h> 22aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 23aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Hubernamespace android { 24aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 25aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huberstruct DataSource; 26aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huberstruct String8; 27aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 28aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huberstruct ID3 { 29aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber enum Version { 30aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ID3_UNKNOWN, 3143782d3bc9883885f1650bdd74f0bcfc8d7ad3feAndreas Huber ID3_V1, 3243782d3bc9883885f1650bdd74f0bcfc8d7ad3feAndreas Huber ID3_V1_1, 33aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ID3_V2_2, 34c944cbe28ed052d53f634c8e3df1b6d717a64eaeAndreas Huber ID3_V2_3, 35c944cbe28ed052d53f634c8e3df1b6d717a64eaeAndreas Huber ID3_V2_4, 36aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber }; 37aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 38aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ID3(const sp<DataSource> &source); 39aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ~ID3(); 40aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 41aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber bool isValid() const; 42aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 43aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber Version version() const; 44aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 45aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber const void *getAlbumArt(size_t *length, String8 *mime) const; 46aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 47aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber struct Iterator { 48aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber Iterator(const ID3 &parent, const char *id); 49aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ~Iterator(); 50aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 51aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber bool done() const; 52aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber void getID(String8 *id) const; 53aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber void getString(String8 *s) const; 54aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber const uint8_t *getData(size_t *length) const; 55aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber void next(); 56aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 57aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber private: 58aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber const ID3 &mParent; 59aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber char *mID; 60aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber size_t mOffset; 61aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 62aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber const uint8_t *mFrameData; 63aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber size_t mFrameSize; 64aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 65aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber void findFrame(); 66aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 67aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber size_t getHeaderLength() const; 68aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 69aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber Iterator(const Iterator &); 70aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber Iterator &operator=(const Iterator &); 71aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber }; 72aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 73aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huberprivate: 74aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber bool mIsValid; 75aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber uint8_t *mData; 76aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber size_t mSize; 77aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber size_t mFirstFrameOffset; 78aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber Version mVersion; 79aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 8043782d3bc9883885f1650bdd74f0bcfc8d7ad3feAndreas Huber bool parseV1(const sp<DataSource> &source); 8143782d3bc9883885f1650bdd74f0bcfc8d7ad3feAndreas Huber bool parseV2(const sp<DataSource> &source); 82aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber void removeUnsynchronization(); 835d266dd84ef6bbdede935e60b24f34c245982960Andreas Huber bool removeUnsynchronizationV2_4(bool iTunesHack); 84aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 85c944cbe28ed052d53f634c8e3df1b6d717a64eaeAndreas Huber static bool ParseSyncsafeInteger(const uint8_t encoded[4], size_t *x); 86c944cbe28ed052d53f634c8e3df1b6d717a64eaeAndreas Huber 87aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ID3(const ID3 &); 88aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber ID3 &operator=(const ID3 &); 89aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber}; 90aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 91aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber} // namespace android 92aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 93aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber#endif // ID3_H_ 94aee3c6394a367abf283936cb8b8bd85ed028c050Andreas Huber 95