1 // Copyright 2014 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.
5 #ifndef REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
6 #define REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
15 class DesktopCapturer
;
20 class ClientSessionControl
;
22 class HostExtensionSession
;
27 class ExtensionMessage
;
30 // Helper class used to create and manage a set of HostExtensionSession
31 // instances depending upon the set of registered HostExtensions, and the
32 // set of capabilities negotiated between client and host.
33 class HostExtensionSessionManager
{
35 typedef std::vector
<HostExtension
*> HostExtensions
;
37 // Creates an extension manager for the specified |extensions|.
38 HostExtensionSessionManager(const HostExtensions
& extensions
,
39 ClientSessionControl
* client_session_control
);
40 virtual ~HostExtensionSessionManager();
42 // Returns the union of all capabilities supported by registered extensions.
43 std::string
GetCapabilities() const;
45 // Calls the corresponding hook functions for each extension, to allow them
46 // to wrap or replace video pipeline components. Only extensions which return
47 // true from ModifiesVideoPipeline() will be called.
48 // The order in which extensions are called is undefined.
49 void OnCreateVideoCapturer(scoped_ptr
<webrtc::DesktopCapturer
>* capturer
);
50 void OnCreateVideoEncoder(scoped_ptr
<VideoEncoder
>* encoder
);
52 // Handles completion of authentication and capabilities negotiation, creating
53 // the set of HostExtensionSessions to match the client's capabilities.
54 void OnNegotiatedCapabilities(protocol::ClientStub
* client_stub
,
55 const std::string
& capabilities
);
57 // Passes |message| to each HostExtensionSession in turn until the message
58 // is handled, or none remain. Returns true if the message was handled.
59 // It is not valid for more than one extension to handle the same message.
60 bool OnExtensionMessage(const protocol::ExtensionMessage
& message
);
63 typedef ScopedVector
<HostExtensionSession
> HostExtensionSessions
;
65 // Passed to HostExtensionSessions to allow them to send messages,
66 // disconnect the session, etc.
67 ClientSessionControl
* client_session_control_
;
68 protocol::ClientStub
* client_stub_
;
70 // The HostExtensions to instantiate for the session, if it reaches the
71 // authenticated state.
72 HostExtensions extensions_
;
74 // The instantiated HostExtensionSessions, used to handle extension messages.
75 HostExtensionSessions extension_sessions_
;
77 DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManager
);
80 } // namespace remoting
82 #endif // REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_