niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
mflodman@webrtc.org | e06ca3c | 2012-06-29 13:20:14 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
andrew@webrtc.org | 9841d92 | 2012-10-31 05:22:11 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/video_render/include/video_render_defines.h" |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 15 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 16 | #include "webrtc/video_engine/include/vie_render.h" |
| 17 | #include "webrtc/video_engine/vie_frame_provider_base.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | class VideoRender; |
| 22 | class VideoRenderCallback; |
| 23 | class ViERenderManager; |
| 24 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 25 | class ViEExternalRendererImpl : public VideoRenderCallback { |
| 26 | public: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | ViEExternalRendererImpl(); |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 28 | virtual ~ViEExternalRendererImpl() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 30 | int SetViEExternalRenderer(ExternalRenderer* external_renderer, |
| 31 | RawVideoType video_input_format); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 33 | // Implements VideoRenderCallback. |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 34 | virtual int32_t RenderFrame(const uint32_t stream_id, |
| 35 | I420VideoFrame& video_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 37 | private: |
wu@webrtc.org | 9dba525 | 2013-08-05 20:36:57 +0000 | [diff] [blame] | 38 | void NotifyFrameSizeChange(const uint32_t stream_id, |
| 39 | I420VideoFrame& video_frame); |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 40 | ExternalRenderer* external_renderer_; |
| 41 | RawVideoType external_renderer_format_; |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 42 | int external_renderer_width_; |
| 43 | int external_renderer_height_; |
| 44 | // Converted_frame_ in color format specified by render_format_. |
mflodman@webrtc.org | 7b3f3b1 | 2012-01-17 12:12:42 +0000 | [diff] [blame] | 45 | scoped_ptr<VideoFrame> converted_frame_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 48 | class ViERenderer: public ViEFrameCallback { |
| 49 | public: |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 50 | static ViERenderer* CreateViERenderer(const int32_t render_id, |
| 51 | const int32_t engine_id, |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 52 | VideoRender& render_module, |
| 53 | ViERenderManager& render_manager, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 54 | const uint32_t z_order, |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 55 | const float left, |
| 56 | const float top, |
| 57 | const float right, |
| 58 | const float bottom); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | ~ViERenderer(void); |
| 60 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 61 | int32_t StartRender(); |
| 62 | int32_t StopRender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 64 | int32_t GetLastRenderedFrame(const int32_t renderID, |
| 65 | I420VideoFrame& video_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
mflodman@webrtc.org | f4f2145 | 2012-09-28 11:27:35 +0000 | [diff] [blame] | 67 | int SetExpectedRenderDelay(int render_delay); |
| 68 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 69 | int32_t ConfigureRenderer(const unsigned int z_order, |
| 70 | const float left, |
| 71 | const float top, |
| 72 | const float right, |
| 73 | const float bottom); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
| 75 | VideoRender& RenderModule(); |
| 76 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 77 | int32_t EnableMirroring(const int32_t render_id, |
| 78 | const bool enable, |
| 79 | const bool mirror_xaxis, |
| 80 | const bool mirror_yaxis); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 82 | int32_t SetTimeoutImage(const I420VideoFrame& timeout_image, |
| 83 | const int32_t timeout_value); |
| 84 | int32_t SetRenderStartImage(const I420VideoFrame& start_image); |
| 85 | int32_t SetExternalRenderer(const int32_t render_id, |
| 86 | RawVideoType video_input_format, |
| 87 | ExternalRenderer* external_renderer); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
pbos@webrtc.org | d29d4e9 | 2013-11-20 13:19:54 +0000 | [diff] [blame] | 89 | int32_t SetVideoRenderCallback(const int32_t render_id, |
| 90 | VideoRenderCallback* callback); |
| 91 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 92 | private: |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 93 | ViERenderer(const int32_t render_id, const int32_t engine_id, |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 94 | VideoRender& render_module, |
| 95 | ViERenderManager& render_manager); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 97 | int32_t Init(const uint32_t z_order, |
| 98 | const float left, |
| 99 | const float top, |
| 100 | const float right, |
| 101 | const float bottom); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | |
| 103 | // Implement ViEFrameCallback |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 104 | virtual void DeliverFrame(int id, |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 105 | I420VideoFrame* video_frame, |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 106 | int num_csrcs = 0, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 107 | const uint32_t CSRC[kRtpCsrcSize] = NULL); |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 108 | virtual void DelayChanged(int id, int frame_delay); |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 109 | virtual int GetPreferedFrameSettings(int* width, |
| 110 | int* height, |
| 111 | int* frame_rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | virtual void ProviderDestroyed(int id); |
| 113 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 114 | uint32_t render_id_; |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 115 | VideoRender& render_module_; |
| 116 | ViERenderManager& render_manager_; |
| 117 | VideoRenderCallback* render_callback_; |
| 118 | ViEExternalRendererImpl* incoming_external_callback_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
mflodman@webrtc.org | 5885a41 | 2011-12-09 05:52:32 +0000 | [diff] [blame] | 121 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | |
mflodman@webrtc.org | e06ca3c | 2012-06-29 13:20:14 +0000 | [diff] [blame] | 123 | #endif // WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ |