contentmgmt/referencedrmagent/RefTestAgent/streamingrefagent/source/utils/srautils.cpp
changeset 19 cd501b96611d
parent 8 35751d3474b7
child 61 641f389e9157
equal deleted inserted replaced
15:da2ae96f639b 19:cd501b96611d
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include "srautils.h"
    20 #include "srautils.h"
    21 #include <s32file.h>
    21 #include <s32file.h>
       
    22 #ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
    22 #include <sdpfmtattributefield.h>
    23 #include <sdpfmtattributefield.h>
    23 #include <sdpcodecstringpool.h>
    24 #include <sdpcodecstringpool.h>
    24 #include <sdpattributefield.h>
    25 #include <sdpattributefield.h>
       
    26 #endif
    25 
    27 
    26 HBufC8* ExtractKmsIdLC(const TDesC8& aValue)
    28 HBufC8* ExtractKmsIdLC(const TDesC8& aValue)
    27 /**
    29 /**
    28  	Searches the given format attribute value for KMS ID.
    30  	Searches the given format attribute value for KMS ID.
    29  	@param The format attribute value.
    31  	@param The format attribute value.
    70  	@param aSupportedKmsIds The list of supported KMS Ids. The delimeter of the list is semi-colon.
    72  	@param aSupportedKmsIds The list of supported KMS Ids. The delimeter of the list is semi-colon.
    71  	@return ETrue if the test stream agent recognizes the SDP format and the KMS Id is supported.
    73  	@return ETrue if the test stream agent recognizes the SDP format and the KMS Id is supported.
    72 	@return EFalse if the test stream agent fails to recognize the SDP format or is unable to decode the key stream.
    74 	@return EFalse if the test stream agent fails to recognize the SDP format or is unable to decode the key stream.
    73  */
    75  */
    74 	{
    76 	{
       
    77 	TBool supported = EFalse;
       
    78 #ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
    75 	//FormatAttributeFields method is not constant. So create a new instance.
    79 	//FormatAttributeFields method is not constant. So create a new instance.
    76 	CSdpMediaField* sdp = aSdpKeyStream.CloneL();
    80 	CSdpMediaField* sdp = aSdpKeyStream.CloneL();
    77 	CleanupStack::PushL(sdp);
    81 	CleanupStack::PushL(sdp);
    78 	
    82 	
    79 	TInt attributesCount = sdp->FormatAttributeFields().Count();
    83 	TInt attributesCount = sdp->FormatAttributeFields().Count();
    81 		{
    85 		{
    82 		CleanupStack::PopAndDestroy(sdp);
    86 		CleanupStack::PopAndDestroy(sdp);
    83 		return EFalse;
    87 		return EFalse;
    84 		}
    88 		}
    85 
    89 
    86 	TBool supported = EFalse;
       
    87 	HBufC8* kmsid(0);
    90 	HBufC8* kmsid(0);
    88 	
    91 	
    89 	for(TInt i=0; i<attributesCount && !supported; ++i)
    92 	for(TInt i=0; i<attributesCount && !supported; ++i)
    90 		{
    93 		{
    91 		if(sdp->FormatAttributeFields()[i]->Format().Compare(_L8("ipdc-ksm"))) continue;
    94 		if(sdp->FormatAttributeFields()[i]->Format().Compare(_L8("ipdc-ksm"))) continue;
    98 			supported = ETrue;
   101 			supported = ETrue;
    99 			}
   102 			}
   100 		CleanupStack::PopAndDestroy(kmsid);
   103 		CleanupStack::PopAndDestroy(kmsid);
   101 		}
   104 		}
   102 	CleanupStack::PopAndDestroy(sdp);
   105 	CleanupStack::PopAndDestroy(sdp);
   103 	
   106 #else 
       
   107 	(void) aSdpKeyStream;
       
   108 	(void) aSupportedKmsIds;
       
   109 #endif
   104 	return supported;
   110 	return supported;
   105 	}
   111 	}
   106 
   112 
   107 
   113 
   108 
   114 
   167 EXPORT_C void DoSetRightsObjectL(RFs& aFs, CSdpMediaField& aSdp, CSraRightsObject*& aRo, const TDesC& aPrivateFolder)
   173 EXPORT_C void DoSetRightsObjectL(RFs& aFs, CSdpMediaField& aSdp, CSraRightsObject*& aRo, const TDesC& aPrivateFolder)
   168 /**
   174 /**
   169  	Finds and loads the Rights Object specified in the SDP given.
   175  	Finds and loads the Rights Object specified in the SDP given.
   170  */
   176  */
   171 	{
   177 	{
       
   178 #ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
   172 	// Find the rights object if it is defined in the SDP
   179 	// Find the rights object if it is defined in the SDP
   173 	CSdpAttributeField* roAttrField = NULL;
   180 	CSdpAttributeField* roAttrField = NULL;
   174 	TInt count = aSdp.AttributeFields().Count();
   181 	TInt count = aSdp.AttributeFields().Count();
   175 	if(count <= 0)
   182 	if(count <= 0)
   176 		{
   183 		{
   200 	
   207 	
   201 	if(roAttrField) 
   208 	if(roAttrField) 
   202 		{//the rights object is defined in the SDP
   209 		{//the rights object is defined in the SDP
   203 		FindAndLoadRightsObjectL(aFs, roAttrField->Value(), aPrivateFolder, aRo);
   210 		FindAndLoadRightsObjectL(aFs, roAttrField->Value(), aPrivateFolder, aRo);
   204 		}
   211 		}
       
   212 #else
       
   213 	(void) aFs;
       
   214 	(void) aSdp;
       
   215 	(void) aRo;
       
   216 	(void) aPrivateFolder;
       
   217 #endif
   205 	}
   218 	}
   206 
   219 
   207 EXPORT_C void DoSetSdpMediaFieldL(RFs& aFs, CSdpMediaField*& aSdp, CSraRightsObject*& aRo, const TDesC8& aSdpData, const TDesC& aPrivateFolder)
   220 EXPORT_C void DoSetSdpMediaFieldL(RFs& aFs, CSdpMediaField*& aSdp, CSraRightsObject*& aRo, const TDesC8& aSdpData, const TDesC& aPrivateFolder)
   208 /**
   221 /**
   209  	Generates a Service Description Protocol (SDP) object from the given SDP data.
   222  	Generates a Service Description Protocol (SDP) object from the given SDP data.
   213  	@param aRo Rights Object which is found in the private folder of the agent.
   226  	@param aRo Rights Object which is found in the private folder of the agent.
   214  	@param aSdpData The SDP data sent by the client.
   227  	@param aSdpData The SDP data sent by the client.
   215  	@param aPrivateFolder The private folder of the agent.
   228  	@param aPrivateFolder The private folder of the agent.
   216   */
   229   */
   217 	{
   230 	{
       
   231 #ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
   218 	ASSERT(!aSdp);
   232 	ASSERT(!aSdp);
   219 	// Decode the received message into an SDP object
   233 	// Decode the received message into an SDP object
   220 	aSdp = CSdpMediaField::DecodeL(aSdpData,ETrue);
   234 	aSdp = CSdpMediaField::DecodeL(aSdpData,ETrue);
   221 	// Set the specified RO
   235 	// Set the specified RO
   222 	DoSetRightsObjectL(aFs, *aSdp, aRo, aPrivateFolder);
   236 	DoSetRightsObjectL(aFs, *aSdp, aRo, aPrivateFolder);
   223 	}
   237 #else
       
   238 	(void) aFs;
       
   239 	(void) aSdp;
       
   240 	(void) aRo;
       
   241 	(void) aSdpData;
       
   242 	(void) aPrivateFolder;
       
   243 #endif
       
   244 	}