blob: c9e69e9f970091ff0416f0fb6b1e04af3991b360 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
12#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
13
pbos@webrtc.org5aa3f1b2013-07-12 08:12:08 +000014#include "webrtc/engine_configurations.h"
15#include "webrtc/modules/video_render/include/video_render.h"
16#include "webrtc/system_wrappers/interface/map_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
niklase@google.com470e71d2011-07-07 08:21:25 +000018namespace webrtc {
19class CriticalSectionWrapper;
20class IncomingVideoStream;
21class IVideoRender;
22class MapWrapper;
23
24// Class definitions
25class ModuleVideoRenderImpl: public VideoRender
26{
27public:
28 /*
29 * VideoRenderer constructor/destructor
30 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000031 ModuleVideoRenderImpl(const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000032 const VideoRenderType videoRenderType,
33 void* window, const bool fullscreen);
34
35 virtual ~ModuleVideoRenderImpl();
36
37 /*
niklase@google.com470e71d2011-07-07 08:21:25 +000038 * Change the unique identifier of this object
39 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000040 virtual int32_t ChangeUniqueId(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +000041
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000042 virtual int32_t TimeUntilNextProcess();
43 virtual int32_t Process();
niklase@google.com470e71d2011-07-07 08:21:25 +000044
45 /*
46 * Returns the render window
47 */
48 virtual void* Window();
49
50 /*
51 * Change render window
52 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000053 virtual int32_t ChangeWindow(void* window);
niklase@google.com470e71d2011-07-07 08:21:25 +000054
55 /*
56 * Returns module id
57 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000058 int32_t Id();
niklase@google.com470e71d2011-07-07 08:21:25 +000059
60 /**************************************************************************
61 *
62 * Incoming Streams
63 *
64 ***************************************************************************/
65
66 /*
67 * Add incoming render stream
68 */
69 virtual VideoRenderCallback
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000070 * AddIncomingRenderStream(const uint32_t streamId,
71 const uint32_t zOrder,
niklase@google.com470e71d2011-07-07 08:21:25 +000072 const float left, const float top,
73 const float right, const float bottom);
74 /*
75 * Delete incoming render stream
76 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000077 virtual int32_t
78 DeleteIncomingRenderStream(const uint32_t streamId);
niklase@google.com470e71d2011-07-07 08:21:25 +000079
80 /*
81 * Add incoming render callback, used for external rendering
82 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000083 virtual int32_t
84 AddExternalRenderCallback(const uint32_t streamId,
niklase@google.com470e71d2011-07-07 08:21:25 +000085 VideoRenderCallback* renderObject);
86
87 /*
88 * Get the porperties for an incoming render stream
89 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000090 virtual int32_t
91 GetIncomingRenderStreamProperties(const uint32_t streamId,
92 uint32_t& zOrder,
niklase@google.com470e71d2011-07-07 08:21:25 +000093 float& left, float& top,
94 float& right, float& bottom) const;
95 /*
96 * Incoming frame rate for the specified stream.
97 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000098 virtual uint32_t GetIncomingFrameRate(const uint32_t streamId);
niklase@google.com470e71d2011-07-07 08:21:25 +000099
100 /*
101 * Returns the number of incoming streams added to this render module
102 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000103 virtual uint32_t GetNumIncomingRenderStreams() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
105 /*
106 * Returns true if this render module has the streamId added, false otherwise.
107 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000108 virtual bool HasIncomingRenderStream(const uint32_t streamId) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
110 /*
111 *
112 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000113 virtual int32_t
114 RegisterRawFrameCallback(const uint32_t streamId,
niklase@google.com470e71d2011-07-07 08:21:25 +0000115 VideoRenderCallback* callbackObj);
116
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000117 virtual int32_t GetLastRenderedFrame(const uint32_t streamId,
118 I420VideoFrame &frame) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000119
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000120 virtual int32_t SetExpectedRenderDelay(uint32_t stream_id,
121 int32_t delay_ms);
mflodman@webrtc.orgf4f21452012-09-28 11:27:35 +0000122
niklase@google.com470e71d2011-07-07 08:21:25 +0000123 /**************************************************************************
124 *
125 * Start/Stop
126 *
127 ***************************************************************************/
128
129 /*
130 * Starts rendering the specified stream
131 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000132 virtual int32_t StartRender(const uint32_t streamId);
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
134 /*
135 * Stops the renderer
136 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000137 virtual int32_t StopRender(const uint32_t streamId);
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
139 /*
140 * Sets the renderer in start state, no streams removed.
141 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000142 virtual int32_t ResetRender();
niklase@google.com470e71d2011-07-07 08:21:25 +0000143
144 /**************************************************************************
145 *
146 * Properties
147 *
148 ***************************************************************************/
149
150 /*
151 * Returns the prefered render video type
152 */
153 virtual RawVideoType PreferredVideoType() const;
154
155 /*
156 * Returns true if the renderer is in fullscreen mode, otherwise false.
157 */
158 virtual bool IsFullScreen();
159
160 /*
161 * Gets screen resolution in pixels
162 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000163 virtual int32_t
164 GetScreenResolution(uint32_t& screenWidth,
165 uint32_t& screenHeight) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000166
167 /*
168 * Get the actual render rate for this stream. I.e rendered frame rate,
169 * not frames delivered to the renderer.
170 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000171 virtual uint32_t RenderFrameRate(const uint32_t streamId);
niklase@google.com470e71d2011-07-07 08:21:25 +0000172
173 /*
174 * Set cropping of incoming stream
175 */
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000176 virtual int32_t SetStreamCropping(const uint32_t streamId,
177 const float left, const float top,
178 const float right, const float bottom);
niklase@google.com470e71d2011-07-07 08:21:25 +0000179
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000180 virtual int32_t ConfigureRenderer(const uint32_t streamId,
181 const unsigned int zOrder,
182 const float left, const float top,
183 const float right, const float bottom);
niklase@google.com470e71d2011-07-07 08:21:25 +0000184
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000185 virtual int32_t SetTransparentBackground(const bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000186
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000187 virtual int32_t FullScreenRender(void* window, const bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000188
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000189 virtual int32_t SetBitmap(const void* bitMap,
190 const uint8_t pictureId,
191 const void* colorKey,
192 const float left, const float top,
193 const float right, const float bottom);
niklase@google.com470e71d2011-07-07 08:21:25 +0000194
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000195 virtual int32_t SetText(const uint8_t textId,
196 const uint8_t* text,
197 const int32_t textLength,
198 const uint32_t textColorRef,
199 const uint32_t backgroundColorRef,
200 const float left, const float top,
201 const float right, const float bottom);
niklase@google.com470e71d2011-07-07 08:21:25 +0000202
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000203 virtual int32_t SetStartImage(const uint32_t streamId,
204 const I420VideoFrame& videoFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +0000205
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000206 virtual int32_t SetTimeoutImage(const uint32_t streamId,
207 const I420VideoFrame& videoFrame,
208 const uint32_t timeout);
niklase@google.com470e71d2011-07-07 08:21:25 +0000209
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000210 virtual int32_t MirrorRenderStream(const int renderId,
211 const bool enable,
212 const bool mirrorXAxis,
213 const bool mirrorYAxis);
niklase@google.com470e71d2011-07-07 08:21:25 +0000214
215private:
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +0000216 int32_t _id;
niklase@google.com470e71d2011-07-07 08:21:25 +0000217 CriticalSectionWrapper& _moduleCrit;
218 void* _ptrWindow;
niklase@google.com470e71d2011-07-07 08:21:25 +0000219 bool _fullScreen;
220
221 IVideoRender* _ptrRenderer;
222 MapWrapper& _streamRenderMap;
223};
224
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000225} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000226
227#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_