os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteagents/src/videoplayagent.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Part of the MVS Agents for TechView
sl@0
    15
//
sl@0
    16
sl@0
    17
#ifdef SYMBIAN_BUILD_GCE
sl@0
    18
#include <videoplayer2.h>
sl@0
    19
#include <surfaceeventhandler.h>
sl@0
    20
#endif
sl@0
    21
sl@0
    22
#include "videoplayagent.h"
sl@0
    23
sl@0
    24
/**
sl@0
    25
Constructs and initialises a new instance of the MVS video play agent
sl@0
    26
sl@0
    27
This function leaves if the video play agent object cannot be created.
sl@0
    28
sl@0
    29
@param  aObserver
sl@0
    30
        A client class to receive notifications from the video player.
sl@0
    31
sl@0
    32
@return A pointer to the new video play agent object.
sl@0
    33
*/
sl@0
    34
EXPORT_C CMVSVideoPlayAgent* CMVSVideoPlayAgent::NewL(MMVSClientObserver& aObserver)
sl@0
    35
	{
sl@0
    36
	CMVSVideoPlayAgent* self = new(ELeave) CMVSVideoPlayAgent(aObserver);
sl@0
    37
	CleanupStack::PushL(self);
sl@0
    38
	self->ConstructL();
sl@0
    39
	CleanupStack::Pop(self);
sl@0
    40
	return self;
sl@0
    41
	}
sl@0
    42
sl@0
    43
void CMVSVideoPlayAgent::ConstructL()
sl@0
    44
	{
sl@0
    45
	User::LeaveIfError(iFileLogger.Connect());
sl@0
    46
    iFileLogger.CreateLog(_L("LogMVSappUi"),_L("LogFile.txt"),EFileLoggingModeAppend);
sl@0
    47
    }
sl@0
    48
sl@0
    49
sl@0
    50
/**
sl@0
    51
Destructor. Closes any open video clips and frees any resources held by the Video Player.
sl@0
    52
*/
sl@0
    53
EXPORT_C CMVSVideoPlayAgent::~CMVSVideoPlayAgent()
sl@0
    54
	{
sl@0
    55
#ifdef SYMBIAN_BUILD_GCE
sl@0
    56
    delete iVideoPlayer2;
sl@0
    57
    iVideoPlayer2 = NULL;
sl@0
    58
#endif  // SYMBIAN_BUILD_GCE
sl@0
    59
    
sl@0
    60
	delete iVideoPlayer;
sl@0
    61
	iVideoPlayer = NULL;
sl@0
    62
sl@0
    63
    if(iFileLogger.Handle())
sl@0
    64
     	{
sl@0
    65
     	iFileLogger.CloseLog();
sl@0
    66
	 	iFileLogger.Close();
sl@0
    67
     	}
sl@0
    68
     	
sl@0
    69
    iFileName.Close();
sl@0
    70
    }
sl@0
    71
sl@0
    72
sl@0
    73
CMVSVideoPlayAgent::CMVSVideoPlayAgent(MMVSClientObserver& aObserver)
sl@0
    74
    : iObserver(aObserver),
sl@0
    75
      iControllerUid(KNullUid)
sl@0
    76
	{
sl@0
    77
	}
sl@0
    78
sl@0
    79
/**
sl@0
    80
Check if CVideoPlayerUtility2 is used for current video playback.
sl@0
    81
sl@0
    82
@return ETrue if CVideoPlayerUtility2 is used for video playback.  EFalse if 
sl@0
    83
        CVideoPlayerUtility is used.
sl@0
    84
*/
sl@0
    85
EXPORT_C TBool CMVSVideoPlayAgent::SupportVideoPlayerUtility2() const
sl@0
    86
    {
sl@0
    87
    if (iCurrentVideoPlayer == NULL)
sl@0
    88
        {            
sl@0
    89
        return EFalse;
sl@0
    90
        }
sl@0
    91
    
sl@0
    92
    if (iCurrentVideoPlayer == iVideoPlayer)
sl@0
    93
        {
sl@0
    94
        return EFalse;        
sl@0
    95
        }
sl@0
    96
        
sl@0
    97
    return ETrue;
sl@0
    98
    }
sl@0
    99
sl@0
   100
/**
sl@0
   101
Set the auto scale on the current video player for the specified window.
sl@0
   102
sl@0
   103
@see CVideoPlayerUtility
sl@0
   104
*/
sl@0
   105
#ifdef SYMBIAN_BUILD_GCE
sl@0
   106
EXPORT_C void CMVSVideoPlayAgent::SetAutoScaleL(RWindow& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos)
sl@0
   107
	{
sl@0
   108
	iVideoPlayer2->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos);
sl@0
   109
#else
sl@0
   110
EXPORT_C void CMVSVideoPlayAgent::SetAutoScaleL(RWindow& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos)
sl@0
   111
	{
sl@0
   112
	User::Leave(KErrNotSupported);
sl@0
   113
#endif
sl@0
   114
	}
sl@0
   115
sl@0
   116
/**
sl@0
   117
Set the auto scale on the current video player.
sl@0
   118
sl@0
   119
@see CVideoPlayerUtility
sl@0
   120
*/
sl@0
   121
EXPORT_C void CMVSVideoPlayAgent::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos)
sl@0
   122
	{
sl@0
   123
#ifdef SYMBIAN_BUILD_GCE
sl@0
   124
	iCurrentVideoPlayer->SetAutoScaleL(aScaleType, aHorizPos, aVertPos);
sl@0
   125
#else
sl@0
   126
	// Remove warnings
sl@0
   127
	aScaleType = aScaleType;
sl@0
   128
	aHorizPos = aHorizPos;
sl@0
   129
	aVertPos = aVertPos;
sl@0
   130
	User::Leave(KErrNotSupported);
sl@0
   131
#endif
sl@0
   132
	}
sl@0
   133
sl@0
   134
/**
sl@0
   135
Video output settings, pre initialisation of all the required settings to play a 
sl@0
   136
video clip
sl@0
   137
sl@0
   138
This function leaves if the video player utility object cannot be created.
sl@0
   139
sl@0
   140
@param  aObserver
sl@0
   141
        A client class to receive notifications from the video player.
sl@0
   142
@param  aPriority
sl@0
   143
        This client's relative priority. This is a value between EMdaPriorityMin and
sl@0
   144
        EMdaPriorityMax and represents a relative priority. A higher value indicates
sl@0
   145
        a more important request.
sl@0
   146
@param  aPref
sl@0
   147
        The required behaviour if a higher priority client takes over the sound output device.
sl@0
   148
        One of the values defined by TMdaPriorityPreference.
sl@0
   149
@param  aWs
sl@0
   150
        The window server session id.
sl@0
   151
@param  aScreenDevice
sl@0
   152
        The software device screen.
sl@0
   153
@param  aWindow
sl@0
   154
        The display window.
sl@0
   155
@param  aScreenRect
sl@0
   156
        The dimensions of the display window.
sl@0
   157
@param  aClipRect
sl@0
   158
        The area of the video clip to display in the window.
sl@0
   159
*/     
sl@0
   160
EXPORT_C void CMVSVideoPlayAgent::SetVideoOutputL(RWsSession& aWs,
sl@0
   161
                                                  CWsScreenDevice& aScreenDevice,
sl@0
   162
                                                  RWindow& aWindow,
sl@0
   163
                                                  TRect& aScreenRect,
sl@0
   164
                                                  TRect& aClipRect)
sl@0
   165
	{
sl@0
   166
	iFileLogger.Write(_L("SettingVideoOutput"));
sl@0
   167
sl@0
   168
#ifdef SYMBIAN_BUILD_GCE
sl@0
   169
    // if CVideoPlayerUtility2 is available, instantiate both CVideoPlayerUtility2 &
sl@0
   170
    // CVideoPlayerUtility, as it is not clear whether the controller used for a 
sl@0
   171
    // particular media file also supports the CVideoPlayerUtility2 API until OpenFileL
sl@0
   172
    // is called.  
sl@0
   173
	if (iVideoPlayer2)
sl@0
   174
	    {
sl@0
   175
        delete iVideoPlayer2;
sl@0
   176
        iVideoPlayer2 = NULL;
sl@0
   177
	    }
sl@0
   178
	    
sl@0
   179
    iVideoPlayer2 = CVideoPlayerUtility2::NewL(*this, 
sl@0
   180
                                               EMdaPriorityNormal, 
sl@0
   181
    	                                       EMdaPriorityPreferenceNone);
sl@0
   182
#endif  // SYMBIAN_BUILD_GCE
sl@0
   183
sl@0
   184
	if (iVideoPlayer)
sl@0
   185
	    {
sl@0
   186
        delete iVideoPlayer;
sl@0
   187
        iVideoPlayer = NULL;
sl@0
   188
	    }	
sl@0
   189
    iVideoPlayer = CVideoPlayerUtility::NewL(*this, 
sl@0
   190
                                             EMdaPriorityNormal, 
sl@0
   191
    	                                     EMdaPriorityPreferenceNone, 
sl@0
   192
    	                                     aWs, 
sl@0
   193
    	                                     aScreenDevice,
sl@0
   194
    	                                     aWindow,
sl@0
   195
    	                                     aScreenRect,
sl@0
   196
    	                                     aClipRect);
sl@0
   197
	}
sl@0
   198
sl@0
   199
/**
sl@0
   200
Adds a new window for displaying the video picture.  This is only applicable if 
sl@0
   201
CVideoPlayerUtility2 is used.
sl@0
   202
sl@0
   203
This function leaves if the video player utility object failed to add display window or
sl@0
   204
if this function is called when CVideoPlayerUtility2 is not being used.
sl@0
   205
sl@0
   206
@param  aObserver
sl@0
   207
        A client class to receive notifications from the video player.
sl@0
   208
@param  aPriority
sl@0
   209
        This client's relative priority. This is a value between EMdaPriorityMin and
sl@0
   210
        EMdaPriorityMax and represents a relative priority. A higher value indicates
sl@0
   211
        a more important request.
sl@0
   212
@param  aPref
sl@0
   213
        The required behaviour if a higher priority client takes over the sound output device.
sl@0
   214
        One of the values defined by TMdaPriorityPreference.
sl@0
   215
@param  aWs
sl@0
   216
        The window server session id.
sl@0
   217
@param  aScreenDevice
sl@0
   218
        The software device screen.
sl@0
   219
@param  aWindow
sl@0
   220
        The display window.
sl@0
   221
@param  aScreenRect
sl@0
   222
        The dimensions of the display window.
sl@0
   223
@param  aClipRect
sl@0
   224
        The area of the video clip to display in the window.
sl@0
   225
@leave  KErrNotSupported if CVideoPlayerUtility2 is not the current video utility in use
sl@0
   226
@see    CVideoPlayerUtility2::AddDisplayWindowL       
sl@0
   227
*/     
sl@0
   228
#ifdef SYMBIAN_BUILD_GCE
sl@0
   229
EXPORT_C void CMVSVideoPlayAgent::AddDisplayWindowL(RWsSession& aWs,
sl@0
   230
                                                    CWsScreenDevice& aScreenDevice,
sl@0
   231
                                                    RWindow& aWindow,
sl@0
   232
                                                    const TRect& aScreenRect,
sl@0
   233
                                                    const TRect& aClipRect)
sl@0
   234
#else
sl@0
   235
EXPORT_C void CMVSVideoPlayAgent::AddDisplayWindowL(RWsSession& /* aWs */,
sl@0
   236
                                                    CWsScreenDevice& /* aScreenDevice */,
sl@0
   237
                                                    RWindow& /* aWindow */,
sl@0
   238
                                                    const TRect& /* aScreenRect */,
sl@0
   239
                                                    const TRect& /* aClipRect */)
sl@0
   240
#endif  // SYMBIAN_BUILD_GCE
sl@0
   241
    {
sl@0
   242
#ifdef SYMBIAN_BUILD_GCE
sl@0
   243
    if (SupportVideoPlayerUtility2())
sl@0
   244
        {
sl@0
   245
        iVideoPlayer2->AddDisplayWindowL(aWs, 
sl@0
   246
                                         aScreenDevice, 
sl@0
   247
                                         aWindow, 
sl@0
   248
                                         aScreenRect,
sl@0
   249
                                         aClipRect);
sl@0
   250
        iWindow = &aWindow;
sl@0
   251
sl@0
   252
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   253
        if (iEnableSubtitlesOnAdd)
sl@0
   254
        	{
sl@0
   255
        	iVideoPlayer2->EnableSubtitlesL();
sl@0
   256
        	iEnableSubtitlesOnAdd = EFalse;
sl@0
   257
        	}
sl@0
   258
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   259
        
sl@0
   260
        return;
sl@0
   261
        }
sl@0
   262
#endif  // SYMBIAN_BUILD_GCE        
sl@0
   263
    User::Leave(KErrNotSupported);
sl@0
   264
    }
sl@0
   265
sl@0
   266
#ifdef SYMBIAN_BUILD_GCE
sl@0
   267
EXPORT_C void CMVSVideoPlayAgent::AddDisplayWindowL(RWsSession& aWs,
sl@0
   268
                                                    CWsScreenDevice& aScreenDevice,
sl@0
   269
                                                    RWindow& aWindow)
sl@0
   270
#else
sl@0
   271
EXPORT_C void CMVSVideoPlayAgent::AddDisplayWindowL(RWsSession& /* aWs */,
sl@0
   272
                                                    CWsScreenDevice& /* aScreenDevice */,
sl@0
   273
                                                    RWindow& /* aWindow */)
sl@0
   274
#endif  // SYMBIAN_BUILD_GCE
sl@0
   275
    {
sl@0
   276
#ifdef SYMBIAN_BUILD_GCE
sl@0
   277
    if (SupportVideoPlayerUtility2())
sl@0
   278
        {
sl@0
   279
        iVideoPlayer2->AddDisplayWindowL(aWs, 
sl@0
   280
                                         aScreenDevice, 
sl@0
   281
                                         aWindow);
sl@0
   282
        iWindow = &aWindow;
sl@0
   283
        
sl@0
   284
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   285
        if (iEnableSubtitlesOnAdd)
sl@0
   286
        	{
sl@0
   287
        	iVideoPlayer2->EnableSubtitlesL();
sl@0
   288
        	iEnableSubtitlesOnAdd = EFalse;
sl@0
   289
        	}
sl@0
   290
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   291
        return;
sl@0
   292
        }
sl@0
   293
#endif  // SYMBIAN_BUILD_GCE        
sl@0
   294
    User::Leave(KErrNotSupported);
sl@0
   295
    }
sl@0
   296
sl@0
   297
EXPORT_C void CMVSVideoPlayAgent::AddDisplayL(RWsSession& aWs, TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler)
sl@0
   298
	{
sl@0
   299
	if (!SupportVideoPlayerUtility2())
sl@0
   300
		{
sl@0
   301
		User::Leave(KErrNotSupported);
sl@0
   302
		}
sl@0
   303
	
sl@0
   304
	iVideoPlayer2->AddDisplayL(aWs, aDisplay, aEventHandler);
sl@0
   305
	}
sl@0
   306
sl@0
   307
/**
sl@0
   308
Removes a window that is currently being used to display the video picture.
sl@0
   309
sl@0
   310
This function should only be called if CVideoPlayerUtility2 is currently being used for display 
sl@0
   311
of video.
sl@0
   312
sl@0
   313
@param  aWindow
sl@0
   314
        The window to be removed
sl@0
   315
@leave  KErrNotSupported if CVideoPlayerUtility2 is not the current video player utility.
sl@0
   316
@see    CVideoPlayerUtility2::RemoveDisplayWindow
sl@0
   317
*/                                    
sl@0
   318
EXPORT_C void CMVSVideoPlayAgent::RemoveDisplayWindowL(RWindow& aWindow)
sl@0
   319
    {
sl@0
   320
#ifdef SYMBIAN_BUILD_GCE
sl@0
   321
    if (SupportVideoPlayerUtility2())
sl@0
   322
        {
sl@0
   323
        iVideoPlayer2->RemoveDisplayWindow(aWindow);
sl@0
   324
        iWindow = NULL;        
sl@0
   325
        return;
sl@0
   326
        }
sl@0
   327
#endif  // SYMBIAN_BUILD_GCE
sl@0
   328
	// Remove compiler warning
sl@0
   329
	aWindow = aWindow;        
sl@0
   330
    User::Leave(KErrNotSupported);
sl@0
   331
    }
