Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "streamagentresolver.h"
17 #include "streamagentinfo.h"
18 #include <caf/streaming/streamagentfactory.h>
19 #include <caf/patchdata.h>
22 #include <caf/caferr.h>
24 using namespace StreamAccess;
26 CStreamAgentResolver* CStreamAgentResolver::NewLC()
28 CStreamAgentResolver* self = new(ELeave) CStreamAgentResolver();
29 CleanupStack::PushL(self);
34 CStreamAgentResolver::CStreamAgentResolver()
38 CStreamAgentResolver::~CStreamAgentResolver()
40 // Reset and Destroy the stream agent information array
41 iStreamAgentInfoArray.ResetAndDestroy();
44 void CStreamAgentResolver::ConstructL()
46 // Construct a list of the available stream agent interface implementations
47 BuildStreamAgentListL();
50 void CStreamAgentResolver::BuildStreamAgentListL()
52 /* Construct a new implementation information array that is used in conjunction with the ECOM
53 * framework in order to retrieve resource data about the available stream agent plug-ins
55 RImplInfoPtrArray agentImplArray;
56 CleanupStack::PushL(TCleanupItem(CleanAgentImplArray, &agentImplArray));
57 REComSession::ListImplementationsL(KUidStreamAgentFactoryInterface, agentImplArray);
59 TInt streamAgentCount = agentImplArray.Count();
61 DEBUG_PRINTF2(_L("Number of streaming agents found on the device: %d"),streamAgentCount);
63 for (TInt i = 0; i < streamAgentCount; ++i)
65 /* In order to load stream agents from sources other than ROM, the patch
66 * data KCafLoadPostProductionAgents must be set to True (non-zero).
67 * Default SymbianOS behavior is to only load file and streaming agents from ROM
69 if ((KCafLoadPostProductionAgents == 0) &&
70 !agentImplArray[i]->RomBased())
72 /* If the stream agent is not in ROM, don't load it because it might
78 /* Construct a seperate element in the CStreamAgentInfo array for each of the
79 * identified stream agent implementations
81 AddStreamAgentL(*agentImplArray[i]);
84 CleanupStack::PopAndDestroy(&agentImplArray);
87 void CStreamAgentResolver::CleanAgentImplArray(TAny* aArray)
89 // Performs the cleanup on the implementation information array
90 static_cast<RImplInfoPtrArray*>(aArray)->ResetAndDestroy();
93 void CStreamAgentResolver::AddStreamAgentL(const CImplementationInformation& aAgentInfo)
95 // Create a new CStreamAgentInfo instance to add to the stream agent list
96 CStreamAgentInfo* agentInformation = CStreamAgentInfo::NewLC(aAgentInfo);
98 TUid agentUid(agentInformation->ImplementationUid());
99 TPtrC agentName(agentInformation->Name());
101 DEBUG_PRINTF3(_L("Stream Agent Identified: 0x%08x (%S)"),agentUid,&agentName);
103 // Append the CStreamAgentInfo object to the stream agent information array
104 User::LeaveIfError(iStreamAgentInfoArray.Append(agentInformation));
105 CleanupStack::Pop(agentInformation);
108 CStreamAgentInfo& CStreamAgentResolver::ResolveSdpKeyStreamL(const CSdpMediaField& aSdpKeyStream) const
110 TInt streamAgentInfoCount = iStreamAgentInfoArray.Count();
112 /* Loop through each of the identified stream agents to determine which (if any) supports
113 * the SDP key management description
115 for(TInt i=0; i < streamAgentInfoCount; ++i)
117 if(iStreamAgentInfoArray[i]->IsKeyStreamSupportedL(aSdpKeyStream))
119 TUid agentUid(iStreamAgentInfoArray[i]->ImplementationUid());
120 TPtrC agentName (iStreamAgentInfoArray[i]->Name());
121 DEBUG_PRINTF3(_L("Key stream is supported by the agent: 0x%08x (%S)"),agentUid,&agentName);
122 return *iStreamAgentInfoArray[i];
126 // If a stream agent capable of decoding the key stream can not be found, leave with KErrCANoAgent
127 DEBUG_PRINTF(_L("A stream agent capable of decoding the key stream can not be found!"));
128 User::Leave(KErrCANoAgent);
130 // Return NULL reference to avoid warnings (should never get here)
131 CStreamAgentInfo* retVal=NULL;