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 // Creates an extension manager for the specified |extensions|.
36 HostExtensionSessionManager(const std::vector
<HostExtension
*>& extensions
,
37 ClientSessionControl
* client_session_control
);
38 virtual ~HostExtensionSessionManager();
40 // Returns the union of all capabilities supported by registered extensions.
41 std::string
GetCapabilities();
43 // Calls the corresponding hook functions in each extension in turn, to give
44 // them an opportunity to wrap or replace video components.
45 scoped_ptr
<webrtc::DesktopCapturer
> OnCreateVideoCapturer(
46 scoped_ptr
<webrtc::DesktopCapturer
> capturer
);
47 scoped_ptr
<VideoEncoder
> OnCreateVideoEncoder(
48 scoped_ptr
<VideoEncoder
> encoder
);
50 // Handles completion of authentication and capabilities negotiation, creating
51 // the set of |HostExtensionSession| to match the client's capabilities.
52 void OnNegotiatedCapabilities(protocol::ClientStub
* client_stub
,
53 const std::string
& capabilities
);
55 // Passes |message| to each |HostExtensionSession| in turn until the message
56 // is handled, or none remain. Returns true if the message was handled.
57 bool OnExtensionMessage(const protocol::ExtensionMessage
& message
);
60 typedef std::vector
<HostExtension
*> HostExtensionList
;
61 typedef ScopedVector
<HostExtensionSession
> HostExtensionSessionList
;
63 // Passed to HostExtensionSessions to allow them to send messages,
64 // disconnect the session, etc.
65 ClientSessionControl
* client_session_control_
;
66 protocol::ClientStub
* client_stub_
;
68 // List of HostExtensions to attach to the session, if it reaches the
69 // authenticated state.
70 HostExtensionList extensions_
;
72 // List of HostExtensionSessions, used to handle extension messages.
73 HostExtensionSessionList extension_sessions_
;
75 DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManager
);
78 } // namespace remoting
80 #endif // REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_