OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "webrtc/engine_configurations.h" |
| 12 #include "webrtc/modules/video_render/windows/video_render_windows_impl.h" |
| 13 |
| 14 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 15 #include "webrtc/system_wrappers/include/trace.h" |
| 16 #ifdef DIRECT3D9_RENDERING |
| 17 #include "webrtc/modules/video_render/windows/video_render_direct3d9.h" |
| 18 #endif |
| 19 |
| 20 #include <tchar.h> |
| 21 |
| 22 namespace webrtc { |
| 23 |
| 24 VideoRenderWindowsImpl::VideoRenderWindowsImpl(const int32_t id, |
| 25 const VideoRenderType videoRenderType, void* window, const bool fullscreen) |
| 26 : _renderWindowsCritsect(*CriticalSectionWrapper::CreateCriticalSection()), |
| 27 _prtWindow(window), |
| 28 _fullscreen(fullscreen), |
| 29 _renderMethod(kVideoRenderWinD3D9), |
| 30 _ptrRendererWin(NULL) { |
| 31 } |
| 32 |
| 33 VideoRenderWindowsImpl::~VideoRenderWindowsImpl() |
| 34 { |
| 35 delete &_renderWindowsCritsect; |
| 36 if (_ptrRendererWin) |
| 37 { |
| 38 delete _ptrRendererWin; |
| 39 _ptrRendererWin = NULL; |
| 40 } |
| 41 } |
| 42 |
| 43 int32_t VideoRenderWindowsImpl::Init() |
| 44 { |
| 45 // Create the win renderer |
| 46 switch (_renderMethod) |
| 47 { |
| 48 case kVideoRenderWinD3D9: |
| 49 { |
| 50 #ifdef DIRECT3D9_RENDERING |
| 51 VideoRenderDirect3D9* ptrRenderer; |
| 52 ptrRenderer = new VideoRenderDirect3D9(NULL, (HWND) _prtWindow, _ful
lscreen); |
| 53 if (ptrRenderer == NULL) |
| 54 { |
| 55 break; |
| 56 } |
| 57 _ptrRendererWin = reinterpret_cast<IVideoRenderWin*>(ptrRenderer); |
| 58 #else |
| 59 return NULL; |
| 60 #endif //DIRECT3D9_RENDERING |
| 61 } |
| 62 break; |
| 63 default: |
| 64 break; |
| 65 } |
| 66 |
| 67 //Init renderer |
| 68 if (_ptrRendererWin) |
| 69 return _ptrRendererWin->Init(); |
| 70 else |
| 71 return -1; |
| 72 } |
| 73 |
| 74 int32_t VideoRenderWindowsImpl::ChangeWindow(void* window) |
| 75 { |
| 76 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 77 if (!_ptrRendererWin) |
| 78 { |
| 79 return -1; |
| 80 } |
| 81 else |
| 82 { |
| 83 return _ptrRendererWin->ChangeWindow(window); |
| 84 } |
| 85 } |
| 86 |
| 87 VideoRenderCallback* |
| 88 VideoRenderWindowsImpl::AddIncomingRenderStream(const uint32_t streamId, |
| 89 const uint32_t zOrder, |
| 90 const float left, |
| 91 const float top, |
| 92 const float right, |
| 93 const float bottom) |
| 94 { |
| 95 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 96 VideoRenderCallback* renderCallback = NULL; |
| 97 |
| 98 if (!_ptrRendererWin) |
| 99 { |
| 100 } |
| 101 else |
| 102 { |
| 103 renderCallback = _ptrRendererWin->CreateChannel(streamId, zOrder, left, |
| 104 top, right, bottom); |
| 105 } |
| 106 |
| 107 return renderCallback; |
| 108 } |
| 109 |
| 110 int32_t VideoRenderWindowsImpl::DeleteIncomingRenderStream( |
| 111 const uint32_t
streamId) |
| 112 { |
| 113 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 114 int32_t error = -1; |
| 115 if (!_ptrRendererWin) |
| 116 { |
| 117 } |
| 118 else |
| 119 { |
| 120 error = _ptrRendererWin->DeleteChannel(streamId); |
| 121 } |
| 122 return error; |
| 123 } |
| 124 |
| 125 int32_t VideoRenderWindowsImpl::GetIncomingRenderStreamProperties( |
| 126 const ui
nt32_t streamId, |
| 127 uint32_t
& zOrder, |
| 128 float& l
eft, |
| 129 float& t
op, |
| 130 float& r
ight, |
| 131 float& b
ottom) const |
| 132 { |
| 133 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 134 zOrder = 0; |
| 135 left = 0; |
| 136 top = 0; |
| 137 right = 0; |
| 138 bottom = 0; |
| 139 |
| 140 int32_t error = -1; |
| 141 if (!_ptrRendererWin) |
| 142 { |
| 143 } |
| 144 else |
| 145 { |
| 146 error = _ptrRendererWin->GetStreamSettings(streamId, 0, zOrder, left, |
| 147 top, right, bottom); |
| 148 } |
| 149 return error; |
| 150 } |
| 151 |
| 152 int32_t VideoRenderWindowsImpl::StartRender() |
| 153 { |
| 154 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 155 int32_t error = -1; |
| 156 if (!_ptrRendererWin) |
| 157 { |
| 158 } |
| 159 else |
| 160 { |
| 161 error = _ptrRendererWin->StartRender(); |
| 162 } |
| 163 return error; |
| 164 } |
| 165 |
| 166 int32_t VideoRenderWindowsImpl::StopRender() |
| 167 { |
| 168 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 169 int32_t error = -1; |
| 170 if (!_ptrRendererWin) |
| 171 { |
| 172 } |
| 173 else |
| 174 { |
| 175 error = _ptrRendererWin->StopRender(); |
| 176 } |
| 177 return error; |
| 178 } |
| 179 |
| 180 VideoRenderType VideoRenderWindowsImpl::RenderType() |
| 181 { |
| 182 return kRenderWindows; |
| 183 } |
| 184 |
| 185 RawVideoType VideoRenderWindowsImpl::PerferedVideoType() |
| 186 { |
| 187 return kVideoI420; |
| 188 } |
| 189 |
| 190 bool VideoRenderWindowsImpl::FullScreen() |
| 191 { |
| 192 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 193 bool fullscreen = false; |
| 194 if (!_ptrRendererWin) |
| 195 { |
| 196 } |
| 197 else |
| 198 { |
| 199 fullscreen = _ptrRendererWin->IsFullScreen(); |
| 200 } |
| 201 return fullscreen; |
| 202 } |
| 203 |
| 204 int32_t VideoRenderWindowsImpl::GetGraphicsMemory( |
| 205 uint64_t& totalGraphicsM
emory, |
| 206 uint64_t& availableGraph
icsMemory) const |
| 207 { |
| 208 if (_ptrRendererWin) |
| 209 { |
| 210 return _ptrRendererWin->GetGraphicsMemory(totalGraphicsMemory, |
| 211 availableGraphicsMemory); |
| 212 } |
| 213 |
| 214 totalGraphicsMemory = 0; |
| 215 availableGraphicsMemory = 0; |
| 216 return -1; |
| 217 } |
| 218 |
| 219 int32_t VideoRenderWindowsImpl::GetScreenResolution( |
| 220 uint32_t& screenWidth, |
| 221 uint32_t& screenHeight
) const |
| 222 { |
| 223 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 224 screenWidth = 0; |
| 225 screenHeight = 0; |
| 226 return 0; |
| 227 } |
| 228 |
| 229 uint32_t VideoRenderWindowsImpl::RenderFrameRate( |
| 230 const uint32_t streamId) |
| 231 { |
| 232 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 233 return 0; |
| 234 } |
| 235 |
| 236 int32_t VideoRenderWindowsImpl::SetStreamCropping( |
| 237 const uint32_t streamId, |
| 238 const float left, |
| 239 const float top, |
| 240 const float right, |
| 241 const float bottom) |
| 242 { |
| 243 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 244 int32_t error = -1; |
| 245 if (!_ptrRendererWin) |
| 246 { |
| 247 } |
| 248 else |
| 249 { |
| 250 error = _ptrRendererWin->SetCropping(streamId, 0, left, top, right, |
| 251 bottom); |
| 252 } |
| 253 return error; |
| 254 } |
| 255 |
| 256 int32_t VideoRenderWindowsImpl::ConfigureRenderer( |
| 257 const uint32_t streamId, |
| 258 const unsigned int zOrde
r, |
| 259 const float left, |
| 260 const float top, |
| 261 const float right, |
| 262 const float bottom) |
| 263 { |
| 264 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 265 int32_t error = -1; |
| 266 if (!_ptrRendererWin) |
| 267 { |
| 268 } |
| 269 else |
| 270 { |
| 271 error = _ptrRendererWin->ConfigureRenderer(streamId, 0, zOrder, left, |
| 272 top, right, bottom); |
| 273 } |
| 274 |
| 275 return error; |
| 276 } |
| 277 |
| 278 int32_t VideoRenderWindowsImpl::SetTransparentBackground( |
| 279 const bool enable
) |
| 280 { |
| 281 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 282 int32_t error = -1; |
| 283 if (!_ptrRendererWin) |
| 284 { |
| 285 } |
| 286 else |
| 287 { |
| 288 error = _ptrRendererWin->SetTransparentBackground(enable); |
| 289 } |
| 290 return error; |
| 291 } |
| 292 |
| 293 int32_t VideoRenderWindowsImpl::SetText( |
| 294 const uint8_t textId, |
| 295 const uint8_t* text, |
| 296 const int32_t textLength, |
| 297 const uint32_t textColorRef, |
| 298 const uint32_t backgroundColorRef, |
| 299 const float left, |
| 300 const float top, |
| 301 const float right, |
| 302 const float bottom) |
| 303 { |
| 304 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 305 int32_t error = -1; |
| 306 if (!_ptrRendererWin) |
| 307 { |
| 308 } |
| 309 else |
| 310 { |
| 311 error = _ptrRendererWin->SetText(textId, text, textLength, |
| 312 textColorRef, backgroundColorRef, |
| 313 left, top, right, bottom); |
| 314 } |
| 315 return error; |
| 316 } |
| 317 |
| 318 int32_t VideoRenderWindowsImpl::SetBitmap(const void* bitMap, |
| 319 const uint8_t pictureId, |
| 320 const void* colorKey, |
| 321 const float left, const float top, |
| 322 const float right, const float bottom) |
| 323 { |
| 324 CriticalSectionScoped cs(&_renderWindowsCritsect); |
| 325 int32_t error = -1; |
| 326 if (!_ptrRendererWin) |
| 327 { |
| 328 } |
| 329 else |
| 330 { |
| 331 error = _ptrRendererWin->SetBitmap(bitMap, pictureId, colorKey, left, |
| 332 top, right, bottom); |
| 333 } |
| 334 return error; |
| 335 } |
| 336 |
| 337 } // namespace webrtc |
OLD | NEW |