sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "mvsvideocontrol.h" sl@0: sl@0: CMVSVideoControl* CMVSVideoControl::NewLC(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent) sl@0: { sl@0: CMVSVideoControl* self = new (ELeave) CMVSVideoControl(aVideoPlayAgent, aDisplay); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aParent); sl@0: return self; sl@0: } sl@0: sl@0: CMVSVideoControl* CMVSVideoControl::NewL(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay, RWindowTreeNode& aParent) sl@0: { sl@0: CMVSVideoControl* self = CMVSVideoControl::NewLC(aVideoPlayAgent, aDisplay, aParent); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMVSVideoControl::CMVSVideoControl(CMVSVideoPlayAgent& aVideoPlayAgent, TInt aDisplay) : sl@0: iVideoPlayAgent(aVideoPlayAgent), sl@0: iDisplay(aDisplay) sl@0: { sl@0: } sl@0: sl@0: void CMVSVideoControl::ConstructL(RWindowTreeNode& aParent) sl@0: { sl@0: CreateWindowL(aParent); sl@0: iPip = CMVSPipControl::NewL(Window()); sl@0: sl@0: Window().SetBackgroundColor(KRgbDarkGray); sl@0: } sl@0: sl@0: CMVSVideoControl::~CMVSVideoControl() sl@0: { sl@0: iOverlayText.Close(); sl@0: delete iPip; sl@0: } sl@0: sl@0: RWindow& CMVSVideoControl::ControlWindow() const sl@0: { sl@0: return Window(); sl@0: } sl@0: sl@0: TInt CMVSVideoControl::ScreenNumber() const sl@0: { sl@0: return iDisplay; sl@0: } sl@0: sl@0: CMVSPipControl& CMVSVideoControl::Pip() const sl@0: { sl@0: return *iPip; sl@0: } sl@0: sl@0: void CMVSVideoControl::EnablePip(CMVSPipControl::TRenderType aRenderType) sl@0: { sl@0: iPip->ControlWindow().SetVisible(ETrue); sl@0: iPip->SetRenderType(aRenderType); sl@0: } sl@0: sl@0: void CMVSVideoControl::DisablePip() sl@0: { sl@0: iPip->ControlWindow().SetVisible(EFalse); sl@0: } sl@0: sl@0: void CMVSVideoControl::SetOverlayTextL(const TDesC& aOverlayText) sl@0: { sl@0: iOverlayText.Close(); sl@0: iOverlayText.CreateL(aOverlayText); sl@0: } sl@0: sl@0: void CMVSVideoControl::ClearOverlayText() sl@0: { sl@0: iOverlayText.Close(); sl@0: } sl@0: sl@0: #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT sl@0: void CMVSVideoControl::Draw(const TRect& aRect) const sl@0: #else sl@0: void CMVSVideoControl::Draw(const TRect& /*aRect*/) const sl@0: #endif sl@0: { sl@0: #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT sl@0: iVideoPlayAgent.RenderSubtitle(aRect); sl@0: #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT sl@0: sl@0: if (0 < iOverlayText.Length()) sl@0: { sl@0: //Establish a Graphics Context sl@0: CWindowGc& gc = SystemGc(); sl@0: sl@0: //Establish a drawing rectangle sl@0: TRect rect=Rect(); sl@0: sl@0: // Draw the overlay text if needed sl@0: gc.SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: gc.SetBrushColor(KRgbRed); sl@0: sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetPenColor(KRgbBlue); sl@0: sl@0: // Get a font sl@0: const CFont* appFont = CEikonEnv::Static()->AnnotationFont(); sl@0: gc.UseFont(appFont); sl@0: sl@0: // Rect will always be at lest 3 in size sl@0: rect.Shrink(3, 3); sl@0: TInt baseline = (rect.Height() + appFont->AscentInPixels()) >> 1; sl@0: sl@0: gc.DrawText(iOverlayText, rect, baseline, CGraphicsContext::ECenter); sl@0: sl@0: //Done with our font sl@0: gc.DiscardFont(); sl@0: } sl@0: } sl@0: sl@0: TInt CMVSVideoControl::CountComponentControls() const sl@0: { sl@0: return 1; sl@0: } sl@0: sl@0: CCoeControl* CMVSVideoControl::ComponentControl(TInt aIndex) const sl@0: { sl@0: if (aIndex == 0) sl@0: { sl@0: return iPip; sl@0: } sl@0: else sl@0: { sl@0: return NULL; sl@0: } sl@0: } sl@0: sl@0: CMVSPipControl* CMVSPipControl::NewL(RWindowTreeNode& aParent) sl@0: { sl@0: CMVSPipControl* self = new (ELeave) CMVSPipControl(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aParent); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMVSPipControl::CMVSPipControl() sl@0: { sl@0: } sl@0: sl@0: void CMVSPipControl::ConstructL(RWindowTreeNode& aParent) sl@0: { sl@0: CreateWindowL(aParent); sl@0: Window().SetBackgroundColor(TRgb(0, 0)); sl@0: } sl@0: sl@0: CMVSPipControl::~CMVSPipControl() sl@0: { sl@0: } sl@0: sl@0: void CMVSPipControl::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: } sl@0: sl@0: void CMVSPipControl::MmsehSurfaceCreated(TInt aDisplayId, const TSurfaceId& /*aId*/, const TRect& aCropRect, TVideoAspectRatio /*aAspectRatio*/) sl@0: { sl@0: __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant()); sl@0: iDisplayId = aDisplayId; sl@0: iCropRect = aCropRect; sl@0: } sl@0: sl@0: void CMVSPipControl::MmsehSurfaceParametersChanged(const TSurfaceId& /*aId*/, const TRect& /*aCropRect*/, TVideoAspectRatio /*aAspectRatio*/) sl@0: { sl@0: __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant()); sl@0: } sl@0: sl@0: void CMVSPipControl::MmsehRemoveSurface(const TSurfaceId& /*aId*/) sl@0: { sl@0: __ASSERT_ALWAYS(iRenderType == EUseCrp, User::Invariant()); sl@0: } sl@0: sl@0: void CMVSPipControl::SetRenderType(TRenderType aRenderType) sl@0: { sl@0: iRenderType = aRenderType; sl@0: } sl@0: sl@0: void CMVSPipControl::Clear() sl@0: { sl@0: DrawNow(); sl@0: } sl@0: sl@0: RWindow& CMVSPipControl::ControlWindow() const sl@0: { sl@0: return Window(); sl@0: }