1/*
2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#pragma once
20
21#if ENABLE(MEDIA_STREAM)
22
23#include "UserMediaPermissionRequestManagerProxy.h"
24#include <WebCore/CaptureDevice.h>
25#include <wtf/RunLoop.h>
26
27namespace WebKit {
28
29class WebProcessProxy;
30
31class UserMediaProcessManager {
32public:
33
34 static UserMediaProcessManager& singleton();
35
36 UserMediaProcessManager();
37
38 bool willCreateMediaStream(UserMediaPermissionRequestManagerProxy&, bool withAudio, bool withVideo);
39 void muteCaptureMediaStreamsExceptIn(WebPageProxy&);
40
41 void revokeSandboxExtensionsIfNeeded(WebProcessProxy&);
42
43 void setCaptureEnabled(bool);
44 bool captureEnabled() const { return m_captureEnabled; }
45
46 void denyNextUserMediaRequest() { m_denyNextRequest = true; }
47
48 void beginMonitoringCaptureDevices();
49
50private:
51 void captureDevicesChanged();
52
53 Vector<WebCore::CaptureDevice> m_captureDevices;
54 RunLoop::Timer<UserMediaProcessManager> m_debounceTimer;
55 bool m_captureEnabled { true };
56 bool m_denyNextRequest { false };
57};
58
59} // namespace WebKit
60
61#endif
62