1a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber/* 2a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * Copyright (C) 2010 The Android Open Source Project 3a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * 4a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * you may not use this file except in compliance with the License. 6a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * You may obtain a copy of the License at 7a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * 8a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * 10a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * Unless required by applicable law or agreed to in writing, software 11a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * See the License for the specific language governing permissions and 14a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber * limitations under the License. 15a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber */ 16a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 17a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#ifndef ANOTHER_PACKET_SOURCE_H_ 18a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 19a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#define ANOTHER_PACKET_SOURCE_H_ 20a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 21a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#include <media/stagefright/foundation/ABase.h> 22a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#include <media/stagefright/MediaSource.h> 23a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#include <utils/threads.h> 24a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#include <utils/List.h> 25a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 2654e6649e4cac3475593f3acb7894837fa1dc61ebAndreas Huber#include "ATSParser.h" 2754e6649e4cac3475593f3acb7894837fa1dc61ebAndreas Huber 28a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Hubernamespace android { 29a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 30a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huberstruct ABuffer; 31a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 32a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huberstruct AnotherPacketSource : public MediaSource { 33a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber AnotherPacketSource(const sp<MetaData> &meta); 34a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 3554e6649e4cac3475593f3acb7894837fa1dc61ebAndreas Huber void setFormat(const sp<MetaData> &meta); 3654e6649e4cac3475593f3acb7894837fa1dc61ebAndreas Huber 37a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber virtual status_t start(MetaData *params = NULL); 38a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber virtual status_t stop(); 39a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber virtual sp<MetaData> getFormat(); 40a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 41a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber virtual status_t read( 42a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber MediaBuffer **buffer, const ReadOptions *options = NULL); 43a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 44a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber bool hasBufferAvailable(status_t *finalResult); 45a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 46a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber status_t nextBufferTime(int64_t *timeUs); 47a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber 48a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber void queueAccessUnit(const sp<ABuffer> &buffer); 49669ad13de924af145771837b339c882e30ea8ce2Andreas Huber 50669ad13de924af145771837b339c882e30ea8ce2Andreas Huber void queueDiscontinuity( 51669ad13de924af145771837b339c882e30ea8ce2Andreas Huber ATSParser::DiscontinuityType type, const sp<AMessage> &extra); 52669ad13de924af145771837b339c882e30ea8ce2Andreas Huber 53a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber void signalEOS(status_t result); 54a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 55a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber status_t dequeueAccessUnit(sp<ABuffer> *buffer); 56a15874665fa785c82afa9f2e8cb3512470c297cbAndreas Huber 57a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huberprotected: 58a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber virtual ~AnotherPacketSource(); 59a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 60a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huberprivate: 61a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber Mutex mLock; 62a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber Condition mCondition; 63a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 6466a051af37c3d7a610802c0c58906dc0faefa6beAndreas Huber bool mIsAudio; 65a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber sp<MetaData> mFormat; 66a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber List<sp<ABuffer> > mBuffers; 67a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber status_t mEOSResult; 68a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 6966a051af37c3d7a610802c0c58906dc0faefa6beAndreas Huber bool wasFormatChange(int32_t discontinuityType) const; 7066a051af37c3d7a610802c0c58906dc0faefa6beAndreas Huber 71a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber DISALLOW_EVIL_CONSTRUCTORS(AnotherPacketSource); 72a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber}; 73a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 74a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 75a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber} // namespace android 76a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber 77a557b24ac4dd568d86b08753f7c0361d04f80d46Andreas Huber#endif // ANOTHER_PACKET_SOURCE_H_ 78