blob: 24e59266bcd69fa887510b9b4996c1a4a4295063 [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
42 int64_t render_time) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000043
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000044 protected:
45 virtual ~ExternalRenderer() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000046};
47
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000048class WEBRTC_DLLEXPORT ViERender {
49 public:
50 // Factory for the ViERender sub‐API and increases an internal reference
51 // counter if successful. Returns NULL if the API is not supported or if
52 // construction fails.
53 static ViERender* GetInterface(VideoEngine* video_engine);
niklase@google.com470e71d2011-07-07 08:21:25 +000054
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000055 // Releases the ViERender sub-API and decreases an internal reference
56 // counter. Returns the new reference count. This value should be zero
57 // for all sub-API:s before the VideoEngine object can be safely deleted.
58 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000060 // Registers render module.
61 virtual int RegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000062
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000063 // Deregisters render module.
64 virtual int DeRegisterVideoRenderModule(VideoRender& render_module) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000065
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000066 // Sets the render destination for a given render ID.
67 virtual int AddRenderer(const int render_id,
68 void* window,
69 const unsigned int z_order,
70 const float left,
71 const float top,
72 const float right,
73 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000074
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000075 // Removes the renderer for a stream.
76 virtual int RemoveRenderer(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000077
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000078 // Starts rendering a render stream.
79 virtual int StartRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000081 // Stops rendering a render stream.
82 virtual int StopRender(const int render_id) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
mflodman@webrtc.orgf4f21452012-09-28 11:27:35 +000084 // Set expected render time needed by graphics card or external renderer, i.e.
85 // the number of ms a frame will be sent to rendering before the actual render
86 // time.
87 virtual int SetExpectedRenderDelay(int render_id, int render_delay) = 0;
88
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000089 // Configures an already added render stream.
90 virtual int ConfigureRender(int render_id,
91 const unsigned int z_order,
92 const float left,
93 const float top,
94 const float right,
95 const float bottom) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000096
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000097 // This function mirrors the rendered stream left and right or up and down.
98 virtual int MirrorRenderStream(const int render_id,
99 const bool enable,
100 const bool mirror_xaxis,
101 const bool mirror_yaxis) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000103 // External render.
104 virtual int AddRenderer(const int render_id,
105 RawVideoType video_input_format,
106 ExternalRenderer* renderer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000107
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000108 protected:
109 ViERender() {}
110 virtual ~ViERender() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000111};
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000112
113} // namespace webrtc
114
115#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_