LiveDataSource.h revision a44153c1a57202fb538659eb50706e60454d6273
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 LIVE_DATA_SOURCE_H_ 18 19#define LIVE_DATA_SOURCE_H_ 20 21#include <media/stagefright/foundation/ABase.h> 22#include <media/stagefright/DataSource.h> 23#include <utils/threads.h> 24#include <utils/List.h> 25 26namespace android { 27 28struct ABuffer; 29 30struct LiveDataSource : public DataSource { 31 LiveDataSource(); 32 33 virtual status_t initCheck() const; 34 35 virtual ssize_t readAt(off64_t offset, void *data, size_t size); 36 37 void queueBuffer(const sp<ABuffer> &buffer); 38 void queueEOS(status_t finalResult); 39 void reset(); 40 41 size_t countQueuedBuffers(); 42 43protected: 44 virtual ~LiveDataSource(); 45 46private: 47 Mutex mLock; 48 Condition mCondition; 49 50 off64_t mOffset; 51 List<sp<ABuffer> > mBufferQueue; 52 status_t mFinalResult; 53 54 FILE *mBackupFile; 55 56 DISALLOW_EVIL_CONSTRUCTORS(LiveDataSource); 57}; 58 59} // namespace android 60 61#endif // LIVE_DATA_SOURCE_H_ 62