mpx/commonframework/common/src/mpxmedia.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of media
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mpxlog.h>
       
    20 #include <mpxuser.h>
       
    21 #include "mpxmedia.h"
       
    22 #include "mpxmediaarray.h"
       
    23 #include "mpxcollectionpath.h"
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CMPXMedia::NewL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CMPXMedia* CMPXMedia::NewL()
       
    30     {
       
    31     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    32     CleanupStack::PushL(m);
       
    33     m->CMPXMediaBase::ConstructL();
       
    34     CleanupStack::Pop(m);
       
    35     return m;
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CMPXMedia::NewL
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CMPXMedia* CMPXMedia::NewL(const TArray<TInt>& aSupportedIds)
       
    43     {
       
    44     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    45     CleanupStack::PushL(m);
       
    46     m->ConstructL(aSupportedIds);
       
    47     CleanupStack::Pop(m);
       
    48     return m;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CMPXMedia::NewL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CMPXMedia* CMPXMedia::NewL(RReadStream& aStream)
       
    56     {
       
    57     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    58     CleanupStack::PushL(m);
       
    59     m->ConstructL(aStream);
       
    60     CleanupStack::Pop(m);
       
    61     return m;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CMPXMedia::NewL
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CMPXMedia* CMPXMedia::NewL(TInt aDataHandle)
       
    69 
       
    70     {
       
    71     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    72     CleanupStack::PushL(m);
       
    73     m->CMPXMediaBase::ConstructL(aDataHandle);
       
    74     CleanupStack::Pop(m);
       
    75     return m;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CMPXMedia::NewL
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C CMPXMedia* CMPXMedia::NewL(const CMPXMedia& aMedia)
       
    83     {
       
    84     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    85     CleanupStack::PushL(m);
       
    86     m->CMPXMediaBase::ConstructL(aMedia);
       
    87     CleanupStack::Pop(m);
       
    88     return m;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CMPXMedia::CopyL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C CMPXMedia* CMPXMedia::CopyL(const CMPXMedia& aMedia)
       
    96     {
       
    97     CMPXMedia* m=new(ELeave)CMPXMedia();
       
    98     CleanupStack::PushL(m);
       
    99     m->CopyConstructL(aMedia);
       
   100     CleanupStack::Pop(m);
       
   101     return m;
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------------------------
       
   105 // Overloaded assignment operator
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C CMPXMedia& CMPXMedia::operator=(const CMPXMedia& aMedia)
       
   109     {
       
   110 //    MPX_FUNC_EX("CMPXMedia::operator=()");
       
   111     MPX_ASSERT(aMedia.iData&&aMedia.iDataHandle);
       
   112     MPX_ASSERT(iClientHandle);
       
   113     //
       
   114     if (this!=&aMedia)
       
   115         {
       
   116         Clear();
       
   117         iDataHandle=aMedia.iDataHandle;
       
   118         iData=aMedia.iData;
       
   119         iData->AddRef(iClientHandle);
       
   120         } // otherwise assign itself
       
   121     return *this;
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // Destructor
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 EXPORT_C CMPXMedia::~CMPXMedia()
       
   129     {
       
   130     iAttributes.Close();
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CMPXMedia::HeapMemoryInfoL
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CMPXMedia::HeapMemoryInfoL( TInt& aTotal, TInt& aUsed )
       
   138     {
       
   139     return MMPXData::HeapMemoryInfoL( aTotal, aUsed);
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // Externalize
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C void CMPXMedia::ExternalizeL(RWriteStream& aStream) const
       
   147     {
       
   148     DoExternalizeL(aStream,MMPXData::EMedia);
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // Internalize
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C void CMPXMedia::InternalizeL(RReadStream& aStream)
       
   156     {
       
   157     DoInternalizeL(aStream,MMPXData::EMedia);
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // Clears data
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 EXPORT_C void CMPXMedia::Reset()
       
   165     {
       
   166 //    MPX_FUNC_EX("CMPXMedia::Reset()");
       
   167     MPX_ASSERT(iClientHandle&&iData);
       
   168     //
       
   169     ResetLocal(); // Local data
       
   170     iData->Reset(iClientHandle); // Clears heap data for this object
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // Possible content IDs that denote the type of content the source of this
       
   175 // object can supply;
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C const TArray<TInt> CMPXMedia::SupportedIds() const
       
   179     {
       
   180     MPX_ASSERT(iClientHandle&&iData);
       
   181     return iData->SupportedIds(iClientHandle);
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // The attributes provided in this media object
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C const TArray<TMPXAttribute> CMPXMedia::Attributes() const
       
   189     {
       
   190     const_cast<CMPXMedia*>(this)->RefreshAttributes();
       
   191     return iAttributes.Array();
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // Does this object contain the value for a given attribute
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 EXPORT_C TBool CMPXMedia::IsSupported(const TMPXAttribute& aAttribute) const
       
   199     {
       
   200     MPX_ASSERT(iClientHandle&&iData);
       
   201     return KErrNotFound!=iData->Index(iClientHandle,aAttribute);
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // The number of attribute values provided in this media object
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 EXPORT_C TInt CMPXMedia::Count() const
       
   209     {
       
   210     return CMPXMediaBase::Count();
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // The attribute for a specific index
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C const TMPXAttribute& CMPXMedia::Attribute(TInt aIndex) const
       
   218     {
       
   219     MPX_ASSERT(iClientHandle&&iData);
       
   220     MPX_ASSERT(aIndex>=0&&aIndex<Count());
       
   221     //
       
   222     return iData->Attribute(iClientHandle,aIndex);
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // The attributes set for a specific content
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C TUint CMPXMedia::AttributesSet(TInt aContentId) const
       
   230     {
       
   231     const_cast<CMPXMedia*>(this)->RefreshAttributes();
       
   232     TUint attributesSet(0);
       
   233     for (TInt i=iAttributes.Count();--i>=0;)
       
   234         {
       
   235         TMPXAttribute attr(iAttributes[i]);
       
   236         if (attr.ContentId()==aContentId)
       
   237             {
       
   238             attributesSet|=attr.AttributeId();
       
   239             }
       
   240         }
       
   241     return attributesSet;
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // The index of a given attribute
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 EXPORT_C TInt CMPXMedia::Index(const TMPXAttribute& aAttribute) const
       
   249     {
       
   250     MPX_ASSERT(iClientHandle&&iData);
       
   251     return iData->Index(iClientHandle,aAttribute);
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // The type of data stored for the attribute
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 EXPORT_C TMPXAttributeType CMPXMedia::Type(TInt aIndex) const
       
   259     {
       
   260     MPX_ASSERT(iClientHandle&&iData);
       
   261     MPX_ASSERT(aIndex>=0&&aIndex<Count());
       
   262     //
       
   263     return iData->AttributeType(iClientHandle,aIndex);
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // The type of data stored for the attribute
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 EXPORT_C TMPXAttributeType CMPXMedia::Type(const TMPXAttribute& aAttribute) const
       
   271     {
       
   272     MPX_ASSERT(iClientHandle&&iData);
       
   273     TMPXAttributeType type(EMPXTypeUnknown);
       
   274     TInt index(Index(aAttribute));
       
   275     if (KErrNotFound!=index)
       
   276         {
       
   277         type = Type(index);
       
   278         }
       
   279     return type;
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // The value for a specific attribute
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 EXPORT_C const TDesC& CMPXMedia::ValueText(const TMPXAttribute& aAttribute) const
       
   287     {
       
   288     TPtrC* text=Value<TPtrC>(aAttribute);
       
   289     return text?(const TDesC&)*text:KNullDesC;
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // Add a new attribute value to this object, or modifies existing
       
   294 // value if already present
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 EXPORT_C  void CMPXMedia::SetTextValueL(
       
   298     const TMPXAttribute& aAttribute,
       
   299     const TDesC& aValue)
       
   300     {
       
   301     TPtrC8 data((TUint8*)aValue.Ptr(),aValue.Size());
       
   302     SetValueL(aAttribute,data,EMPXTypeText);
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // Merges in the attributes of the provided media
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 EXPORT_C void CMPXMedia::MergeMediaL( const CMPXMedia& aMedia )
       
   310     {
       
   311     // Do not merge the same data handle
       
   312     if( Data() != aMedia.Data() )
       
   313         {
       
   314         for ( TInt i = 0; i < aMedia.Count(); i++ )
       
   315             {
       
   316             TMPXAttributeType type( aMedia.Type( i ));
       
   317             TMPXAttribute att( aMedia.Attribute( i ));
       
   318             // Need to handle text differently since it's
       
   319             // possible to have KNullDesC, which will result
       
   320             // in an invalid TPtrC.
       
   321             if ( EMPXTypeText == type )
       
   322                 {
       
   323                 const TDesC& t( aMedia.ValueText( att ));
       
   324                 if ( t == KNullDesC )
       
   325                     {
       
   326                     // Cannot use reference to KNullDesC, must
       
   327                     // use the literal directly.
       
   328                     SetTextValueL( att, KNullDesC );
       
   329                     }
       
   330                 else
       
   331                     {
       
   332                     SetTextValueL( att, t );
       
   333                     }
       
   334                 }
       
   335             else
       
   336                 {
       
   337                 TPtrC8 ptr( aMedia.iData->Value( aMedia.iClientHandle, i ));
       
   338                 SetValueL( att, ptr, type );
       
   339                 }
       
   340             }
       
   341         }
       
   342     }
       
   343 
       
   344 // -----------------------------------------------------------------------------
       
   345 // Compares if the specified media's attribute matches this one
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C TBool CMPXMedia::Match(
       
   349     const CMPXMedia& aMedia,
       
   350     const TMPXAttribute& aAtt )
       
   351     {
       
   352     TBool result( EFalse );
       
   353     TInt myIndex( Index( aAtt ));
       
   354     if ( KErrNotFound != myIndex )
       
   355         {
       
   356         TInt index( aMedia.Index( aAtt ));
       
   357         if ( KErrNotFound != index )
       
   358             {
       
   359             if ( Type( myIndex ) == aMedia.Type( index ))
       
   360                 {
       
   361                 TPtrC8 myPtr( iData->Value( iClientHandle, myIndex ));
       
   362                 TPtrC8 ptr( aMedia.iData->Value( aMedia.iClientHandle, index ));
       
   363                 result = ( myPtr == ptr );
       
   364                 }
       
   365             }
       
   366         }
       
   367     return result;
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // CMPXMedia::Delete
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 EXPORT_C void CMPXMedia::Delete(const TMPXAttribute& aAttribute)
       
   375     {
       
   376 //    MPX_FUNC_EX("CMPXMedia::Delete(const TMPXAttribute& aAttribute)");
       
   377     Delete(iData->Index(iClientHandle,aAttribute));
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CMPXMedia::Delete
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 EXPORT_C void CMPXMedia::Delete(TInt aIndex)
       
   385     {
       
   386 //    MPX_FUNC_EX("CMPXMedia::Delete(TInt aIndex)");
       
   387     if (KErrNotFound != aIndex)
       
   388         {
       
   389         MPX_ASSERT(aIndex>=0&&aIndex<Count());
       
   390         DeleteLocal(aIndex);
       
   391         iData->Delete(iClientHandle,aIndex);
       
   392         } // do nothing. the same behaviour as the v1 although it should panic
       
   393     }
       
   394 
       
   395 // -----------------------------------------------------------------------------
       
   396 // CMPXMedia::ConstructL
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 void CMPXMedia::ConstructL(const TArray<TInt>& aSupportedIds)
       
   400     {
       
   401     CMPXMediaBase::ConstructL();
       
   402     User::LeaveIfError(iData->SetSupportedIds(iClientHandle,aSupportedIds));
       
   403     }
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CMPXMedia::ConstructL
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 void CMPXMedia::ConstructL(RReadStream& aStream)
       
   410     {
       
   411     MPX_ASSERT(!iData&&!iDataHandle);
       
   412     InternalizeL(aStream);
       
   413     }
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // CMPXMedia::SetValueL
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 EXPORT_C void CMPXMedia::SetValueL(
       
   420     const TMPXAttribute& aAttribute,
       
   421     const TDesC8& aValue,
       
   422     TMPXAttributeType aType)
       
   423     {
       
   424     MPX_ASSERT(iData&&iClientHandle);
       
   425     //
       
   426     LockHeapLC();
       
   427     TInt i=iData->Index(iClientHandle,aAttribute);
       
   428     if (i==KErrNotFound)
       
   429         {
       
   430         User::LeaveIfError(iData->Append(iClientHandle,aAttribute,aType,aValue));
       
   431         }
       
   432      else
       
   433         {
       
   434         DeleteLocal(i);
       
   435         iData->Set(iClientHandle,aAttribute,aType,aValue,i);
       
   436         }
       
   437     CleanupStack::PopAndDestroy(); //unlock heap
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CMPXMedia::ValuePtr. Returns NULL if (a) there is no such object with the
       
   442 // given attribute; (b) object cannot be created (e.g. no memory); (c) it's an
       
   443 // arbitrary CBase object (only CMPXMedia, CMPXMediaArray, and CMPXCollectionPath
       
   444 // are supported. Otherwise, returns a pointer to the object which is also stored
       
   445 // locally
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 EXPORT_C TAny* CMPXMedia::ValuePtr(const TMPXAttribute& aAttribute) const
       
   449     {
       
   450     MPX_ASSERT(iData&&iClientHandle);
       
   451     MMPXData::LockHeap( iClientHandle );
       
   452     TAny* obj=NULL;
       
   453     TInt index=iData->Index(iClientHandle,aAttribute);
       
   454     TMPXAttributeType type=EMPXTypeUnknown;
       
   455 
       
   456     if (index!=KErrNotFound) // Check if the value exist or not
       
   457         {
       
   458         type=iData->AttributeType(iClientHandle,index);
       
   459         // Check local values to see if there and current
       
   460         //
       
   461         TInt uid=iData->Uid(iClientHandle,index);
       
   462         const TValue* v=LocalValue(uid);
       
   463         if (!v)
       
   464             {
       
   465             TPtrC8 data=iData->Value(iClientHandle,index);
       
   466             TInt size=data.Size();
       
   467             const TAny* ptr=data.Ptr();
       
   468             //
       
   469             switch(type)
       
   470                 {
       
   471             case EMPXTypeText:
       
   472                 obj=new TPtrC((TUint16*)ptr,size/2);
       
   473                 break;
       
   474                 //
       
   475             case EMPXTypeCObject:
       
   476                 TRAP_IGNORE(obj=ValueCObjectL(data));
       
   477                 break;
       
   478                 //
       
   479             case EMPXTypeError: // Error type is TInt, flow down
       
   480             case EMPXTypeTObject:
       
   481                 //
       
   482                 // Create a decriptor pointing to the data. But the pointer
       
   483                 // within the descriptor must be returned by this method
       
   484                 //
       
   485                  obj=new TPtrC8((TUint8*)ptr,size);
       
   486                 break;
       
   487                 //
       
   488             default:
       
   489                 MPX_ASSERT(0);
       
   490                 break;
       
   491                 }
       
   492             if (obj)
       
   493                 {
       
   494                 CMPXMedia& theMedia=*const_cast<CMPXMedia*>(this);
       
   495                 TInt err=theMedia.SetLocal(TValue(obj,uid,type)); // Add new one
       
   496                 if (err!=KErrNone)
       
   497                     {
       
   498                     theMedia.DeletePtr(obj,type);
       
   499                     obj=NULL;
       
   500                     }
       
   501                 }
       
   502             }
       
   503         else
       
   504             {
       
   505             obj=v->iValue;
       
   506             }
       
   507         }
       
   508     MMPXData::UnlockHeap(iClientHandle);
       
   509     return (type==EMPXTypeTObject||type==EMPXTypeError)?(obj?(TAny*)static_cast<TPtrC8*>(obj)->Ptr():NULL):obj;
       
   510     }
       
   511 
       
   512 EXPORT_C TMPXAttributeType CMPXMedia::GetValue(const TMPXAttribute& aAttribute, TDes8& aValue) const
       
   513     {
       
   514     MPX_ASSERT(iData&&iClientHandle);
       
   515     MMPXData::LockHeap( iClientHandle );
       
   516     TInt index=iData->Index(iClientHandle,aAttribute);
       
   517     TMPXAttributeType type=EMPXTypeUnknown;
       
   518     
       
   519     if (index!=KErrNotFound) // Check if the value exist or not
       
   520         {
       
   521         type=iData->AttributeType(iClientHandle,index);
       
   522         aValue = iData->Value(iClientHandle,index).Left(aValue.MaxLength());
       
   523         }
       
   524     MMPXData::UnlockHeap(iClientHandle);
       
   525     return type;
       
   526     }
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 // CMPXMedia::RefreshAttributes
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 void CMPXMedia::RefreshAttributes()
       
   533     {
       
   534     // Reconstructs array of attributes
       
   535     //
       
   536     iAttributes.Reset();
       
   537     for (TInt i=iData->Count(iClientHandle);--i>=0;)
       
   538         {
       
   539         (void)iAttributes.Append(iData->Attribute(iClientHandle,i));
       
   540         }
       
   541     }
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // CMPXMedia::ResetLocal
       
   545 // -----------------------------------------------------------------------------
       
   546 //
       
   547 void CMPXMedia::ResetLocal()
       
   548     {
       
   549     CMPXMediaBase::ResetLocal();
       
   550     iAttributes.Reset();
       
   551     }
       
   552 
       
   553 // -----------------------------------------------------------------------------
       
   554 // CMPXMedia::ValueCObjectL
       
   555 // -----------------------------------------------------------------------------
       
   556 //
       
   557 TAny* CMPXMedia::ValueCObjectL(const TDesC8& aData) const
       
   558     {
       
   559     TAny* obj=NULL;
       
   560     TInt size=aData.Size();
       
   561     TUint* ptr=(TUint*)aData.Ptr();
       
   562 
       
   563 #ifdef _DEBUG
       
   564     const TBool ptrAddrIsOnBoundary = ((TUint)ptr & 3) == 0;
       
   565 
       
   566     // Only dereference 4-byte word on 4-byte word boundary
       
   567     MPX_ASSERT(ptrAddrIsOnBoundary); // assert if this is not the case
       
   568 #endif
       
   569 
       
   570     MMPXData::TMPXObjectType t=*(MMPXData::TMPXObjectType*)ptr;
       
   571     switch(t)
       
   572         {
       
   573         case MMPXData::EMedia:
       
   574             MPX_ASSERT(size==sizeof(TInt)+sizeof(TUint)); // i.e 8 bytes
       
   575             obj=CMPXMedia::NewL(*++ptr);
       
   576             break;
       
   577             //
       
   578         case MMPXData::EMediaArray:
       
   579             MPX_ASSERT(size==sizeof(TInt)+sizeof(TUint)); // i.e 8 bytes
       
   580             obj=ValueL<CMPXMediaArray>(aData);
       
   581             break;
       
   582             //
       
   583         case MMPXData::EPath:
       
   584             obj=ValueL<CMPXCollectionPath>(aData);
       
   585             break;
       
   586             //
       
   587         default:
       
   588             //
       
   589             // obj=NULL, i.e. arbitrary C objects
       
   590             // ARE NOT SUPPORTED by this method
       
   591             //
       
   592             MPX_ASSERT(0); // For now, to catch clients that use this
       
   593             break;
       
   594             }
       
   595         return obj;
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // CMPXMedia::SetErrorL
       
   600 // -----------------------------------------------------------------------------
       
   601 EXPORT_C void CMPXMedia::SetErrorL(const TMPXAttribute& aAttribute, TInt aError)
       
   602     {
       
   603     TPtrC8 value((TUint8*)&aError,sizeof(TInt));
       
   604     SetValueL(aAttribute,value,EMPXTypeError);
       
   605     }
       
   606 
       
   607 // -----------------------------------------------------------------------------
       
   608 // CMPXMedia::Error
       
   609 // -----------------------------------------------------------------------------
       
   610 EXPORT_C TInt CMPXMedia::Error(const TMPXAttribute& aAttribute) const
       
   611     {
       
   612     if (Type(aAttribute)==EMPXTypeError)
       
   613         {
       
   614         TInt* v=(TInt*)ValuePtr(aAttribute);
       
   615         return v?*v:KErrNone; // return KErrNone if none exists!
       
   616         }
       
   617     else
       
   618         return KErrNone;
       
   619     }
       
   620 
       
   621 // END OF FILE