Argus Camera Sample
Argus Camera Sample
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
renderer
Composer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* * Neither the name of NVIDIA CORPORATION nor the names of its
13
* contributors may be used to endorse or promote products derived
14
* from this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#ifndef COMPOSER_H
30
#define COMPOSER_H
31
32
#include "EGLGlobal.h"
33
34
#include <list>
35
36
#include "Window.h"
37
#include "Thread.h"
38
#include "
Mutex.h
"
39
40
#include "GLContext.h"
41
42
namespace
ArgusSamples
43
{
44
45
class
StreamConsumer;
46
47
/**
48
* The composer is used to render multiple EGL streams into the windows. The streams are arranged
49
* into a regular grid.
50
*/
51
class
Composer
:
public
Thread,
public
Window::IResizeObserver
52
{
53
public
:
54
/**
55
* Get the composer instance.
56
*/
57
static
Composer
&
getInstance
();
58
59
/**
60
* Shutdown, free all resources
61
*/
62
bool
shutdown
();
63
64
/**
65
* Bind an EGL stream. A bound and active stream is rendered. Newly bound streams are inactive.
66
*
67
* @param eglStream [in]
68
*/
69
bool
bindStream
(EGLStreamKHR eglStream);
70
71
/**
72
* Unbind a bound EGL stream.
73
*
74
* @param eglStream [in]
75
*/
76
bool
unbindStream
(EGLStreamKHR eglStream);
77
78
/**
79
* Set the active state of the stream, only active streams are rendered
80
*
81
* @param eglStream [in]
82
* @param active [in]
83
*/
84
bool
setStreamActive
(EGLStreamKHR eglStream,
bool
active);
85
86
/**
87
* Set the stream aspect ratio
88
*
89
* @param eglStream [in]
90
* @param aspectRatio [in] aspect ration of the images transported by the stream
91
*/
92
bool
setStreamAspectRatio
(EGLStreamKHR eglStream,
float
aspectRatio);
93
94
/**
95
* Get the EGL display
96
*/
97
EGLDisplay
getEGLDisplay
()
98
{
99
if
(
initialize
())
100
return
m_display
.get();
101
102
return
EGL_NO_DISPLAY;
103
}
104
105
private
:
106
Composer
();
107
~Composer
();
108
109
// this is a singleton, hide copy constructor etc.
110
Composer
(
const
Composer
&);
111
Composer
&
operator=
(
const
Composer
&);
112
113
bool
initialize
();
114
115
/** @name Thread methods */
116
/**@{*/
117
virtual
bool
threadInitialize
();
118
virtual
bool
threadExecute
();
119
virtual
bool
threadShutdown
();
120
/**@}*/
121
122
/** @name IResizeObserver methods */
123
/**@{*/
124
virtual
bool
onResize
(uint32_t width, uint32_t height);
125
/**@}*/
126
127
bool
renderStreams
(uint32_t activeStreams);
128
129
bool
m_initialized
;
///< set if initialized
130
131
EGLDisplayHolder
m_display
;
///< EGL display
132
133
GLContext
m_context
;
///< GL context
134
uint32_t
m_program
;
///< program to render streams
135
uint32_t
m_vbo
;
///< vertex buffer object
136
uint32_t
m_windowWidth
;
///< window width
137
uint32_t
m_windowHeight
;
///< window height
138
float
m_windowAspectRatio
;
///< window aspect ratio
139
140
Mutex
m_mutex
;
///< to protect access to the stream array
141
142
/**
143
* Each bound EGL stream has a stream consumer and can be active or inactive.
144
*/
145
class
Stream
146
{
147
public
:
148
explicit
Stream
(
StreamConsumer
*consumer)
149
:
m_consumer
(consumer)
150
,
m_active
(false)
151
,
m_shutdown
(false)
152
{
153
}
154
155
StreamConsumer
*
m_consumer
;
///< the stream consumer
156
bool
m_active
;
///< if set then the stream is active and rendered
157
bool
m_shutdown
;
///< shutdown and remove the stream
158
};
159
160
typedef
std::list<Stream>
StreamList
;
///< a list of streams
161
StreamList
m_streams
;
///< the list of composed streams
162
};
163
164
};
// namespace ArgusSamples
165
166
#endif // COMPOSER_H
Generated on Mon Aug 7 2017 10:33:32 for Argus Camera Sample by
1.8.1