M3UParser.h revision 2a4d22d79e927f2245537921e10fc5fda1c47a29
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 M3U_PARSER_H_ 18 19#define M3U_PARSER_H_ 20 21#include <media/stagefright/foundation/ABase.h> 22#include <media/stagefright/foundation/AMessage.h> 23#include <media/stagefright/foundation/AString.h> 24#include <utils/Vector.h> 25 26namespace android { 27 28struct M3UParser : public RefBase { 29 M3UParser(const char *baseURI, const void *data, size_t size); 30 31 status_t initCheck() const; 32 33 bool isExtM3U() const; 34 bool isVariantPlaylist() const; 35 36 sp<AMessage> meta(); 37 38 size_t size(); 39 bool itemAt(size_t index, AString *uri, sp<AMessage> *meta = NULL); 40 41protected: 42 virtual ~M3UParser(); 43 44private: 45 struct Item { 46 AString mURI; 47 sp<AMessage> mMeta; 48 }; 49 50 status_t mInitCheck; 51 52 AString mBaseURI; 53 bool mIsExtM3U; 54 bool mIsVariantPlaylist; 55 56 sp<AMessage> mMeta; 57 Vector<Item> mItems; 58 59 status_t parse(const void *data, size_t size); 60 61 static status_t parseMetaData( 62 const AString &line, sp<AMessage> *meta, const char *key); 63 64 static status_t parseStreamInf( 65 const AString &line, sp<AMessage> *meta); 66 67 static status_t ParseInt32(const char *s, int32_t *x); 68 69 DISALLOW_EVIL_CONSTRUCTORS(M3UParser); 70}; 71 72} // namespace android 73 74#endif // M3U_PARSER_H_ 75