ATSParser.h revision bc7f5b2e56107cfeaeeab13cf8979379e3c2f139
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 A_TS_PARSER_H_ 18 19#define A_TS_PARSER_H_ 20 21#include <sys/types.h> 22 23#include <media/stagefright/foundation/ABase.h> 24#include <media/stagefright/foundation/AMessage.h> 25#include <utils/Vector.h> 26#include <utils/RefBase.h> 27 28namespace android { 29 30struct ABitReader; 31struct ABuffer; 32struct MediaSource; 33 34struct ATSParser : public RefBase { 35 enum DiscontinuityType { 36 DISCONTINUITY_NONE, 37 DISCONTINUITY_HTTPLIVE, 38 DISCONTINUITY_SEEK, 39 DISCONTINUITY_FORMATCHANGE 40 }; 41 42 ATSParser(); 43 44 void feedTSPacket(const void *data, size_t size); 45 void signalDiscontinuity(DiscontinuityType type); 46 void signalEOS(status_t finalResult); 47 48 enum SourceType { 49 AVC_VIDEO, 50 MPEG2ADTS_AUDIO 51 }; 52 sp<MediaSource> getSource(SourceType type); 53 54 bool PTSTimeDeltaEstablished(); 55 56protected: 57 virtual ~ATSParser(); 58 59private: 60 struct Program; 61 struct Stream; 62 63 Vector<sp<Program> > mPrograms; 64 65 void parseProgramAssociationTable(ABitReader *br); 66 void parseProgramMap(ABitReader *br); 67 void parsePES(ABitReader *br); 68 69 void parsePID( 70 ABitReader *br, unsigned PID, 71 unsigned payload_unit_start_indicator); 72 73 void parseAdaptationField(ABitReader *br); 74 void parseTS(ABitReader *br); 75 76 DISALLOW_EVIL_CONSTRUCTORS(ATSParser); 77}; 78 79} // namespace android 80 81#endif // A_TS_PARSER_H_ 82