|
1 /* |
|
2 * Copyright (c) 2009 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 #include "mcevideostream.h" |
|
18 #include "mcevideocodec.h" |
|
19 #include "mcesession.h" |
|
20 #include "mcemanager.h" |
|
21 #include "mcefilesource.h" |
|
22 #include "mcemediasink.h" |
|
23 #include "mcecamerasource.h" |
|
24 //#include "mcertpsource.h" |
|
25 #include "mcertpsink.h" |
|
26 #include "mcedisplaysink.h" |
|
27 #include "mceh263codec.h" |
|
28 |
|
29 #define _FLAT_DATA static_cast<CMceComVideoStream*>( iFlatData ) |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // Factory method |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 EXPORT_C CMceVideoStream* CMceVideoStream::NewL() |
|
41 { |
|
42 CMceVideoStream* self = CMceVideoStream::NewLC(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // Factory method |
|
49 // Leaves instance on CleanupStack. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CMceVideoStream* CMceVideoStream::NewLC() |
|
53 { |
|
54 CMceVideoStream* self = new (ELeave) CMceVideoStream(); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // Destructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CMceVideoStream::~CMceVideoStream() |
|
66 { |
|
67 iCodecs.ResetAndDestroy(); |
|
68 iSupportedVideoCodecs.ResetAndDestroy(); |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // Returns codec. |
|
74 // Returns the codecs available to the session. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C const RPointerArray<CMceVideoCodec>& CMceVideoStream::Codecs() |
|
78 { |
|
79 return iCodecs; |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C void CMceVideoStream::AddCodecL( CMceVideoCodec* aCodec ) |
|
88 { |
|
89 __ASSERT_ALWAYS(aCodec, User::Leave(KErrArgument)); |
|
90 iCodecs.AppendL(aCodec); |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C void CMceVideoStream::RemoveCodecL( CMceVideoCodec& aCodec ) |
|
99 { |
|
100 for(int i = 0; i < iCodecs.Count(); i++ ) |
|
101 { |
|
102 if( iCodecs[i] == &aCodec ) |
|
103 { |
|
104 delete iCodecs[i]; |
|
105 iCodecs.Remove( i ); |
|
106 } |
|
107 } |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // NOT IMPLEMENTED YET |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C void CMceVideoStream::ReplaceCodecsL( RPointerArray<CMceVideoCodec>* /*aCodecs*/ ) |
|
116 { |
|
117 User::Leave( KErrNotSupported ); |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C const RPointerArray<const CMceVideoCodec>& |
|
126 CMceVideoStream::SupportedVideoCodecs() const |
|
127 { |
|
128 return iSupportedVideoCodecs; |
|
129 } |
|
130 |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMceVideoStream::InitializeL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMceVideoStream::InitializeL( CMceSession& aParent ) |
|
137 { |
|
138 CMceMediaStream::InitializeL( aParent ); |
|
139 |
|
140 InitializeL( &aParent.Manager() ); |
|
141 |
|
142 for( TInt i = 0; i < iCodecs.Count(); i++ ) |
|
143 { |
|
144 iCodecs[i]->InitializeL( *this ); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMceVideoStream::InitializeL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMceVideoStream::InitializeL( CMceManager* aManager ) |
|
154 { |
|
155 CMceMediaStream::InitializeL( aManager ); |
|
156 if ( aManager && iCodecs.Count() == 0 ) |
|
157 { |
|
158 const RPointerArray<const CMceVideoCodec> supportedCodecs = |
|
159 aManager->SupportedVideoCodecs(); |
|
160 |
|
161 TBool fileCodecAdded( EFalse ); |
|
162 for( TInt i = 0; i < supportedCodecs.Count() && !fileCodecAdded; i++ ) |
|
163 { |
|
164 if ( iSource && iSource->Type() == KMceFileSource ) |
|
165 { |
|
166 // Fake codec using file name |
|
167 CMceFileSource* fileSource = |
|
168 static_cast<CMceFileSource*>(iSource); |
|
169 TBuf8<256*2> fileName; |
|
170 fileName.Copy( fileSource->iFileName ); |
|
171 const TDesC8& currentCodecName( supportedCodecs[i]->SdpName() ); |
|
172 |
|
173 if ( ( fileName.FindF( KMceSDPNameH264() ) >= 0 && |
|
174 currentCodecName.FindF( KMceSDPNameH264() ) >= 0 || |
|
175 ( fileName.FindF( KMceSDPNameH263() ) >= 0 && |
|
176 currentCodecName.FindF( KMceSDPNameH263() ) >= 0 ) ) ) |
|
177 { |
|
178 CMceVideoCodec* codec = supportedCodecs[i]->CloneL(); |
|
179 CleanupStack::PushL( codec ); |
|
180 iCodecs.AppendL( codec ); |
|
181 CleanupStack::Pop( codec ); |
|
182 iState = EInitialized; |
|
183 fileCodecAdded = ETrue; |
|
184 } |
|
185 else |
|
186 { |
|
187 iState = ETranscodingRequired; |
|
188 } |
|
189 |
|
190 } |
|
191 else |
|
192 { |
|
193 CMceVideoCodec* codec = supportedCodecs[i]->CloneL(); |
|
194 CleanupStack::PushL( codec ); |
|
195 iCodecs.AppendL( codec ); |
|
196 CleanupStack::Pop( codec ); |
|
197 } |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CMceVideoStream::IsAllowedCombination |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CMceVideoStream::IsAllowedCombination() |
|
208 { |
|
209 return ETrue; |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // Default C++ constructor. |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 CMceVideoStream::CMceVideoStream() |
|
218 :CMceMediaStream() |
|
219 { |
|
220 iType = KMceVideo; |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // Symbian 2nd phase constructor. |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CMceVideoStream::ConstructL() |
|
229 { |
|
230 } |
|
231 |