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 #ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_INTERFACE_VIDEO_RENDER_H_ 12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_INTERFACE_VIDEO_RENDER_H_ 13 14 /* 15 * video_render.h 16 * 17 * This header file together with module.h and module_common_types.h 18 * contains all of the APIs that are needed for using the video render 19 * module class. 20 * 21 */ 22 23 #include "webrtc/modules/interface/module.h" 24 #include "webrtc/modules/video_render/include/video_render_defines.h" 25 26 namespace webrtc { 27 28 // Class definitions 29 class VideoRender: public Module 30 { 31 public: 32 /* 33 * Create a video render module object 34 * 35 * id - unique identifier of this video render module object 36 * window - pointer to the window to render to 37 * fullscreen - true if this is a fullscreen renderer 38 * videoRenderType - type of renderer to create 39 */ 40 static VideoRender 41 * CreateVideoRender( 42 const int32_t id, 43 void* window, 44 const bool fullscreen, 45 const VideoRenderType videoRenderType = 46 kRenderDefault); 47 48 /* 49 * Destroy a video render module object 50 * 51 * module - object to destroy 52 */ 53 static void DestroyVideoRender(VideoRender* module); 54 55 /* 56 * Change the unique identifier of this object 57 * 58 * id - new unique identifier of this video render module object 59 */ 60 virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE = 0; 61 62 virtual int32_t TimeUntilNextProcess() OVERRIDE = 0; 63 virtual int32_t Process() OVERRIDE = 0; 64 65 /************************************************************************** 66 * 67 * Window functions 68 * 69 ***************************************************************************/ 70 71 /* 72 * Get window for this renderer 73 */ 74 virtual void* Window() = 0; 75 76 /* 77 * Change render window 78 * 79 * window - the new render window, assuming same type as originally created. 80 */ 81 virtual int32_t ChangeWindow(void* window) = 0; 82 83 /************************************************************************** 84 * 85 * Incoming Streams 86 * 87 ***************************************************************************/ 88 89 /* 90 * Add incoming render stream 91 * 92 * streamID - id of the stream to add 93 * zOrder - relative render order for the streams, 0 = on top 94 * left - position of the stream in the window, [0.0f, 1.0f] 95 * top - position of the stream in the window, [0.0f, 1.0f] 96 * right - position of the stream in the window, [0.0f, 1.0f] 97 * bottom - position of the stream in the window, [0.0f, 1.0f] 98 * 99 * Return - callback class to use for delivering new frames to render. 100 */ 101 virtual VideoRenderCallback 102 * AddIncomingRenderStream(const uint32_t streamId, 103 const uint32_t zOrder, 104 const float left, const float top, 105 const float right, const float bottom) = 0; 106 /* 107 * Delete incoming render stream 108 * 109 * streamID - id of the stream to add 110 */ 111 virtual int32_t 112 DeleteIncomingRenderStream(const uint32_t streamId) = 0; 113 114 /* 115 * Add incoming render callback, used for external rendering 116 * 117 * streamID - id of the stream the callback is used for 118 * renderObject - the VideoRenderCallback to use for this stream, NULL to remove 119 * 120 * Return - callback class to use for delivering new frames to render. 121 */ 122 virtual int32_t 123 AddExternalRenderCallback(const uint32_t streamId, 124 VideoRenderCallback* renderObject) = 0; 125 126 /* 127 * Get the porperties for an incoming render stream 128 * 129 * streamID - [in] id of the stream to get properties for 130 * zOrder - [out] relative render order for the streams, 0 = on top 131 * left - [out] position of the stream in the window, [0.0f, 1.0f] 132 * top - [out] position of the stream in the window, [0.0f, 1.0f] 133 * right - [out] position of the stream in the window, [0.0f, 1.0f] 134 * bottom - [out] position of the stream in the window, [0.0f, 1.0f] 135 */ 136 virtual int32_t 137 GetIncomingRenderStreamProperties(const uint32_t streamId, 138 uint32_t& zOrder, 139 float& left, float& top, 140 float& right, float& bottom) const = 0; 141 /* 142 * The incoming frame rate to the module, not the rate rendered in the window. 143 */ 144 virtual uint32_t 145 GetIncomingFrameRate(const uint32_t streamId) = 0; 146 147 /* 148 * Returns the number of incoming streams added to this render module 149 */ 150 virtual uint32_t GetNumIncomingRenderStreams() const = 0; 151 152 /* 153 * Returns true if this render module has the streamId added, false otherwise. 154 */ 155 virtual bool 156 HasIncomingRenderStream(const uint32_t streamId) const = 0; 157 158 /* 159 * Registers a callback to get raw images in the same time as sent 160 * to the renderer. To be used for external rendering. 161 */ 162 virtual int32_t 163 RegisterRawFrameCallback(const uint32_t streamId, 164 VideoRenderCallback* callbackObj) = 0; 165 166 /* 167 * This method is usefull to get last rendered frame for the stream specified 168 */ 169 virtual int32_t 170 GetLastRenderedFrame(const uint32_t streamId, 171 I420VideoFrame &frame) const = 0; 172 173 /************************************************************************** 174 * 175 * Start/Stop 176 * 177 ***************************************************************************/ 178 179 /* 180 * Starts rendering the specified stream 181 */ 182 virtual int32_t StartRender(const uint32_t streamId) = 0; 183 184 /* 185 * Stops the renderer 186 */ 187 virtual int32_t StopRender(const uint32_t streamId) = 0; 188 189 /* 190 * Resets the renderer 191 * No streams are removed. The state should be as after AddStream was called. 192 */ 193 virtual int32_t ResetRender() = 0; 194 195 /************************************************************************** 196 * 197 * Properties 198 * 199 ***************************************************************************/ 200 201 /* 202 * Returns the preferred render video type 203 */ 204 virtual RawVideoType PreferredVideoType() const = 0; 205 206 /* 207 * Returns true if the renderer is in fullscreen mode, otherwise false. 208 */ 209 virtual bool IsFullScreen() = 0; 210 211 /* 212 * Gets screen resolution in pixels 213 */ 214 virtual int32_t 215 GetScreenResolution(uint32_t& screenWidth, 216 uint32_t& screenHeight) const = 0; 217 218 /* 219 * Get the actual render rate for this stream. I.e rendered frame rate, 220 * not frames delivered to the renderer. 221 */ 222 virtual uint32_t RenderFrameRate(const uint32_t streamId) = 0; 223 224 /* 225 * Set cropping of incoming stream 226 */ 227 virtual int32_t SetStreamCropping(const uint32_t streamId, 228 const float left, 229 const float top, 230 const float right, 231 const float bottom) = 0; 232 233 /* 234 * re-configure renderer 235 */ 236 237 // Set the expected time needed by the graphics card or external renderer, 238 // i.e. frames will be released for rendering |delay_ms| before set render 239 // time in the video frame. 240 virtual int32_t SetExpectedRenderDelay(uint32_t stream_id, 241 int32_t delay_ms) = 0; 242 243 virtual int32_t ConfigureRenderer(const uint32_t streamId, 244 const unsigned int zOrder, 245 const float left, 246 const float top, 247 const float right, 248 const float bottom) = 0; 249 250 virtual int32_t SetTransparentBackground(const bool enable) = 0; 251 252 virtual int32_t FullScreenRender(void* window, const bool enable) = 0; 253 254 virtual int32_t SetBitmap(const void* bitMap, 255 const uint8_t pictureId, 256 const void* colorKey, 257 const float left, const float top, 258 const float right, const float bottom) = 0; 259 260 virtual int32_t SetText(const uint8_t textId, 261 const uint8_t* text, 262 const int32_t textLength, 263 const uint32_t textColorRef, 264 const uint32_t backgroundColorRef, 265 const float left, const float top, 266 const float right, const float bottom) = 0; 267 268 /* 269 * Set a start image. The image is rendered before the first image has been delivered 270 */ 271 virtual int32_t 272 SetStartImage(const uint32_t streamId, 273 const I420VideoFrame& videoFrame) = 0; 274 275 /* 276 * Set a timout image. The image is rendered if no videoframe has been delivered 277 */ 278 virtual int32_t SetTimeoutImage(const uint32_t streamId, 279 const I420VideoFrame& videoFrame, 280 const uint32_t timeout)= 0; 281 282 virtual int32_t MirrorRenderStream(const int renderId, 283 const bool enable, 284 const bool mirrorXAxis, 285 const bool mirrorYAxis) = 0; 286 }; 287 } // namespace webrtc 288 #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_INTERFACE_VIDEO_RENDER_H_ 289