mmswadaptation/videorenderer/src/resourcefilereader.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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 "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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include <barsread.h>
       
    22 #include <mmf/devvideo/devvideobase.h>
       
    23 #include <videorenderer.rsg>
       
    24 #include "resourcefilereader.h"
       
    25 #include "rendererutil.h"
       
    26 
       
    27 
       
    28 CResourceFileReader* CResourceFileReader::NewL(const TDesC& aResourceFile)
       
    29 	{
       
    30 	CResourceFileReader* self = CResourceFileReader::NewLC(aResourceFile);
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CResourceFileReader* CResourceFileReader::NewLC(const TDesC& aResourceFile)
       
    36 	{
       
    37 	CResourceFileReader* self = new (ELeave) CResourceFileReader();
       
    38 	CleanupStack::PushL(self);
       
    39 	self->ConstructL(aResourceFile);
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 CResourceFileReader::CResourceFileReader()
       
    44 	{
       
    45 	}
       
    46 
       
    47 void CResourceFileReader::ConstructL(const TDesC& aResourceFile)
       
    48 	{
       
    49 	User::LeaveIfError(iFs.Connect());
       
    50     iResourceFile.OpenL(iFs, aResourceFile);
       
    51 	}
       
    52 
       
    53 CResourceFileReader::~CResourceFileReader()
       
    54 	{
       
    55 	iResourceFile.Close();
       
    56 	iFs.Close();
       
    57 	}
       
    58 
       
    59 void CResourceFileReader::ReadSupportedFormatL(RArray<TUncompressedVideoFormat>& aArray)
       
    60 	{
       
    61 	aArray.Reset(); // first clear the old data
       
    62 
       
    63 	HBufC8* res = iResourceFile.AllocReadLC(GCE_SUPPORTED_FORMAT);
       
    64 	TResourceReader reader;
       
    65 	reader.SetBuffer(res);
       
    66 
       
    67 	TInt count = reader.ReadInt16();
       
    68 	for (TInt i = 0; i < count; ++i)
       
    69 		{
       
    70 		TVideoRendererPixelFormat format = static_cast<TVideoRendererPixelFormat>(reader.ReadUint32());
       
    71 		TUncompressedVideoFormat uncompressedFormat = VideoRendererUtil::ConvertPixelFormatToUncompressedVideoFormatL(format);
       
    72 		aArray.AppendL(uncompressedFormat);
       
    73 		}
       
    74 	
       
    75 	CleanupStack::PopAndDestroy(res);
       
    76 	}
       
    77 
       
    78 void CResourceFileReader::ReadTimerInfoL(TInt64& aDefaultDelay, TInt64& aMaxDelay)
       
    79 	{
       
    80 	HBufC8* res = iResourceFile.AllocReadLC(TIMER);
       
    81 	TResourceReader reader;
       
    82 	reader.SetBuffer(res);
       
    83 	
       
    84 	aDefaultDelay = static_cast<TInt64>(reader.ReadInt32());
       
    85 	aMaxDelay = static_cast<TInt64>(reader.ReadInt32());
       
    86 	
       
    87 	CleanupStack::PopAndDestroy(res);
       
    88 	}