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 "webrtc/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 ChangeUniqueId(const int32_t id)44 virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE { 45 return 0; 46 } 47 TimeUntilNextProcess()48 virtual int32_t TimeUntilNextProcess() OVERRIDE { return 0; } 49 Process()50 virtual int32_t Process() OVERRIDE { return 0; } 51 Window()52 virtual void* Window() OVERRIDE { 53 rtc::CritScope cs(&render_critical_); 54 return window_; 55 } 56 ChangeWindow(void * window)57 virtual int32_t ChangeWindow(void* window) OVERRIDE { 58 rtc::CritScope cs(&render_critical_); 59 window_ = window; 60 return 0; 61 } 62 63 virtual webrtc::VideoRenderCallback* AddIncomingRenderStream( 64 const uint32_t stream_id, 65 const uint32_t zOrder, 66 const float left, const float top, 67 const float right, const float bottom) OVERRIDE; 68 69 virtual int32_t DeleteIncomingRenderStream(const uint32_t stream_id) OVERRIDE; 70 71 virtual int32_t AddExternalRenderCallback( 72 const uint32_t stream_id, 73 webrtc::VideoRenderCallback* render_object) OVERRIDE; 74 GetIncomingRenderStreamProperties(const uint32_t stream_id,uint32_t & zOrder,float & left,float & top,float & right,float & bottom)75 virtual int32_t GetIncomingRenderStreamProperties( 76 const uint32_t stream_id, 77 uint32_t& zOrder, 78 float& left, float& top, 79 float& right, float& bottom) const OVERRIDE { 80 return -1; 81 } 82 GetIncomingFrameRate(const uint32_t stream_id)83 virtual uint32_t GetIncomingFrameRate(const uint32_t stream_id) OVERRIDE { 84 return 0; 85 } 86 GetNumIncomingRenderStreams()87 virtual uint32_t GetNumIncomingRenderStreams() const OVERRIDE { 88 return static_cast<uint32_t>(stream_render_map_.size()); 89 } 90 91 virtual bool HasIncomingRenderStream(const uint32_t stream_id) const OVERRIDE; 92 RegisterRawFrameCallback(const uint32_t stream_id,webrtc::VideoRenderCallback * callback_obj)93 virtual int32_t RegisterRawFrameCallback( 94 const uint32_t stream_id, 95 webrtc::VideoRenderCallback* callback_obj) OVERRIDE { 96 return -1; 97 } 98 GetLastRenderedFrame(const uint32_t stream_id,webrtc::I420VideoFrame & frame)99 virtual int32_t GetLastRenderedFrame( 100 const uint32_t stream_id, 101 webrtc::I420VideoFrame &frame) const OVERRIDE { 102 return -1; 103 } 104 105 virtual int32_t StartRender(const uint32_t stream_id) OVERRIDE; 106 107 virtual int32_t StopRender(const uint32_t stream_id) OVERRIDE; 108 ResetRender()109 virtual int32_t ResetRender() OVERRIDE { return 0; } 110 111 virtual webrtc::RawVideoType PreferredVideoType() const OVERRIDE; 112 IsFullScreen()113 virtual bool IsFullScreen() OVERRIDE { return false; } 114 GetScreenResolution(uint32_t & screenWidth,uint32_t & screenHeight)115 virtual int32_t GetScreenResolution(uint32_t& screenWidth, 116 uint32_t& screenHeight) const OVERRIDE { 117 return -1; 118 } 119 RenderFrameRate(const uint32_t stream_id)120 virtual uint32_t RenderFrameRate(const uint32_t stream_id) OVERRIDE { 121 return 0; 122 } 123 SetStreamCropping(const uint32_t stream_id,const float left,const float top,const float right,const float bottom)124 virtual int32_t SetStreamCropping( 125 const uint32_t stream_id, 126 const float left, const float top, 127 const float right, 128 const float bottom) OVERRIDE { 129 return -1; 130 } 131 SetExpectedRenderDelay(uint32_t stream_id,int32_t delay_ms)132 virtual int32_t SetExpectedRenderDelay(uint32_t stream_id, 133 int32_t delay_ms) OVERRIDE { 134 return -1; 135 } 136 ConfigureRenderer(const uint32_t stream_id,const unsigned int zOrder,const float left,const float top,const float right,const float bottom)137 virtual int32_t ConfigureRenderer( 138 const uint32_t stream_id, 139 const unsigned int zOrder, 140 const float left, const float top, 141 const float right, 142 const float bottom) OVERRIDE { 143 return -1; 144 } 145 SetTransparentBackground(const bool enable)146 virtual int32_t SetTransparentBackground(const bool enable) OVERRIDE { 147 return -1; 148 } 149 FullScreenRender(void * window,const bool enable)150 virtual int32_t FullScreenRender(void* window, const bool enable) OVERRIDE { 151 return -1; 152 } 153 SetBitmap(const void * bitMap,const uint8_t pictureId,const void * colorKey,const float left,const float top,const float right,const float bottom)154 virtual int32_t SetBitmap(const void* bitMap, 155 const uint8_t pictureId, const void* colorKey, 156 const float left, const float top, 157 const float right, const float bottom) OVERRIDE { 158 return -1; 159 } 160 SetText(const uint8_t textId,const uint8_t * text,const int32_t textLength,const uint32_t textColorRef,const uint32_t backgroundColorRef,const float left,const float top,const float right,const float bottom)161 virtual int32_t SetText(const uint8_t textId, 162 const uint8_t* text, 163 const int32_t textLength, 164 const uint32_t textColorRef, 165 const uint32_t backgroundColorRef, 166 const float left, const float top, 167 const float right, const float bottom) OVERRIDE { 168 return -1; 169 } 170 SetStartImage(const uint32_t stream_id,const webrtc::I420VideoFrame & videoFrame)171 virtual int32_t SetStartImage( 172 const uint32_t stream_id, 173 const webrtc::I420VideoFrame& videoFrame) OVERRIDE { 174 return -1; 175 } 176 SetTimeoutImage(const uint32_t stream_id,const webrtc::I420VideoFrame & videoFrame,const uint32_t timeout)177 virtual int32_t SetTimeoutImage( 178 const uint32_t stream_id, 179 const webrtc::I420VideoFrame& videoFrame, 180 const uint32_t timeout) OVERRIDE { 181 return -1; 182 } 183 MirrorRenderStream(const int renderId,const bool enable,const bool mirrorXAxis,const bool mirrorYAxis)184 virtual int32_t MirrorRenderStream(const int renderId, 185 const bool enable, 186 const bool mirrorXAxis, 187 const bool mirrorYAxis) OVERRIDE { 188 return -1; 189 } 190 191 private: 192 typedef std::map<uint32_t, PassthroughStream*> StreamMap; 193 194 PassthroughStream* FindStream(const uint32_t stream_id) const; 195 196 void* window_; 197 StreamMap stream_render_map_; 198 rtc::CriticalSection render_critical_; 199 }; 200 } // namespace cricket 201 202 #endif // TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_ 203