diff options
Diffstat (limited to 'cast/streaming/receiver_session.h')
-rw-r--r-- | cast/streaming/receiver_session.h | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/cast/streaming/receiver_session.h b/cast/streaming/receiver_session.h index 3c341279..0f9f00cf 100644 --- a/cast/streaming/receiver_session.h +++ b/cast/streaming/receiver_session.h @@ -16,6 +16,7 @@ #include "cast/streaming/offer_messages.h" #include "cast/streaming/receiver_packet_router.h" #include "cast/streaming/resolution.h" +#include "cast/streaming/rpc_broker.h" #include "cast/streaming/sender_message.h" #include "cast/streaming/session_config.h" #include "cast/streaming/session_messenger.h" @@ -26,9 +27,9 @@ namespace cast { class Environment; class Receiver; -// This class is responsible for listening for streaming (both mirroring and -// remoting) requests from Cast Sender devices, then negotiating capture -// constraints and instantiating audio and video Receiver objects. +// This class is responsible for listening for streaming requests from Cast +// Sender devices, then negotiating capture constraints and instantiating audio +// and video Receiver objects. // The owner of this session is expected to provide a client for // updates, an environment for getting UDP socket information (as well as // other OS dependencies), and a set of preferences to be used for @@ -62,17 +63,33 @@ class ReceiverSession final : public Environment::SocketSubscriber { VideoCaptureConfig video_config; }; + // This struct contains all of the information necessary to begin remoting + // once we get a remoting request from a Sender. + struct RemotingNegotiation { + ConfiguredReceivers receivers; + + // The RPC broker to be used for subscribing to remoting proto messages. + RpcBroker* broker; + }; + // The embedder should provide a client for handling connections. // When a connection is established, the OnNegotiated callback is called. class Client { public: enum ReceiversDestroyingReason { kEndOfSession, kRenegotiated }; - // Called when a new set of receivers has been negotiated. This may be - // called multiple times during a session, as renegotiations occur. + // Called when a set of streaming receivers has been negotiated. Both this + // and |OnRemotingNegotiated| may be called repeatedly as negotiations occur + // through the life of a session. virtual void OnNegotiated(const ReceiverSession* session, ConfiguredReceivers receivers) = 0; + // Called when a set of remoting receivers has been negotiated. This will + // only be called if |RemotingPreferences| are provided as part of + // constructing the ReceiverSession object. + virtual void OnRemotingNegotiated(const ReceiverSession* session, + RemotingNegotiation negotiation) {} + // Called immediately preceding the destruction of this session's receivers. // If |reason| is |kEndOfSession|, OnNegotiated() will never be called // again; if it is |kRenegotiated|, OnNegotiated() will be called again @@ -92,7 +109,7 @@ class ReceiverSession final : public Environment::SocketSubscriber { // Information about the display the receiver is attached to. struct Display { // The display limitations of the actual screen, used to provide upper - // bounds on mirroring and remoting streams. For example, we will never + // bounds on streams. For example, we will never // send 60FPS if it is going to be displayed on a 30FPS screen. // Note that we may exceed the display width and height for standard // content sizes like 720p or 1080p. @@ -166,6 +183,12 @@ class ReceiverSession final : public Environment::SocketSubscriber { // TODO(issuetracker.google.com/184429130): the mirroring control // protocol needs to be updated to allow more discrete support. struct RemotingPreferences { + RemotingPreferences(); + RemotingPreferences(RemotingPreferences&&) noexcept; + RemotingPreferences(const RemotingPreferences&) = delete; + RemotingPreferences& operator=(RemotingPreferences&&) noexcept; + RemotingPreferences& operator=(const RemotingPreferences&) = delete; + // Current remoting senders take an "all or nothing" support for audio // codec support. While Opus and AAC support is handled in our Preferences' // |audio_codecs| property, support for the following codecs must be @@ -219,7 +242,7 @@ class ReceiverSession final : public Environment::SocketSubscriber { // Libcast remoting support is opt-in: embedders wishing to field remoting // offers may provide a set of remoting preferences, or leave nullptr for - // all remoting OFFERs to be rejected in favor of continuing mirroring. + // all remoting OFFERs to be rejected in favor of continuing streaming. std::unique_ptr<RemotingPreferences> remoting; }; @@ -263,6 +286,10 @@ class ReceiverSession final : public Environment::SocketSubscriber { void OnOffer(SenderMessage message); void OnCapabilitiesRequest(SenderMessage message); + // Selects streams from an offer based on its configuration, and sets + // them in the session properties. + void SelectStreams(const Offer& offer, SessionProperties* properties); + // Creates receivers and sends an appropriate Answer message using the // session properties. void InitializeSession(const SessionProperties& properties); @@ -307,6 +334,10 @@ class ReceiverSession final : public Environment::SocketSubscriber { // through |Client::OnReceiversDestroying|. std::unique_ptr<Receiver> current_audio_receiver_; std::unique_ptr<Receiver> current_video_receiver_; + + // If remoting, we store the RpcBroker used by the embedder to send RPC + // messages from the remoting protobuf specification. + std::unique_ptr<RpcBroker> broker_; }; } // namespace cast |