|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mccmediastream.h" |
|
22 |
|
23 #include <mmcccodecinformation.h> |
|
24 #include <mmccinterface.h> |
|
25 #include "mccsession.h" |
|
26 #include "mcclink.h" |
|
27 |
|
28 |
|
29 const TInt KAudioPrefVoipAudioUplink = 0x05220001; |
|
30 const TInt KAudioPrefVoipAudioDownlink = 0x05210001; |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CMccMediaStream::ConstructL |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 void CMccMediaStream::ConstructL() |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CMccMediaStream::NewL |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CMccMediaStream* CMccMediaStream::NewL( CMccLink* aLink, CMccSession* aSession, |
|
45 TStreamDirection aStreamDirection ) |
|
46 { |
|
47 CMccMediaStream* self = new( ELeave ) CMccMediaStream( |
|
48 aLink, aSession, aStreamDirection ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CMccMediaStream::CMccMediaStream |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CMccMediaStream::CMccMediaStream( CMccLink* aLink, CMccSession* aSession, |
|
60 TStreamDirection aStreamDirection ) : |
|
61 iLink( aLink ), iSession( aSession ), iStreamDirection( aStreamDirection ), |
|
62 iState( EStreamReady ) |
|
63 { |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CMccMediaStream::~CMccMediaStream |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CMccMediaStream::~CMccMediaStream() |
|
71 { |
|
72 if ( ERtcpStreamStarted == iState ) |
|
73 { |
|
74 iSession->MccInterface()->StopStream( iSession->MccSessionId(), |
|
75 iLink->LinkId(), iStreamId ); |
|
76 } |
|
77 if ( iStreamId ) |
|
78 { |
|
79 iSession->MccInterface()->DeleteStream( iSession->MccSessionId(), |
|
80 iLink->LinkId(), iStreamId ); |
|
81 } |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CMccMediaStream::CreateStreamL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CMccMediaStream::CreateStreamL( TInt32& aStreamId, TRequestStatus& aStatus ) |
|
89 { |
|
90 TUint32 dataSinkId; |
|
91 TUint32 dataSourceId; |
|
92 |
|
93 RPointerArray<CMccCodecInformation> codecArray; |
|
94 |
|
95 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( |
|
96 codecArray ); |
|
97 User::LeaveIfError( iSession->MccInterface()->GetCapabilities( codecArray ) ); |
|
98 CleanupStack::Pop( &codecArray ); |
|
99 |
|
100 if ( EUpStream == iStreamDirection ) |
|
101 { |
|
102 User::LeaveIfError( iSession->MccInterface()->AddDataSink( KMccRtpSinkUid, |
|
103 KNullDesC8, dataSinkId ) ); |
|
104 User::LeaveIfError( iSession->MccInterface()->AddDataSource( KUidMmfAudioInput, |
|
105 KNullDesC8, dataSourceId ) ); |
|
106 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
107 |
|
108 User::LeaveIfError( iSession->MccInterface()->CreateStream( |
|
109 iSession->MccSessionId(), iLink->LinkId(), iStreamId, |
|
110 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
111 } |
|
112 else |
|
113 { |
|
114 User::LeaveIfError( iSession->MccInterface()->AddDataSink( KUidMmfAudioOutput, |
|
115 KNullDesC8, dataSinkId ) ); |
|
116 User::LeaveIfError( iSession->MccInterface()->AddDataSource( KMccRtpSourceUid, |
|
117 KNullDesC8, dataSourceId ) ); |
|
118 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioDownlink ); |
|
119 |
|
120 User::LeaveIfError( iSession->MccInterface()->CreateStream( |
|
121 iSession->MccSessionId(), iLink->LinkId(), iStreamId, KMccAudioDownlinkStream, |
|
122 *codecArray[0] ) ); |
|
123 } |
|
124 iState = EStreamCreated; |
|
125 |
|
126 User::LeaveIfError( iSession->MccInterface()->PrepareStream( |
|
127 iSession->MccSessionId(), iLink->LinkId(), iStreamId ) ); |
|
128 |
|
129 aStreamId = iStreamId; |
|
130 aStatus = KRequestPending; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CMccMediaStream::PrepareStreamL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CMccMediaStream::PrepareStreamL( TRequestStatus& aStatus ) |
|
138 { |
|
139 User::LeaveIfError( iSession->MccInterface()->PrepareStream( |
|
140 iSession->MccSessionId(), iLink->LinkId(), iStreamId ) ); |
|
141 |
|
142 aStatus = KRequestPending; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CMccMediaStream::StartStreamL |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CMccMediaStream::StartStreamL( TRequestStatus& aStatus ) |
|
150 { |
|
151 User::LeaveIfError( iSession->MccInterface()->StartStream( |
|
152 iSession->MccSessionId(), iLink->LinkId(), iStreamId ) ); |
|
153 |
|
154 aStatus = KRequestPending; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CMccMediaStream::StreamId |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 TUint32 CMccMediaStream::StreamId() |
|
162 { |
|
163 return iStreamId; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CMccMediaStream::State |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TMccStreamState CMccMediaStream::State() |
|
171 { |
|
172 return iState; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CMccMediaStream::SetState |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CMccMediaStream::SetState( TMccStreamState aState ) |
|
180 { |
|
181 iState = aState; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CMccMediaStream::Delete |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 TInt CMccMediaStream::Delete() |
|
189 { |
|
190 iState = EStreamReady; |
|
191 return iSession->MccInterface()->DeleteStream( iSession->MccSessionId(), |
|
192 iLink->LinkId(), iStreamId ); |
|
193 } |