1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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 
11 #ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_EXTERNAL_VIDEO_RENDER_EXTERNAL_IMPL_H_
12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_EXTERNAL_VIDEO_RENDER_EXTERNAL_IMPL_H_
13 
14 #include "webrtc/modules/include/module_common_types.h"
15 #include "webrtc/modules/video_render/i_video_render.h"
16 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
17 
18 namespace webrtc {
19 
20 // Class definitions
21 class VideoRenderExternalImpl: IVideoRender, public VideoRenderCallback
22 {
23 public:
24     /*
25      *   Constructor/destructor
26      */
27 
28     VideoRenderExternalImpl(const int32_t id,
29                             const VideoRenderType videoRenderType,
30                             void* window, const bool fullscreen);
31 
32     virtual ~VideoRenderExternalImpl();
33 
34     virtual int32_t Init();
35 
36     virtual int32_t ChangeWindow(void* window);
37 
38     /**************************************************************************
39      *
40      *   Incoming Streams
41      *
42      ***************************************************************************/
43 
44     virtual VideoRenderCallback
45             * AddIncomingRenderStream(const uint32_t streamId,
46                                       const uint32_t zOrder,
47                                       const float left, const float top,
48                                       const float right, const float bottom);
49 
50     virtual int32_t
51             DeleteIncomingRenderStream(const uint32_t streamId);
52 
53     virtual int32_t
54             GetIncomingRenderStreamProperties(const uint32_t streamId,
55                                               uint32_t& zOrder,
56                                               float& left, float& top,
57                                               float& right, float& bottom) const;
58 
59     /**************************************************************************
60      *
61      *   Start/Stop
62      *
63      ***************************************************************************/
64 
65     virtual int32_t StartRender();
66 
67     virtual int32_t StopRender();
68 
69     /**************************************************************************
70      *
71      *   Properties
72      *
73      ***************************************************************************/
74 
75     virtual VideoRenderType RenderType();
76 
77     virtual RawVideoType PerferedVideoType();
78 
79     virtual bool FullScreen();
80 
81     virtual int32_t
82             GetGraphicsMemory(uint64_t& totalGraphicsMemory,
83                               uint64_t& availableGraphicsMemory) const;
84 
85     virtual int32_t
86             GetScreenResolution(uint32_t& screenWidth,
87                                 uint32_t& screenHeight) const;
88 
89     virtual uint32_t RenderFrameRate(const uint32_t streamId);
90 
91     virtual int32_t SetStreamCropping(const uint32_t streamId,
92                                       const float left, const float top,
93                                       const float right, const float bottom);
94 
95     virtual int32_t ConfigureRenderer(const uint32_t streamId,
96                                       const unsigned int zOrder,
97                                       const float left, const float top,
98                                       const float right, const float bottom);
99 
100     virtual int32_t SetTransparentBackground(const bool enable);
101 
102     virtual int32_t SetText(const uint8_t textId,
103                             const uint8_t* text,
104                             const int32_t textLength,
105                             const uint32_t textColorRef,
106                             const uint32_t backgroundColorRef,
107                             const float left, const float top,
108                             const float right, const float bottom);
109 
110     virtual int32_t SetBitmap(const void* bitMap,
111                               const uint8_t pictureId,
112                               const void* colorKey, const float left,
113                               const float top, const float right,
114                               const float bottom);
115 
116     // VideoRenderCallback
117     virtual int32_t RenderFrame(const uint32_t streamId,
118                                 const VideoFrame& videoFrame);
119 
120 private:
121     CriticalSectionWrapper& _critSect;
122     bool _fullscreen;
123 };
124 
125 }  // namespace webrtc
126 
127 
128 #endif  // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_EXTERNAL_VIDEO_RENDER_EXTERNAL_IMPL_H_
129