serviceproviders/sapi_mediamanagement/mediamanagementservice/src/mgvideoresolution.cpp
changeset 19 989d2f495d90
equal deleted inserted replaced
14:a36b1e19a461 19:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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 the License "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:  This Class is used to find resolution of video file
       
    15 *				
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include"mgvideoresolution.h"
       
    22 #include "mgmediacontainer.h"
       
    23 /// Implementation for CMediaContainer
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CVideoResolution::NewL
       
    27 // Returns the instance of CVideoResolution.
       
    28 // -----------------------------------------------------------------------------
       
    29 
       
    30 CVideoResolution* CVideoResolution::NewL(TDesC& aUrl)
       
    31     {
       
    32     CVideoResolution* self = new(ELeave)CVideoResolution();
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL(aUrl);
       
    35     CleanupStack::Pop(self);
       
    36     return self;
       
    37     }
       
    38 // -----------------------------------------------------------------------------
       
    39 // CVideoResolution::CVideoResolution
       
    40 // C++ Constructor
       
    41 // -----------------------------------------------------------------------------
       
    42 CVideoResolution::CVideoResolution():iMediaContainer(NULL),iVideoUtility(NULL),iVideoFilePath(NULL)
       
    43 {
       
    44 
       
    45 }
       
    46 // -----------------------------------------------------------------------------
       
    47 // CVideoResolution::ConstructL
       
    48 // Two phase constructor
       
    49 // -----------------------------------------------------------------------------
       
    50 void CVideoResolution::ConstructL(TDesC& aUrl)
       
    51     {
       
    52     // Creating container class instance
       
    53     TRect rect(TPoint(2,2),TSize(4,4)); 
       
    54     iMediaContainer =CMediaContainer::NewL(rect) ;
       
    55 
       
    56     iVideoUtility = CVideoPlayerUtility::NewL(*this,EMdaPriorityNormal,EMdaPriorityPreferenceNone,iMediaContainer->ClientWsSession(),iMediaContainer->ScreenDevice(),iMediaContainer->ClientWindow(), iMediaContainer->VideoRect(),iMediaContainer->VideoRect());
       
    57 
       
    58     iVideoFilePath = aUrl.AllocL();
       
    59     }
       
    60 // -----------------------------------------------------------------------------
       
    61 // CVideoResolution::~CVideoResolution
       
    62 // Destructor
       
    63 // -----------------------------------------------------------------------------
       
    64 CVideoResolution::~CVideoResolution()
       
    65     {
       
    66     if(iVideoFilePath)
       
    67         {
       
    68         delete iVideoFilePath;
       
    69         }
       
    70 
       
    71     if(iMediaContainer)
       
    72     	{
       
    73     	delete iMediaContainer;
       
    74     	}
       
    75 	if(iVideoUtility)    
       
    76     	{
       
    77     	delete iVideoUtility;
       
    78     	}
       
    79    
       
    80    
       
    81     }
       
    82 // -----------------------------------------------------------------------------
       
    83 // CVideoResolution::GetresolutionL
       
    84 // Get Resolution 
       
    85 // -----------------------------------------------------------------------------
       
    86 
       
    87 TBool CVideoResolution::GetresolutionL(TSize& aSize)
       
    88     {
       
    89     iVideoUtility->OpenFileL(*iVideoFilePath);
       
    90     CActiveScheduler::Start();
       
    91     iVideoUtility->Prepare();
       
    92      CActiveScheduler::Start();
       
    93    iVideoUtility->VideoFrameSizeL(aSize);
       
    94    
       
    95    if(aSize == TSize(0,0))
       
    96         {
       
    97         return false;
       
    98         }
       
    99     
       
   100     return true;    
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CVideoResolution::MvpuoOpenComplete
       
   105 // Protected method derived from MVideoPlayerUtilityObserver
       
   106 // -----------------------------------------------------------------------------
       
   107 
       
   108 void CVideoResolution::MvpuoOpenComplete(TInt aError){
       
   109  iErr= aError;
       
   110  CActiveScheduler::Stop();
       
   111  
       
   112  }
       
   113  
       
   114 // -----------------------------------------------------------------------------
       
   115 // CVideoResolution::MvpuoPrepareComplete
       
   116 // Protected method derived from MVideoPlayerUtilityObserver
       
   117 // -----------------------------------------------------------------------------
       
   118  void CVideoResolution::MvpuoPrepareComplete(TInt aError){
       
   119  iErr= aError;
       
   120  CActiveScheduler::Stop();
       
   121 
       
   122  }
       
   123        
       
   124  // -----------------------------------------------------------------------------
       
   125  // CVideoResolution::MvpuoFrameReady
       
   126  // Protected method derived from MVideoPlayerUtilityObserver
       
   127  // -----------------------------------------------------------------------------
       
   128 
       
   129  void CVideoResolution::MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError)
       
   130      {
       
   131      iErr= aError;
       
   132      CActiveScheduler::Stop();
       
   133   
       
   134      }
       
   135  // -----------------------------------------------------------------------------
       
   136  // CVideoResolution::MvpuoPlayComplete
       
   137  // Protected method derived from MVideoPlayerUtilityObserver
       
   138  // -----------------------------------------------------------------------------
       
   139   void CVideoResolution::MvpuoPlayComplete(TInt aError) {
       
   140   iErr= aError;
       
   141   CActiveScheduler::Stop();
       
   142 
       
   143   }
       
   144   // -----------------------------------------------------------------------------
       
   145    // CVideoResolution::MvpuoEvent
       
   146    // Protected method derived from MVideoPlayerUtilityObserver
       
   147    // -----------------------------------------------------------------------------
       
   148    void CVideoResolution::MvpuoEvent(const TMMFEvent& aEvent) {
       
   149    
       
   150    CActiveScheduler::Stop();
       
   151    }