video_render_internal_impl.cc revision 98f53510b222f71fdd8b799b2f33737ceeb28c61
1ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org/* 2ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * 4ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * Use of this source code is governed by a BSD-style license 5ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * that can be found in the LICENSE file in the root of the source 6ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * tree. An additional intellectual property rights grant can be found 7ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * in the file PATENTS. All contributing project authors may 8ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org */ 10ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 11ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include <assert.h> 12ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 139a638662726784dd0d4c044fa8f772f32b22f4c5Peter Boström#include "webrtc/common_video/interface/incoming_video_stream.h" 14ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/engine_configurations.h" 15ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/i_video_render.h" 16ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/include/video_render_defines.h" 17ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/video_render_impl.h" 1898f53510b222f71fdd8b799b2f33737ceeb28c61Henrik Kjellander#include "webrtc/system_wrappers/include/critical_section_wrapper.h" 1998f53510b222f71fdd8b799b2f33737ceeb28c61Henrik Kjellander#include "webrtc/system_wrappers/include/trace.h" 20ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 21ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined (_WIN32) 22ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/windows/video_render_windows_impl.h" 23ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderWindows 24ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 25ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org// WEBRTC_IOS should go before WEBRTC_MAC because WEBRTC_MAC 26ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org// gets defined if WEBRTC_IOS is defined 27ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_IOS) 28ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderiOS 29ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/ios/video_render_ios_impl.h" 30ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_MAC) 31ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(COCOA_RENDERING) 32ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderCocoa 33ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/mac/video_render_mac_cocoa_impl.h" 34ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(CARBON_RENDERING) 35ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderCarbon 36ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/mac/video_render_mac_carbon_impl.h" 37ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 38ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 39ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_ANDROID) 40ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/android/video_render_android_impl.h" 41ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/android/video_render_android_native_opengl2.h" 42ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/android/video_render_android_surface_view.h" 43ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderAndroid 44ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 45ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_LINUX) 46ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/linux/video_render_linux_impl.h" 47ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderX11 48ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 49ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#else 50ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org//Other platforms 51ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 52ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 53ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org// For external rendering 54ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#include "webrtc/modules/video_render/external/video_render_external_impl.h" 55ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#ifndef STANDARD_RENDERING 56ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#define STANDARD_RENDERING kRenderExternal 57ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif // STANDARD_RENDERING 58ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 59ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgnamespace webrtc { 60ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 61ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgVideoRender* 62ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgVideoRender::CreateVideoRender(const int32_t id, 63ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org void* window, 64ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const bool fullscreen, 65ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const VideoRenderType videoRenderType/*=kRenderDefault*/) 66ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 67ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderType resultVideoRenderType = videoRenderType; 68ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (videoRenderType == kRenderDefault) 69ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 70ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org resultVideoRenderType = STANDARD_RENDERING; 71ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 72ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return new ModuleVideoRenderImpl(id, resultVideoRenderType, window, 73ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org fullscreen); 74ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 75ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 76ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgvoid VideoRender::DestroyVideoRender( 77ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRender* module) 78ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 79ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (module) 80ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 81ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete module; 82ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 83ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 84ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 85ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgModuleVideoRenderImpl::ModuleVideoRenderImpl( 86ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const int32_t id, 87ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const VideoRenderType videoRenderType, 88ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org void* window, 89ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const bool fullscreen) : 90ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _id(id), _moduleCrit(*CriticalSectionWrapper::CreateCriticalSection()), 91ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrWindow(window), _fullScreen(fullscreen), _ptrRenderer(NULL) 92ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 93ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 94ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Create platform specific renderer 95ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org switch (videoRenderType) 96ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 97ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(_WIN32) 98ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderWindows: 99ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 100ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderWindowsImpl* ptrRenderer; 101ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderWindowsImpl(_id, videoRenderType, window, _fullScreen); 102ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (ptrRenderer) 103ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 104ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 105ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 106ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 107ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 108ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 109ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_IOS) 110ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderiOS: 111ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 112ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderIosImpl* ptrRenderer = new VideoRenderIosImpl(_id, window, _fullScreen); 113ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if(ptrRenderer) 114ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 115ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 116ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 117ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 118ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 119ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 120ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_MAC) 121ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 122ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(COCOA_RENDERING) 123ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderCocoa: 124ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 125ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCocoaImpl* ptrRenderer = new VideoRenderMacCocoaImpl(_id, videoRenderType, window, _fullScreen); 126ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if(ptrRenderer) 127ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 128ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 129ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 130ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 131ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 132ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 133ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(CARBON_RENDERING) 134ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderCarbon: 135ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 136ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCarbonImpl* ptrRenderer = new VideoRenderMacCarbonImpl(_id, videoRenderType, window, _fullScreen); 137ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if(ptrRenderer) 138ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 139ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 140ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 141ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 142ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 143ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 144ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 145ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_ANDROID) 146ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderAndroid: 147ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 148ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if(AndroidNativeOpenGl2Renderer::UseOpenGL2(window)) 149ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 150ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org AndroidNativeOpenGl2Renderer* ptrRenderer = NULL; 151ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new AndroidNativeOpenGl2Renderer(_id, videoRenderType, window, _fullScreen); 152ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (ptrRenderer) 153ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 154ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*> (ptrRenderer); 155ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 156ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 157ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org else 158ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 159ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org AndroidSurfaceViewRenderer* ptrRenderer = NULL; 160ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new AndroidSurfaceViewRenderer(_id, videoRenderType, window, _fullScreen); 161ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (ptrRenderer) 162ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 163ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*> (ptrRenderer); 164ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 165ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 166ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 167ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 168ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 169ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_LINUX) 170ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderX11: 171ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 172ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderLinuxImpl* ptrRenderer = NULL; 173ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderLinuxImpl(_id, videoRenderType, window, _fullScreen); 174ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if ( ptrRenderer ) 175ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 176ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*> (ptrRenderer); 177ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 178ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 179ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 180ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 181ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#else 182ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Other platforms 183ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 184ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderExternal: 185ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 186ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderExternalImpl* ptrRenderer(NULL); 187ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderExternalImpl(_id, videoRenderType, 188ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org window, _fullScreen); 189ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (ptrRenderer) 190ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 191ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*> (ptrRenderer); 192ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 193ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 194ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 195ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org default: 196ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Error... 197ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 198ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 199ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_ptrRenderer) 200ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 201ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_ptrRenderer->Init() == -1) 202ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 203ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 204ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 205ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 206ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 207ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgModuleVideoRenderImpl::~ModuleVideoRenderImpl() 208ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 209ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete &_moduleCrit; 210ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 211ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org for (IncomingVideoStreamMap::iterator it = _streamRenderMap.begin(); 212ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org it != _streamRenderMap.end(); 213ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ++it) { 214ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete it->second; 215ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 216ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 217ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Delete platform specific renderer 218ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_ptrRenderer) 219ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 220ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderType videoRenderType = _ptrRenderer->RenderType(); 221ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 222ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org switch (videoRenderType) 223ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 224ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderExternal: 225ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 226ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderExternalImpl 227ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org * ptrRenderer = 228ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org reinterpret_cast<VideoRenderExternalImpl*> (_ptrRenderer); 229ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 230ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 231ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 232ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 233ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(_WIN32) 234ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderWindows: 235ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 236ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderWindowsImpl* ptrRenderer = reinterpret_cast<VideoRenderWindowsImpl*>(_ptrRenderer); 237ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 238ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 239ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 240ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 241ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_IOS) 242ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderiOS: 243ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 244ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderIosImpl* ptrRenderer = reinterpret_cast<VideoRenderIosImpl*> (_ptrRenderer); 245ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 246ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 247ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 248ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 249ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_MAC) 250ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 251ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(COCOA_RENDERING) 252ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderCocoa: 253ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 254ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCocoaImpl* ptrRenderer = reinterpret_cast<VideoRenderMacCocoaImpl*> (_ptrRenderer); 255ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 256ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 257ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 258ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 259ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(CARBON_RENDERING) 260ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderCarbon: 261ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 262ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCarbonImpl* ptrRenderer = reinterpret_cast<VideoRenderMacCarbonImpl*> (_ptrRenderer); 263ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 264ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 265ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 266ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 267ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 268ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 269ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_ANDROID) 270ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderAndroid: 271ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 272ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderAndroid* ptrRenderer = reinterpret_cast<VideoRenderAndroid*> (_ptrRenderer); 273ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 274ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 275ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 276ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 277ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 278ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_LINUX) 279ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org case kRenderX11: 280ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 281ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderLinuxImpl* ptrRenderer = reinterpret_cast<VideoRenderLinuxImpl*> (_ptrRenderer); 282ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 283ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete ptrRenderer; 284ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 285ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 286ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#else 287ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org //other platforms 288ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 289ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 290ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org default: 291ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Error... 292ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org break; 293ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 294ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 295ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 296ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 2970b1534c52eab79372557a6d81aaf4dd9407f55d3pkasting@chromium.orgint64_t ModuleVideoRenderImpl::TimeUntilNextProcess() 298ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 299ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Not used 300ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 50; 301ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 302ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::Process() 303ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 304ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Not used 305ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 0; 306ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 307ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 308ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgvoid* 309ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgModuleVideoRenderImpl::Window() 310ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 311ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 312ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrWindow; 313ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 314ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 315ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::ChangeWindow(void* window) 316ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 317ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 318ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 319ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 320ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(WEBRTC_IOS) // WEBRTC_IOS must go before WEBRTC_MAC 321ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 322ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete _ptrRenderer; 323ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 324ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderIosImpl* ptrRenderer; 325ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderIosImpl(_id, window, _fullScreen); 326ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!ptrRenderer) 327ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 328ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 329ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 330ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 331ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->ChangeWindow(window); 332ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(WEBRTC_MAC) 333ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 334ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = NULL; 335ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete _ptrRenderer; 336ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 337ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#if defined(COCOA_RENDERING) 338ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCocoaImpl* ptrRenderer; 339ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderMacCocoaImpl(_id, kRenderCocoa, window, _fullScreen); 340ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#elif defined(CARBON_RENDERING) 341ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderMacCarbonImpl* ptrRenderer; 342ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ptrRenderer = new VideoRenderMacCarbonImpl(_id, kRenderCarbon, window, _fullScreen); 343ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 344ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!ptrRenderer) 345ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 346ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 347ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 348ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer = reinterpret_cast<IVideoRender*>(ptrRenderer); 349ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->ChangeWindow(window); 350ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 351ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#else 352ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 353ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 354ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 355ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 356ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 357ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 358ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->ChangeWindow(window); 359ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 360ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org#endif 361ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 362ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 363ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::Id() 364ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 365ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 366ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _id; 367ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 368ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 369ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orguint32_t ModuleVideoRenderImpl::GetIncomingFrameRate(const uint32_t streamId) { 370ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 371ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 372ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::iterator it = _streamRenderMap.find(streamId); 373ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 374ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (it == _streamRenderMap.end()) { 375ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // This stream doesn't exist 376ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, 377ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org kTraceVideoRenderer, 378ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _id, 379ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream doesn't exist", 380ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org __FUNCTION__); 381ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 0; 382ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 383ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org assert(it->second != NULL); 384ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return it->second->IncomingRate(); 385ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 386ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 387ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgVideoRenderCallback* 388ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgModuleVideoRenderImpl::AddIncomingRenderStream(const uint32_t streamId, 389ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t zOrder, 390ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float left, 391ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float top, 392ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float right, 393ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float bottom) 394ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 395ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 396ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 397ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 398ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 399ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 400ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 401ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return NULL; 402ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 403ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 404ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_streamRenderMap.find(streamId) != _streamRenderMap.end()) { 405ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // The stream already exists... 406ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 407ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream already exists", __FUNCTION__); 408ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return NULL; 409ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 410ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 411ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderCallback* ptrRenderCallback = 412ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer->AddIncomingRenderStream(streamId, zOrder, left, top, 413ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org right, bottom); 414ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (ptrRenderCallback == NULL) 415ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 416ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 417ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: Can't create incoming stream in renderer", 418ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org __FUNCTION__); 419ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return NULL; 420ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 421ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 422ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Create platform independant code 423c043afc60534786c88d0cf0f1a96c70a50df87b1Peter Boström IncomingVideoStream* ptrIncomingStream = new IncomingVideoStream(streamId); 424c043afc60534786c88d0cf0f1a96c70a50df87b1Peter Boström ptrIncomingStream->SetRenderCallback(ptrRenderCallback); 425c043afc60534786c88d0cf0f1a96c70a50df87b1Peter Boström VideoRenderCallback* moduleCallback = ptrIncomingStream->ModuleCallback(); 426ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 427ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Store the stream 428ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _streamRenderMap[streamId] = ptrIncomingStream; 429ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 430ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return moduleCallback; 431ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 432ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 433ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::DeleteIncomingRenderStream( 434ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId) 435ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 436ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 437ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 438ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 439ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 440ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 441ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 442ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 443ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 444ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 445ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId); 446ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 447ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 448ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 449ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream doesn't exist", __FUNCTION__); 450ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 451ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 452ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 453ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delete item->second; 454ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 455ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _ptrRenderer->DeleteIncomingRenderStream(streamId); 456ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 457ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _streamRenderMap.erase(item); 458ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 459ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 0; 460ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 461ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 462ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::AddExternalRenderCallback( 463ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId, 464ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderCallback* renderObject) { 465ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 466ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 467ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId); 468ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 469ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 470ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 471ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 472ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream doesn't exist", __FUNCTION__); 473ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 474ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 475ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 476ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item->second == NULL) { 477ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 478ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: could not get stream", __FUNCTION__); 479ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 480ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 481c043afc60534786c88d0cf0f1a96c70a50df87b1Peter Boström item->second->SetExternalCallback(renderObject); 482c043afc60534786c88d0cf0f1a96c70a50df87b1Peter Boström return 0; 483ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 484ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 485ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::GetIncomingRenderStreamProperties( 486ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId, 487ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org uint32_t& zOrder, 488ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org float& left, 489ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org float& top, 490ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org float& right, 491ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org float& bottom) const { 492ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 493ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 494ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 495ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 496ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 497ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 498ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 499ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 500ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 501ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->GetIncomingRenderStreamProperties(streamId, zOrder, 502ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org left, top, right, 503ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org bottom); 504ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 505ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 506ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orguint32_t ModuleVideoRenderImpl::GetNumIncomingRenderStreams() const 507ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 508ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 509ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 510ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return static_cast<uint32_t>(_streamRenderMap.size()); 511ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 512ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 513ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgbool ModuleVideoRenderImpl::HasIncomingRenderStream( 514ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId) const { 515ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 516ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 517ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _streamRenderMap.find(streamId) != _streamRenderMap.end(); 518ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 519ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 520ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::RegisterRawFrameCallback( 521ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId, 522ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org VideoRenderCallback* callbackObj) { 523ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 524ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 525ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 526ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::StartRender(const uint32_t streamId) 527ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 528ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 529ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 530ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 531ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 532ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 533ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 534ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 535ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 536ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 537ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Start the stream 538ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId); 539ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 540ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 541ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 542ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 543ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 544ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 545ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item->second->Start() == -1) 546ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 547ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 548ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 549ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 550ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Start the HW renderer 551ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_ptrRenderer->StartRender() == -1) 552ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 553ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 554ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 555ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 0; 556ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 557ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 558ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::StopRender(const uint32_t streamId) 559ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 560ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 561ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 562ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 563ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 564ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 565ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s(%d): No renderer", __FUNCTION__, streamId); 566ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 567ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 568ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 569ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Stop the incoming stream 570ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId); 571ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 572ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 573ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 574ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 575ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 576ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 577ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item->second->Stop() == -1) 578ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 579ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 580ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 581ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 582ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return 0; 583ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 584ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 585ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::ResetRender() 586ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 587ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 588ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 589ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org int32_t ret = 0; 590ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // Loop through all incoming streams and reset them 591ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org for (IncomingVideoStreamMap::iterator it = _streamRenderMap.begin(); 592ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org it != _streamRenderMap.end(); 593ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ++it) { 594ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (it->second->Reset() == -1) 595ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org ret = -1; 596ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 597ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return ret; 598ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 599ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 600ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgRawVideoType ModuleVideoRenderImpl::PreferredVideoType() const 601ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 602ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 603ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 604ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (_ptrRenderer == NULL) 605ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 606ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return kVideoI420; 607ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 608ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 609ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->PerferedVideoType(); 610ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 611ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 612ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgbool ModuleVideoRenderImpl::IsFullScreen() 613ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 614ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 615ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 616ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 617ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 618ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 619ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 620ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 621ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 622ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->FullScreen(); 623ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 624ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 625ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::GetScreenResolution( 626ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org uint32_t& screenWidth, 627ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org uint32_t& screenHeight) const 628ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 629ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 630ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 631ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 632ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 633ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 634ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 635ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 636ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 637ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->GetScreenResolution(screenWidth, screenHeight); 638ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 639ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 640ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orguint32_t ModuleVideoRenderImpl::RenderFrameRate( 641ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId) 642ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 643ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 644ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 645ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 646ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 647ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 648ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 649ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 650ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 651ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->RenderFrameRate(streamId); 652ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 653ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 654ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::SetStreamCropping( 655ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId, 656ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float left, 657ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float top, 658ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float right, 659ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float bottom) 660ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 661ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 662ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 663ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 664ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 665ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 666ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 667ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 668ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 669ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->SetStreamCropping(streamId, left, top, right, bottom); 670ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 671ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 672ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::SetTransparentBackground(const bool enable) 673ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 674ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 675ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 676ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 677ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 678ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 679ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 680ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 681ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 682ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->SetTransparentBackground(enable); 683ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 684ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 685ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::FullScreenRender(void* window, const bool enable) 686ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 687ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 688ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 689ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 690ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::SetText( 691ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint8_t textId, 692ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint8_t* text, 693ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const int32_t textLength, 694ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t textColorRef, 695ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t backgroundColorRef, 696ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float left, const float top, 697ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float right, 698ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float bottom) 699ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 700ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 701ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 702ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 703ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 704ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 705ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 706ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 707ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 708ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->SetText(textId, text, textLength, textColorRef, 709ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org backgroundColorRef, left, top, right, bottom); 710ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 711ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 712ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::SetBitmap(const void* bitMap, 713ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint8_t pictureId, 714ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const void* colorKey, 715ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float left, 716ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float top, 717ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float right, 718ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float bottom) 719ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 720ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 721ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 722ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 723ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 724ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 725ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 726ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 727ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 728ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->SetBitmap(bitMap, pictureId, colorKey, left, top, 729ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org right, bottom); 730ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 731ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 732ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::SetExpectedRenderDelay( 733ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org uint32_t stream_id, int32_t delay_ms) { 734ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 735ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 736ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) { 737ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 738ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 739ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 740ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 741ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 742ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::const_iterator item = 743ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _streamRenderMap.find(stream_id); 744ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) { 745ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // This stream doesn't exist 746ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 747ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s(%u, %d): stream doesn't exist", __FUNCTION__, stream_id, 748ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org delay_ms); 749ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 750ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 751ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 752ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org assert(item->second != NULL); 753ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return item->second->SetExpectedRenderDelay(delay_ms); 754ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 755ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 756ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.orgint32_t ModuleVideoRenderImpl::ConfigureRenderer( 757ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const uint32_t streamId, 758ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const unsigned int zOrder, 759ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float left, 760ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float top, 761ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float right, 762ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org const float bottom) 763ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org{ 764ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 765ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 766ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 767ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 768ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 769ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 770ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return false; 771ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 772ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return _ptrRenderer->ConfigureRenderer(streamId, zOrder, left, top, right, 773ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org bottom); 774ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 775ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 7764765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchezint32_t ModuleVideoRenderImpl::SetStartImage(const uint32_t streamId, 7774765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez const VideoFrame& videoFrame) { 778ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 779ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 780ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 781ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 782ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 783ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 784ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 785ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 786ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 787ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::const_iterator item = 788ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _streamRenderMap.find(streamId); 789ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 790ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 791ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // This stream doesn't exist 792ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 793ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream doesn't exist", __FUNCTION__); 794ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 795ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 796ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org assert (item->second != NULL); 797ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return item->second->SetStartImage(videoFrame); 798ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 799ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 800ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 8014765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchezint32_t ModuleVideoRenderImpl::SetTimeoutImage(const uint32_t streamId, 8024765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez const VideoFrame& videoFrame, 8034765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez const uint32_t timeout) { 804ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org CriticalSectionScoped cs(&_moduleCrit); 805ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 806ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (!_ptrRenderer) 807ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 808ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 809ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: No renderer", __FUNCTION__); 810ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 811ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 812ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 813ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org IncomingVideoStreamMap::const_iterator item = 814ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org _streamRenderMap.find(streamId); 815ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org if (item == _streamRenderMap.end()) 816ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org { 817ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org // This stream doesn't exist 818ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, 819ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org "%s: stream doesn't exist", __FUNCTION__); 820ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return -1; 821ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org } 822ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org assert(item->second != NULL); 823ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org return item->second->SetTimeoutImage(videoFrame, timeout); 824ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} 825ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org 826ab071daab89462db77158e637ba059dba8c9ece7andresp@webrtc.org} // namespace webrtc 827