sl@0
   332
sl@0
   333
EXPORT_C void CMVSVideoPlayAgent::RemoveDisplay(TInt aDisplay)
sl@0
   334
	{
sl@0
   335
	if (!SupportVideoPlayerUtility2())
sl@0
   336
		{
sl@0
   337
		User::Leave(KErrNotSupported);
sl@0
   338
		}
sl@0
   339
sl@0
   340
	iVideoPlayer2->RemoveDisplay(aDisplay);
sl@0
   341
	}
sl@0
   342
sl@0
   343
/**
sl@0
   344
Opens a video clip from a file.
sl@0
   345
sl@0
   346
This function opens a video clip from a file,this function searches through a list of all available
sl@0
   347
plugins and attempts to use each one until successful or the end of the list is reached.
sl@0
   348
sl@0
   349
Once the opening of the video clip is complete, successfully or otherwise, the callback function 
sl@0
   350
CMVSVideoPlayAgent::MvpuoOpenComplete() is called.
sl@0
   351
sl@0
   352
This function leaves if errors are encountered opening the specified video clip file, or in initialising a 
sl@0
   353
specified/unspecified controller plugin.
sl@0
   354
sl@0
   355
This function can leave with one of the specified error codes. 
sl@0
   356
sl@0
   357
@param  aFileName
sl@0
   358
        The full path name of the file containing the video data.
sl@0
   359
*/
sl@0
   360
EXPORT_C void CMVSVideoPlayAgent::OpenFileL(const TDesC& aFileName)
sl@0
   361
	{
sl@0
   362
    OpenFileL(aFileName, KNullUid);                
sl@0
   363
    }
sl@0
   364
sl@0
   365
EXPORT_C void CMVSVideoPlayAgent::OpenFileL(const TDesC& aFileName, TUid aControllerUid)
sl@0
   366
	{
sl@0
   367
	iFileLogger.Write(_L("Opening a File For CMVSVideoPlayAgent "));
sl@0
   368
	
sl@0
   369
	// remembers the file name & the controller Uid used for opening file
sl@0
   370
	iFileName.Close();
sl@0
   371
	iFileName.CreateL(aFileName);
sl@0
   372
	iControllerUid = aControllerUid;
sl@0
   373
sl@0
   374
    __ASSERT_DEBUG(iVideoPlayer, User::Leave(KErrNotReady));
sl@0
   375
    iVideoPlayer->Close();	
sl@0
   376
    
sl@0
   377
#ifdef SYMBIAN_BUILD_GCE
sl@0
   378
    __ASSERT_DEBUG(iVideoPlayer2, User::Leave(KErrNotReady));
sl@0
   379
    iVideoPlayer2->Close();
sl@0
   380
sl@0
   381
    // First attempt is always to open a file with CVideoPlayerUtility2 if GCE 
sl@0
   382
    // is enabled
sl@0
   383
    iVideoPlayer2->OpenFileL(aFileName, aControllerUid);
sl@0
   384
    iCurrentVideoPlayer = iVideoPlayer2;
sl@0
   385
#else
sl@0
   386
    iVideoPlayer->OpenFileL(aFileName, aControllerUid);
sl@0
   387
    iCurrentVideoPlayer = iVideoPlayer;
sl@0
   388
#endif  // SYMBIAN_BUILD_GCE	
sl@0
   389
sl@0
   390
	// Now that we have selected the video player, we can issue the request for notification.
sl@0
   391
	if (iRequestNotify)
sl@0
   392
		{
sl@0
   393
		RegisterForNotification();
sl@0
   394
		}
sl@0
   395
	} 
sl@0
   396
sl@0
   397
EXPORT_C void CMVSVideoPlayAgent::OpenFileL(TMMSource& /*aSource*/)
sl@0
   398
	{
sl@0
   399
	}
sl@0
   400
sl@0
   401
EXPORT_C void CMVSVideoPlayAgent::OpenDesL(const TDesC8& /*aDescriptor*/)
sl@0
   402
	{
sl@0
   403
	}
sl@0
   404
		 
sl@0
   405
void CMVSVideoPlayAgent::MvpuoOpenComplete(TInt aError)
sl@0
   406
	{
sl@0
   407
	iFileLogger.Write(_L("CMVSVideoPlayAgent:MvpuoOpenComplete"));
sl@0
   408
	if(aError == KErrNone)
sl@0
   409
    	{
sl@0
   410
    	iState = EVideoOpening;
sl@0
   411
    	iFileLogger.Write(_L("MvpuoOpenComplete:VideoOpening"));
sl@0
   412
    	iObserver.UpdateStateChange(iState, KErrNone);
sl@0
   413
sl@0
   414
        iCurrentVideoPlayer->Prepare();            
sl@0
   415
    	}
sl@0
   416
#ifdef SYMBIAN_BUILD_GCE    	
sl@0
   417
    else if (iCurrentVideoPlayer == iVideoPlayer2 && aError == KErrNotSupported)
sl@0
   418
        {	
sl@0
   419
        // if the controller cannot support GS, try use CVideoPlayerUtility instead
sl@0
   420
        TRAPD(err, iVideoPlayer->OpenFileL(iFileName, iControllerUid));
sl@0
   421
        
sl@0
   422
        if (err != KErrNone)
sl@0
   423
        	{
sl@0
   424
        	iState = ENotReady; //init failed so from opening to NotReady
sl@0
   425
	     	iFileLogger.Write(_L("MvpuoOpenComplete:From Opening to  NotReady"));
sl@0
   426
	     	iObserver.UpdateStateChange(iState, err);
sl@0
   427
        	}
sl@0
   428
        
sl@0
   429
        iCurrentVideoPlayer = iVideoPlayer;
sl@0
   430
        
sl@0
   431
        // We are switching to a different controller.  Cancel the notification request on one
sl@0
   432
        // controller and reissue it on the other.
sl@0
   433
		if (iRequestNotify)
sl@0
   434
			{
sl@0
   435
			iVideoPlayer2->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
sl@0
   436
			RegisterForNotification();
sl@0
   437
			}
sl@0
   438
        }
sl@0
   439
#endif  // SYMBIAN_BUILD_GCE    	        
sl@0
   440
    else            
sl@0
   441
		{
sl@0
   442
     	iState = ENotReady; //init failed so from opening to NotReady
sl@0
   443
     	iFileLogger.Write(_L("MvpuoOpenComplete:From Opening to  NotReady"));
sl@0
   444
     	iObserver.UpdateStateChange(iState, aError);
sl@0
   445
		}
sl@0
   446
	}
sl@0
   447
sl@0
   448
void CMVSVideoPlayAgent::MvpuoPrepareComplete(TInt aError)
sl@0
   449
	{
sl@0
   450
	iFileLogger.Write(_L("CMVSVideoPlayAgent:MvpuoPrepareComplete"));
sl@0
   451
	if(aError == KErrNone)
sl@0
   452
    	{
sl@0
   453
    	iState = EVideoOpened;
sl@0
   454
        iFileLogger.Write(_L("MvpuoPrepareComplete:Video Opened"));
sl@0
   455
    	}
sl@0
   456
    else
sl@0
   457
		{
sl@0
   458
     	iState = ENotReady; //prepare failed so from preparing to NotReady
sl@0
   459
     	iFileLogger.Write(_L("MvpuoPrepareComplete failed : from preparing to NotReady")) ;
sl@0
   460
		}
sl@0
   461
	iObserver.UpdateStateChange(iState, aError);
sl@0
   462
	}
sl@0
   463
sl@0
   464
void CMVSVideoPlayAgent::MvpuoPlayComplete(TInt aError)
sl@0
   465
	{
sl@0
   466
	if(aError == KErrNone)
sl@0
   467
    	{
sl@0
   468
    	iState = EVideoOpened;
sl@0
   469
    	iFileLogger.Write(_L("MvpuoPlayComplete:Video Opened"));
sl@0
   470
    	}
sl@0
   471
    else
sl@0
   472
		{
sl@0
   473
     	iState = ENotReady; //playcomplete failed so from playcomplete to NotReady
sl@0
   474
     	iFileLogger.Write(_L("MvpuoPlayComplete failed : from playcomplete to NotReady")) ;
sl@0
   475
		}
sl@0
   476
	iObserver.UpdateStateChange(iState, aError);
sl@0
   477
	}
