Andreas Huber | 7a747b8 | 2010-06-07 15:19:40 -0700 | [diff] [blame] | 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 | |
| 26 | namespace android { |
| 27 | |
| 28 | struct ABuffer; |
| 29 | struct ASessionDescription; |
| 30 | |
| 31 | struct APacketSource : public MediaSource { |
| 32 | APacketSource(const sp<ASessionDescription> &sessionDesc, size_t index); |
| 33 | |
Andreas Huber | 57648e4 | 2010-08-04 10:14:30 -0700 | [diff] [blame] | 34 | status_t initCheck() const; |
| 35 | |
Andreas Huber | 7a747b8 | 2010-06-07 15:19:40 -0700 | [diff] [blame] | 36 | virtual status_t start(MetaData *params = NULL); |
| 37 | virtual status_t stop(); |
| 38 | virtual sp<MetaData> getFormat(); |
| 39 | |
| 40 | virtual status_t read( |
| 41 | MediaBuffer **buffer, const ReadOptions *options = NULL); |
| 42 | |
| 43 | void queueAccessUnit(const sp<ABuffer> &buffer); |
| 44 | void signalEOS(status_t result); |
| 45 | |
Andreas Huber | e0dd7d3 | 2010-08-24 14:33:58 -0700 | [diff] [blame] | 46 | void flushQueue(); |
Andreas Huber | 57648e4 | 2010-08-04 10:14:30 -0700 | [diff] [blame] | 47 | |
Andreas Huber | eeb97d9 | 2010-08-27 13:29:08 -0700 | [diff] [blame] | 48 | int64_t getNormalPlayTimeUs(); |
| 49 | |
| 50 | void setNormalPlayTimeMapping( |
| 51 | uint32_t rtpTime, int64_t normalPlayTimeUs); |
| 52 | |
Andreas Huber | 4d8f66b | 2010-09-01 15:05:28 -0700 | [diff] [blame] | 53 | int64_t getQueueDurationUs(bool *eos); |
| 54 | |
Andreas Huber | 7a747b8 | 2010-06-07 15:19:40 -0700 | [diff] [blame] | 55 | protected: |
| 56 | virtual ~APacketSource(); |
| 57 | |
| 58 | private: |
Andreas Huber | 57648e4 | 2010-08-04 10:14:30 -0700 | [diff] [blame] | 59 | status_t mInitCheck; |
| 60 | |
Andreas Huber | 7a747b8 | 2010-06-07 15:19:40 -0700 | [diff] [blame] | 61 | Mutex mLock; |
| 62 | Condition mCondition; |
| 63 | |
| 64 | sp<MetaData> mFormat; |
| 65 | List<sp<ABuffer> > mBuffers; |
| 66 | status_t mEOSResult; |
| 67 | |
Andreas Huber | 38285db | 2010-10-08 12:06:27 -0700 | [diff] [blame] | 68 | bool mIsAVC; |
| 69 | bool mScanForIDR; |
| 70 | |
Andreas Huber | eeb97d9 | 2010-08-27 13:29:08 -0700 | [diff] [blame] | 71 | uint32_t mClockRate; |
| 72 | |
| 73 | uint32_t mRTPTimeBase; |
| 74 | int64_t mNormalPlayTimeBaseUs; |
| 75 | |
| 76 | int64_t mLastNormalPlayTimeUs; |
| 77 | |
| 78 | void updateNormalPlayTime_l(const sp<ABuffer> &buffer); |
| 79 | |
Andreas Huber | 7a747b8 | 2010-06-07 15:19:40 -0700 | [diff] [blame] | 80 | DISALLOW_EVIL_CONSTRUCTORS(APacketSource); |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | } // namespace android |
| 85 | |
| 86 | #endif // A_PACKET_SOURCE_H_ |