os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/mvsvideocontrol.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) 2008-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
//
sl@0
    15
sl@0
    16
#include <eikenv.h>
sl@0
    17
#include <mvs/videoplayagent.h>
sl@0
    18
sl@0
    19
#include "mvsvideocontrol.h"
sl@0
    20
sl@0
    21
CMVSVideoControl* CMVSVideoControl::NewLC(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent)
sl@0
    22
	{
sl@0
    23
	CMVSVideoControl* self = new (ELeave) CMVSVideoControl(aVideoPlayAgent, aDisplay);
sl@0
    24
	CleanupStack::PushL(self);
sl@0
    25
	self->ConstructL(aParent);
sl@0
    26
	return self;
sl@0
    27
	}
sl@0
    28
sl@0
    29
CMVSVideoControl* CMVSVideoControl::NewL(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent)
sl@0
    30
	{
sl@0
    31
	CMVSVideoControl* self = CMVSVideoControl::NewLC(aVideoPlayAgent, aDisplay, aParent);
sl@0
    32
	CleanupStack::Pop(self);
sl@0
    33
	return self;
sl@0
    34
	}
sl@0
    35
sl@0
    36
CMVSVideoControl::CMVSVideoControl(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay) :
sl@0
    37
	iVideoPlayAgent(aVideoPlayAgent),
sl@0
    38
	iDisplay(aDisplay)
sl@0
    39
	{
sl@0
    40
	}
sl@0
    41
sl@0
    42
void CMVSVideoControl::ConstructL(RWindowTreeNode& aParent)
sl@0
    43
	{
sl@0
    44
	CreateWindowL(aParent);
sl@0
    45
	iPip = CMVSPipControl::NewL(Window());
sl@0
    46
	
sl@0
    47
  	Window().SetBackgroundColor(KRgbDarkGray);
sl@0
    48
	}
sl@0
    49
sl@0
    50
CMVSVideoControl::~CMVSVideoControl()
sl@0
    51
	{
sl@0
    52
	iOverlayText.Close();
sl@0
    53
	delete iPip;
sl@0
    54
	}
sl@0
    55
sl@0
    56
RWindow& CMVSVideoControl::ControlWindow() const
sl@0
    57
	{
sl@0
    58
	return Window();
sl@0
    59
	}
sl@0
    60
sl@0
    61
TInt CMVSVideoControl::ScreenNumber() const
sl@0
    62
	{
sl@0
    63
	return iDisplay;
sl@0
    64
	}
sl@0
    65
	
sl@0
    66
CMVSPipControl& CMVSVideoControl::Pip() const
sl@0
    67
	{
sl@0
    68
	return *iPip;
sl@0
    69
	}
sl@0
    70
sl@0
    71
void CMVSVideoControl::EnablePip(CMVSPipControl::TRenderType aRenderType)
sl@0
    72
	{
sl@0
    73
	iPip->ControlWindow().SetVisible(ETrue);
sl@0
    74
	iPip->SetRenderType(aRenderType);
sl@0
    75
	}
sl@0
    76
sl@0
    77
void CMVSVideoControl::DisablePip()
sl@0
    78
	{
sl@0
    79
	iPip->ControlWindow().SetVisible(EFalse);
sl@0
    80
	}
sl@0
    81
sl@0
    82
void CMVSVideoControl::SetOverlayTextL(const TDesC& aOverlayText)
sl@0
    83
	{
sl@0
    84
	iOverlayText.Close();
sl@0
    85
	iOverlayText.CreateL(aOverlayText);
sl@0
    86
	}
sl@0
    87
sl@0
    88
void CMVSVideoControl::ClearOverlayText()
sl@0
    89
	{
sl@0
    90
	iOverlayText.Close();
sl@0
    91
	}
sl@0
    92
sl@0
    93
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
    94
void CMVSVideoControl::Draw(const TRect& aRect) const
sl@0
    95
#else
sl@0
    96
void CMVSVideoControl::Draw(const TRect& /*aRect*/) const
sl@0
    97
