Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/video_render/mac/video_render_mac_cocoa_impl.mm @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 7.2 KB
Line 
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#if defined(COCOA_RENDERING)
13
14#import "cocoa_render_view.h"
15
16#include "video_render_mac_cocoa_impl.h"
17#include "critical_section_wrapper.h"
18#include "video_render_nsopengl.h"
19#include "trace.h"
20
21namespace webrtc {
22
23VideoRenderMacCocoaImpl::VideoRenderMacCocoaImpl(const int32_t id,
24        const VideoRenderType videoRenderType,
25        void* window,
26        const bool fullscreen) :
27_id(id),
28_renderMacCocoaCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
29_fullScreen(fullscreen),
30_ptrWindow(window)
31{
32
33    WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "Constructor %s:%d", __FUNCTION__, __LINE__);
34}
35
36VideoRenderMacCocoaImpl::~VideoRenderMacCocoaImpl()
37{
38    WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "Destructor %s:%d", __FUNCTION__, __LINE__);
39    delete &_renderMacCocoaCritsect;
40    if (_ptrCocoaRender)
41    {
42        delete _ptrCocoaRender;
43        _ptrCocoaRender = NULL;
44    }
45}
46
47int32_t
48VideoRenderMacCocoaImpl::Init()
49{
50
51    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
52    WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d", __FUNCTION__, __LINE__);
53
54    // cast ptrWindow from void* to CocoaRenderer. Void* was once NSOpenGLView, and CocoaRenderer is NSOpenGLView.
55    _ptrCocoaRender = new VideoRenderNSOpenGL((CocoaRenderView*)_ptrWindow, _fullScreen, _id);
56    if (!_ptrWindow)
57    {
58        WEBRTC_TRACE(kTraceWarning, kTraceVideoRenderer, _id, "Constructor %s:%d", __FUNCTION__, __LINE__);
59        return -1;
60    }
61    int retVal = _ptrCocoaRender->Init();
62    if (retVal == -1)
63    {
64        WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "Failed to init %s:%d", __FUNCTION__, __LINE__);
65        return -1;
66    }
67
68    return 0;
69}
70
71int32_t
72VideoRenderMacCocoaImpl::ChangeUniqueId(const int32_t id)
73{
74    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
75    WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s", __FUNCTION__);
76    _id = id;
77
78    if(_ptrCocoaRender)
79    {
80        _ptrCocoaRender->ChangeUniqueID(_id);
81    }
82
83    return 0;
84}
85
86int32_t
87VideoRenderMacCocoaImpl::ChangeWindow(void* window)
88{
89
90    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
91    WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s changing ID to ", __FUNCTION__, window);
92
93    if (window == NULL)
94    {
95        return -1;
96    }
97    _ptrWindow = window;
98
99
100    _ptrWindow = window;
101    _ptrCocoaRender->ChangeWindow((CocoaRenderView*)_ptrWindow);
102
103    return 0;
104}
105
106VideoRenderCallback*
107VideoRenderMacCocoaImpl::AddIncomingRenderStream(const uint32_t streamId,
108        const uint32_t zOrder,
109        const float left,
110        const float top,
111        const float right,
112        const float bottom)
113{
114    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
115    WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "%s", __FUNCTION__);
116    VideoChannelNSOpenGL* nsOpenGLChannel = NULL;
117
118    if(!_ptrWindow)
119    {
120    }
121
122    if(!nsOpenGLChannel)
123    {
124        nsOpenGLChannel = _ptrCocoaRender->CreateNSGLChannel(streamId, zOrder, left, top, right, bottom);
125    }
126
127    return nsOpenGLChannel;
128
129}
130
131int32_t
132VideoRenderMacCocoaImpl::DeleteIncomingRenderStream(const uint32_t streamId)
133{
134    WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Constructor %s:%d", __FUNCTION__, __LINE__);
135    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
136    _ptrCocoaRender->DeleteNSGLChannel(streamId);
137
138    return 0;
139}
140
141int32_t
142VideoRenderMacCocoaImpl::GetIncomingRenderStreamProperties(const uint32_t streamId,
143        uint32_t& zOrder,
144        float& left,
145        float& top,
146        float& right,
147        float& bottom) const
148{
149    return _ptrCocoaRender->GetChannelProperties(streamId, zOrder, left, top, right, bottom);
150}
151
152int32_t
153VideoRenderMacCocoaImpl::StartRender()
154{
155    return _ptrCocoaRender->StartRender();
156}
157
158int32_t
159VideoRenderMacCocoaImpl::StopRender()
160{
161    return _ptrCocoaRender->StopRender();
162}
163
164VideoRenderType
165VideoRenderMacCocoaImpl::RenderType()
166{
167    return kRenderCocoa;
168}
169
170RawVideoType
171VideoRenderMacCocoaImpl::PerferedVideoType()
172{
173    return kVideoI420;
174}
175
176bool
177VideoRenderMacCocoaImpl::FullScreen()
178{
179    return false;
180}
181
182int32_t
183VideoRenderMacCocoaImpl::GetGraphicsMemory(uint64_t& totalGraphicsMemory,
184        uint64_t& availableGraphicsMemory) const
185{
186    totalGraphicsMemory = 0;
187    availableGraphicsMemory = 0;
188    return 0;
189}
190
191int32_t
192VideoRenderMacCocoaImpl::GetScreenResolution(uint32_t& screenWidth,
193        uint32_t& screenHeight) const
194{
195    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
196    NSScreen* mainScreen = [NSScreen mainScreen];
197
198    NSRect frame = [mainScreen frame];
199
200    screenWidth = frame.size.width;
201    screenHeight = frame.size.height;
202    return 0;
203}
204
205uint32_t
206VideoRenderMacCocoaImpl::RenderFrameRate(const uint32_t streamId)
207{
208    CriticalSectionScoped cs(&_renderMacCocoaCritsect);
209    return 0;
210}
211
212int32_t
213VideoRenderMacCocoaImpl::SetStreamCropping(const uint32_t streamId,
214        const float left,
215        const float top,
216        const float right,
217        const float bottom)
218{
219    return 0;
220}
221
222int32_t VideoRenderMacCocoaImpl::ConfigureRenderer(const uint32_t streamId,
223                                                   const unsigned int zOrder,
224                                                   const float left,
225                                                   const float top,
226                                                   const float right,
227                                                   const float bottom)
228{
229    return 0;
230}
231
232int32_t
233VideoRenderMacCocoaImpl::SetTransparentBackground(const bool enable)
234{
235    return 0;
236}
237
238int32_t VideoRenderMacCocoaImpl::SetText(const uint8_t textId,
239                                         const uint8_t* text,
240                                         const int32_t textLength,
241                                         const uint32_t textColorRef,
242                                         const uint32_t backgroundColorRef,
243                                         const float left,
244                                         const float top,
245                                         const float right,
246                                         const float bottom)
247{
248    return _ptrCocoaRender->SetText(textId, text, textLength, textColorRef, backgroundColorRef, left, top, right, bottom);
249}
250
251int32_t VideoRenderMacCocoaImpl::SetBitmap(const void* bitMap,
252                                           const uint8_t pictureId,
253                                           const void* colorKey,
254                                           const float left,
255                                           const float top,
256                                           const float right,
257                                           const float bottom)
258{
259    return 0;
260}
261
262int32_t VideoRenderMacCocoaImpl::FullScreenRender(void* window, const bool enable)
263{
264    return -1;
265}
266
267}  // namespace webrtc
268
269#endif // COCOA_RENDERING
Note: See TracBrowser for help on using the repository browser.