sl@0
   478
sl@0
   479
void CMVSVideoPlayAgent::MvpuoFrameReady(class CFbsBitmap&, TInt)
sl@0
   480
	{
sl@0
   481
	}
sl@0
   482
sl@0
   483
void CMVSVideoPlayAgent::MvpuoEvent(const TMMFEvent& /*aEvent*/)
sl@0
   484
	{	
sl@0
   485
	}	
sl@0
   486
	
sl@0
   487
void CMVSVideoPlayAgent::MarncResourceAvailable(TUid aNotificationEventId, const TDesC8& aNotificationData)
sl@0
   488
	{
sl@0
   489
	if(aNotificationEventId == KMMFEventCategoryAudioResourceAvailable)
sl@0
   490
		{
sl@0
   491
		iObserver.MvsResourceNotification(aNotificationData);
sl@0
   492
		}
sl@0
   493
	}
sl@0
   494
	
sl@0
   495
EXPORT_C void CMVSVideoPlayAgent::Prepare()
sl@0
   496
	{	
sl@0
   497
    iCurrentVideoPlayer->Prepare();	
sl@0
   498
	}
sl@0
   499
sl@0
   500
sl@0
   501
/**
sl@0
   502
Closes the video clip.
sl@0
   503
Updates the state to ENotReady after closing
sl@0
   504
*/
sl@0
   505
EXPORT_C void CMVSVideoPlayAgent::Close()
sl@0
   506
	{
sl@0
   507
	iFileLogger.Write(_L("CMVSVideoPlayAgent Closed"));
sl@0
   508
	
sl@0
   509
#ifdef SYMBIAN_BUILD_GCE
sl@0
   510
    if (SupportVideoPlayerUtility2())
sl@0
   511
        {            	
sl@0
   512
        // Can't leave at this point, this will just remove the leave scan warning
sl@0
   513
        TRAP_IGNORE(RemoveDisplayWindowL(*iWindow));
sl@0
   514
        iVideoPlayer2->Close();
sl@0
   515
        }
sl@0
   516
#endif  // SYMBIAN_BUILD_GCE
sl@0
   517
    iVideoPlayer->Close();
sl@0
   518
    
sl@0
   519
	iObserver.UpdateStateChange(ENotReady, KErrNone);
sl@0
   520
    iCurrentVideoPlayer = NULL;	
sl@0
   521
	}
sl@0
   522
sl@0
   523
sl@0
   524
/**
sl@0
   525
Begins playback of the initialised video sample at the current volume and priority levels.
sl@0
   526
sl@0
   527
When playing of the video sample is complete, successfully or otherwise, the callback function
sl@0
   528
CMVSVideoPlayAgent::MvpuoPlayComplete() is called.Updates the current state to EVideoPlaying,
sl@0
   529
and once playing is over it updates the state to EVideoOpen.
sl@0
   530
*/
sl@0
   531
EXPORT_C void CMVSVideoPlayAgent::Play()
sl@0
   532
	{
sl@0
   533
    iCurrentVideoPlayer->Play();
sl@0
   534
sl@0
   535
	iState = EVideoPlaying;
sl@0
   536
	iObserver.UpdateStateChange(iState, KErrNone);
sl@0
   537
	}
sl@0
   538
sl@0
   539
sl@0
   540
/**
sl@0
   541
Begins playback of the initialised video sample at the specified start and end points.
sl@0
   542
sl@0
   543
When playing of the video sample is complete, successfully or otherwise, the callback function
sl@0
   544
CMVSVideoPlayAgent::MvpuoPlayComplete() is called.Updates the current state to EVideoPlaying,
sl@0
   545
and once playing is over it updates the state to EVideoOpen.
sl@0
   546
sl@0
   547
@param  aStartTime
sl@0
   548
        The point at which to start playback.
sl@0
   549
@param  aEndTime
sl@0
   550
        The point at which to terminate playback.
sl@0
   551
*/
sl@0
   552
EXPORT_C void CMVSVideoPlayAgent::Play(const TTimeIntervalMicroSeconds& aStartPoint, 
sl@0
   553
                                       const TTimeIntervalMicroSeconds& aEndPoint)
sl@0
   554
	{
sl@0
   555
    iCurrentVideoPlayer->Play(aStartPoint, aEndPoint);
sl@0
   556
sl@0
   557
	iState = EVideoPlaying;
sl@0
   558
	iObserver.UpdateStateChange(iState, KErrNone);
sl@0
   559
	}
sl@0
   560
sl@0
   561
sl@0
   562
/**
sl@0
   563
Stops playback of the video sample as soon as is possible. 
sl@0
   564
sl@0
   565
If the video sample is playing, playback is stopped as soon as possible and the callback function 
sl@0
   566
CMVSVideoPlayAgent::MvpuoPlayComplete() is called.
sl@0
   567
sl@0
   568
If playback is already complete, this function has no effect. In addition, under these circumstances 
sl@0
   569
the callback function CMVSVideoPlayAgent::MvpuoPlayComplete() is not called either.
sl@0
   570
sl@0
   571
The position is reset to the beginning of the file.
sl@0
   572
sl@0
   573
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   574
        another of the system-wide error codes.
sl@0
   575
Also Updates the state to EVideoStopped
sl@0
   576
*/
sl@0
   577
EXPORT_C TInt CMVSVideoPlayAgent::Stop()
sl@0
   578
	{
sl@0
   579
	TInt err = KErrNotReady;
sl@0
   580
    if (iCurrentVideoPlayer)
sl@0
   581
		{
sl@0
   582
		err = iCurrentVideoPlayer->Stop();
sl@0
   583
		}
sl@0
   584
sl@0
   585
	if (err == KErrNone)
sl@0
   586
		{
sl@0
   587
		iState = EVideoStopped;
sl@0
   588
		iFileLogger.Write(_L("CMVSVideoPlayAgent Stopped"));
sl@0
   589
		}
sl@0
   590
	else
sl@0
   591
		{
sl@0
   592
		iState = ENotReady;
sl@0
   593
		}
sl@0
   594
    iObserver.UpdateStateChange(iState, err);
sl@0
   595
    
sl@0
   596
    return err;
sl@0
   597
	}
sl@0
   598
sl@0
   599
sl@0
   600
/**
sl@0
   601
Video playback is paused. The current position is maintained and playback can be
sl@0
   602
resumed by calling Play.
sl@0
   603
*/
sl@0
   604
EXPORT_C void CMVSVideoPlayAgent::PauseL()
sl@0
   605
	{
sl@0
   606
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
   607
	
sl@0
   608
    TRAPD(err, iCurrentVideoPlayer->PauseL());
sl@0
   609
	if(err == KErrNone)
sl@0
   610
		{
sl@0
   611
		iState = EVideoPaused;
sl@0
   612
		iFileLogger.Write(_L("CMVSVideoPlayAgent Paused "));
sl@0
   613
		}
sl@0
   614
	else
sl@0
   615
		{
sl@0
   616
		iState = ENotReady;
sl@0
   617
		iFileLogger.Write(_L("CMVSVideoPlayAgent Not Ready"));	
sl@0
   618
		}	
sl@0
   619
	iObserver.UpdateStateChange(iState, err);
sl@0
   620
	}
sl@0
   621
	
sl@0
   622
sl@0
   623
/**
sl@0
   624
Sends custom command to the plugin controller.
sl@0
   625
Passes handle and size of the drawable window.
sl@0
   626
sl@0
   627
Sets the display window. This is used to provide the video controller with an area of
sl@0
   628
the display to render the current video frame.
sl@0
   629
sl@0
   630
@param  aWs
sl@0
   631
        The window server session ID.
sl@0
   632
@param  aScreenDevice
sl@0
   633
        The software device screen.
sl@0
   634
@param  aWindowRect
sl@0
   635
        The window to display.
sl@0
   636
@param  aScreenRect
sl@0
   637
        The dimensions of the display window.
sl@0
   638
@param  aClipRect
sl@0
   639
        The area of the video clip to display in the window.
sl@0
   640
*/	
sl@0
   641
