1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 * |
|
18 */ |
|
19 /* |
|
20 * ============================================================================ |
|
21 * Name : Mp4demux.h |
|
22 * Part of : Videoplayer |
|
23 * Origin : |
|
24 * Created : Mon Sep 10 13:48:59 2001 by jykokkon |
|
25 * Description: |
|
26 * |
|
27 * Version : |
|
28 * %version: 3 %, %date_modified: Wed Jan 28 15:16:13 2009 % by %derived_by: mkarimak % |
|
29 * |
|
30 * --------------------------------------------------------------------------- |
|
31 * Version history: |
|
32 * Template version: 1.02, 21.6.2000 by maparnan |
|
33 * <ccm_history> |
|
34 * |
|
35 * Version: 1, Mon Sep 10 13:49:00 2001 by jykokkon |
|
36 * Ref: ?reference_to_reason_doc_if_any (e.g. ActionDb Id) |
|
37 * ?change_reason_comment |
|
38 * |
|
39 * </ccm_history> |
|
40 * ============================================================================ |
|
41 */ |
|
42 |
|
43 #ifndef __MP4DEMUX_H__ |
|
44 #define __MP4DEMUX_H__ |
|
45 |
|
46 // INCLUDES |
|
47 |
|
48 #ifndef __DEMULTIPLEXER_H__ |
|
49 #include "demultiplexer.h" |
|
50 #endif |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 |
|
54 class CActiveQueue; |
|
55 class CStatusMonitor; |
|
56 class CMP4Parser; |
|
57 |
|
58 // CLASS DEFINITIONS |
|
59 |
|
60 class CMP4Demux : public CDemultiplexer |
|
61 { |
|
62 public: // Constants |
|
63 |
|
64 enum TErrorCode |
|
65 { |
|
66 EInternalAssertionFailure = -2300 |
|
67 }; |
|
68 |
|
69 // The type of data in an output channel |
|
70 enum TChannelDataType |
|
71 { |
|
72 EDataNone = 0, |
|
73 EDataAudio, |
|
74 EDataVideo |
|
75 }; |
|
76 |
|
77 public: // Data structures |
|
78 |
|
79 // Demux parameters |
|
80 struct TStreamParameters |
|
81 { |
|
82 TUint iPicturePeriodMs; |
|
83 TUint iAudioFramesInSample; |
|
84 }; |
|
85 |
|
86 // One output channel |
|
87 struct TOutputChannel |
|
88 { |
|
89 TChannelDataType iDataType; |
|
90 CActiveQueue *iTargetQueue; |
|
91 }; |
|
92 |
|
93 |
|
94 public: // Constructors and destructor |
|
95 |
|
96 /** |
|
97 * Two-phased constructor. |
|
98 */ |
|
99 |
|
100 static CMP4Demux* NewL(CActiveQueue *anInputQueue, |
|
101 TUint aNumChannels, TOutputChannel *aOutputChannels, |
|
102 TStreamParameters *aParameters, |
|
103 CStatusMonitor *aStatusMonitor, |
|
104 CMP4Parser *aParser, |
|
105 TInt aPriority=EPriorityStandard); |
|
106 |
|
107 /** |
|
108 * Destructor. |
|
109 */ |
|
110 ~CMP4Demux(); |
|
111 |
|
112 public: // New functions |
|
113 |
|
114 /** |
|
115 * Read a number of frames to video queue |
|
116 * |
|
117 * @param aCount Number of frames to read |
|
118 * @return Error code |
|
119 */ |
|
120 TInt ReadVideoFrames(TInt aCount); |
|
121 |
|
122 public: // Functions from base classes |
|
123 |
|
124 /** |
|
125 * From CDemultiplexer Start demultiplexing |
|
126 */ |
|
127 void Start(); |
|
128 |
|
129 /** |
|
130 * From CDemultiplexer Stop demultiplexing |
|
131 */ |
|
132 void Stop(); |
|
133 |
|
134 /** |
|
135 * From CDataProcessor Standard active object running method |
|
136 */ |
|
137 void RunL(); |
|
138 |
|
139 /** |
|
140 * From CDataProcessor Called by the input queue object when |
|
141 * the input stream has ended |
|
142 * @param aUserPointer user data pointer |
|
143 */ |
|
144 void StreamEndReached(TAny *aUserPointer); |
|
145 |
|
146 /** |
|
147 * From CDataProcessor Cancels any asynchronous requests pending |
|
148 */ |
|
149 void DoCancel(); |
|
150 |
|
151 private: // Internal methods |
|
152 |
|
153 /** |
|
154 * C++ default constructor. |
|
155 */ |
|
156 CMP4Demux(CActiveQueue *anInputQueue, |
|
157 TUint aNumChannels, TOutputChannel *aOutputChannels, |
|
158 TStreamParameters *aParameters, |
|
159 CStatusMonitor *aStatusMonitor, |
|
160 CMP4Parser *aParser, |
|
161 TInt aPriority); |
|
162 |
|
163 /** |
|
164 * Second-phase constructor |
|
165 */ |
|
166 void ConstructL(); |
|
167 |
|
168 /** |
|
169 * Select audio/video frame to be demuxed next |
|
170 * (used when stream is in a local file) |
|
171 */ |
|
172 void SetFrameType(); |
|
173 |
|
174 /** |
|
175 * Get number of free blocks in target queue |
|
176 * @return TUint number of blocks |
|
177 */ |
|
178 TUint NumFreeBlocks(); |
|
179 |
|
180 /** |
|
181 * Get information about next frame from parser |
|
182 * @return TInt error code |
|
183 */ |
|
184 TInt GetFrameInfo(); |
|
185 |
|
186 /** |
|
187 * Read next frame(s) from parser & send them to |
|
188 * decoder |
|
189 * @return TInt error code |
|
190 */ |
|
191 TInt ReadAndSendFrames(); |
|
192 |
|
193 private: // Data |
|
194 CStatusMonitor *iMonitor; // status monitor object |
|
195 CActiveQueue *iInputQueue; // input data queue |
|
196 CMP4Parser *iParser; // MP4 format parser object |
|
197 |
|
198 TUint iNumOutputChannels; // the number of output channels used |
|
199 TOutputChannel *iOutputChannels; // the output channels |
|
200 |
|
201 TBool iGotFrame; // TRUE if a frame is available |
|
202 |
|
203 TUint iBytesDemuxed; // bytes demuxed during current run |
|
204 |
|
205 TOutputChannel *iVideoChannel; // the channel used for output space checks |
|
206 TOutputChannel *iAudioChannel; // the channel used for output space checks |
|
207 |
|
208 TUint iAudioFramesInSample; // number of audio frames in MP4 sample |
|
209 TUint iPicturePeriodMs; // average coded picture period |
|
210 |
|
211 TBool iDemultiplexing; // are we demuxing? |
|
212 |
|
213 TUint iFrameLen; // length of next frame to be retrieved |
|
214 TChannelDataType iFrameType; // type of next frame to be retrieved |
|
215 |
|
216 TBool iAudioEnd; |
|
217 TBool iVideoEnd; |
|
218 TBool iStreamEnd; // has the stream end been reached? |
|
219 TBool iStreamEndDemuxed; // have we demultiplexed everything up to strem end? |
|
220 TBool iReaderSet; // have we been set as a reader to the input queue? |
|
221 TBool iWriterSet; // have we been set as a writer to the output queues? |
|
222 |
|
223 TPtr8 *iInputBlock; // current input queue block |
|
224 |
|
225 }; |
|
226 |
|
227 #endif // __MP4DEMUX_H__ |
|
228 |
|
229 // End of File |
|