1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ 7 8 #include <cstdint> 9 #include <memory> 10 #include <string> 11 12 #include "base/callback_forward.h" 13 #include "base/memory/ref_counted.h" 14 #include "base/memory/weak_ptr.h" 15 #include "remoting/host/desktop_and_cursor_conditional_composer.h" 16 #include "remoting/host/desktop_environment_options.h" 17 18 namespace webrtc { 19 class DesktopCapturer; 20 class MouseCursorMonitor; 21 } // namespace webrtc 22 23 namespace remoting { 24 25 class ActionExecutor; 26 class AudioCapturer; 27 class ClientSessionControl; 28 class FileOperations; 29 class InputInjector; 30 class KeyboardLayoutMonitor; 31 class ScreenControls; 32 33 namespace protocol { 34 class KeyboardLayout; 35 } // namespace protocol 36 37 // Provides factory methods for creation of audio/video capturers and event 38 // executor for a given desktop environment. 39 class DesktopEnvironment { 40 public: ~DesktopEnvironment()41 virtual ~DesktopEnvironment() {} 42 43 // Factory methods used to create audio/video capturers, event executor, and 44 // screen controls object for a particular desktop environment. 45 virtual std::unique_ptr<ActionExecutor> CreateActionExecutor() = 0; 46 virtual std::unique_ptr<AudioCapturer> CreateAudioCapturer() = 0; 47 virtual std::unique_ptr<InputInjector> CreateInputInjector() = 0; 48 virtual std::unique_ptr<ScreenControls> CreateScreenControls() = 0; 49 virtual std::unique_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() = 0; 50 virtual std::unique_ptr<webrtc::MouseCursorMonitor> 51 CreateMouseCursorMonitor() = 0; 52 virtual std::unique_ptr<KeyboardLayoutMonitor> CreateKeyboardLayoutMonitor( 53 base::RepeatingCallback<void(const protocol::KeyboardLayout&)> 54 callback) = 0; 55 virtual std::unique_ptr<FileOperations> CreateFileOperations() = 0; 56 57 // For platforms that require the mouse cursor to be composited into the video 58 // stream when it is not rendered by the client, returns a composing capturer. 59 // If the platform already does this, this method return null, and the caller 60 // should use CreateVideoCapturer() instead. 61 virtual std::unique_ptr<DesktopAndCursorConditionalComposer> 62 CreateComposingVideoCapturer() = 0; 63 64 // Returns the set of all capabilities supported by |this|. 65 virtual std::string GetCapabilities() const = 0; 66 67 // Passes the final set of capabilities negotiated between the client and host 68 // to |this|. 69 virtual void SetCapabilities(const std::string& capabilities) = 0; 70 71 // Returns an id which identifies the current desktop session on Windows. 72 // Other platforms will always return the default value (UINT32_MAX). 73 virtual uint32_t GetDesktopSessionId() const = 0; 74 }; 75 76 // Used to create |DesktopEnvironment| instances. 77 class DesktopEnvironmentFactory { 78 public: ~DesktopEnvironmentFactory()79 virtual ~DesktopEnvironmentFactory() {} 80 81 // Creates an instance of |DesktopEnvironment|. Returns a nullptr pointer if 82 // the desktop environment could not be created for any reason (if the curtain 83 // failed to active for instance). |client_session_control| must outlive 84 // the created desktop environment. 85 virtual std::unique_ptr<DesktopEnvironment> Create( 86 base::WeakPtr<ClientSessionControl> client_session_control, 87 const DesktopEnvironmentOptions& options) = 0; 88 89 // Returns |true| if created |DesktopEnvironment| instances support audio 90 // capture. 91 virtual bool SupportsAudioCapture() const = 0; 92 }; 93 94 } // namespace remoting 95 96 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ 97