|
1 /* |
|
2 * Copyright (c) 2007 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: Provides services for SDP Security Descriptions. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CMCESECUREMEDIASESSION_H |
|
23 #define CMCESECUREMEDIASESSION_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <e32cmn.h> |
|
28 #include <e32std.h> |
|
29 #include <in_sock.h> |
|
30 #include <stringpool.h> |
|
31 |
|
32 #include "mcemediadefs.h" |
|
33 #include "mcesrv.h" |
|
34 #include "mcecomsession.h" |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CSdpDocument; |
|
38 class CMceComSession; |
|
39 class CMceComAudioStream; |
|
40 class CSdpMediaField; |
|
41 class CMceMediaManager; |
|
42 class CMceSdpCodec; |
|
43 class CMceSecureDesStream; |
|
44 class CMccSecureInterface; |
|
45 class CMceSrvStream; |
|
46 class CMceComCodec; |
|
47 class CMceComMediaStream; |
|
48 |
|
49 |
|
50 /*enum TSecStreamCryptoType |
|
51 { |
|
52 E_CryptoIn =1, |
|
53 E_CryptoOut |
|
54 }; |
|
55 */ |
|
56 const TUint KCyptoCountSendRecv = 2; |
|
57 const TUint KCyptoCountSendOrRecv = 1; |
|
58 /** |
|
59 * Class for storing session specific SDP parameters |
|
60 */ |
|
61 class CMceSecureMediaSession : public CBase |
|
62 { |
|
63 |
|
64 public: // Constructors and destructor |
|
65 |
|
66 /** |
|
67 * Two-phased constructor. |
|
68 */ |
|
69 static CMceSecureMediaSession* NewL( CMceComSession& aSession, |
|
70 CMceMediaManager& aManager, |
|
71 CMccSecureInterface& aSecureInterface ); |
|
72 |
|
73 /** |
|
74 * Two-phased constructor. |
|
75 */ |
|
76 static CMceSecureMediaSession* NewLC( CMceComSession& aSession, |
|
77 CMceMediaManager& aManager, |
|
78 CMccSecureInterface& aSecureInterface ); |
|
79 |
|
80 /** |
|
81 * Destructor. |
|
82 */ |
|
83 ~CMceSecureMediaSession(); |
|
84 |
|
85 public: |
|
86 |
|
87 /** |
|
88 * Createas a SDPDocument based on the streams in iSession. For each stream |
|
89 * a media line is created in the sdp document. Fails if one of the streams |
|
90 * is not supported / failed |
|
91 * @param aStream a MceComMediaStream |
|
92 * @param aMediaLine |
|
93 * @return KErrNone if successful, otherwise failed |
|
94 */ |
|
95 void EncodeSecureDesSdpOfferL( CMceComMediaStream& aStream, |
|
96 CSdpMediaField& aMediaLine); |
|
97 |
|
98 /** |
|
99 * Goes through the secure line from answer and store the secure keys information |
|
100 * @param aStream a MceComMediaStream |
|
101 * @param aMediaLine |
|
102 * @return void |
|
103 */ |
|
104 void DecodeSecureDesSdpAnswerL( CMceComMediaStream& aStream, |
|
105 CSdpMediaField& aMediaLine); |
|
106 |
|
107 /** |
|
108 * Decodes the incoming offer. For each media line in the offer, create corresponding |
|
109 * secure stream and secure keys information |
|
110 * @param aStream a MceComMediaStream |
|
111 * @param aMediaLine |
|
112 * @return void |
|
113 */ |
|
114 void DecodeSecureDesSdpOfferL( CMceComMediaStream& aStream, |
|
115 CSdpMediaField& aMediaLine); |
|
116 |
|
117 /** |
|
118 * Creates an answer based on the OFFER received and the application's |
|
119 * updated preferences. |
|
120 * @param aStream a MceComMediaStream |
|
121 * @param aMediaLine |
|
122 * @return void |
|
123 */ |
|
124 void EncodeSecureDesSdpAnswerL( CMceComMediaStream& aStream, |
|
125 CSdpMediaField& aMediaLine); |
|
126 |
|
127 /** |
|
128 * Decodes an medialine based on the OFFER received and the application's |
|
129 * updated preferences. |
|
130 * @param aStream a MceComMediaStream |
|
131 * @param aMediaLine |
|
132 * @return void |
|
133 */ |
|
134 void DecodeSecureDesSdpUpdateL( CMceComMediaStream& aStream, |
|
135 CSdpMediaField& aMediaLine ); |
|
136 |
|
137 |
|
138 /** |
|
139 * Cleans secure crypto information in SdpDocuemnt MediaLine |
|
140 * @param aStream a MceComMediaStream |
|
141 * @param aMediaLine |
|
142 * @return void |
|
143 */ |
|
144 void CleanSecureCryptoInfoL(CSdpMediaField& aMediaLine); |
|
145 |
|
146 |
|
147 /** |
|
148 * Binds crypto context into stream. Binding must be done |
|
149 * before stream is prepared. |
|
150 * @since Series 60 3.2 |
|
151 * @return KErrNone if success; otherwise system wide error code. |
|
152 */ |
|
153 TInt BindStreamCrypto(); |
|
154 |
|
155 /** |
|
156 * Set stream to be updated when MccEvent called back |
|
157 * @since Series 60 3.2 |
|
158 * @param aContextId context needed to be updated |
|
159 * @return KErrNone if success; otherwise system wide error code. |
|
160 */ |
|
161 void ContextNeedUpdated( TUint32 aContextId ); |
|
162 |
|
163 /** |
|
164 * Copy secure description streams into new secure media session |
|
165 * @since Series 60 3.2 |
|
166 * @param aSession a secure media session to be copied from |
|
167 * @return void |
|
168 */ |
|
169 void CopyStreamsL(CMceSecureMediaSession& aSession); |
|
170 |
|
171 |
|
172 TInt SdpCryptoAttributeCount( CSdpMediaField& aMediaLine); |
|
173 |
|
174 void RemoveSecureCrypto(); |
|
175 |
|
176 private: |
|
177 |
|
178 /** |
|
179 * By default Symbian 2nd phase constructor is private. |
|
180 */ |
|
181 void ConstructL(); |
|
182 |
|
183 /** |
|
184 * C++ default constructor |
|
185 */ |
|
186 CMceSecureMediaSession( CMceComSession& aSession, |
|
187 CMceMediaManager& aManager, |
|
188 CMccSecureInterface& aSecureInterface); |
|
189 |
|
190 TBool IfStreamMatchMedia(CMceComMediaStream& aMediaStream, |
|
191 CMceSecureDesStream& aStream, |
|
192 CSdpMediaField& aMediaLine); |
|
193 |
|
194 TBool IsSecureSdpMsgL( CSdpMediaField& aMediaLine ); |
|
195 |
|
196 public: // Data |
|
197 |
|
198 CMceMediaManager& iManager; |
|
199 |
|
200 // reference to corresponding server stream |
|
201 CMceComSession& iSession; |
|
202 |
|
203 CMccSecureInterface& iSecureInterface; |
|
204 |
|
205 TBool iKeyNeedUpdated; |
|
206 TBool iCryptoContextUpdate; |
|
207 TBool iLSReadyToBind; |
|
208 |
|
209 private: |
|
210 |
|
211 RStringPool iStringPool; |
|
212 const TStringTable* iStringTable; |
|
213 |
|
214 RPointerArray< CMceSecureDesStream > iMceSecureDesStreams; |
|
215 //definitions for unit testing |
|
216 MCEMM_UT_DEFINITIONS |
|
217 friend class UT_CMceSecureMediaSession; |
|
218 }; |
|
219 |
|
220 #endif // CMCESECUREMEDIASESSION_H |
|
221 |
|
222 // End of File |