@@ -49,7 +49,7 @@ namespace extensions {
49
49
void OnSourceThumbnailChanged (DesktopMediaList* list, int index) override ;
50
50
51
51
bool started_;
52
- std::unique_ptr<DesktopMediaList> media_list_;
52
+ std::vector<std:: unique_ptr<DesktopMediaList> > media_list_;
53
53
54
54
DISALLOW_COPY_AND_ASSIGN (NwDesktopCaptureMonitor);
55
55
};
@@ -191,8 +191,7 @@ namespace extensions {
191
191
}
192
192
193
193
NwDesktopCaptureMonitor::NwDesktopCaptureMonitor ()
194
- : started_(false )
195
- , media_list_(nullptr ) {
194
+ : started_(false ) {
196
195
}
197
196
198
197
void NwDesktopCaptureMonitor::Start (bool screens, bool windows) {
@@ -205,17 +204,30 @@ namespace extensions {
205
204
webrtc::DesktopCaptureOptions options = webrtc::DesktopCaptureOptions::CreateDefault ();
206
205
options.set_disable_effects (false );
207
206
208
- if (screens)
209
- media_list_.reset (new NativeDesktopMediaList (content::DesktopMediaID::TYPE_SCREEN, webrtc::DesktopCapturer::CreateScreenCapturer (options)));
210
- else if (windows)
211
- media_list_.reset (new NativeDesktopMediaList (content::DesktopMediaID::TYPE_WINDOW, webrtc::DesktopCapturer::CreateWindowCapturer (options)));
207
+ if (screens) {
208
+ std::unique_ptr<DesktopMediaList> screen_media_list =
209
+ base::MakeUnique<NativeDesktopMediaList>(
210
+ content::DesktopMediaID::TYPE_SCREEN,
211
+ webrtc::DesktopCapturer::CreateScreenCapturer (options));
212
+ media_list_.push_back (std::move (screen_media_list));
213
+ }
214
+
215
+ if (windows) {
216
+ std::unique_ptr<DesktopMediaList> window_media_list =
217
+ base::MakeUnique<NativeDesktopMediaList>(
218
+ content::DesktopMediaID::TYPE_WINDOW,
219
+ webrtc::DesktopCapturer::CreateWindowCapturer (options));
220
+ media_list_.push_back (std::move (window_media_list));
221
+ }
212
222
213
- media_list_->StartUpdating (this );
223
+ for (auto & media_list : media_list_) {
224
+ media_list->StartUpdating (this );
225
+ }
214
226
}
215
227
216
228
void NwDesktopCaptureMonitor::Stop () {
217
229
started_ = false ;
218
- media_list_.reset ();
230
+ media_list_.clear ();
219
231
}
220
232
221
233
bool NwDesktopCaptureMonitor::IsStarted () {
@@ -243,8 +255,8 @@ namespace extensions {
243
255
}
244
256
245
257
void NwDesktopCaptureMonitor::OnSourceAdded (DesktopMediaList* list, int index) {
246
- DesktopMediaList::Source src = media_list_ ->GetSource (index);
247
-
258
+ DesktopMediaList::Source src = list ->GetSource (index);
259
+
248
260
std::string type;
249
261
switch (src.id .type ) {
250
262
case content::DesktopMediaID::TYPE_WINDOW:
@@ -283,19 +295,19 @@ void NwDesktopCaptureMonitor::OnSourceRemoved(DesktopMediaList* list, int index)
283
295
}
284
296
285
297
void NwDesktopCaptureMonitor::OnSourceMoved (DesktopMediaList* list, int old_index, int new_index) {
286
- DesktopMediaList::Source src = media_list_ ->GetSource (new_index);
298
+ DesktopMediaList::Source src = list ->GetSource (new_index);
287
299
std::unique_ptr<base::ListValue> args = nwapi::nw__screen::OnSourceOrderChanged::Create (
288
300
src.id .ToString (),
289
301
new_index,
290
302
old_index);
291
303
DispatchEvent (
292
304
events::HistogramValue::UNKNOWN,
293
305
nwapi::nw__screen::OnSourceOrderChanged::kEventName ,
294
- std::move (args));
306
+ std::move (args));
295
307
}
296
308
297
309
void NwDesktopCaptureMonitor::OnSourceNameChanged (DesktopMediaList* list, int index) {
298
- DesktopMediaList::Source src = media_list_ ->GetSource (index);
310
+ DesktopMediaList::Source src = list ->GetSource (index);
299
311
std::unique_ptr<base::ListValue> args = nwapi::nw__screen::OnSourceNameChanged::Create (
300
312
src.id .ToString (),
301
313
base::UTF16ToUTF8 (src.name ));
@@ -308,7 +320,7 @@ void NwDesktopCaptureMonitor::OnSourceNameChanged(DesktopMediaList* list, int in
308
320
void NwDesktopCaptureMonitor::OnSourceThumbnailChanged (DesktopMediaList* list, int index) {
309
321
std::string base64;
310
322
311
- DesktopMediaList::Source src = media_list_ ->GetSource (index);
323
+ DesktopMediaList::Source src = list ->GetSource (index);
312
324
SkBitmap bitmap = src.thumbnail .GetRepresentation (1 ).sk_bitmap ();
313
325
std::vector<unsigned char > data;
314
326
bool success = gfx::PNGCodec::EncodeBGRASkBitmap (bitmap, false , &data);
0 commit comments