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_AVC_ASSEMBLER_H_ 18 19 #define A_AVC_ASSEMBLER_H_ 20 21 #include "ARTPAssembler.h" 22 23 #include <utils/List.h> 24 #include <utils/RefBase.h> 25 #include <utils/String8.h> 26 27 namespace android { 28 29 struct ABuffer; 30 struct AMessage; 31 32 struct AAVCAssembler : public ARTPAssembler { 33 explicit AAVCAssembler(const sp<AMessage> ¬ify); 34 35 typedef List<sp<ABuffer> > Queue; 36 protected: 37 virtual ~AAVCAssembler(); 38 39 virtual AssemblyStatus assembleMore(const sp<ARTPSource> &source); 40 virtual void onByeReceived(); 41 virtual void packetLost(); 42 43 private: 44 sp<AMessage> mNotifyMsg; 45 46 uint32_t mAccessUnitRTPTime; 47 bool mNextExpectedSeqNoValid; 48 uint32_t mNextExpectedSeqNo; 49 bool mAccessUnitDamaged; 50 bool mFirstIFrameProvided; 51 int32_t mLastCvo; 52 uint64_t mLastIFrameProvidedAtMs; 53 int32_t mWidth; 54 int32_t mHeight; 55 List<sp<ABuffer> > mNALUnits; 56 57 int32_t addNack(const sp<ARTPSource> &source); 58 void checkSpsUpdated(const sp<ABuffer> &buffer); 59 void checkIFrameProvided(const sp<ABuffer> &buffer); 60 bool dropFramesUntilIframe(const sp<ABuffer> &buffer); 61 AssemblyStatus addNALUnit(const sp<ARTPSource> &source); 62 void addSingleNALUnit(const sp<ABuffer> &buffer); 63 AssemblyStatus addFragmentedNALUnit(List<sp<ABuffer> > *queue); 64 bool addSingleTimeAggregationPacket(const sp<ABuffer> &buffer); 65 66 void submitAccessUnit(); 67 68 int32_t pickStartSeq(const Queue *q, uint32_t first, int64_t play, int64_t jit); 69 int32_t deleteUnitUnderSeq(Queue *q, uint32_t seq); 70 71 DISALLOW_EVIL_CONSTRUCTORS(AAVCAssembler); 72 }; 73 74 } // namespace android 75 76 #endif // A_AVC_ASSEMBLER_H_ 77