EXPORT_C void CMVSVideoPlayAgent::SetDisplayWindowL(RWsSession &aWs, CWsScreenDevice &aScreenDevice, RWindow &aWindow, const TRect &aWindowRect, const TRect &aClipRect)
sl@0
   642
	{
sl@0
   643
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
   644
	
sl@0
   645
	iFileLogger.Write(_L("SettingDisplayWindow"));	
sl@0
   646
    iCurrentVideoPlayer->SetDisplayWindowL(aWs, aScreenDevice, aWindow, aWindowRect, aClipRect);
sl@0
   647
	}
sl@0
   648
	
sl@0
   649
sl@0
   650
/**
sl@0
   651
Sets the video frame rate.
sl@0
   652
sl@0
   653
@param  aFramesPerSecond
sl@0
   654
        The number of frames per second to request.
sl@0
   655
*/
sl@0
   656
EXPORT_C void CMVSVideoPlayAgent::SetVideoFrameRateL(TReal32 aFramesPerSecond)
sl@0
   657
	{
sl@0
   658
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
   659
	
sl@0
   660
	iFileLogger.Write(_L("SettingVedioFrameRate "));
sl@0
   661
    iCurrentVideoPlayer->SetVideoFrameRateL(aFramesPerSecond);
sl@0
   662
	}
sl@0
   663
sl@0
   664
sl@0
   665
/**
sl@0
   666
Sets the playback volume for the audio track of the video clip.
sl@0
   667
sl@0
   668
The volume can be changed before or during playback and is effective immediately. The volume can
sl@0
   669
be set to any value between zero (mute) and the maximum permissible volume
sl@0
   670
(determined using MaxVolume()).
sl@0
   671
sl@0
   672
To determine if the current video clip contains an audio track, use AudioEnabledL().
sl@0
   673
sl@0
   674
sl@0
   675
@param  aVolume
sl@0
   676
        The volume, between 0 and MaxVolume().
sl@0
   677
*/
sl@0
   678
EXPORT_C void CMVSVideoPlayAgent::SetVolumeL(TInt aVolume)
sl@0
   679
	{
sl@0
   680
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));			
sl@0
   681
	
sl@0
   682
	iFileLogger.Write(_L("Setting CMVSVideoPlayAgent's Volume "));
sl@0
   683
	iCurrentVideoPlayer->SetVolumeL(aVolume);
sl@0
   684
	}
sl@0
   685
	
sl@0
   686
sl@0
   687
/**
sl@0
   688
Sets the current playback balance for the audio track of the video clip.
sl@0
   689
sl@0
   690
The balance can be any value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight,
sl@0
   691
the default value being KMMFBalanceCenter.
sl@0
   692
sl@0
   693
@param  aBalance
sl@0
   694
        The balance value to set.
sl@0
   695
*/
sl@0
   696
EXPORT_C void CMVSVideoPlayAgent::SetBalanceL(TInt aBalance)
sl@0
   697
	{
sl@0
   698
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));				
sl@0
   699
	
sl@0
   700
	iFileLogger.Write(_L("Setting CMVSVideoPlayAgent's Balance"));
sl@0
   701
	iCurrentVideoPlayer->SetBalanceL(aBalance);
sl@0
   702
	}
sl@0
   703
	
sl@0
   704
sl@0
   705
/**
sl@0
   706
Sets the playback priority. 
sl@0
   707
sl@0
   708
This is used to arbitrate between multiple objects simultaneously trying to accesses
sl@0
   709
the sound hardware.
sl@0
   710
sl@0
   711
@param  aPriority
sl@0
   712
        The priority level to apply, EMdaPriorityMin client can be interrupted by any other 
sl@0
   713
        client, EMdaPriorityNormal client can only be interrupted by a client with a higher 
sl@0
   714
        priority or EMdaPriorityMax client cannot be interrupted by other clients.
sl@0
   715
@param  aPref
sl@0
   716
        The time and quality preferences to apply, enumerated in TMdaPriorityPreference.
sl@0
   717
*/
sl@0
   718
EXPORT_C void CMVSVideoPlayAgent::SetPriorityL(TInt aPriority, TMdaPriorityPreference aPref)
sl@0
   719
	{
sl@0
   720
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));				
sl@0
   721
	
sl@0
   722
	iFileLogger.Write(_L("Setting Priority of CMVSVideoPlayAgent"));
sl@0
   723
	iCurrentVideoPlayer->SetPriorityL(aPriority, aPref);
sl@0
   724
	}
sl@0
   725
	
sl@0
   726
sl@0
   727
/**
sl@0
   728
Sets the position within the video clip from where to start playback.
sl@0
   729
sl@0
   730
@param  aPosition
sl@0
   731
        Position from start of clip in microseconds.
sl@0
   732
*/
sl@0
   733
EXPORT_C void CMVSVideoPlayAgent::SetPositionL(const TTimeIntervalMicroSeconds &aPosition)
sl@0
   734
    {
sl@0
   735
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));					
sl@0
   736
sl@0
   737
    iFileLogger.Write(_L("Setting Position of CMVSVideoPlayAgent"));
sl@0
   738
    iCurrentVideoPlayer->SetPositionL(aPosition);
sl@0
   739
    }
sl@0
   740
	
sl@0
   741
sl@0
   742
/**
sl@0
   743
Rotates the video image on the screen.
sl@0
   744
sl@0
   745
@param  aRotation
sl@0
   746
        The desired rotation to apply in 90 degree increments.
sl@0
   747
*/
sl@0
   748
EXPORT_C void CMVSVideoPlayAgent::SetRotationL(TVideoRotation aRotation)
sl@0
   749
	{
sl@0
   750
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));					
sl@0
   751
		
sl@0
   752
	iFileLogger.Write(_L("Setting Rotations of CMVSVideoPlayAgent"));
sl@0
   753
    iCurrentVideoPlayer->SetRotationL(aRotation);
sl@0
   754
	}
sl@0
   755
	
sl@0
   756
sl@0
   757
sl@0
   758
/**
sl@0
   759
Scales the video image to a specified percentage of its original size.
sl@0
   760
sl@0
   761
@param  aWidthPercentage
sl@0
   762
        The percentage (100 = original size) to be used to scale the width of the video image
sl@0
   763
@param  aHeightPercentage
sl@0
   764
        The percentage (100 = original size) to be used to scale the height of the video image. 
sl@0
   765
        If this is not equal to aWidthPercentage then the image may be distorted.
sl@0
   766
@param  aAntiAliasFiltering
sl@0
   767
        A boolean specifying if anti-aliasing should be used. True if anti-aliasing filtering 
sl@0
   768
        should be used.  If the plugin does not	support this kind of processing, 
sl@0
   769
        this value will be ignored.
sl@0
   770
*/
sl@0
   771
EXPORT_C void CMVSVideoPlayAgent::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, TBool aAntiAliasFiltering)
sl@0
   772
	{
sl@0
   773
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));					
sl@0
   774
		
sl@0
   775
	iFileLogger.Write(_L("Setting ScaleFactor of CMVSVideoPlayAgent"));
sl@0
   776
	iCurrentVideoPlayer->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aAntiAliasFiltering);
sl@0
   777
	}
sl@0
   778
sl@0
   779
sl@0
   780
/**
sl@0
   781
Selects a region of the video image to be displayed.
sl@0
   782
sl@0
   783
@param  aCropRegion
sl@0
   784
        The dimensions of the crop region, relative to the video image.
sl@0
   785
@see   GetCropRegionL
sl@0
   786
*/
sl@0
   787
EXPORT_C void CMVSVideoPlayAgent::SetCropRegionL(const TRect& aCropRegion)
sl@0
   788
	{
sl@0
   789
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));					
sl@0
   790
	
sl@0
   791
	iFileLogger.Write(_L("Setting CorpRegion of CMVSVideoPlayAgent"));
sl@0
   792
    iCurrentVideoPlayer->SetCropRegionL(aCropRegion);
sl@0
   793
	}
sl@0
   794
sl@0
   795
/**
sl@0
   796
Selects the video extent on the screen, relative to the window.
sl@0
   797
sl@0
   798
@param  aVideoExtent
sl@0
   799
        The new video extent, relative to the window
sl@0
   800
@leave  KErrNotSupport if CVideoPlayerUtility is used for video playback
sl@0
   801
*/
sl@0
   802
#ifdef SYMBIAN_BUILD_GCE
sl@0
   803
