|
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 "comxil3gpmuxervideoinputport.h" |
|
25 #include "comxil3gpmuxerprocessingfunction.h" |
|
26 #include "log.h" |
|
27 |
|
28 const TUint KDefaultBitRate = 5000; |
|
29 |
|
30 |
|
31 |
|
32 COmxIL3GPMuxerVideoInputPort* COmxIL3GPMuxerVideoInputPort::NewL(const TOmxILCommonPortData& aCommonPortData) |
|
33 |
|
34 { |
|
35 DEBUG_PRINTF(_L8("COmxIL3GPMuxerVideoInputPort::NewL")); |
|
36 // TODO these arrays must left empty, to be removed from the video port constructor |
|
37 RArray<OMX_VIDEO_CODINGTYPE> supportedCodings; |
|
38 RArray<OMX_COLOR_FORMATTYPE> supportedColorFormats; |
|
39 CleanupClosePushL(supportedCodings); |
|
40 CleanupClosePushL(supportedColorFormats); |
|
41 |
|
42 COmxIL3GPMuxerVideoInputPort* self = new(ELeave) COmxIL3GPMuxerVideoInputPort(); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(aCommonPortData, supportedCodings, supportedColorFormats); |
|
45 CleanupStack::Pop(self); |
|
46 |
|
47 CleanupStack::PopAndDestroy(2, &supportedCodings); |
|
48 |
|
49 return self; |
|
50 } |
|
51 |
|
52 COmxIL3GPMuxerVideoInputPort::COmxIL3GPMuxerVideoInputPort() |
|
53 { |
|
54 GetParamPortDefinition().format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; |
|
55 } |
|
56 |
|
57 void COmxIL3GPMuxerVideoInputPort::ConstructL(const TOmxILCommonPortData& aCommonPortData, |
|
58 const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedCodings, |
|
59 const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColourFormats) |
|
60 { |
|
61 COmxILVideoPort::ConstructL(aCommonPortData, aSupportedCodings, aSupportedColourFormats); |
|
62 // as there are only four items, do not require a sort order |
|
63 // if this list gets larger consider using binary search |
|
64 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingUnused); |
|
65 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingAVC); |
|
66 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingH263); |
|
67 GetSupportedVideoFormats().AppendL(OMX_VIDEO_CodingMPEG4); |
|
68 |
|
69 GetSupportedColorFormats().AppendL(OMX_COLOR_FormatUnused); |
|
70 |
|
71 GetParamPortDefinition().format.video.nBitrate = KDefaultBitRate; |
|
72 } |
|
73 |
|
74 COmxIL3GPMuxerVideoInputPort::~COmxIL3GPMuxerVideoInputPort() |
|
75 { |
|
76 } |
|
77 |
|
78 OMX_ERRORTYPE COmxIL3GPMuxerVideoInputPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const |
|
79 { |
|
80 OMX_ERRORTYPE omxRetValue = COmxILVideoPort::GetLocalOmxParamIndexes(aIndexArray); |
|
81 if (omxRetValue != OMX_ErrorNone) |
|
82 { |
|
83 return omxRetValue; |
|
84 } |
|
85 |
|
86 return OMX_ErrorNone; |
|
87 } |
|
88 |
|
89 OMX_ERRORTYPE COmxIL3GPMuxerVideoInputPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const |
|
90 { |
|
91 return COmxILVideoPort::GetLocalOmxConfigIndexes(aIndexArray); |
|
92 } |
|
93 |
|
94 OMX_ERRORTYPE COmxIL3GPMuxerVideoInputPort::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
95 TAny* apComponentParameterStructure) const |
|
96 { |
|
97 DEBUG_PRINTF2(_L8("COmxIL3GPMuxerVideoInputPort::GetParameter : aParamIndex[%u]"), aParamIndex); |
|
98 return COmxILVideoPort::GetParameter(aParamIndex, apComponentParameterStructure); |
|
99 } |
|
100 |
|
101 OMX_ERRORTYPE COmxIL3GPMuxerVideoInputPort::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
102 const TAny* apComponentParameterStructure, |
|
103 TBool& aUpdateProcessingFunction) |
|
104 { |
|
105 DEBUG_PRINTF2(_L8("COmxIL3GPMuxerVideoInputPort::SetParameter : aParamIndex[%u]"), aParamIndex); |
|
106 return COmxILVideoPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction); |
|
107 } |
|
108 |
|
109 OMX_ERRORTYPE COmxIL3GPMuxerVideoInputPort::SetFormatInPortDefinition(const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition, |
|
110 TBool& aUpdateProcessingFunction) |
|
111 { |
|
112 if (aPortDefinition.nBufferCountActual > KMaxVideoBuffers) |
|
113 { |
|
114 return OMX_ErrorBadParameter; |
|
115 } |
|
116 |
|
117 const OMX_VIDEO_PORTDEFINITIONTYPE& newVidDef = aPortDefinition.format.video; |
|
118 OMX_VIDEO_PORTDEFINITIONTYPE& myVidDef = GetParamPortDefinition().format.video; |
|
119 |
|
120 if(newVidDef.eColorFormat != OMX_COLOR_FormatUnused) |
|
121 { |
|
122 return OMX_ErrorBadParameter; |
|
123 } |
|
124 // change to FindInUnsignedKeyOrder if many more formats are added |
|
125 // FIXME this should allow OMX_VIDEO_CodingAutoDetect |
|
126 if(GetSupportedVideoFormats().Find(newVidDef.eCompressionFormat) == KErrNotFound) |
|
127 { |
|
128 return OMX_ErrorBadParameter; |
|
129 } |
|
130 |
|
131 // copy the new port definition |
|
132 myVidDef = newVidDef; |
|
133 |
|
134 // ignore parameters which make no sense, either because the output is compressed or because |
|
135 // we are not a display component |
|
136 myVidDef.nSliceHeight = 0; |
|
137 myVidDef.nStride = 0; |
|
138 myVidDef.pNativeRender = NULL; |
|
139 myVidDef.pNativeWindow = NULL; |
|
140 |
|
141 // ignore the MIME type - the field eCompressionFormat will identify the stream type. |
|
142 // if we want to support GetParameter() for the MIME type, I think the component needs to |
|
143 // make a copy of the C string passed in and return a pointer to that. (cMIMEType is a char*). |
|
144 myVidDef.cMIMEType = NULL; |
|
145 |
|
146 aUpdateProcessingFunction = ETrue; |
|
147 |
|
148 return OMX_ErrorNone; |
|
149 } |
|
150 |
|
151 TBool COmxIL3GPMuxerVideoInputPort::IsTunnelledPortCompatible(const OMX_PARAM_PORTDEFINITIONTYPE& /*aPortDefinition*/) const |
|
152 { |
|
153 // TODO (The base class should do this checking) |
|
154 return ETrue; |
|
155 } |
|
156 |
|
157 void COmxIL3GPMuxerVideoInputPort::GetVideoProperties(OMX_U32& aFrameWidth, OMX_U32& aFrameHeight, OMX_U32& aFramerate, OMX_U32& aBitRate) |
|
158 { |
|
159 aFrameWidth = GetParamPortDefinition().format.video.nFrameWidth; |
|
160 aFrameHeight = GetParamPortDefinition().format.video.nFrameHeight; |
|
161 aFramerate = GetParamPortDefinition().format.video.xFramerate; |
|
162 aBitRate = GetParamPortDefinition().format.video.nBitrate; |
|
163 } |