ID3.h revision 83e5850bdf9c8b5c36c364b367b039674eb827ad
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17#ifndef ID3_H_ 18 19#define ID3_H_ 20 21#include <utils/RefBase.h> 22 23namespace android { 24 25struct DataSource; 26struct String8; 27 28struct ID3 { 29 enum Version { 30 ID3_UNKNOWN, 31 ID3_V1, 32 ID3_V1_1, 33 ID3_V2_2, 34 ID3_V2_3 35 }; 36 37 ID3(const sp<DataSource> &source); 38 ~ID3(); 39 40 bool isValid() const; 41 42 Version version() const; 43 44 const void *getAlbumArt(size_t *length, String8 *mime) const; 45 46 struct Iterator { 47 Iterator(const ID3 &parent, const char *id); 48 ~Iterator(); 49 50 bool done() const; 51 void getID(String8 *id) const; 52 void getString(String8 *s) const; 53 const uint8_t *getData(size_t *length) const; 54 void next(); 55 56 private: 57 const ID3 &mParent; 58 char *mID; 59 size_t mOffset; 60 61 const uint8_t *mFrameData; 62 size_t mFrameSize; 63 64 void findFrame(); 65 66 size_t getHeaderLength() const; 67 68 Iterator(const Iterator &); 69 Iterator &operator=(const Iterator &); 70 }; 71 72private: 73 bool mIsValid; 74 uint8_t *mData; 75 size_t mSize; 76 size_t mFirstFrameOffset; 77 Version mVersion; 78 79 bool parseV1(const sp<DataSource> &source); 80 bool parseV2(const sp<DataSource> &source); 81 void removeUnsynchronization(); 82 83 ID3(const ID3 &); 84 ID3 &operator=(const ID3 &); 85}; 86 87} // namespace android 88 89#endif // ID3_H_ 90 91