niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 5aa3f1b | 2013-07-12 08:12:08 +0000 | [diff] [blame] | 14 | #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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | class CriticalSectionWrapper; |
| 20 | class IncomingVideoStream; |
| 21 | class IVideoRender; |
| 22 | class MapWrapper; |
| 23 | |
| 24 | // Class definitions |
| 25 | class ModuleVideoRenderImpl: public VideoRender |
| 26 | { |
| 27 | public: |
| 28 | /* |
| 29 | * VideoRenderer constructor/destructor |
| 30 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 31 | ModuleVideoRenderImpl(const int32_t id, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | const VideoRenderType videoRenderType, |
| 33 | void* window, const bool fullscreen); |
| 34 | |
| 35 | virtual ~ModuleVideoRenderImpl(); |
| 36 | |
| 37 | /* |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | * Change the unique identifier of this object |
| 39 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 40 | virtual int32_t ChangeUniqueId(const int32_t id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 42 | virtual int32_t TimeUntilNextProcess(); |
| 43 | virtual int32_t Process(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
| 45 | /* |
| 46 | * Returns the render window |
| 47 | */ |
| 48 | virtual void* Window(); |
| 49 | |
| 50 | /* |
| 51 | * Change render window |
| 52 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 53 | virtual int32_t ChangeWindow(void* window); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * Returns module id |
| 57 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 58 | int32_t Id(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
| 60 | /************************************************************************** |
| 61 | * |
| 62 | * Incoming Streams |
| 63 | * |
| 64 | ***************************************************************************/ |
| 65 | |
| 66 | /* |
| 67 | * Add incoming render stream |
| 68 | */ |
| 69 | virtual VideoRenderCallback |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 70 | * AddIncomingRenderStream(const uint32_t streamId, |
| 71 | const uint32_t zOrder, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | const float left, const float top, |
| 73 | const float right, const float bottom); |
| 74 | /* |
| 75 | * Delete incoming render stream |
| 76 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 77 | virtual int32_t |
| 78 | DeleteIncomingRenderStream(const uint32_t streamId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * Add incoming render callback, used for external rendering |
| 82 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 83 | virtual int32_t |
| 84 | AddExternalRenderCallback(const uint32_t streamId, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | VideoRenderCallback* renderObject); |
| 86 | |
| 87 | /* |
| 88 | * Get the porperties for an incoming render stream |
| 89 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 90 | virtual int32_t |
| 91 | GetIncomingRenderStreamProperties(const uint32_t streamId, |
| 92 | uint32_t& zOrder, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | float& left, float& top, |
| 94 | float& right, float& bottom) const; |
| 95 | /* |
| 96 | * Incoming frame rate for the specified stream. |
| 97 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 98 | virtual uint32_t GetIncomingFrameRate(const uint32_t streamId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * Returns the number of incoming streams added to this render module |
| 102 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 103 | virtual uint32_t GetNumIncomingRenderStreams() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Returns true if this render module has the streamId added, false otherwise. |
| 107 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 108 | virtual bool HasIncomingRenderStream(const uint32_t streamId) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * |
| 112 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 113 | virtual int32_t |
| 114 | RegisterRawFrameCallback(const uint32_t streamId, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | VideoRenderCallback* callbackObj); |
| 116 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 117 | virtual int32_t GetLastRenderedFrame(const uint32_t streamId, |
| 118 | I420VideoFrame &frame) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 120 | virtual int32_t SetExpectedRenderDelay(uint32_t stream_id, |
| 121 | int32_t delay_ms); |
mflodman@webrtc.org | f4f2145 | 2012-09-28 11:27:35 +0000 | [diff] [blame] | 122 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | /************************************************************************** |
| 124 | * |
| 125 | * Start/Stop |
| 126 | * |
| 127 | ***************************************************************************/ |
| 128 | |
| 129 | /* |
| 130 | * Starts rendering the specified stream |
| 131 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 132 | virtual int32_t StartRender(const uint32_t streamId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
| 134 | /* |
| 135 | * Stops the renderer |
| 136 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 137 | virtual int32_t StopRender(const uint32_t streamId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | |
| 139 | /* |
| 140 | * Sets the renderer in start state, no streams removed. |
| 141 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 142 | virtual int32_t ResetRender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 143 | |
| 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.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 163 | virtual int32_t |
| 164 | GetScreenResolution(uint32_t& screenWidth, |
| 165 | uint32_t& screenHeight) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 166 | |
| 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.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 171 | virtual uint32_t RenderFrameRate(const uint32_t streamId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | |
| 173 | /* |
| 174 | * Set cropping of incoming stream |
| 175 | */ |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 176 | virtual int32_t SetStreamCropping(const uint32_t streamId, |
| 177 | const float left, const float top, |
| 178 | const float right, const float bottom); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 179 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 180 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 184 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 185 | virtual int32_t SetTransparentBackground(const bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 186 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 187 | virtual int32_t FullScreenRender(void* window, const bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 188 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 189 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 194 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 195 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 202 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 203 | virtual int32_t SetStartImage(const uint32_t streamId, |
| 204 | const I420VideoFrame& videoFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 206 | virtual int32_t SetTimeoutImage(const uint32_t streamId, |
| 207 | const I420VideoFrame& videoFrame, |
| 208 | const uint32_t timeout); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 209 | |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 210 | virtual int32_t MirrorRenderStream(const int renderId, |
| 211 | const bool enable, |
| 212 | const bool mirrorXAxis, |
| 213 | const bool mirrorYAxis); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 214 | |
| 215 | private: |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 216 | int32_t _id; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 217 | CriticalSectionWrapper& _moduleCrit; |
| 218 | void* _ptrWindow; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 219 | bool _fullScreen; |
| 220 | |
| 221 | IVideoRender* _ptrRenderer; |
| 222 | MapWrapper& _streamRenderMap; |
| 223 | }; |
| 224 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 225 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 226 | |
| 227 | #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_ |