EXPORT_C void CMVSVideoPlayAgent::SetVideoExtentL(const TRect& aVideoExtent)
sl@0
   804
#else
sl@0
   805
EXPORT_C void CMVSVideoPlayAgent::SetVideoExtentL(const TRect& /* aVideoExtent */)
sl@0
   806
#endif  // SYMBIAN_BUILD_GCE
sl@0
   807
	{
sl@0
   808
	iFileLogger.Write(_L("Setting VideoExtent of CMVSVideoPlayAgent"));
sl@0
   809
	
sl@0
   810
#ifdef SYMBIAN_BUILD_GCE	
sl@0
   811
	if(SupportVideoPlayerUtility2())
sl@0
   812
		{
sl@0
   813
		if (iWindow)
sl@0
   814
		    {		        
sl@0
   815
		    iVideoPlayer2->SetVideoExtentL(*iWindow, aVideoExtent);
sl@0
   816
		    }            		    
sl@0
   817
        else 
sl@0
   818
            {
sl@0
   819
		    iFileLogger.Write(_L("WARNING - Display Window has not been set.  Caller should save these values to be set again later."));
sl@0
   820
            }
sl@0
   821
		return;
sl@0
   822
		}
sl@0
   823
#endif  // SYMBIAN_BUILD_GCE		
sl@0
   824
sl@0
   825
	User::Leave(KErrNotSupported);
sl@0
   826
	}
sl@0
   827
sl@0
   828
/**
sl@0
   829
Selects the window clipping rectangle, relative to the window
sl@0
   830
sl@0
   831
@param  aWindowClipRect
sl@0
   832
        The new window clipping rectangle, relative to the window
sl@0
   833
@leave  KErrNotSupport if CVideoPlayerUtility is used for video playback
sl@0
   834
*/
sl@0
   835
#ifdef SYMBIAN_BUILD_GCE
sl@0
   836
EXPORT_C void CMVSVideoPlayAgent::SetWindowClipRectL(const TRect& aWindowClipRect)
sl@0
   837
#else
sl@0
   838
EXPORT_C void CMVSVideoPlayAgent::SetWindowClipRectL(const TRect& /* aWindowClipRect */)
sl@0
   839
#endif  // SYMBIAN_BUILD_GCE
sl@0
   840
	{
sl@0
   841
    iFileLogger.Write(_L("Setting WindowClippingRect of CMVSVideoPlayAgent"));
sl@0
   842
	
sl@0
   843
#ifdef SYMBIAN_BUILD_GCE
sl@0
   844
    if (SupportVideoPlayerUtility2())
sl@0
   845
        {            	
sl@0
   846
        if (iWindow)
sl@0
   847
            {                
sl@0
   848
            iVideoPlayer2->SetWindowClipRectL(*iWindow, aWindowClipRect);	
sl@0
   849
            }
sl@0
   850
        else 
sl@0
   851
            {
sl@0
   852
		    iFileLogger.Write(_L("WARNING - Display Window has not been set.  Caller should save these values to be set again later."));
sl@0
   853
            }
sl@0
   854
        return;
sl@0
   855
        }
sl@0
   856
#endif  // SYMBIAN_BUILD_GCE        														
sl@0
   857
sl@0
   858
    User::Leave(KErrNotSupported);
sl@0
   859
	}
sl@0
   860
sl@0
   861
sl@0
   862
/**
sl@0
   863
Gets the current frame. The current frame is requested, and will be sent to
sl@0
   864
the client asynchrynously.
sl@0
   865
sl@0
   866
@param  aDisplayMode
sl@0
   867
        The display mode for the retrieved frame.
sl@0
   868
*/
sl@0
   869
EXPORT_C void CMVSVideoPlayAgent::GetFrameL(TDisplayMode aDisplayMode)
sl@0
   870
	{
sl@0
   871
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));						
sl@0
   872
	iCurrentVideoPlayer->GetFrameL(aDisplayMode);
sl@0
   873
	}
sl@0
   874
sl@0
   875
sl@0
   876
/**
sl@0
   877
Gets the current frame. The current frame is requested, and will be sent to
sl@0
   878
the client asynchrynously.
sl@0
   879
sl@0
   880
@param  aDisplayMode
sl@0
   881
        The display mode for the retrieved frame.
sl@0
   882
@param  aIntent
sl@0
   883
        The DRM Intent to pass to the controller.
sl@0
   884
*/
sl@0
   885
EXPORT_C void CMVSVideoPlayAgent::GetFrameL(TDisplayMode aDisplayMode, ContentAccess::TIntent aIntent)
sl@0
   886
	{
sl@0
   887
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));							
sl@0
   888
	iCurrentVideoPlayer->GetFrameL(aDisplayMode, aIntent);
sl@0
   889
	}
sl@0
   890
sl@0
   891
sl@0
   892
/**
sl@0
   893
Returns the video frame rate in frames/second.
sl@0
   894
sl@0
   895
@return The video frame rate (frames/second).
sl@0
   896
*/
sl@0
   897
EXPORT_C TReal32 CMVSVideoPlayAgent::VideoFrameRateL()
sl@0
   898
	{
sl@0
   899
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));							
sl@0
   900
	
sl@0
   901
	iFileLogger.Write(_L("Getting VideoFrameRate for CMVSVideoPlayAgent"));
sl@0
   902
	return iCurrentVideoPlayer->VideoFrameRateL();
sl@0
   903
	}
sl@0
   904
sl@0
   905
sl@0
   906
/**
sl@0
   907
Gets the video frame size.
sl@0
   908
sl@0
   909
@param  aSize
sl@0
   910
        The video frame size
sl@0
   911
*/
sl@0
   912
EXPORT_C void CMVSVideoPlayAgent::VideoFrameSizeL(TSize &aSize) 
sl@0
   913
	{
sl@0
   914
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));								
sl@0
   915
	
sl@0
   916
	iFileLogger.Write(_L("Getting VideoFrameFrameSize for CMVSVideoPlayAgent"));	
sl@0
   917
	iCurrentVideoPlayer->VideoFrameSizeL(aSize);
sl@0
   918
	}
sl@0
   919
sl@0
   920
sl@0
   921
/**
sl@0
   922
Returns the video format's MIME type.
sl@0
   923
sl@0
   924
@return The video clip's MIME type.
sl@0
   925
*/
sl@0
   926
EXPORT_C const TDesC8& CMVSVideoPlayAgent::VideoFormatMimeType() 
sl@0
   927
	{
sl@0
   928
    if (iCurrentVideoPlayer)
sl@0
   929
        {
sl@0
   930
	    return iCurrentVideoPlayer->VideoFormatMimeType();            
sl@0
   931
        }
sl@0
   932
    else 
sl@0
   933
        {            
sl@0
   934
        return KNullDesC8;								
sl@0
   935
        }
sl@0
   936
	}
sl@0
   937
sl@0
   938
sl@0
   939
/**
sl@0
   940
Returns the video bit rate.
sl@0
   941
sl@0
   942
@return The video bit rate in bits/second.
sl@0
   943
*/
sl@0
   944
EXPORT_C TInt CMVSVideoPlayAgent::VideoBitRateL() 
sl@0
   945
	{
sl@0
   946
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));									
sl@0
   947
	
sl@0
   948
	iFileLogger.Write(_L("Getting VideoBitRate for CMVSVideoPlayAgent"));
sl@0
   949
	return iCurrentVideoPlayer->VideoBitRateL();
sl@0
   950
	}
sl@0
   951
sl@0
   952
sl@0
   953
/**
sl@0
   954
Returns the audio bit rate in bits/second.
sl@0
   955
sl@0
   956
@return The audio bit rate (bits/second).
sl@0
   957
*/
sl@0
   958
EXPORT_C TInt CMVSVideoPlayAgent::AudioBitRateL()
sl@0
   959
	{
sl@0
   960
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));									
sl@0
   961
		
sl@0
   962
	iFileLogger.Write(_L("Getting AudioBitRate for CMVSVideoPlayAgent"));	
sl@0
   963
	return iCurrentVideoPlayer->AudioBitRateL();
sl@0
   964
	}
sl@0
   965
sl@0
   966
sl@0
   967
/**
sl@0
   968
Returns the codec used for the audio component of the video clip.
sl@0
   969
sl@0
   970
@return The four character code representing the audio codec.
sl@0
   971
*/
sl@0
   972
