• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 ///////////////////////////////////////////////////////////////////////////////
19 //
20 // payload_parser.h
21 //
22 // Defines the abstract payload parser type.
23 //
24 ///////////////////////////////////////////////////////////////////////////////
25 
26 #ifndef PAYLOAD_PARSER_H_INCLUDED
27 #define PAYLOAD_PARSER_H_INCLUDED
28 
29 #ifndef OSCL_VECTOR_H_INCLUDED
30 #include "oscl_vector.h"
31 #endif
32 #ifndef OSCL_REFCOUNTER_MEMFRAG_INCLUDED
33 #include "oscl_refcounter_memfrag.h"
34 #endif
35 #ifndef MEDIAINFO_H_INCLUDED
36 #include "media_info.h"
37 #endif
38 
39 ///////////////////////////////////////////////////////////////////////////////
40 //
41 // enum PayloadParserStatus
42 //
43 // Payload parser return codes.
44 //
45 ///////////////////////////////////////////////////////////////////////////////
46 
47 enum PayloadParserStatus
48 {
49     PayloadParserStatus_Failure,
50     PayloadParserStatus_Success,
51     PayloadParserStatus_InputNotExhausted,
52     PayloadParserStatus_MemorAllocFail,
53     PayloadParserStatus_DataNotReady,
54     PayloadParserStatus_EmptyQueue
55 };
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 //
59 // class IPayloadParser
60 //
61 // Abstract payload parser interface.
62 //
63 ///////////////////////////////////////////////////////////////////////////////
64 
65 class IPayloadParser
66 {
67     public:
68 
~IPayloadParser()69         virtual ~IPayloadParser() { };
70 
71         // Init()
72         //
73         // Applies media info data structure to a given payload parser.
74         OSCL_IMPORT_REF virtual bool Init(mediaInfo* config) = 0;
75 
76         // Payload structure
77         //
78         // Used to pass information in and out of the payload parser for
79         // a given stream.
80         class Payload
81         {
82             public:
Payload()83                 Payload() : stream(0), timestamp(0), sequence(0),
84                         marker(false), randAccessPt(false), incompframe(false), consumed(false), endOfNAL(false) {}
Payload(uint32 stream,uint32 timestamp,uint32 sequence,bool marker,bool randAccessPt,bool consumed,bool incompframe,bool endOfNAL)85                 Payload(uint32 stream, uint32 timestamp, uint32 sequence,
86                         bool marker, bool randAccessPt, bool consumed, bool incompframe, bool endOfNAL)
87                 {
88                     this->stream = stream;
89                     this->timestamp = timestamp;
90                     this->sequence = sequence;
91                     this->marker = marker;
92                     this->randAccessPt = randAccessPt;
93                     this->consumed = consumed;
94                     this->incompframe = incompframe;
95                     this->endOfNAL = endOfNAL;
96                 }
Payload(const Payload & aPayLoad)97                 Payload(const Payload& aPayLoad)
98                 {
99                     Copy(aPayLoad);
100                 }
101                 Payload& operator=(const Payload& aPayLoad)
102                 {
103                     if (&aPayLoad != this)
104                     {
105                         Copy(aPayLoad);
106                     }
107                     return (*this);
108                 }
109                 uint32 stream;
110                 uint32 timestamp;
111                 uint32 sequence;
112                 //The marker bit signifies the last packet of an access unit or frame.
113                 bool marker;
114                 bool randAccessPt;
115                 bool incompframe;
116                 bool consumed;
117                 //endOfNAL is used by the RFC3984 (H.264 / AVC) parser and decoder.
118                 //It is set to true for last NAL fragment and whole NALs
119                 //and set to false for the first and middle fragments.
120                 bool endOfNAL;
121                 Oscl_Vector<OsclRefCounterMemFrag, OsclMemAllocator> vfragments;
122 
123             private:
Copy(const Payload & aPayLoad)124                 void Copy(const Payload& aPayLoad)
125                 {
126                     stream = aPayLoad.stream;
127                     timestamp = aPayLoad.timestamp;
128                     sequence = aPayLoad.sequence;
129                     marker = aPayLoad.marker;
130                     randAccessPt = aPayLoad.randAccessPt;
131                     consumed = aPayLoad.consumed;
132                     vfragments = aPayLoad.vfragments;
133                     incompframe = aPayLoad.incompframe;
134                     endOfNAL = aPayLoad.endOfNAL;
135                 }
136         };
137 
138         // Parse()
139         //
140         // Performs parsing of a given input packet consisting of a vector of
141         // buffers. The parsed output is a vector of parsed payloads where each
142         // element in the vector corresponds to the stream id.
143         OSCL_IMPORT_REF virtual PayloadParserStatus Parse(const Payload& inputPacket,
144                 Oscl_Vector<Payload, OsclMemAllocator>& vParsedPayloads) = 0;
145 
146         // Reposition()
147         //
148         // Tells the payload parser a repositioning is in effect.
149         // Change internal seqnum if adjustSequence is enabled
150         OSCL_IMPORT_REF virtual void Reposition(const bool adjustSequence = false, const uint32 stream = 0, const uint32 seqnum = 0) = 0;
151 
152         // GetMinCurrTimestamp()
153         //
154         // Returns the smallest current timestamp among all streams managed
155         // by the payload parser.
156         OSCL_IMPORT_REF virtual uint32 GetMinCurrTimestamp() = 0;
157 };
158 
159 
160 
161 #endif // PAYLOAD_PARSER_H_INCLUDED
162