@@ -39,13 +39,15 @@ VideoCaptureSourceSelector::VideoCaptureSourceSelector(QWidget *parent,
39
39
obs_data_t *videoData)
40
40
: QWidget(parent),
41
41
_sourceName (sourceName),
42
- _noneSelected(true )
42
+ _noneSelected(true ),
43
+ _deactivated(false )
43
44
{
44
45
std::string imageBaseDir =
45
46
obs_get_module_data_path (obs_current_module ());
46
47
imageBaseDir += " /images/" ;
47
48
48
49
setFixedWidth (258 );
50
+ _loading = true ;
49
51
50
52
auto layout = new QVBoxLayout (this );
51
53
layout->setContentsMargins (0 , 0 , 0 , 16 );
@@ -90,22 +92,17 @@ VideoCaptureSourceSelector::VideoCaptureSourceSelector(QWidget *parent,
90
92
91
93
connect (_videoSources, &QComboBox::currentIndexChanged, this ,
92
94
[this ](int index) {
95
+ _loading = true ;
93
96
if (index > 0 ) {
94
97
auto vSettings = obs_data_create ();
95
98
std::string id = _videoSourceIds[index];
96
99
obs_data_set_string (vSettings,
97
- " video_device_id" ,
98
- id.c_str ());
99
- obs_source_reset_settings (_videoCaptureSource,
100
- vSettings);
100
+ " video_device_id" ,
101
+ id.c_str ());
102
+ _changeSource (vSettings);
101
103
obs_data_release (vSettings);
102
- this ->_noneSelected = false ;
103
- this ->_videoPreview ->show ();
104
- this ->_blank ->hide ();
105
104
} else {
106
- this ->_noneSelected = true ;
107
- this ->_videoPreview ->hide ();
108
- this ->_blank ->show ();
105
+ _changeSource (nullptr );
109
106
}
110
107
});
111
108
}
@@ -163,11 +160,44 @@ void VideoCaptureSourceSelector::_setupTempSource(obs_data_t *videoData)
163
160
// obs_data_release(videoSettings);
164
161
}
165
162
163
+ void VideoCaptureSourceSelector::_changeSource (obs_data_t *vSettings)
164
+ {
165
+ if (vSettings != nullptr ) {
166
+ blog (LOG_INFO, " _changeSource called." );
167
+ if (_videoCaptureSource) {
168
+ obs_source_t * tmp = _videoCaptureSource;
169
+ _videoCaptureSource = nullptr ;
170
+ obs_source_release (tmp);
171
+ }
172
+
173
+ const char * videoSourceId = " dshow_input" ;
174
+ const char * vId = obs_get_latest_input_type_id (videoSourceId);
175
+ _videoCaptureSource = obs_source_create_private (
176
+ vId, " elgato-cloud-video-config" , vSettings);
177
+
178
+ this ->_noneSelected = false ;
179
+ this ->_videoPreview ->show ();
180
+ this ->_blank ->hide ();
181
+ } else {
182
+ this ->_noneSelected = true ;
183
+ this ->_videoPreview ->hide ();
184
+ this ->_blank ->show ();
185
+ if (_videoCaptureSource) {
186
+ obs_source_t * tmp = _videoCaptureSource;
187
+ _videoCaptureSource = nullptr ;
188
+ obs_source_release (tmp);
189
+ }
190
+ }
191
+
192
+ }
193
+
166
194
void VideoCaptureSourceSelector::DrawVideoPreview (void *data, uint32_t cx,
167
195
uint32_t cy)
168
196
{
169
197
auto config = static_cast <VideoCaptureSourceSelector *>(data);
170
-
198
+ if (config->_loading ) {
199
+ config->_loading = false ;
200
+ }
171
201
if (!config->_videoCaptureSource )
172
202
return ;
173
203
0 commit comments