serviceproviders/sapi_mediamanagement/mediamanagementservice/src/mgvideoresolution.cpp
author asimpson@symbian.org
Thu, 15 Oct 2009 18:00:22 +0100
branchRCL_1
changeset 14 660c3e4e8769
parent 5 989d2f495d90
permissions -rw-r--r--
Added tag PDK_2.0.0 for changeset c6ce67be4e89

/*
* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  This Class is used to find resolution of video file
*				
*
*/



#include"mgvideoresolution.h"
#include "mgmediacontainer.h"
/// Implementation for CMediaContainer

// -----------------------------------------------------------------------------
// CVideoResolution::NewL
// Returns the instance of CVideoResolution.
// -----------------------------------------------------------------------------

CVideoResolution* CVideoResolution::NewL(TDesC& aUrl)
    {
    CVideoResolution* self = new(ELeave)CVideoResolution();
    CleanupStack::PushL(self);
    self->ConstructL(aUrl);
    CleanupStack::Pop(self);
    return self;
    }
// -----------------------------------------------------------------------------
// CVideoResolution::CVideoResolution
// C++ Constructor
// -----------------------------------------------------------------------------
CVideoResolution::CVideoResolution():iMediaContainer(NULL),iVideoUtility(NULL),iVideoFilePath(NULL)
{

}
// -----------------------------------------------------------------------------
// CVideoResolution::ConstructL
// Two phase constructor
// -----------------------------------------------------------------------------
void CVideoResolution::ConstructL(TDesC& aUrl)
    {
    // Creating container class instance
    TRect rect(TPoint(2,2),TSize(4,4)); 
    iMediaContainer =CMediaContainer::NewL(rect) ;

    iVideoUtility = CVideoPlayerUtility::NewL(*this,EMdaPriorityNormal,EMdaPriorityPreferenceNone,iMediaContainer->ClientWsSession(),iMediaContainer->ScreenDevice(),iMediaContainer->ClientWindow(), iMediaContainer->VideoRect(),iMediaContainer->VideoRect());

    iVideoFilePath = aUrl.AllocL();
    }
// -----------------------------------------------------------------------------
// CVideoResolution::~CVideoResolution
// Destructor
// -----------------------------------------------------------------------------
CVideoResolution::~CVideoResolution()
    {
    if(iVideoFilePath)
        {
        delete iVideoFilePath;
        }

    if(iMediaContainer)
    	{
    	delete iMediaContainer;
    	}
	if(iVideoUtility)    
    	{
    	delete iVideoUtility;
    	}
   
   
    }
// -----------------------------------------------------------------------------
// CVideoResolution::GetresolutionL
// Get Resolution 
// -----------------------------------------------------------------------------

TBool CVideoResolution::GetresolutionL(TSize& aSize)
    {
    iVideoUtility->OpenFileL(*iVideoFilePath);
    CActiveScheduler::Start();
    iVideoUtility->Prepare();
     CActiveScheduler::Start();
   iVideoUtility->VideoFrameSizeL(aSize);
   
   if(aSize == TSize(0,0))
        {
        return false;
        }
    
    return true;    
    }

// -----------------------------------------------------------------------------
// CVideoResolution::MvpuoOpenComplete
// Protected method derived from MVideoPlayerUtilityObserver
// -----------------------------------------------------------------------------

void CVideoResolution::MvpuoOpenComplete(TInt aError){
 iErr= aError;
 CActiveScheduler::Stop();
 
 }
 
// -----------------------------------------------------------------------------
// CVideoResolution::MvpuoPrepareComplete
// Protected method derived from MVideoPlayerUtilityObserver
// -----------------------------------------------------------------------------
 void CVideoResolution::MvpuoPrepareComplete(TInt aError){
 iErr= aError;
 CActiveScheduler::Stop();

 }
       
 // -----------------------------------------------------------------------------
 // CVideoResolution::MvpuoFrameReady
 // Protected method derived from MVideoPlayerUtilityObserver
 // -----------------------------------------------------------------------------

 void CVideoResolution::MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError)
     {
     iErr= aError;
     CActiveScheduler::Stop();
  
     }
 // -----------------------------------------------------------------------------
 // CVideoResolution::MvpuoPlayComplete
 // Protected method derived from MVideoPlayerUtilityObserver
 // -----------------------------------------------------------------------------
  void CVideoResolution::MvpuoPlayComplete(TInt aError) {
  iErr= aError;
  CActiveScheduler::Stop();

  }
  // -----------------------------------------------------------------------------
   // CVideoResolution::MvpuoEvent
   // Protected method derived from MVideoPlayerUtilityObserver
   // -----------------------------------------------------------------------------
   void CVideoResolution::MvpuoEvent(const TMMFEvent& aEvent) {
   
   CActiveScheduler::Stop();
   }