1/* 2 * Copyright (c) 2013 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#if !defined(__has_feature) || !__has_feature(objc_arc) 12#error "This file requires ARC support." 13#endif 14 15#include "webrtc/modules/video_render/ios/video_render_ios_impl.h" 16#include "webrtc/modules/video_render/ios/video_render_ios_gles20.h" 17#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 18#include "webrtc/system_wrappers/interface/trace.h" 19 20using namespace webrtc; 21 22#define IOS_UNSUPPORTED() \ 23 WEBRTC_TRACE(kTraceError, \ 24 kTraceVideoRenderer, \ 25 id_, \ 26 "%s is not supported on the iOS platform.", \ 27 __FUNCTION__); \ 28 return -1; 29 30VideoRenderIosImpl::VideoRenderIosImpl(const int32_t id, 31 void* window, 32 const bool full_screen) 33 : id_(id), 34 ptr_window_(window), 35 full_screen_(full_screen), 36 crit_sec_(CriticalSectionWrapper::CreateCriticalSection()) {} 37 38VideoRenderIosImpl::~VideoRenderIosImpl() { 39 delete crit_sec_; 40} 41 42int32_t VideoRenderIosImpl::Init() { 43 CriticalSectionScoped cs(crit_sec_); 44 45 ptr_ios_render_.reset(new VideoRenderIosGles20( 46 (__bridge VideoRenderIosView*)ptr_window_, full_screen_, id_)); 47 48 return ptr_ios_render_->Init(); 49 ; 50} 51 52int32_t VideoRenderIosImpl::ChangeUniqueId(const int32_t id) { 53 CriticalSectionScoped cs(crit_sec_); 54 id_ = id; 55 56 return ptr_ios_render_->ChangeUniqueID(id_); 57} 58 59int32_t VideoRenderIosImpl::ChangeWindow(void* window) { 60 CriticalSectionScoped cs(crit_sec_); 61 if (window == NULL) { 62 return -1; 63 } 64 65 ptr_window_ = window; 66 67 return ptr_ios_render_->ChangeWindow(ptr_window_); 68} 69 70VideoRenderCallback* VideoRenderIosImpl::AddIncomingRenderStream( 71 const uint32_t stream_id, 72 const uint32_t z_order, 73 const float left, 74 const float top, 75 const float right, 76 const float bottom) { 77 CriticalSectionScoped cs(crit_sec_); 78 if (!ptr_window_) { 79 return NULL; 80 } 81 82 return ptr_ios_render_->CreateEaglChannel( 83 stream_id, z_order, left, top, right, bottom); 84} 85 86int32_t VideoRenderIosImpl::DeleteIncomingRenderStream( 87 const uint32_t stream_id) { 88 CriticalSectionScoped cs(crit_sec_); 89 90 return ptr_ios_render_->DeleteEaglChannel(stream_id); 91} 92 93int32_t VideoRenderIosImpl::GetIncomingRenderStreamProperties( 94 const uint32_t stream_id, 95 uint32_t& z_order, 96 float& left, 97 float& top, 98 float& right, 99 float& bottom) const { 100 IOS_UNSUPPORTED(); 101} 102 103int32_t VideoRenderIosImpl::StartRender() { 104 return ptr_ios_render_->StartRender(); 105} 106 107int32_t VideoRenderIosImpl::StopRender() { 108 return ptr_ios_render_->StopRender(); 109} 110 111VideoRenderType VideoRenderIosImpl::RenderType() { return kRenderiOS; } 112 113RawVideoType VideoRenderIosImpl::PerferedVideoType() { return kVideoI420; } 114 115bool VideoRenderIosImpl::FullScreen() { IOS_UNSUPPORTED(); } 116 117int32_t VideoRenderIosImpl::GetGraphicsMemory( 118 uint64_t& totalGraphicsMemory, 119 uint64_t& availableGraphicsMemory) const { 120 IOS_UNSUPPORTED(); 121} 122 123int32_t VideoRenderIosImpl::GetScreenResolution(uint32_t& screenWidth, 124 uint32_t& screenHeight) const { 125 return ptr_ios_render_->GetScreenResolution(screenWidth, screenHeight); 126} 127 128uint32_t VideoRenderIosImpl::RenderFrameRate(const uint32_t streamId) { 129 IOS_UNSUPPORTED(); 130} 131 132int32_t VideoRenderIosImpl::SetStreamCropping(const uint32_t streamId, 133 const float left, 134 const float top, 135 const float right, 136 const float bottom) { 137 return ptr_ios_render_->SetStreamCropping(streamId, left, top, right, bottom); 138} 139 140int32_t VideoRenderIosImpl::ConfigureRenderer(const uint32_t streamId, 141 const unsigned int zOrder, 142 const float left, 143 const float top, 144 const float right, 145 const float bottom) { 146 IOS_UNSUPPORTED(); 147} 148 149int32_t VideoRenderIosImpl::SetTransparentBackground(const bool enable) { 150 IOS_UNSUPPORTED(); 151} 152 153int32_t VideoRenderIosImpl::SetText(const uint8_t textId, 154 const uint8_t* text, 155 const int32_t textLength, 156 const uint32_t textColorRef, 157 const uint32_t backgroundColorRef, 158 const float left, 159 const float top, 160 const float right, 161 const float bottom) { 162 IOS_UNSUPPORTED(); 163} 164 165int32_t VideoRenderIosImpl::SetBitmap(const void* bitMap, 166 const uint8_t pictureId, 167 const void* colorKey, 168 const float left, 169 const float top, 170 const float right, 171 const float bottom) { 172 IOS_UNSUPPORTED(); 173} 174 175int32_t VideoRenderIosImpl::FullScreenRender(void* window, const bool enable) { 176 IOS_UNSUPPORTED(); 177} 178