EXPORT_C TFourCC CMVSVideoPlayAgent::AudioTypeL()
sl@0
   973
	{
sl@0
   974
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));										
sl@0
   975
	
sl@0
   976
	iFileLogger.Write(_L("Getting AudioType for CMVSVideoPlayAgent"));
sl@0
   977
	return iCurrentVideoPlayer->AudioTypeL();
sl@0
   978
	}
sl@0
   979
sl@0
   980
sl@0
   981
/**
sl@0
   982
Returns whether the current clip has an audio stream.
sl@0
   983
sl@0
   984
@return Boolean indication the presence of an audio stream. ETrue if an audio track is present,
sl@0
   985
        otherwise EFalse.
sl@0
   986
*/
sl@0
   987
EXPORT_C TBool CMVSVideoPlayAgent::AudioEnabledL() 
sl@0
   988
	{
sl@0
   989
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));
sl@0
   990
	
sl@0
   991
	iFileLogger.Write(_L("CMVSVideoPlayAgent's Audio Enabled"));
sl@0
   992
	return iCurrentVideoPlayer->AudioEnabledL();
sl@0
   993
	}
sl@0
   994
sl@0
   995
sl@0
   996
/**
sl@0
   997
Returns the current playback position.
sl@0
   998
sl@0
   999
@return The current position from the start of the clip in microseconds.
sl@0
  1000
*/
sl@0
  1001
EXPORT_C TTimeIntervalMicroSeconds CMVSVideoPlayAgent::PositionL() 
sl@0
  1002
	{
sl@0
  1003
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));
sl@0
  1004
	return iCurrentVideoPlayer->PositionL();
sl@0
  1005
	}
sl@0
  1006
sl@0
  1007
sl@0
  1008
/**
sl@0
  1009
Returns the duration of video clip in mircoseconds.
sl@0
  1010
sl@0
  1011
@return The duration of clip in microseconds.
sl@0
  1012
*/
sl@0
  1013
EXPORT_C TTimeIntervalMicroSeconds CMVSVideoPlayAgent::DurationL() 
sl@0
  1014
	{
sl@0
  1015
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));	
sl@0
  1016
	return iCurrentVideoPlayer->DurationL();
sl@0
  1017
	}
sl@0
  1018
sl@0
  1019
sl@0
  1020
/**
sl@0
  1021
Returns the current playback volume for the audio track of the video clip.
sl@0
  1022
sl@0
  1023
@return A value between 0 (mute) and the maximum volume returned by MaxVolume().
sl@0
  1024
*/
sl@0
  1025
EXPORT_C TInt CMVSVideoPlayAgent::Volume() 
sl@0
  1026
	{
sl@0
  1027
	return iCurrentVideoPlayer->Volume();
sl@0
  1028
	}
sl@0
  1029
sl@0
  1030
sl@0
  1031
/**
sl@0
  1032
Get the current playback priority. This is used to arbitrate between simultaneous accesses of
sl@0
  1033
the sound hardware.
sl@0
  1034
sl@0
  1035
@param  aPriority
sl@0
  1036
        On return, contains the priority level, EMdaPriorityMin client can be interrupted by any
sl@0
  1037
        other client, EMdaPriorityNormal client can only be interrupted by a client with a higher 
sl@0
  1038
        priority or EMdaPriorityMax client cannot be interrupted by other clients.
sl@0
  1039
@param  aPref
sl@0
  1040
        On return, contains the time and quality preferences, enumerated in TMdaPriorityPreference.
sl@0
  1041
*/
sl@0
  1042
EXPORT_C void CMVSVideoPlayAgent::PriorityL(TInt &aPriority, TMdaPriorityPreference &aPref) 
sl@0
  1043
	{
sl@0
  1044
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1045
	iCurrentVideoPlayer->PriorityL(aPriority, aPref);
sl@0
  1046
	}
sl@0
  1047
sl@0
  1048
sl@0
  1049
/**
sl@0
  1050
Returns the current balance setting for the audio track of the video clip.
sl@0
  1051
sl@0
  1052
@return A balance value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.
sl@0
  1053
*/
sl@0
  1054
EXPORT_C TInt CMVSVideoPlayAgent::Balance() 
sl@0
  1055
	{
sl@0
  1056
	return iCurrentVideoPlayer->Balance();	
sl@0
  1057
	}
sl@0
  1058
sl@0
  1059
	
sl@0
  1060
/**
sl@0
  1061
Query the rotation that is currently applied to the video image.
sl@0
  1062
sl@0
  1063
@return The applied rotation
sl@0
  1064
sl@0
  1065
@see   SetRotationL
sl@0
  1066
*/
sl@0
  1067
EXPORT_C TVideoRotation CMVSVideoPlayAgent::RotationL() 
sl@0
  1068
	{
sl@0
  1069
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1070
	return iCurrentVideoPlayer->RotationL();
sl@0
  1071
	}
sl@0
  1072
sl@0
  1073
sl@0
  1074
/**
sl@0
  1075
Gets the scale factor currently applied to the video image.
sl@0
  1076
sl@0
  1077
@param  aWidthPercentage
sl@0
  1078
        On function return, contains the current scaling percentage applied to the width of the
sl@0
  1079
        video image (100 = original size).
sl@0
  1080
@param  aHeightPercentage
sl@0
  1081
        On function return, contains the current scaling percentage applied to the height of the
sl@0
  1082
        of the video image (100 = original size).
sl@0
  1083
@param  aAntiAliasFiltering
sl@0
  1084
        The boolean specifying if anit-aliasing is being used.
sl@0
  1085
@see    SetScaleFactorL
sl@0
  1086
*/
sl@0
  1087
EXPORT_C void CMVSVideoPlayAgent::GetScaleFactorL(TReal32 &aWidthPercentage, TReal32 &aHeightPercentage, TBool &aAntiAliasFiltering) 
sl@0
  1088
	{
sl@0
  1089
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1090
	iCurrentVideoPlayer->GetScaleFactorL(aWidthPercentage, 
sl@0
  1091
	                                     aHeightPercentage, 
sl@0
  1092
	                                     aAntiAliasFiltering);
sl@0
  1093
	}
sl@0
  1094
sl@0
  1095
sl@0
  1096
/**
sl@0
  1097
Gets the crop region currently applied to the image.
sl@0
  1098
sl@0
  1099
@param  aCropRegion
sl@0
  1100
        The dimensions of the crop region, relative to the video image. If no
sl@0
  1101
        crop region has been applied, the full dimensions of the video image will
sl@0
  1102
        be returned.
sl@0
  1103
sl@0
  1104
@see   SetCropRegionL
sl@0
  1105
*/
sl@0
  1106
EXPORT_C void CMVSVideoPlayAgent::GetCropRegionL(TRect &aCropRegion) 
sl@0
  1107
	{
sl@0
  1108
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1109
	iCurrentVideoPlayer->GetCropRegionL(aCropRegion);
sl@0
  1110
	}
sl@0
  1111
sl@0
  1112
sl@0
  1113
/**
sl@0
  1114
Returns the number of meta data entries associated with this clip.
sl@0
  1115
sl@0
  1116
@return The number of meta data entries.
sl@0
  1117
*/
sl@0
  1118
EXPORT_C TInt CMVSVideoPlayAgent::NumberOfMetaDataEntriesL()
sl@0
  1119
	{
sl@0
  1120
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1121
    return iCurrentVideoPlayer->NumberOfMetaDataEntriesL();
sl@0
  1122
	}
sl@0
  1123
sl@0
  1124
sl@0
  1125
/**
sl@0
  1126
Returns an array containing the MetaDataEntry for the given audio clip
sl@0
  1127
sl@0
  1128
@param  aMetaData
sl@0
  1129
        The meta data Array
sl@0
  1130
sl@0
  1131
@leave	Leaves with KErrNotFound if the meta data entry does not exist or
sl@0
  1132
		KErrNotSupported if the controller does not support meta data 
sl@0
  1133
		information for this format. Other errors indicate more general system
sl@0
  1134
		failure.
sl@0
  1135
*/
sl@0
  1136
EXPORT_C void  CMVSVideoPlayAgent::GetMetaDataArrayL(RPointerArray<CMMFMetaDataEntry>& aMetaData)
sl@0
  1137
	{
sl@0
  1138
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1139
	
sl@0
  1140
	//Reset the meta array
sl@0
  1141
    aMetaData.Reset();        
sl@0
  1142
    TInt entries = NumberOfMetaDataEntriesL();
sl@0
  1143
       
sl@0
  1144
    CMMFMetaDataEntry* entry = NULL;        
sl@0
  1145
  	for(TInt index= 0; index < entries; ++index)
sl@0
  1146
		{
sl@0
  1147
        entry = iCurrentVideoPlayer->MetaDataEntryL(index);
sl@0
  1148
		aMetaData.Append(entry);        
sl@0
  1149
        }
sl@0
  1150
	}
sl@0
  1151
sl@0
  1152
/**
sl@0
  1153
Returns the controller implementation information associated with the current controller.
sl@0
  1154
sl@0
  1155
@return The controller implementation structure
sl@0
  1156
*/	
sl@0
  1157
EXPORT_C const CMMFControllerImplementationInformation& CMVSVideoPlayAgent::ControllerImplementationInformationL()
sl@0
  1158
	{
sl@0
  1159
    __ASSERT_DEBUG(iCurrentVideoPlayer, User::Leave(KErrNotReady));		
sl@0
  1160
    	
sl@0
  1161
	iFileLogger.Write(_L("Getting the ControllerImplementationInformation of CMVSVideoPlayAgent")) ;
sl@0
  1162
    return iCurrentVideoPlayer->ControllerImplementationInformationL();
sl@0
  1163
	}
sl@0
  1164
sl@0
  1165
sl@0
  1166
/**
sl@0
  1167
Returns the current state of the CMVSAudioPlayAgent.
sl@0
  1168
sl@0
  1169
@return The current state, iState.
sl@0
  1170
*/
sl@0
  1171
EXPORT_C TMVSState CMVSVideoPlayAgent::GetState()
sl@0
  1172
	{
sl@0
  1173
	return iState;
sl@0
  1174
	}
sl@0
  1175
sl@0
  1176
/**
sl@0
  1177
Sets the specified output screen to render the video.
sl@0
  1178
sl@0
  1179
@return KErrNone,on success else any of the system wide error code.
sl@0
  1180
*/
sl@0
  1181
EXPORT_C TInt CMVSVideoPlayAgent::SetScreenNumber(TInt aScreenNumber)
sl@0
  1182
	{
sl@0
  1183
	TInt err = KErrNone;
sl@0
  1184
	
sl@0
  1185
    if (!iCurrentVideoPlayer)
sl@0
  1186
        {
sl@0
  1187
        err = iVideoPlayer->SetInitScreenNumber(aScreenNumber);
sl@0
  1188
        }
sl@0
  1189
    else
sl@0
  1190
    	{
sl@0
  1191
    	err = iCurrentVideoPlayer->SetInitScreenNumber(aScreenNumber);
sl@0
  1192
    	}
sl@0
  1193
    
sl@0
  1194
    if (err == KErrNone)
sl@0
  1195
		{
sl@0
  1196
	    iScreenNumber = aScreenNumber;
sl@0
  1197
		}
sl@0
  1198
		
sl@0
  1199
    return err;
sl@0
  1200
	}
sl@0
  1201
sl@0
  1202
/**
sl@0
  1203
Registers for audio resource notification.
sl@0
  1204
sl@0
  1205
@return KErrNone,on success else any of the system wide error code.
sl@0
  1206
*/
sl@0
  1207
EXPORT_C TInt CMVSVideoPlayAgent::RegisterForNotification()
sl@0
  1208
	{
sl@0
  1209
	if (!iCurrentVideoPlayer)
sl@0
  1210
	    {
sl@0
  1211
        // Set the request notify flag.  When we select which video player we are using we
sl@0
  1212
	    // will issue the request for notification.
sl@0
  1213
	    iRequestNotify = ETrue;
sl@0
  1214
        return KErrNone;			        
sl@0
  1215
	    }
sl@0
  1216
	
sl@0
  1217
    return iCurrentVideoPlayer->RegisterAudioResourceNotification(*this, KMMFEventCategoryAudioResourceAvailable);
sl@0
  1218
	}
sl@0
  1219
sl@0
  1220
/**
sl@0
  1221
Cancels any existing registeration to audio resource notification.
sl@0
  1222
sl@0
  1223
@return KErrNone,on success else any of the system wide error code.
sl@0
  1224
*/	
sl@0
  1225
EXPORT_C TInt CMVSVideoPlayAgent::CancelNotification()
sl@0
  1226
	{
sl@0
  1227
	if (!iCurrentVideoPlayer)
sl@0
  1228
	    {
sl@0
  1229
	    iRequestNotify = EFalse;
sl@0
  1230
        return KErrNone;
sl@0
  1231
	    }
sl@0
  1232
	
sl@0
  1233
    return iCurrentVideoPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
sl@0
  1234
	}
sl@0
  1235
	
sl@0
  1236
EXPORT_C TInt CMVSVideoPlayAgent::WillResumePlay()
sl@0
  1237
	{
sl@0
  1238
	if (!iCurrentVideoPlayer)
sl@0
  1239
	    {
sl@0
  1240
        return KErrNotReady;			        
sl@0
  1241
	    }
sl@0
  1242
    return iCurrentVideoPlayer->WillResumePlay();
sl@0
  1243
	}
sl@0
  1244
sl@0
  1245
/**
sl@0
  1246
Returns an integer representing the maximum volume that the audio track can support.
sl@0
  1247
sl@0
  1248
This is the maximum value that can be passed to SetVolumeL(). This value is platform 
sl@0
  1249
independent, but is always greater than or equal to one.
sl@0
  1250
sl@0
  1251
@return The maximum playback volume.
sl@0
  1252
*/
sl@0
  1253
EXPORT_C TInt CMVSVideoPlayAgent::MaxVolume() 
sl@0
  1254
    {
sl@0
  1255
	if (!iCurrentVideoPlayer)
sl@0
  1256
	    {
sl@0
  1257
        return iVideoPlayer->MaxVolume();
sl@0
  1258
	    }
sl@0
  1259
	
sl@0
  1260
    return iCurrentVideoPlayer->MaxVolume();
sl@0
  1261
    }
sl@0
  1262
    
sl@0
  1263
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
  1264
EXPORT_C void CMVSVideoPlayAgent::EnableSubtitlesL()
sl@0
  1265
	{
sl@0
  1266
	__ASSERT_DEBUG(iVideoPlayer2, User::Leave(KErrNotReady));
sl@0
  1267
	
sl@0
  1268
	if (iWindow)
sl@0
  1269
		{
sl@0
  1270
		iVideoPlayer2->EnableSubtitlesL();
sl@0
  1271
		}
sl@0
  1272
	else
sl@0
  1273
		{
sl@0
  1274
		iEnableSubtitlesOnAdd = ETrue;
sl@0
  1275
		}
sl@0
  1276
	}
sl@0
  1277
sl@0
  1278
EXPORT_C void CMVSVideoPlayAgent::DisableSubtitlesL()
sl@0
  1279
	{
sl@0
  1280
	__ASSERT_DEBUG(iVideoPlayer2, User::Leave(KErrNotReady));
sl@0
  1281
	iVideoPlayer2->DisableSubtitles();
sl@0
  1282
	iEnableSubtitlesOnAdd = EFalse;
sl@0
  1283
	}
sl@0
  1284
sl@0
  1285
EXPORT_C TBool CMVSVideoPlayAgent::SubtitlesAvailable()
sl@0
  1286
	{
sl@0
  1287
	if (iVideoPlayer2)
sl@0
  1288
		{
sl@0
  1289
		return iVideoPlayer2->SubtitlesAvailable();
sl@0
  1290
		}
sl@0
  1291
	
sl@0
  1292
	return EFalse;
sl@0
  1293
	}
sl@0
  1294
sl@0
  1295
EXPORT_C void CMVSVideoPlayAgent::RenderSubtitle(const TRect& aRect)
sl@0
  1296
	{
sl@0
  1297
	if (iVideoPlayer2)
sl@0
  1298
		{
sl@0
  1299
		iVideoPlayer2->RedrawSubtitle(*iWindow, aRect);
sl@0
  1300
		}
sl@0
  1301
	}
sl@0
  1302
sl@0
  1303
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT