1- /*
2- * Copyright 2019 Alex Andres
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-
17- #include " media/video/desktop/DesktopCapturer.h"
18-
19- #include " modules/desktop_capture/desktop_capturer.h"
20- #include " modules/desktop_capture/desktop_capture_options.h"
21- #include " modules/desktop_capture/desktop_and_cursor_composer.h"
22-
23- namespace jni
24- {
25- DesktopCapturer::DesktopCapturer (bool screenCapturer) :
26- focusSelectedSource (false )
27- {
28- auto options = webrtc::DesktopCaptureOptions::CreateDefault ();
29- // Enable desktop effects.
30- options.set_disable_effects (false );
31-
32- #if defined(WEBRTC_WIN)
33- options.set_allow_directx_capturer (true );
34- #endif
35-
36- if (screenCapturer) {
37- capturer.reset (new webrtc::DesktopAndCursorComposer (
38- webrtc::DesktopCapturer::CreateScreenCapturer (options),
39- options));
40- }
41- else {
42- capturer = std::make_unique<webrtc::DesktopAndCursorComposer>(
43- webrtc::DesktopCapturer::CreateWindowCapturer (options), options);
44- }
45- }
46-
47- DesktopCapturer::~DesktopCapturer ()
48- {
49- capturer.reset ();
50- }
51-
52- void DesktopCapturer::Start (Callback * callback)
53- {
54- capturer->Start (callback);
55-
56- if (focusSelectedSource) {
57- capturer->FocusOnSelectedSource ();
58- }
59- }
60-
61- void DesktopCapturer::SetSharedMemoryFactory (std::unique_ptr<webrtc::SharedMemoryFactory> factory)
62- {
63- capturer->SetSharedMemoryFactory (std::move (factory));
64- }
65-
66- void DesktopCapturer::CaptureFrame ()
67- {
68- capturer->CaptureFrame ();
69- }
70-
71- void DesktopCapturer::SetExcludedWindow (webrtc::WindowId window)
72- {
73- capturer->SetExcludedWindow (window);
74- }
75-
76- bool DesktopCapturer::GetSourceList (SourceList * sources)
77- {
78- return capturer->GetSourceList (sources);
79- }
80-
81- bool DesktopCapturer::SelectSource (SourceId id)
82- {
83- return capturer->SelectSource (id);
84- }
85-
86- bool DesktopCapturer::FocusOnSelectedSource ()
87- {
88- return capturer->FocusOnSelectedSource ();
89- }
90-
91- void DesktopCapturer::setFocusSelectedSource (bool focus)
92- {
93- this ->focusSelectedSource = focus;
94- }
95-
96- bool DesktopCapturer::IsOccluded (const webrtc::DesktopVector & pos)
97- {
98- return capturer->IsOccluded (pos);
99- }
1+ /*
2+ * Copyright 2019 Alex Andres
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ #include " media/video/desktop/DesktopCapturer.h"
18+
19+ #include " modules/desktop_capture/desktop_capturer.h"
20+ #include " modules/desktop_capture/desktop_capture_options.h"
21+ #include " modules/desktop_capture/desktop_and_cursor_composer.h"
22+
23+ namespace jni
24+ {
25+ DesktopCapturer::DesktopCapturer (webrtc::DesktopCapturer * capturer) :
26+ focusSelectedSource (false )
27+ {
28+ this ->capturer .reset (capturer);
29+ }
30+
31+ DesktopCapturer::~DesktopCapturer ()
32+ {
33+ capturer.reset ();
34+ }
35+
36+ void DesktopCapturer::Start (webrtc::DesktopCapturer::Callback * callback)
37+ {
38+ capturer->Start (callback);
39+
40+ if (focusSelectedSource) {
41+ capturer->FocusOnSelectedSource ();
42+ }
43+ }
44+
45+ void DesktopCapturer::SetSharedMemoryFactory (std::unique_ptr<webrtc::SharedMemoryFactory> factory)
46+ {
47+ capturer->SetSharedMemoryFactory (std::move (factory));
48+ }
49+
50+ void DesktopCapturer::SetMaxFrameRate (uint32_t max_frame_rate)
51+ {
52+ capturer->SetMaxFrameRate (max_frame_rate);
53+ }
54+
55+ void DesktopCapturer::CaptureFrame ()
56+ {
57+ capturer->CaptureFrame ();
58+ }
59+
60+ void DesktopCapturer::SetExcludedWindow (webrtc::WindowId window)
61+ {
62+ capturer->SetExcludedWindow (window);
63+ }
64+
65+ bool DesktopCapturer::GetSourceList (webrtc::DesktopCapturer::SourceList * sources)
66+ {
67+ return capturer->GetSourceList (sources);
68+ }
69+
70+ bool DesktopCapturer::SelectSource (webrtc::DesktopCapturer::SourceId id)
71+ {
72+ return capturer->SelectSource (id);
73+ }
74+
75+ bool DesktopCapturer::FocusOnSelectedSource ()
76+ {
77+ return capturer->FocusOnSelectedSource ();
78+ }
79+
80+ void DesktopCapturer::setFocusSelectedSource (bool focus)
81+ {
82+ this ->focusSelectedSource = focus;
83+ }
84+
85+ bool DesktopCapturer::IsOccluded (const webrtc::DesktopVector & pos)
86+ {
87+ return capturer->IsOccluded (pos);
88+ }
10089}
0 commit comments