blob: ab61d7aca735df1f5905a919c75ce8c6f3c43500 [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;
pbos@webrtc.orgd29d4e92013-11-20 13:19:54 +000025class VideoRenderCallback;
niklase@google.com470e71d2011-07-07 08:21:25 +000026
27// This class declares an abstract interface to be used for external renderers.
28// The user implemented derived class is registered using AddRenderer().
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +000029class ExternalRenderer {
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000030 public:
31 // This method will be called when the stream to be rendered changes in
32 // resolution or number of streams mixed in the image.
33 virtual int FrameSizeChange(unsigned int width,
34 unsigned int height,
35 unsigned int number_of_streams) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000036
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000037 // This method is called when a new frame should be rendered.
38 virtual int DeliverFrame(unsigned char* buffer,
39 int buffer_size,
wu@webrtc.org69f8be32012-02-16 18:32:02 +000040 // RTP timestamp in 90kHz.
41 uint32_t time_stamp,
42 // Wallclock render time in miliseconds
wu@webrtc.org9dba5252013-08-05 20:36:57 +000043 int64_t render_time,
44 // Handle of the underlying video frame,
45 void* handle) = 0;
46
47 // Returns true if the renderer supports textures. DeliverFrame can be called
48 // with NULL |buffer| and non-NULL |handle|.
49 virtual bool IsTextureSupported() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000051 protected:
52 virtual ~ExternalRenderer() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000053};
54
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +000055class ViERender {
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000056 public:
57 // Factory for the ViERender sub‐API and increases an internal reference
58 // counter if successful. Returns NULL if the API is not supported or if
59 // construction fails.
60 static ViERender* GetInterface(VideoEngine* video_engine);
niklase@google.com470e71d2011-07-07 08:21:25 +000061
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000062 // Releases the ViERender sub-API and decreases an internal reference
63 // counter. Returns the new reference count. This value should be zero
64 // for all sub-API:s before the VideoEngine object can be safely deleted.
65 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000067 // Registers render module.
68 virtual int RegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000069
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000070 // Deregisters render module.
71 virtual int DeRegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000072
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000073 // Sets the render destination for a given render ID.
74 virtual int AddRenderer(const int render_id,
75 void* window,
76 const unsigned int z_order,
77 const float left,
78 const float top,
79 const float right,
80 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000081
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000082 // Removes the renderer for a stream.
83 virtual int RemoveRenderer(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000084
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000085 // Starts rendering a render stream.
86 virtual int StartRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000087
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000088 // Stops rendering a render stream.
89 virtual int StopRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000090
mflodman@webrtc.orgf4f21452012-09-28 11:27:35 +000091 // Set expected render time needed by graphics card or external renderer, i.e.
92 // the number of ms a frame will be sent to rendering before the actual render
93 // time.
94 virtual int SetExpectedRenderDelay(int render_id, int render_delay) = 0;
95
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000096 // Configures an already added render stream.
97 virtual int ConfigureRender(int render_id,
98 const unsigned int z_order,
99 const float left,
100 const float top,
101 const float right,
102 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000104 // This function mirrors the rendered stream left and right or up and down.
105 virtual int MirrorRenderStream(const int render_id,
106 const bool enable,
107 const bool mirror_xaxis,
108 const bool mirror_yaxis) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000110 // External render.
111 virtual int AddRenderer(const int render_id,
112 RawVideoType video_input_format,
113 ExternalRenderer* renderer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000114
pbos@webrtc.orgd29d4e92013-11-20 13:19:54 +0000115 // Propagating VideoRenderCallback down to the VideoRender module for new API.
116 // Contains default-implementation not to break code mocking this interface.
117 // (Ugly, but temporary.)
118 virtual int AddRenderCallback(int render_id, VideoRenderCallback* callback) {
119 return 0;
120 }
121
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000122 protected:
123 ViERender() {}
124 virtual ~ViERender() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000125};
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000126
127} // namespace webrtc
128
129#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_