APacketSource.h revision cf7b9c7aae758ac0b99833915053c63c2ac46e09
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_PACKET_SOURCE_H_ 18 19#define A_PACKET_SOURCE_H_ 20 21#include <media/stagefright/foundation/ABase.h> 22#include <media/stagefright/MediaSource.h> 23#include <utils/threads.h> 24#include <utils/List.h> 25 26namespace android { 27 28struct ABuffer; 29struct ASessionDescription; 30 31struct APacketSource : public MediaSource { 32 APacketSource(const sp<ASessionDescription> &sessionDesc, size_t index); 33 34 virtual status_t start(MetaData *params = NULL); 35 virtual status_t stop(); 36 virtual sp<MetaData> getFormat(); 37 38 virtual status_t read( 39 MediaBuffer **buffer, const ReadOptions *options = NULL); 40 41 void queueAccessUnit(const sp<ABuffer> &buffer); 42 void signalEOS(status_t result); 43 44protected: 45 virtual ~APacketSource(); 46 47private: 48 Mutex mLock; 49 Condition mCondition; 50 51 sp<MetaData> mFormat; 52 List<sp<ABuffer> > mBuffers; 53 status_t mEOSResult; 54 55 DISALLOW_EVIL_CONSTRUCTORS(APacketSource); 56}; 57 58 59} // namespace android 60 61#endif // A_PACKET_SOURCE_H_ 62