1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 Media Helper Class for handling surface events |
|
19 |
|
20 Shy Ward |
|
21 */ |
|
22 |
|
23 #include "XANGAVideoSink.h" |
|
24 #include "openmaxalwrapper.h" |
|
25 |
|
26 |
|
27 CNgaVideoSink* CNgaVideoSink::NewL() |
|
28 { |
|
29 CNgaVideoSink* self = new CNgaVideoSink(); |
|
30 self->ConstructL(); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CNgaVideoSink::~CNgaVideoSink() |
|
35 { |
|
36 iMediaClientVideoDisplay->RemoveDisplayWindow(*m_pWindow); |
|
37 delete iMediaClientVideoDisplay; |
|
38 if(IsActive()) |
|
39 { |
|
40 Cancel(); |
|
41 } |
|
42 } |
|
43 |
|
44 CNgaVideoSink::CNgaVideoSink() |
|
45 :CActive(EPriorityStandard) |
|
46 { |
|
47 iMediaClientVideoDisplay = NULL; |
|
48 CActiveScheduler::Add(this); |
|
49 m_ThreadHandle.Duplicate(RThread()); |
|
50 m_MediaHelperInitialized = EInitializedReady; |
|
51 m_rotation = EVideoRotationNone; |
|
52 m_scaleWidth = (100.0f); |
|
53 m_scaleHeight = (100.0f); |
|
54 m_horizPos = (EHorizontalAlignCenter); |
|
55 m_vertPos = (EVerticalAlignCenter); |
|
56 } |
|
57 |
|
58 void CNgaVideoSink::RunL() |
|
59 { |
|
60 iMediaClientVideoDisplay->SurfaceCreated(m_surfaceId,m_cropRect,m_pixelAspectRatio,m_cropRegion); |
|
61 } |
|
62 |
|
63 void CNgaVideoSink::Activate() |
|
64 { |
|
65 if(!IsActive()) |
|
66 { |
|
67 iStatus = KRequestPending; |
|
68 SetActive(); |
|
69 } |
|
70 } |
|
71 |
|
72 void CNgaVideoSink::DoCancel() |
|
73 { |
|
74 if(iStatus.Int() == KRequestPending) |
|
75 { |
|
76 TRequestStatus* pStatus = &iStatus; |
|
77 m_ThreadHandle.RequestComplete(pStatus, KErrCancel); |
|
78 } |
|
79 } |
|
80 |
|
81 void CNgaVideoSink::CompleteRequest(TInt status) |
|
82 { |
|
83 // Checking for IsActive alone results in this block getting executed |
|
84 // from other thread more thanone time. Hence the chk for iStatus |
|
85 if(IsActive() && iStatus == KRequestPending) |
|
86 { |
|
87 TRequestStatus* pStatus = &iStatus; |
|
88 m_ThreadHandle.RequestComplete(pStatus, status); |
|
89 } |
|
90 } |
|
91 |
|
92 void CNgaVideoSink::SurfaceCreated(int surfaceid0,int surfaceid1,int surfaceid2,int surfaceid3,int crop_rect_tl_x, |
|
93 int crop_rect_tl_y,int crop_rect_br_x,int crop_rect_br_y,int aspect_ratio_num,int aspect_ratio_denom) |
|
94 { |
|
95 |
|
96 m_surfaceId.iInternal[0] = surfaceid0; |
|
97 m_surfaceId.iInternal[1] = surfaceid1; |
|
98 m_surfaceId.iInternal[2] = surfaceid2; |
|
99 m_surfaceId.iInternal[3] = surfaceid3; |
|
100 m_cropRect.iTl.iX = crop_rect_tl_x; |
|
101 m_cropRect.iTl.iY = crop_rect_tl_y; |
|
102 m_cropRect.iBr.iX = crop_rect_br_x; |
|
103 m_cropRect.iBr.iY = crop_rect_br_y; |
|
104 m_pixelAspectRatio.iNumerator = aspect_ratio_num; |
|
105 m_pixelAspectRatio.iDenominator = aspect_ratio_denom; |
|
106 |
|
107 Activate(); |
|
108 CompleteRequest(KErrNone); |
|
109 |
|
110 } |
|
111 |
|
112 void CNgaVideoSink::ConstructL() |
|
113 { |
|
114 iMediaClientVideoDisplay = CMediaClientVideoDisplay::NewL(0); |
|
115 Activate(); |
|
116 } |
|
117 |
|
118 void CNgaVideoSink::SetNativeDisplayInformation(void* display_info) |
|
119 { |
|
120 //display_info is of type XADataSink |
|
121 //display_info.pLocator is of type XADataLocator_NativeDisplay |
|
122 XADataLocator_NativeDisplay* nativeDisplay; |
|
123 XADataSink* videoSink = (XADataSink*)display_info; |
|
124 |
|
125 nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator); |
|
126 //TODO: scrDevice is not been passed Properly |
|
127 // Add the display window |
|
128 m_cropRegion = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
129 m_videoExtent = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
130 m_cropRect = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
131 m_clipRect = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
132 m_cropRegion = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
133 m_pWindow = ((RWindow*)(nativeDisplay->hWindow)); |
|
134 |
|
135 |
|
136 iMediaClientVideoDisplay->AddDisplayWindowL(m_pWindow, m_clipRect, m_cropRegion, m_videoExtent, m_scaleWidth, m_scaleHeight, |
|
137 m_rotation, EAutoScaleBestFit, m_horizPos, m_vertPos, m_pWindow); |
|
138 |
|
139 } |
|
140 |
|
141 extern "C" { |
|
142 |
|
143 void* nga_video_sink_init() |
|
144 { |
|
145 return CNgaVideoSink::NewL(); |
|
146 } |
|
147 |
|
148 void surface_created(void* context,int surfaceid0,int surfaceid1,int surfaceid2,int surfaceid3,int crop_rect_tl_x, |
|
149 int crop_rect_tl_y,int crop_rect_br_x,int crop_rect_br_y,int aspect_ratio_num,int aspect_ratio_denom) |
|
150 { |
|
151 ((CNgaVideoSink*)(context))->SurfaceCreated(surfaceid0,surfaceid1,surfaceid2,surfaceid3,crop_rect_tl_x, |
|
152 crop_rect_tl_y,crop_rect_br_x,crop_rect_br_y,aspect_ratio_num,aspect_ratio_denom); |
|
153 } |
|
154 |
|
155 void setup_native_display(void* context, void* display_info) |
|
156 { |
|
157 ((CNgaVideoSink*)(context))->SetNativeDisplayInformation(display_info); |
|
158 } |
|
159 |
|
160 } |
|