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 | |
| 14 | #include "engine_configurations.h" |
| 15 | #include "video_render.h" |
| 16 | #include "map_wrapper.h" |
| 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 | */ |
| 31 | ModuleVideoRenderImpl(const WebRtc_Word32 id, |
| 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 | */ |
| 40 | virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); |
| 41 | |
| 42 | virtual WebRtc_Word32 TimeUntilNextProcess(); |
| 43 | virtual WebRtc_Word32 Process(); |
| 44 | |
| 45 | /* |
| 46 | * Returns the render window |
| 47 | */ |
| 48 | virtual void* Window(); |
| 49 | |
| 50 | /* |
| 51 | * Change render window |
| 52 | */ |
| 53 | virtual WebRtc_Word32 ChangeWindow(void* window); |
| 54 | |
| 55 | /* |
| 56 | * Returns module id |
| 57 | */ |
| 58 | WebRtc_Word32 Id(); |
| 59 | |
| 60 | /************************************************************************** |
| 61 | * |
| 62 | * Incoming Streams |
| 63 | * |
| 64 | ***************************************************************************/ |
| 65 | |
| 66 | /* |
| 67 | * Add incoming render stream |
| 68 | */ |
| 69 | virtual VideoRenderCallback |
| 70 | * AddIncomingRenderStream(const WebRtc_UWord32 streamId, |
| 71 | const WebRtc_UWord32 zOrder, |
| 72 | const float left, const float top, |
| 73 | const float right, const float bottom); |
| 74 | /* |
| 75 | * Delete incoming render stream |
| 76 | */ |
| 77 | virtual WebRtc_Word32 |
| 78 | DeleteIncomingRenderStream(const WebRtc_UWord32 streamId); |
| 79 | |
| 80 | /* |
| 81 | * Add incoming render callback, used for external rendering |
| 82 | */ |
| 83 | virtual WebRtc_Word32 |
| 84 | AddExternalRenderCallback(const WebRtc_UWord32 streamId, |
| 85 | VideoRenderCallback* renderObject); |
| 86 | |
| 87 | /* |
| 88 | * Get the porperties for an incoming render stream |
| 89 | */ |
| 90 | virtual WebRtc_Word32 |
| 91 | GetIncomingRenderStreamProperties(const WebRtc_UWord32 streamId, |
| 92 | WebRtc_UWord32& zOrder, |
| 93 | float& left, float& top, |
| 94 | float& right, float& bottom) const; |
| 95 | /* |
| 96 | * Incoming frame rate for the specified stream. |
| 97 | */ |
| 98 | virtual WebRtc_UWord32 GetIncomingFrameRate(const WebRtc_UWord32 streamId); |
| 99 | |
| 100 | /* |
| 101 | * Returns the number of incoming streams added to this render module |
| 102 | */ |
| 103 | virtual WebRtc_UWord32 GetNumIncomingRenderStreams() const; |
| 104 | |
| 105 | /* |
| 106 | * Returns true if this render module has the streamId added, false otherwise. |
| 107 | */ |
| 108 | virtual bool HasIncomingRenderStream(const WebRtc_UWord32 streamId) const; |
| 109 | |
| 110 | /* |
| 111 | * |
| 112 | */ |
| 113 | virtual WebRtc_Word32 |
| 114 | RegisterRawFrameCallback(const WebRtc_UWord32 streamId, |
| 115 | VideoRenderCallback* callbackObj); |
| 116 | |
| 117 | virtual WebRtc_Word32 GetLastRenderedFrame(const WebRtc_UWord32 streamId, |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 118 | I420VideoFrame &frame) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
mflodman@webrtc.org | f4f2145 | 2012-09-28 11:27:35 +0000 | [diff] [blame] | 120 | virtual WebRtc_Word32 SetExpectedRenderDelay(WebRtc_UWord32 stream_id, |
| 121 | WebRtc_Word32 delay_ms); |
| 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 | */ |
| 132 | virtual WebRtc_Word32 StartRender(const WebRtc_UWord32 streamId); |
| 133 | |
| 134 | /* |
| 135 | * Stops the renderer |
| 136 | */ |
| 137 | virtual WebRtc_Word32 StopRender(const WebRtc_UWord32 streamId); |
| 138 | |
| 139 | /* |
| 140 | * Sets the renderer in start state, no streams removed. |
| 141 | */ |
| 142 | virtual WebRtc_Word32 ResetRender(); |
| 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 | */ |
| 163 | virtual WebRtc_Word32 |
| 164 | GetScreenResolution(WebRtc_UWord32& screenWidth, |
| 165 | WebRtc_UWord32& screenHeight) const; |
| 166 | |
| 167 | /* |
| 168 | * Get the actual render rate for this stream. I.e rendered frame rate, |
| 169 | * not frames delivered to the renderer. |
| 170 | */ |
| 171 | virtual WebRtc_UWord32 RenderFrameRate(const WebRtc_UWord32 streamId); |
| 172 | |
| 173 | /* |
| 174 | * Set cropping of incoming stream |
| 175 | */ |
| 176 | virtual WebRtc_Word32 SetStreamCropping(const WebRtc_UWord32 streamId, |
| 177 | const float left, const float top, |
| 178 | const float right, |
| 179 | const float bottom); |
| 180 | |
| 181 | virtual WebRtc_Word32 ConfigureRenderer(const WebRtc_UWord32 streamId, |
| 182 | const unsigned int zOrder, |
| 183 | const float left, const float top, |
| 184 | const float right, |
| 185 | const float bottom); |
| 186 | |
| 187 | virtual WebRtc_Word32 SetTransparentBackground(const bool enable); |
| 188 | |
| 189 | virtual WebRtc_Word32 FullScreenRender(void* window, const bool enable); |
| 190 | |
| 191 | virtual WebRtc_Word32 SetBitmap(const void* bitMap, |
| 192 | const WebRtc_UWord8 pictureId, |
| 193 | const void* colorKey, const float left, |
| 194 | const float top, const float right, |
| 195 | const float bottom); |
| 196 | |
| 197 | virtual WebRtc_Word32 SetText(const WebRtc_UWord8 textId, |
| 198 | const WebRtc_UWord8* text, |
| 199 | const WebRtc_Word32 textLength, |
| 200 | const WebRtc_UWord32 textColorRef, |
| 201 | const WebRtc_UWord32 backgroundColorRef, |
| 202 | const float left, const float top, |
| 203 | const float right, const float bottom); |
| 204 | |
| 205 | virtual WebRtc_Word32 SetStartImage(const WebRtc_UWord32 streamId, |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 206 | const I420VideoFrame& videoFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 207 | |
| 208 | virtual WebRtc_Word32 SetTimeoutImage(const WebRtc_UWord32 streamId, |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 209 | const I420VideoFrame& videoFrame, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 210 | const WebRtc_UWord32 timeout); |
| 211 | |
| 212 | virtual WebRtc_Word32 MirrorRenderStream(const int renderId, |
| 213 | const bool enable, |
| 214 | const bool mirrorXAxis, |
| 215 | const bool mirrorYAxis); |
| 216 | |
| 217 | private: |
| 218 | WebRtc_Word32 _id; |
| 219 | CriticalSectionWrapper& _moduleCrit; |
| 220 | void* _ptrWindow; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 221 | bool _fullScreen; |
| 222 | |
| 223 | IVideoRender* _ptrRenderer; |
| 224 | MapWrapper& _streamRenderMap; |
| 225 | }; |
| 226 | |
| 227 | } //namespace webrtc |
| 228 | |
| 229 | #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_ |