|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include "comxil3gpdemuxervideooutputport.h" |
|
25 #include "comxil3gpdemuxerprocessingfunction.h" |
|
26 #include "tvideoformat.h" |
|
27 |
|
28 |
|
29 _LIT(K3GPDemuxerVideoPortPanic, "COmxIL3GPDemuxerVideoOutputPort"); |
|
30 |
|
31 COmxIL3GPDemuxerVideoOutputPort* COmxIL3GPDemuxerVideoOutputPort::NewL(const TOmxILCommonPortData& aCommonPortData, COmxIL3GPDemuxerProcessingFunction& aProcessingFunction) |
|
32 |
|
33 { |
|
34 // TODO these arrays must left empty, to be removed from the video port constructor |
|
35 RArray<OMX_VIDEO_CODINGTYPE> supportedCodings; |
|
36 RArray<OMX_COLOR_FORMATTYPE> supportedColorFormats; |
|
37 CleanupClosePushL(supportedCodings); |
|
38 CleanupClosePushL(supportedColorFormats); |
|
39 |
|
40 COmxIL3GPDemuxerVideoOutputPort* self = new(ELeave) COmxIL3GPDemuxerVideoOutputPort(aProcessingFunction); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aCommonPortData, supportedCodings, supportedColorFormats); |
|
43 CleanupStack::Pop(self); |
|
44 |
|
45 CleanupStack::PopAndDestroy(2, &supportedCodings); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 COmxIL3GPDemuxerVideoOutputPort::COmxIL3GPDemuxerVideoOutputPort(COmxIL3GPDemuxerProcessingFunction& aProcessingFunction) : |
|
51 iProcessingFunction(&aProcessingFunction) |
|
52 { |
|
53 } |
|
54 |
|
55 void COmxIL3GPDemuxerVideoOutputPort::ConstructL(const TOmxILCommonPortData& aCommonPortData, |
|
56 const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedCodings, |
|
57 const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColorFormats) |
|
58 { |
|
59 COmxILVideoPort::ConstructL(aCommonPortData, aSupportedCodings, aSupportedColorFormats); |
|
60 GetParamPortDefinition().format.video.eCompressionFormat = OMX_VIDEO_CodingAutoDetect; |
|
61 // as there are only four items, do not require a sort order |
|
62 // if this list gets larger consider using binary search |
|
63 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingAutoDetect); |
|
64 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingAVC); |
|
65 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingH263); |
|
66 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingMPEG4); |
|
67 |
|
68 GetSupportedColorFormats().AppendL(OMX_COLOR_FormatUnused); |
|
69 } |
|
70 |
|
71 COmxIL3GPDemuxerVideoOutputPort::~COmxIL3GPDemuxerVideoOutputPort() |
|
72 { |
|
73 } |
|
74 |
|
75 OMX_ERRORTYPE COmxIL3GPDemuxerVideoOutputPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const |
|
76 { |
|
77 OMX_ERRORTYPE omxRetValue = COmxILVideoPort::GetLocalOmxParamIndexes(aIndexArray); |
|
78 if (omxRetValue != OMX_ErrorNone) |
|
79 { |
|
80 return omxRetValue; |
|
81 } |
|
82 |
|
83 TInt err = aIndexArray.InsertInOrder(OMX_IndexParamNumAvailableStreams); |
|
84 // Note that index duplication is OK. |
|
85 if (err == KErrNone || err == KErrAlreadyExists) |
|
86 { |
|
87 err = aIndexArray.InsertInOrder(OMX_IndexParamActiveStream); |
|
88 } |
|
89 |
|
90 if (err != KErrNone && err != KErrAlreadyExists) |
|
91 { |
|
92 return OMX_ErrorInsufficientResources; |
|
93 } |
|
94 |
|
95 return OMX_ErrorNone; |
|
96 } |
|
97 |
|
98 OMX_ERRORTYPE COmxIL3GPDemuxerVideoOutputPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const |
|
99 { |
|
100 return COmxILVideoPort::GetLocalOmxConfigIndexes(aIndexArray); |
|
101 } |
|
102 |
|
103 OMX_ERRORTYPE COmxIL3GPDemuxerVideoOutputPort::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
104 TAny* apComponentParameterStructure) const |
|
105 { |
|
106 switch(aParamIndex) |
|
107 { |
|
108 case OMX_IndexParamNumAvailableStreams: |
|
109 { |
|
110 OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
111 u32Type->nU32 = iProcessingFunction->NumAvailableStreams(COmxIL3GPDemuxer::EPortIndexVideoOutput); |
|
112 return OMX_ErrorNone; |
|
113 } |
|
114 |
|
115 case OMX_IndexParamActiveStream: |
|
116 { |
|
117 OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
118 u32Type->nU32 = iProcessingFunction->ActiveStream(COmxIL3GPDemuxer::EPortIndexVideoOutput); |
|
119 return OMX_ErrorNone; |
|
120 } |
|
121 |
|
122 default: |
|
123 { |
|
124 return COmxILVideoPort::GetParameter(aParamIndex, apComponentParameterStructure); |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 OMX_ERRORTYPE COmxIL3GPDemuxerVideoOutputPort::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
130 const TAny* apComponentParameterStructure, |
|
131 TBool& aUpdateProcessingFunction) |
|
132 { |
|
133 switch(aParamIndex) |
|
134 { |
|
135 case OMX_IndexParamActiveStream: |
|
136 { |
|
137 const OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<const OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
138 return iProcessingFunction->SetActiveStream(COmxIL3GPDemuxer::EPortIndexVideoOutput, u32Type->nU32); |
|
139 } |
|
140 |
|
141 default: |
|
142 { |
|
143 return COmxILVideoPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction); |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 OMX_ERRORTYPE COmxIL3GPDemuxerVideoOutputPort::SetFormatInPortDefinition(const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition, |
|
149 TBool& aUpdateProcessingFunction) |
|
150 { |
|
151 const OMX_VIDEO_PORTDEFINITIONTYPE& newVidDef = aPortDefinition.format.video; |
|
152 OMX_VIDEO_PORTDEFINITIONTYPE& myVidDef = GetParamPortDefinition().format.video; |
|
153 |
|
154 if (aPortDefinition.nBufferCountActual > KMaxVideoBuffers) |
|
155 { |
|
156 return OMX_ErrorBadParameter; |
|
157 } |
|
158 |
|
159 if(newVidDef.eColorFormat != OMX_COLOR_FormatUnused) |
|
160 { |
|
161 return OMX_ErrorBadParameter; |
|
162 } |
|
163 |
|
164 // change to FindInUnsignedKeyOrder if many more formats are added |
|
165 // TODO this should allow OMX_VIDEO_CodingAutoDetect |
|
166 if(GetSupportedVideoFormats().Find(newVidDef.eCompressionFormat) == KErrNotFound) |
|
167 { |
|
168 return OMX_ErrorBadParameter; |
|
169 } |
|
170 |
|
171 // copy the new port definition |
|
172 myVidDef = newVidDef; |
|
173 // ignore parameters which make no sense, either because the output is compressed or because |
|
174 // we are not a display component |
|
175 myVidDef.nSliceHeight = 0; |
|
176 myVidDef.nStride = 0; |
|
177 myVidDef.pNativeRender = NULL; |
|
178 myVidDef.pNativeWindow = NULL; |
|
179 |
|
180 // ignore the MIME type - the field eCompressionFormat will identify the stream type. |
|
181 // if we want to support GetParameter() for the MIME type, I think the component needs to |
|
182 // make a copy of the C string passed in and return a pointer to that. (cMIMEType is a char*). |
|
183 myVidDef.cMIMEType = NULL; |
|
184 |
|
185 aUpdateProcessingFunction = ETrue; |
|
186 |
|
187 return OMX_ErrorNone; |
|
188 } |
|
189 |
|
190 TBool COmxIL3GPDemuxerVideoOutputPort::IsTunnelledPortCompatible(const OMX_PARAM_PORTDEFINITIONTYPE& /*aPortDefinition*/) const |
|
191 { |
|
192 // This function only gets called on input ports, so panic if this is ever called |
|
193 User::Panic(K3GPDemuxerVideoPortPanic, KErrGeneral); |
|
194 return EFalse; // to keep compiler happy |
|
195 } |
|
196 |
|
197 void COmxIL3GPDemuxerVideoOutputPort::FormatDetected(const TSize& aFrameSize, const TVideoFormat& aFormat) |
|
198 { |
|
199 GetParamPortDefinition().format.video.nFrameWidth = aFrameSize.iWidth; |
|
200 GetParamPortDefinition().format.video.nFrameHeight = aFrameSize.iHeight; |
|
201 GetParamPortDefinition().format.video.eCompressionFormat = aFormat.iCoding; |
|
202 // TODO deal with H263/AVC profile |
|
203 } |
|
204 |
|
205 OMX_VIDEO_CODINGTYPE COmxIL3GPDemuxerVideoOutputPort::VideoFormat() |
|
206 { |
|
207 return GetParamPortDefinition().format.video.eCompressionFormat; |
|
208 } |
|
209 |
|
210 /** Returns the number of buffers configured on this port. */ |
|
211 TInt COmxIL3GPDemuxerVideoOutputPort::BufferCount() const |
|
212 { |
|
213 return GetParamPortDefinition().nBufferCountActual; |
|
214 } |