blob: 48afc1adbbd439e8e60ac33ef20d04dda4ce76bf [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
wu@webrtc.org69f8be32012-02-16 18:32:02 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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// This sub-API supports the following functionalities:
12// - Specify render destinations for incoming video streams, capture devices
13// and files.
14// - Configuring render streams.
15
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000016#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_
17#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000018
pbos@webrtc.orgf5d4cb12013-05-17 13:44:48 +000019#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000021namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
niklase@google.com470e71d2011-07-07 08:21:25 +000023class VideoEngine;
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000024class VideoRender;
niklase@google.com470e71d2011-07-07 08:21:25 +000025
26// This class declares an abstract interface to be used for external renderers.
27// The user implemented derived class is registered using AddRenderer().
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000028class WEBRTC_DLLEXPORT ExternalRenderer {
29 public:
30 // This method will be called when the stream to be rendered changes in
31 // resolution or number of streams mixed in the image.
32 virtual int FrameSizeChange(unsigned int width,
33 unsigned int height,
34 unsigned int number_of_streams) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000036 // This method is called when a new frame should be rendered.
37 virtual int DeliverFrame(unsigned char* buffer,
38 int buffer_size,
wu@webrtc.org69f8be32012-02-16 18:32:02 +000039 // RTP timestamp in 90kHz.
40 uint32_t time_stamp,
41 // Wallclock render time in miliseconds
wu@webrtc.org9dba5252013-08-05 20:36:57 +000042 int64_t render_time,
43 // Handle of the underlying video frame,
44 void* handle) = 0;
45
46 // Returns true if the renderer supports textures. DeliverFrame can be called
47 // with NULL |buffer| and non-NULL |handle|.
48 virtual bool IsTextureSupported() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000049
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000050 protected:
51 virtual ~ExternalRenderer() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000052};
53
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000054class WEBRTC_DLLEXPORT ViERender {
55 public:
56 // Factory for the ViERender sub‐API and increases an internal reference
57 // counter if successful. Returns NULL if the API is not supported or if
58 // construction fails.
59 static ViERender* GetInterface(VideoEngine* video_engine);
niklase@google.com470e71d2011-07-07 08:21:25 +000060
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000061 // Releases the ViERender sub-API and decreases an internal reference
62 // counter. Returns the new reference count. This value should be zero
63 // for all sub-API:s before the VideoEngine object can be safely deleted.
64 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000065
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000066 // Registers render module.
67 virtual int RegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000068
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000069 // Deregisters render module.
70 virtual int DeRegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000071
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000072 // Sets the render destination for a given render ID.
73 virtual int AddRenderer(const int render_id,
74 void* window,
75 const unsigned int z_order,
76 const float left,
77 const float top,
78 const float right,
79 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000081 // Removes the renderer for a stream.
82 virtual int RemoveRenderer(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000084 // Starts rendering a render stream.
85 virtual int StartRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000087 // Stops rendering a render stream.
88 virtual int StopRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
mflodman@webrtc.orgf4f21452012-09-28 11:27:35 +000090 // Set expected render time needed by graphics card or external renderer, i.e.
91 // the number of ms a frame will be sent to rendering before the actual render
92 // time.
93 virtual int SetExpectedRenderDelay(int render_id, int render_delay) = 0;
94
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000095 // Configures an already added render stream.
96 virtual int ConfigureRender(int render_id,
97 const unsigned int z_order,
98 const float left,
99 const float top,
100 const float right,
101 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000103 // This function mirrors the rendered stream left and right or up and down.
104 virtual int MirrorRenderStream(const int render_id,
105 const bool enable,
106 const bool mirror_xaxis,
107 const bool mirror_yaxis) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000109 // External render.
110 virtual int AddRenderer(const int render_id,
111 RawVideoType video_input_format,
112 ExternalRenderer* renderer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000114 protected:
115 ViERender() {}
116 virtual ~ViERender() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000117};
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000118
119} // namespace webrtc
120
121#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_