#endif
sl@0
    98
	{
sl@0
    99
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   100
	iVideoPlayAgent.RenderSubtitle(aRect);
sl@0
   101
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   102
      
sl@0
   103
	if (0 < iOverlayText.Length())
sl@0
   104
		{
sl@0
   105
		//Establish a Graphics Context
sl@0
   106
		CWindowGc& gc = SystemGc();
sl@0
   107
sl@0
   108
	    //Establish a drawing rectangle
sl@0
   109
		TRect rect=Rect();
sl@0
   110
sl@0
   111
		// Draw the overlay text if needed
sl@0
   112
        gc.SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
   113
    	gc.SetBrushColor(KRgbRed);
sl@0
   114
         
sl@0
   115
        gc.SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   116
        gc.SetPenColor(KRgbBlue);
sl@0
   117
sl@0
   118
        // Get a font
sl@0
   119
        const CFont* appFont = CEikonEnv::Static()->AnnotationFont();         
sl@0
   120
        gc.UseFont(appFont);        
sl@0
   121
sl@0
   122
		// Rect will always be at lest 3 in size
sl@0
   123
        rect.Shrink(3, 3);
sl@0
   124
	    TInt baseline = (rect.Height() + appFont->AscentInPixels()) >> 1;
sl@0
   125
sl@0
   126
        gc.DrawText(iOverlayText, rect, baseline, CGraphicsContext::ECenter);
sl@0
   127
sl@0
   128
	   	//Done with our font
sl@0
   129
	    gc.DiscardFont();	
sl@0
   130
		}
sl@0
   131
	}
sl@0
   132
sl@0
   133
TInt CMVSVideoControl::CountComponentControls() const
sl@0
   134
	{
sl@0
   135
	return 1;
sl@0
   136
	}
sl@0
   137
sl@0
   138
CCoeControl* CMVSVideoControl::ComponentControl(TInt aIndex) const
sl@0
   139
	{
sl@0
   140
	if (aIndex == 0) 
sl@0
   141
		{
sl@0
   142
		return iPip;
sl@0
   143
		}
sl@0
   144
	else
sl@0
   145
		{
sl@0
   146
		return NULL;
sl@0
   147
		}
sl@0
   148
	}
sl@0
   149
sl@0
   150
CMVSPipControl* CMVSPipControl::NewL(RWindowTreeNode& aParent)
sl@0
   151
	{
sl@0
   152
	CMVSPipControl* self = new (ELeave) CMVSPipControl();
sl@0
   153
	CleanupStack::PushL(self);
sl@0
   154
	self->ConstructL(aParent);
sl@0
   155
	CleanupStack::Pop(self);
sl@0
   156
	return self;
sl@0
   157
	}
sl@0
   158
sl@0
   159
CMVSPipControl::CMVSPipControl() 
sl@0
   160
	{
sl@0
   161
	}
sl@0
   162
sl@0
   163
void CMVSPipControl::ConstructL(RWindowTreeNode& aParent)
sl@0
   164
	{
sl@0
   165
	CreateWindowL(aParent);
sl@0
   166
	Window().SetBackgroundColor(TRgb(0, 0));
sl@0
   167
	}
sl@0
   168
sl@0
   169
CMVSPipControl::~CMVSPipControl()
sl@0
   170
	{
sl@0
   171
	}
sl@0
   172
sl@0
   173
void CMVSPipControl::Draw(const TRect& /*aRect*/) const
sl@0
   174
	{
sl@0
   175
	}
sl@0
   176
sl@0
   177
void CMVSPipControl::MmsehSurfaceCreated(TInt aDisplayId, const TSurfaceId& /*aId*/, const TRect& aCropRect, TVideoAspectRatio /*aAspectRatio*/)
sl@0
   178
	{
sl@0
   179
	__ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());
sl@0
   180
	iDisplayId = aDisplayId;
sl@0
   181
	iCropRect = aCropRect;
sl@0
   182
	}
sl@0
   183
sl@0
   184
void CMVSPipControl::MmsehSurfaceParametersChanged(const TSurfaceId& /*aId*/, const TRect& /*aCropRect*/, TVideoAspectRatio /*aAspectRatio*/)
sl@0
   185
	{
sl@0
   186
	__ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());
sl@0
   187
	}
sl@0
   188
sl@0
   189
void CMVSPipControl::MmsehRemoveSurface(const TSurfaceId& /*aId*/)
sl@0
   190
	{
sl@0
   191
	__ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());	
sl@0
   192
	}
sl@0
   193
sl@0
   194
void CMVSPipControl::SetRenderType(TRenderType aRenderType)
sl@0
   195
	{
sl@0
   196
	iRenderType = aRenderType;
sl@0
   197
	}
sl@0
   198
sl@0
   199
void CMVSPipControl::Clear()
sl@0
   200
	{
sl@0
   201
	DrawNow();
sl@0
   202
	}
sl@0
   203
sl@0
   204
RWindow& CMVSPipControl::ControlWindow() const
sl@0
   205
	{
sl@0
   206
	return Window();
sl@0
   207
	}