mmplugins/cameraplugins/source/webcamera/ecamwebcamerabuffer.cpp
branchRCL_3
changeset 9 9ae0fe04e757
child 64 92a82bc706f7
equal deleted inserted replaced
8:bc06d8566074 9:9ae0fe04e757
       
     1 /*
       
     2 * Copyright (c) 2010 ISB.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * ISB - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <fbs.h>
       
    19 #include "ecamwebcamerabuffer.h"
       
    20 
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // NewL
       
    24 // Takes ownership of aData, but not aBitmap
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CWebCameraBuffer* CWebCameraBuffer::NewL(const CFbsBitmap& aBitmap, HBufC8* aData)
       
    28 	{
       
    29 	CWebCameraBuffer* self = CWebCameraBuffer::NewLC( aBitmap, aData );
       
    30 	CleanupStack::Pop( self );
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // NewLC
       
    36 // Takes ownership of aData, but not aBitmap
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CWebCameraBuffer* CWebCameraBuffer::NewLC(const CFbsBitmap& aBitmap, HBufC8* aData)
       
    40 	{
       
    41 	CWebCameraBuffer* self = new (ELeave) CWebCameraBuffer;
       
    42 	CleanupStack::PushL( self );
       
    43 	self->ConstructL( aBitmap, aData );
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // NewL
       
    50 // Takes ownership of both objects.
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CWebCameraBuffer* CWebCameraBuffer::NewL(CFbsBitmap* aBitmap, HBufC8* aData)
       
    54 	{
       
    55 	CWebCameraBuffer* self = CWebCameraBuffer::NewLC( aBitmap, aData );
       
    56 	CleanupStack::Pop( self );
       
    57 	return self;
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // NewLC
       
    62 // Takes ownership of both objects.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CWebCameraBuffer* CWebCameraBuffer::NewLC(CFbsBitmap* aBitmap, HBufC8* aData)
       
    66 	{
       
    67 	CWebCameraBuffer* self = new (ELeave) CWebCameraBuffer;
       
    68 	CleanupStack::PushL( self );
       
    69 	self->ConstructL( aBitmap, aData );
       
    70 	return self;
       
    71 	}
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Constructor
       
    75 //
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CWebCameraBuffer::CWebCameraBuffer()
       
    79 	: iBitmap(NULL),
       
    80 	  iImageData(NULL),
       
    81 	  iOwnBitmap(ETrue),
       
    82 	  iOwnData(ETrue)
       
    83 	{
       
    84 	}
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // Destructor
       
    88 // *private, because Release() is supposed to be used.*
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 CWebCameraBuffer::~CWebCameraBuffer()
       
    92 	{
       
    93 	iChunk.Close();
       
    94 	delete iBitmap;
       
    95 	delete iImageData;
       
    96 	}
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // ConstructL
       
   100 //
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CWebCameraBuffer::ConstructL(const CFbsBitmap& aBitmap, HBufC8* aData)
       
   104 	{
       
   105 	iBitmap = new (ELeave) CFbsBitmap;
       
   106 	TInt error = iBitmap->Duplicate( aBitmap.Handle() );
       
   107 
       
   108 	iImageData = aData;
       
   109 
       
   110 	User::LeaveIfError( error );
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // ConstructL
       
   115 //
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CWebCameraBuffer::ConstructL(CFbsBitmap* aBitmap, HBufC8* aData)
       
   119 	{
       
   120 	iImageData = aData;
       
   121 	iBitmap    = aBitmap;
       
   122 	}
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // NumFrames
       
   126 //
       
   127 // Number of frames available in the buffer.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 TInt 
       
   131 CWebCameraBuffer::NumFrames()
       
   132 	{
       
   133 	return 1;
       
   134 	}
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // DataL
       
   139 //
       
   140 // Frame data as descriptor.
       
   141 // *not supported here*
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 TDesC8* CWebCameraBuffer::DataL(TInt aFrameIndex)
       
   145 	{
       
   146 	if( aFrameIndex != 0 || !iImageData )
       
   147 		{
       
   148 		User::Leave( KErrNotSupported );
       
   149 		}
       
   150 
       
   151 	return iImageData; 
       
   152 	}
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // BitmapL
       
   156 //
       
   157 // Frame data as bitmap.
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 CFbsBitmap& CWebCameraBuffer::BitmapL(TInt aFrameIndex)
       
   161 	{
       
   162 	if( aFrameIndex != 0 || !iBitmap )
       
   163 		{
       
   164 		User::Leave( KErrNotFound );
       
   165 		}
       
   166 
       
   167 	return *iBitmap;
       
   168 	}
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // DataL
       
   172 //
       
   173 // Frame data as chunk.
       
   174 // *not supported here*
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 RChunk& CWebCameraBuffer::ChunkL()
       
   178 	{
       
   179 	User::Leave( KErrNotSupported );
       
   180 
       
   181 	return iChunk;
       
   182 	}
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // ChunkOffsetL
       
   186 //
       
   187 // Frame data offset in chunk.
       
   188 // *not supported here*
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt 
       
   192 CWebCameraBuffer::ChunkOffsetL(TInt /*aFrameIndex*/)
       
   193 	{
       
   194 	User::Leave( KErrNotSupported );
       
   195 
       
   196 	return 0;
       
   197 	}
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // FrameSize
       
   201 //
       
   202 // Frame data size.
       
   203 // *not supported here, as only bitmap supported*
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 TInt CWebCameraBuffer::FrameSize(TInt /*aFrameIndex*/)
       
   207 	{
       
   208 	return -1;
       
   209 	}
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // Release
       
   213 //
       
   214 // Release this buffer.
       
   215 // Simply deletes this object.
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void CWebCameraBuffer::Release()
       
   219 	{
       
   220 	delete this;
       
   221 	}
       
   222 
       
   223 
       
   224 // end of file