videoplayback/inc/mpxvideoregion.inl
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Inline implementation of MPXVideoRegion
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 5 %
       
    19 
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <s32strm.h>
       
    23 #include "mpxvideo_debug.h"
       
    24 
       
    25 inline
       
    26 CMPXVideoRegion*
       
    27 CMPXVideoRegion::NewL()
       
    28 {
       
    29     CMPXVideoRegion* self = CMPXVideoRegion::NewLC();
       
    30     CleanupStack::Pop( self );
       
    31     return self;
       
    32 }
       
    33 
       
    34 inline
       
    35 CMPXVideoRegion*
       
    36 CMPXVideoRegion::NewLC()
       
    37 {
       
    38     CMPXVideoRegion* self = new (ELeave) CMPXVideoRegion();
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     return self;
       
    42 }
       
    43 
       
    44 inline
       
    45 void
       
    46 CMPXVideoRegion::ConstructL()
       
    47 {
       
    48     iRegion = new RRegion( 10 );
       
    49 }
       
    50 
       
    51 inline
       
    52 CMPXVideoRegion::CMPXVideoRegion()
       
    53 {
       
    54 }
       
    55 
       
    56 inline
       
    57 CMPXVideoRegion::~CMPXVideoRegion()
       
    58 {
       
    59     iRegion->Destroy();
       
    60 }
       
    61 
       
    62 inline
       
    63 void
       
    64 CMPXVideoRegion::Print()
       
    65 {
       
    66     if ( iRegion->CheckError() )
       
    67     {
       
    68         MPX_DEBUG(_L("CMPXVideoRegion::Print() Error in DSA Region"));
       
    69         return;
       
    70     }
       
    71 
       
    72     MPX_DEBUG(_L("CMPXVideoRegion::Print() Rect Count = %d"),
       
    73         iRegion->Count() );
       
    74 
       
    75     const TRect* rectList = iRegion->RectangleList();
       
    76 
       
    77     for ( TInt i = 0 ; i < iRegion->Count() ; ++i )
       
    78     {
       
    79         MPX_DEBUG(_L("CMPXVideoRegion::Print() Rect %d"), i);
       
    80 
       
    81         MPX_DEBUG(_L( "CMPXVideoRegion::Print() (%d, %d), (%d, %d)"),
       
    82             rectList[i].iTl.iX, rectList[i].iTl.iY,
       
    83             rectList[i].iBr.iX, rectList[i].iBr.iY );
       
    84     }
       
    85 }
       
    86 
       
    87 inline
       
    88 void
       
    89 CMPXVideoRegion::SetRegion( RRegion& aRegion )
       
    90 {
       
    91     iRegion->Copy( aRegion );
       
    92 }
       
    93 
       
    94 inline
       
    95 TRegion&
       
    96 CMPXVideoRegion::GetRegion()
       
    97 {
       
    98     return *iRegion;
       
    99 }
       
   100 
       
   101 inline
       
   102 void
       
   103 CMPXVideoRegion::ExternalizeL( RWriteStream& aStream ) const
       
   104 {
       
   105     MPX_ENTER_EXIT(_L("CMPXVideoRegion::ExternalizeL()"));
       
   106 
       
   107     aStream.WriteInt32L( iRegion->Count() );
       
   108 
       
   109     const TRect* rectList = iRegion->RectangleList();
       
   110 
       
   111     for ( TInt i = 0 ; i < iRegion->Count() ; ++i )
       
   112     {
       
   113         aStream.WriteInt32L( rectList[i].iTl.iX );
       
   114         aStream.WriteInt32L( rectList[i].iTl.iY );
       
   115         aStream.WriteInt32L( rectList[i].iBr.iX );
       
   116         aStream.WriteInt32L( rectList[i].iBr.iY );
       
   117     }
       
   118 }
       
   119 
       
   120 //inline
       
   121 void
       
   122 CMPXVideoRegion::InternalizeL( RReadStream& aStream )
       
   123 {
       
   124     MPX_ENTER_EXIT(_L("CMPXVideoRegion::InternalizeL()"));
       
   125 
       
   126     TInt32 count = aStream.ReadInt32L();
       
   127 
       
   128     for ( TInt i = 0 ; i < count; ++i )
       
   129     {
       
   130         TInt32 a = aStream.ReadInt32L();
       
   131         TInt32 b = aStream.ReadInt32L();
       
   132         TInt32 c = aStream.ReadInt32L();
       
   133         TInt32 d = aStream.ReadInt32L();
       
   134 
       
   135         TRect* rect = new (ELeave) TRect( a, b, c, d );
       
   136         iRegion->AddRect( *rect );
       
   137         delete rect;
       
   138     }
       
   139 }