diff options
author | Yuri Wiitala <miu@chromium.org> | 2020-11-09 12:10:55 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-09 20:32:07 +0000 |
commit | 7b6396aaef5bf0693c6b9aa2e4bdbe139a28e57a (patch) | |
tree | bdca6e00b750a3f8c0b9acedaee39729fb29dae6 /cast/standalone_receiver/cast_service.h | |
parent | 82a5b2d213634a64b952e9135901e0f0e4b81571 (diff) | |
download | openscreen-7b6396aaef5bf0693c6b9aa2e4bdbe139a28e57a.tar.gz |
Standalone Receiver: Integration with ApplicationAgent.
Makes the standalone cast receiver a full Cast V2 Receiver with a
launchable "Mirroring App." Replaces "CastAgent" with three modules:
MirroringApplication (new): A front-end launcher and message port for a
ReceiverSession (and a StreamingPlaybackController, which manages the
playback UI).
ApplicatonAgent (prior patch): An implementation of the Cast V2
Application Control spec, able to launch applications and route messages
to/from them.
CastService (new): Glues it all together, from a network server socket,
through the Cast Channel infrastructure, through the ApplicationAgent
and MirroringApplication, to a ReceiverSession and playback GUI.
Bug: b/170134354
Change-Id: I9640a3d0c40f174d9f03bc26ee3c2f160736e290
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2481853
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast/standalone_receiver/cast_service.h')
-rw-r--r-- | cast/standalone_receiver/cast_service.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/cast/standalone_receiver/cast_service.h b/cast/standalone_receiver/cast_service.h new file mode 100644 index 00000000..99137de2 --- /dev/null +++ b/cast/standalone_receiver/cast_service.h @@ -0,0 +1,77 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CAST_STANDALONE_RECEIVER_CAST_SERVICE_H_ +#define CAST_STANDALONE_RECEIVER_CAST_SERVICE_H_ + +#include <memory> +#include <string> + +#include "cast/common/public/service_info.h" +#include "cast/receiver/application_agent.h" +#include "cast/receiver/channel/static_credentials.h" +#include "cast/receiver/public/receiver_socket_factory.h" +#include "cast/standalone_receiver/mirroring_application.h" +#include "discovery/common/reporting_client.h" +#include "discovery/public/dns_sd_service_factory.h" +#include "discovery/public/dns_sd_service_publisher.h" +#include "platform/api/serial_delete_ptr.h" +#include "platform/base/error.h" +#include "platform/base/ip_address.h" + +namespace openscreen { + +struct InterfaceInfo; +class TaskRunner; +class TlsConnectionFactory; + +namespace cast { + +// Assembles all the necessary components and manages their lifetimes, to create +// a full Cast Receiver on the network, with the following overall +// functionality: +// +// * Listens for TCP connections on port 8010. +// * Establishes TLS tunneling over those connections. +// * Wraps a CastSocket API around the TLS connections. +// * Manages available receiver-side applications. +// * Provides a Cast V2 Mirroring application (media streaming playback in an +// on-screen window). +// * Publishes over mDNS to be discoverable to all senders on the same LAN. +class CastService final : public discovery::ReportingClient { + public: + CastService(TaskRunner* task_runner, + const InterfaceInfo& interface, + GeneratedCredentials credentials, + const std::string& friendly_name, + const std::string& model_name, + bool enable_discovery = true); + + ~CastService() final; + + private: + using LazyDeletedDiscoveryService = SerialDeletePtr<discovery::DnsSdService>; + using LazyDeletedDiscoveryPublisher = + SerialDeletePtr<discovery::DnsSdServicePublisher<ServiceInfo>>; + + // discovery::ReportingClient overrides. + void OnFatalError(Error error) final; + void OnRecoverableError(Error error) final; + + const IPEndpoint local_endpoint_; + const GeneratedCredentials credentials_; + + ApplicationAgent agent_; + MirroringApplication mirroring_application_; + ReceiverSocketFactory socket_factory_; + std::unique_ptr<TlsConnectionFactory> connection_factory_; + + LazyDeletedDiscoveryService discovery_service_; + LazyDeletedDiscoveryPublisher discovery_publisher_; +}; + +} // namespace cast +} // namespace openscreen + +#endif // CAST_STANDALONE_RECEIVER_CAST_SERVICE_H_ |