// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CAST_RECEIVER_APPLICATION_AGENT_H_ #define CAST_RECEIVER_APPLICATION_AGENT_H_ #include <map> #include <memory> #include <string> #include <vector> #include "cast/common/channel/cast_socket_message_port.h" #include "cast/common/channel/connection_namespace_handler.h" #include "cast/common/channel/virtual_connection_router.h" #include "cast/common/public/cast_socket.h" #include "cast/receiver/channel/device_auth_namespace_handler.h" #include "cast/receiver/public/receiver_socket_factory.h" #include "platform/api/task_runner.h" #include "platform/base/error.h" #include "platform/base/ip_address.h" #include "util/json/json_value.h" namespace openscreen::cast { class CastSocket; // A service accepting CastSocket connections, and providing a minimal // implementation of the CastV2 application control protocol to launch receiver // applications and route messages to/from them. // // Workflow: One or more Applications are registered under this ApplicationAgent // (e.g., a "mirroring" app). Later, a ReceiverSocketFactory (external to this // class) will listen and establish CastSocket connections, and then pass // CastSockets to this ApplicationAgent via the OnConnect() method. As each // connection is made, device authentication will take place. Then, Cast V2 // application messages asking about application availability are received and // responded to, based on what Applications are registered. Finally, the remote // may request the LAUNCH of an Application (and later a STOP). // // In the meantime, this ApplicationAgent broadcasts RECEIVER_STATUS about what // application is running. In addition, it attempts to launch an "idle screen" // Application whenever no other Application is running. The "idle screen" // Application is usually some kind of screen saver or wallpaper/clock display. // Registering the "idle screen" Application is optional, and if it's not // registered, then nothing will be running during idle periods. class ApplicationAgent final : public ReceiverSocketFactory::Client, public CastMessageHandler, public ConnectionNamespaceHandler::VirtualConnectionPolicy, public VirtualConnectionRouter::SocketErrorHandler { … }; } // namespace openscreen::cast #endif // CAST_RECEIVER_APPLICATION_AGENT_H_