henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_ |
| 29 | #define TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_ |
| 30 | |
| 31 | #include <map> |
| 32 | |
| 33 | #include "talk/base/criticalsection.h" |
| 34 | #include "webrtc/modules/video_render/include/video_render.h" |
| 35 | |
| 36 | namespace cricket { |
| 37 | class PassthroughStream; |
| 38 | |
| 39 | class WebRtcPassthroughRender : public webrtc::VideoRender { |
| 40 | public: |
| 41 | WebRtcPassthroughRender(); |
| 42 | virtual ~WebRtcPassthroughRender(); |
| 43 | |
| 44 | virtual int32_t Version(int8_t* version, |
| 45 | uint32_t& remainingBufferInBytes, |
| 46 | uint32_t& position) const { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | virtual int32_t ChangeUniqueId(const int32_t id) { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | virtual int32_t TimeUntilNextProcess() { return 0; } |
| 55 | |
| 56 | virtual int32_t Process() { return 0; } |
| 57 | |
| 58 | virtual void* Window() { |
| 59 | talk_base::CritScope cs(&render_critical_); |
| 60 | return window_; |
| 61 | } |
| 62 | |
| 63 | virtual int32_t ChangeWindow(void* window) { |
| 64 | talk_base::CritScope cs(&render_critical_); |
| 65 | window_ = window; |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | virtual webrtc::VideoRenderCallback* AddIncomingRenderStream( |
| 70 | const uint32_t stream_id, |
| 71 | const uint32_t zOrder, |
| 72 | const float left, const float top, |
| 73 | const float right, const float bottom); |
| 74 | |
| 75 | virtual int32_t DeleteIncomingRenderStream(const uint32_t stream_id); |
| 76 | |
| 77 | virtual int32_t AddExternalRenderCallback( |
| 78 | const uint32_t stream_id, |
| 79 | webrtc::VideoRenderCallback* render_object); |
| 80 | |
| 81 | virtual int32_t GetIncomingRenderStreamProperties( |
| 82 | const uint32_t stream_id, |
| 83 | uint32_t& zOrder, |
| 84 | float& left, float& top, |
| 85 | float& right, float& bottom) const { |
| 86 | return -1; |
| 87 | } |
| 88 | |
| 89 | virtual uint32_t GetIncomingFrameRate( |
| 90 | const uint32_t stream_id) { |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | virtual uint32_t GetNumIncomingRenderStreams() const { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 95 | return static_cast<uint32_t>(stream_render_map_.size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | virtual bool HasIncomingRenderStream(const uint32_t stream_id) const; |
| 99 | |
| 100 | virtual int32_t RegisterRawFrameCallback( |
| 101 | const uint32_t stream_id, |
| 102 | webrtc::VideoRenderCallback* callback_obj) { |
| 103 | return -1; |
| 104 | } |
| 105 | |
| 106 | virtual int32_t GetLastRenderedFrame( |
| 107 | const uint32_t stream_id, |
| 108 | webrtc::I420VideoFrame &frame) const { |
| 109 | return -1; |
| 110 | } |
| 111 | |
| 112 | virtual int32_t StartRender( |
| 113 | const uint32_t stream_id); |
| 114 | |
| 115 | virtual int32_t StopRender( |
| 116 | const uint32_t stream_id); |
| 117 | |
| 118 | virtual int32_t ResetRender() { return 0; } |
| 119 | |
| 120 | virtual webrtc::RawVideoType PreferredVideoType() const; |
| 121 | |
| 122 | virtual bool IsFullScreen() { return false; } |
| 123 | |
| 124 | virtual int32_t GetScreenResolution(uint32_t& screenWidth, |
| 125 | uint32_t& screenHeight) const { |
| 126 | return -1; |
| 127 | } |
| 128 | |
| 129 | virtual uint32_t RenderFrameRate( |
| 130 | const uint32_t stream_id) { |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | virtual int32_t SetStreamCropping( |
| 135 | const uint32_t stream_id, |
| 136 | const float left, const float top, |
| 137 | const float right, |
| 138 | const float bottom) { |
| 139 | return -1; |
| 140 | } |
| 141 | |
| 142 | virtual int32_t SetExpectedRenderDelay(uint32_t stream_id, int32_t delay_ms) { |
| 143 | return -1; |
| 144 | } |
| 145 | |
| 146 | virtual int32_t ConfigureRenderer( |
| 147 | const uint32_t stream_id, |
| 148 | const unsigned int zOrder, |
| 149 | const float left, const float top, |
| 150 | const float right, |
| 151 | const float bottom) { |
| 152 | return -1; |
| 153 | } |
| 154 | |
| 155 | virtual int32_t SetTransparentBackground(const bool enable) { |
| 156 | return -1; |
| 157 | } |
| 158 | |
| 159 | virtual int32_t FullScreenRender(void* window, const bool enable) { |
| 160 | return -1; |
| 161 | } |
| 162 | |
| 163 | virtual int32_t SetBitmap(const void* bitMap, |
| 164 | const uint8_t pictureId, const void* colorKey, |
| 165 | const float left, const float top, |
| 166 | const float right, const float bottom) { |
| 167 | return -1; |
| 168 | } |
| 169 | |
| 170 | virtual int32_t SetText(const uint8_t textId, |
| 171 | const uint8_t* text, |
| 172 | const int32_t textLength, |
| 173 | const uint32_t textColorRef, |
| 174 | const uint32_t backgroundColorRef, |
| 175 | const float left, const float top, |
| 176 | const float right, const float bottom) { |
| 177 | return -1; |
| 178 | } |
| 179 | |
| 180 | virtual int32_t SetStartImage( |
| 181 | const uint32_t stream_id, |
| 182 | const webrtc::I420VideoFrame& videoFrame) { |
| 183 | return -1; |
| 184 | } |
| 185 | |
| 186 | virtual int32_t SetTimeoutImage( |
| 187 | const uint32_t stream_id, |
| 188 | const webrtc::I420VideoFrame& videoFrame, |
| 189 | const uint32_t timeout) { |
| 190 | return -1; |
| 191 | } |
| 192 | |
| 193 | virtual int32_t MirrorRenderStream(const int renderId, |
| 194 | const bool enable, |
| 195 | const bool mirrorXAxis, |
| 196 | const bool mirrorYAxis) { |
| 197 | return -1; |
| 198 | } |
| 199 | |
| 200 | private: |
| 201 | typedef std::map<uint32_t, PassthroughStream*> StreamMap; |
| 202 | |
| 203 | PassthroughStream* FindStream(const uint32_t stream_id) const; |
| 204 | |
| 205 | void* window_; |
| 206 | StreamMap stream_render_map_; |
| 207 | talk_base::CriticalSection render_critical_; |
| 208 | }; |
| 209 | } // namespace cricket |
| 210 | |
| 211 | #endif // TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_ |