os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/mvsvideocontrol.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/mvsvideocontrol.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,207 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <eikenv.h>
1.20 +#include <mvs/videoplayagent.h>
1.21 +
1.22 +#include "mvsvideocontrol.h"
1.23 +
1.24 +CMVSVideoControl* CMVSVideoControl::NewLC(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent)
1.25 + {
1.26 + CMVSVideoControl* self = new (ELeave) CMVSVideoControl(aVideoPlayAgent, aDisplay);
1.27 + CleanupStack::PushL(self);
1.28 + self->ConstructL(aParent);
1.29 + return self;
1.30 + }
1.31 +
1.32 +CMVSVideoControl* CMVSVideoControl::NewL(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent)
1.33 + {
1.34 + CMVSVideoControl* self = CMVSVideoControl::NewLC(aVideoPlayAgent, aDisplay, aParent);
1.35 + CleanupStack::Pop(self);
1.36 + return self;
1.37 + }
1.38 +
1.39 +CMVSVideoControl::CMVSVideoControl(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay) :
1.40 + iVideoPlayAgent(aVideoPlayAgent),
1.41 + iDisplay(aDisplay)
1.42 + {
1.43 + }
1.44 +
1.45 +void CMVSVideoControl::ConstructL(RWindowTreeNode& aParent)
1.46 + {
1.47 + CreateWindowL(aParent);
1.48 + iPip = CMVSPipControl::NewL(Window());
1.49 +
1.50 + Window().SetBackgroundColor(KRgbDarkGray);
1.51 + }
1.52 +
1.53 +CMVSVideoControl::~CMVSVideoControl()
1.54 + {
1.55 + iOverlayText.Close();
1.56 + delete iPip;
1.57 + }
1.58 +
1.59 +RWindow& CMVSVideoControl::ControlWindow() const
1.60 + {
1.61 + return Window();
1.62 + }
1.63 +
1.64 +TInt CMVSVideoControl::ScreenNumber() const
1.65 + {
1.66 + return iDisplay;
1.67 + }
1.68 +
1.69 +CMVSPipControl& CMVSVideoControl::Pip() const
1.70 + {
1.71 + return *iPip;
1.72 + }
1.73 +
1.74 +void CMVSVideoControl::EnablePip(CMVSPipControl::TRenderType aRenderType)
1.75 + {
1.76 + iPip->ControlWindow().SetVisible(ETrue);
1.77 + iPip->SetRenderType(aRenderType);
1.78 + }
1.79 +
1.80 +void CMVSVideoControl::DisablePip()
1.81 + {
1.82 + iPip->ControlWindow().SetVisible(EFalse);
1.83 + }
1.84 +
1.85 +void CMVSVideoControl::SetOverlayTextL(const TDesC& aOverlayText)
1.86 + {
1.87 + iOverlayText.Close();
1.88 + iOverlayText.CreateL(aOverlayText);
1.89 + }
1.90 +
1.91 +void CMVSVideoControl::ClearOverlayText()
1.92 + {
1.93 + iOverlayText.Close();
1.94 + }
1.95 +
1.96 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.97 +void CMVSVideoControl::Draw(const TRect& aRect) const
1.98 +#else
1.99 +void CMVSVideoControl::Draw(const TRect& /*aRect*/) const
1.100 +#endif
1.101 + {
1.102 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.103 + iVideoPlayAgent.RenderSubtitle(aRect);
1.104 +#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.105 +
1.106 + if (0 < iOverlayText.Length())
1.107 + {
1.108 + //Establish a Graphics Context
1.109 + CWindowGc& gc = SystemGc();
1.110 +
1.111 + //Establish a drawing rectangle
1.112 + TRect rect=Rect();
1.113 +
1.114 + // Draw the overlay text if needed
1.115 + gc.SetBrushStyle(CGraphicsContext::ENullBrush);
1.116 + gc.SetBrushColor(KRgbRed);
1.117 +
1.118 + gc.SetPenStyle(CGraphicsContext::ESolidPen);
1.119 + gc.SetPenColor(KRgbBlue);
1.120 +
1.121 + // Get a font
1.122 + const CFont* appFont = CEikonEnv::Static()->AnnotationFont();
1.123 + gc.UseFont(appFont);
1.124 +
1.125 + // Rect will always be at lest 3 in size
1.126 + rect.Shrink(3, 3);
1.127 + TInt baseline = (rect.Height() + appFont->AscentInPixels()) >> 1;
1.128 +
1.129 + gc.DrawText(iOverlayText, rect, baseline, CGraphicsContext::ECenter);
1.130 +
1.131 + //Done with our font
1.132 + gc.DiscardFont();
1.133 + }
1.134 + }
1.135 +
1.136 +TInt CMVSVideoControl::CountComponentControls() const
1.137 + {
1.138 + return 1;
1.139 + }
1.140 +
1.141 +CCoeControl* CMVSVideoControl::ComponentControl(TInt aIndex) const
1.142 + {
1.143 + if (aIndex == 0)
1.144 + {
1.145 + return iPip;
1.146 + }
1.147 + else
1.148 + {
1.149 + return NULL;
1.150 + }
1.151 + }
1.152 +
1.153 +CMVSPipControl* CMVSPipControl::NewL(RWindowTreeNode& aParent)
1.154 + {
1.155 + CMVSPipControl* self = new (ELeave) CMVSPipControl();
1.156 + CleanupStack::PushL(self);
1.157 + self->ConstructL(aParent);
1.158 + CleanupStack::Pop(self);
1.159 + return self;
1.160 + }
1.161 +
1.162 +CMVSPipControl::CMVSPipControl()
1.163 + {
1.164 + }
1.165 +
1.166 +void CMVSPipControl::ConstructL(RWindowTreeNode& aParent)
1.167 + {
1.168 + CreateWindowL(aParent);
1.169 + Window().SetBackgroundColor(TRgb(0, 0));
1.170 + }
1.171 +
1.172 +CMVSPipControl::~CMVSPipControl()
1.173 + {
1.174 + }
1.175 +
1.176 +void CMVSPipControl::Draw(const TRect& /*aRect*/) const
1.177 + {
1.178 + }
1.179 +
1.180 +void CMVSPipControl::MmsehSurfaceCreated(TInt aDisplayId, const TSurfaceId& /*aId*/, const TRect& aCropRect, TVideoAspectRatio /*aAspectRatio*/)
1.181 + {
1.182 + __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());
1.183 + iDisplayId = aDisplayId;
1.184 + iCropRect = aCropRect;
1.185 + }
1.186 +
1.187 +void CMVSPipControl::MmsehSurfaceParametersChanged(const TSurfaceId& /*aId*/, const TRect& /*aCropRect*/, TVideoAspectRatio /*aAspectRatio*/)
1.188 + {
1.189 + __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());
1.190 + }
1.191 +
1.192 +void CMVSPipControl::MmsehRemoveSurface(const TSurfaceId& /*aId*/)
1.193 + {
1.194 + __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant());
1.195 + }
1.196 +
1.197 +void CMVSPipControl::SetRenderType(TRenderType aRenderType)
1.198 + {
1.199 + iRenderType = aRenderType;
1.200 + }
1.201 +
1.202 +void CMVSPipControl::Clear()
1.203 + {
1.204 + DrawNow();
1.205 + }
1.206 +
1.207 +RWindow& CMVSPipControl::ControlWindow() const
1.208 + {
1.209 + return Window();
1.210 + }