Newer
Older

Lyubomir Marinov
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jitsi.impl.neomedia;
import java.awt.*;
import org.jitsi.impl.neomedia.device.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.protocol.*;
import org.jitsi.util.*;
/**
* Implements {@link QualityControl} for the purposes of
* {@link VideoMediaStreamImpl}.
*
* @author Damian Minkov
* @author Lyubomir Marinov
*/
class QualityControlImpl
implements QualityControl
{
/**
* The <tt>Logger</tt> used by the <tt>QualityControlImpl</tt> class and its
* instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(QualityControlImpl.class);
/**
* This is the local settings from the configuration panel.
*/
private QualityPreset localSettingsPreset;
/**
* The maximum values for resolution, framerate, etc.
*/
private QualityPreset maxPreset;
/**
* The current used preset.
*/
private QualityPreset preset;
/**
* Sets the preset.
*
* @param preset the desired video settings
* @throws OperationFailedException
*/
private void setRemoteReceivePreset(QualityPreset preset)
throws OperationFailedException
{
if (preset.compareTo(getPreferredSendPreset()) > 0)
this.preset = getPreferredSendPreset();
else
{
this.preset = preset;
Dimension resolution;
if (logger.isInfoEnabled()
&& (preset != null)
&& ((resolution = preset.getResolution()) != null))
{
logger.info(
"video send resolution: "
+ resolution.width
+ "x"
+ resolution.height);
}
}
}
/**
* The current preset.
*
* @return the current preset
*/
public QualityPreset getRemoteReceivePreset()
{
return preset;
}
/**
* The minimum resolution values for remote part.
*
* @return minimum resolution values for remote part.
*/
public QualityPreset getRemoteSendMinPreset()
{
/* We do not support such a value at the time of this writing. */
return null;
}
/**
* The max resolution values for remote part.
*
* @return max resolution values for remote part.
*/
public QualityPreset getRemoteSendMaxPreset()
{
return maxPreset;
}
/**
* Does nothing specific locally.
*
* @param preset the max preset
* @throws OperationFailedException not thrown.
*/
public void setPreferredRemoteSendMaxPreset(QualityPreset preset)
throws OperationFailedException
{
setRemoteSendMaxPreset(preset);
}
/**
* Changes remote send preset, the one we will receive.
*
* @param preset
*/
public void setRemoteSendMaxPreset(QualityPreset preset)
{
this.maxPreset = preset;
}
/**
* Gets the local setting of capture.
*
* @return the local setting of capture
*/
private QualityPreset getPreferredSendPreset()
{
if(localSettingsPreset == null)
{
DeviceConfiguration devCfg
= NeomediaServiceUtils
.getMediaServiceImpl()
.getDeviceConfiguration();
localSettingsPreset
= new QualityPreset(
devCfg.getVideoSize(),
devCfg.getFrameRate());
}
return localSettingsPreset;
}
/**
* Sets maximum resolution.
*
* @param res
*/
public void setRemoteReceiveResolution(Dimension res)
{
try
{
setRemoteReceivePreset(new QualityPreset(res));
}
catch(OperationFailedException ofe)
{
logger.warn("Failed to set remote receive resolution", ofe);
}
}
}