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