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 
40 protected:
41     virtual ~AMPEG4ElementaryAssembler();
42 
43     virtual AssemblyStatus assembleMore(const sp<ARTPSource> &source);
44     virtual void onByeReceived();
45     virtual void packetLost();
46 
47 private:
48     sp<AMessage> mNotifyMsg;
49     bool mIsGeneric;
50     AString mParams;
51 
52     unsigned mSizeLength;
53     unsigned mIndexLength;
54     unsigned mIndexDeltaLength;
55     unsigned mCTSDeltaLength;
56     unsigned mDTSDeltaLength;
57     bool mRandomAccessIndication;
58     unsigned mStreamStateIndication;
59     unsigned mAuxiliaryDataSizeLength;
60     bool mHasAUHeader;
61 
62     int32_t mChannelConfig;
63     size_t mSampleRateIndex;
64 
65     uint32_t mAccessUnitRTPTime;
66     bool mNextExpectedSeqNoValid;
67     uint32_t mNextExpectedSeqNo;
68     bool mAccessUnitDamaged;
69     List<sp<ABuffer> > mPackets;
70 
71     AssemblyStatus addPacket(const sp<ARTPSource> &source);
72     void submitAccessUnit();
73 
74     DISALLOW_EVIL_CONSTRUCTORS(AMPEG4ElementaryAssembler);
75 };
76 
77 }  // namespace android
78 
79 #endif  // A_MPEG4_ELEM_ASSEMBLER_H_
80