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/include/critical_section_wrapper.h" 18#include "webrtc/system_wrappers/include/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::ChangeWindow(void* window) { 53 CriticalSectionScoped cs(crit_sec_); 54 if (window == NULL) { 55 return -1; 56 } 57 58 ptr_window_ = window; 59 60 return ptr_ios_render_->ChangeWindow(ptr_window_); 61} 62 63VideoRenderCallback* VideoRenderIosImpl::AddIncomingRenderStream( 64 const uint32_t stream_id, 65 const uint32_t z_order, 66 const float left, 67 const float top, 68 const float right, 69 const float bottom) { 70 CriticalSectionScoped cs(crit_sec_); 71 if (!ptr_window_) { 72 return NULL; 73 } 74 75 return ptr_ios_render_->CreateEaglChannel( 76 stream_id, z_order, left, top, right, bottom); 77} 78 79int32_t VideoRenderIosImpl::DeleteIncomingRenderStream( 80 const uint32_t stream_id) { 81 CriticalSectionScoped cs(crit_sec_); 82 83 return ptr_ios_render_->DeleteEaglChannel(stream_id); 84} 85 86int32_t VideoRenderIosImpl::GetIncomingRenderStreamProperties( 87 const uint32_t stream_id, 88 uint32_t& z_order, 89 float& left, 90 float& top, 91 float& right, 92 float& bottom) const { 93 IOS_UNSUPPORTED(); 94} 95 96int32_t VideoRenderIosImpl::StartRender() { 97 return ptr_ios_render_->StartRender(); 98} 99 100int32_t VideoRenderIosImpl::StopRender() { 101 return ptr_ios_render_->StopRender(); 102} 103 104VideoRenderType VideoRenderIosImpl::RenderType() { return kRenderiOS; } 105 106RawVideoType VideoRenderIosImpl::PerferedVideoType() { return kVideoI420; } 107 108bool VideoRenderIosImpl::FullScreen() { IOS_UNSUPPORTED(); } 109 110int32_t VideoRenderIosImpl::GetGraphicsMemory( 111 uint64_t& totalGraphicsMemory, 112 uint64_t& availableGraphicsMemory) const { 113 IOS_UNSUPPORTED(); 114} 115 116int32_t VideoRenderIosImpl::GetScreenResolution(uint32_t& screenWidth, 117 uint32_t& screenHeight) const { 118 return ptr_ios_render_->GetScreenResolution(screenWidth, screenHeight); 119} 120 121uint32_t VideoRenderIosImpl::RenderFrameRate(const uint32_t streamId) { 122 IOS_UNSUPPORTED(); 123} 124 125int32_t VideoRenderIosImpl::SetStreamCropping(const uint32_t streamId, 126 const float left, 127 const float top, 128 const float right, 129 const float bottom) { 130 return ptr_ios_render_->SetStreamCropping(streamId, left, top, right, bottom); 131} 132 133int32_t VideoRenderIosImpl::ConfigureRenderer(const uint32_t streamId, 134 const unsigned int zOrder, 135 const float left, 136 const float top, 137 const float right, 138 const float bottom) { 139 IOS_UNSUPPORTED(); 140} 141 142int32_t VideoRenderIosImpl::SetTransparentBackground(const bool enable) { 143 IOS_UNSUPPORTED(); 144} 145 146int32_t VideoRenderIosImpl::SetText(const uint8_t textId, 147 const uint8_t* text, 148 const int32_t textLength, 149 const uint32_t textColorRef, 150 const uint32_t backgroundColorRef, 151 const float left, 152 const float top, 153 const float right, 154 const float bottom) { 155 IOS_UNSUPPORTED(); 156} 157 158int32_t VideoRenderIosImpl::SetBitmap(const void* bitMap, 159 const uint8_t pictureId, 160 const void* colorKey, 161 const float left, 162 const float top, 163 const float right, 164 const float bottom) { 165 IOS_UNSUPPORTED(); 166} 167 168int32_t VideoRenderIosImpl::FullScreenRender(void* window, const bool enable) { 169 IOS_UNSUPPORTED(); 170} 171