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_MPEG4_ELEM_ASSEMBLER_H_
18 
19 #define A_MPEG4_ELEM_ASSEMBLER_H_
20 
21 #include "ARTPAssembler.h"
22 
23 #include <media/stagefright/foundation/AString.h>
24 
25 #include <utils/List.h>
26 #include <utils/RefBase.h>
27 
28 #include <OMX_Audio.h>
29 
30 namespace android {
31 
32 struct ABuffer;
33 struct AMessage;
34 
35 struct AMPEG4ElementaryAssembler : public ARTPAssembler {
36     AMPEG4ElementaryAssembler(
37             const sp<AMessage> &notify, const AString &desc,
38             const AString &params);
39     virtual bool initCheck();
40 
41 protected:
42     virtual ~AMPEG4ElementaryAssembler();
43 
44     virtual AssemblyStatus assembleMore(const sp<ARTPSource> &source);
45     virtual void onByeReceived();
46     virtual void packetLost();
47 
48 private:
49     sp<AMessage> mNotifyMsg;
50     bool mIsGeneric;
51     AString mParams;
52 
53     unsigned mSizeLength;
54     unsigned mIndexLength;
55     unsigned mIndexDeltaLength;
56     unsigned mCTSDeltaLength;
57     unsigned mDTSDeltaLength;
58     bool mRandomAccessIndication;
59     unsigned mStreamStateIndication;
60     unsigned mAuxiliaryDataSizeLength;
61     bool mHasAUHeader;
62 
63     int32_t mChannelConfig;
64     size_t mSampleRateIndex;
65 
66     uint32_t mAccessUnitRTPTime;
67     bool mNextExpectedSeqNoValid;
68     uint32_t mNextExpectedSeqNo;
69     bool mAccessUnitDamaged;
70     List<sp<ABuffer> > mPackets;
71 
72     AssemblyStatus addPacket(const sp<ARTPSource> &source);
73     void submitAccessUnit();
74 
75     DISALLOW_EVIL_CONSTRUCTORS(AMPEG4ElementaryAssembler);
76 };
77 
78 }  // namespace android
79 
80 #endif  // A_MPEG4_ELEM_ASSEMBLER_H_
81