aboutsummaryrefslogtreecommitdiff
path: root/cast/streaming/receiver_session.h
diff options
context:
space:
mode:
Diffstat (limited to 'cast/streaming/receiver_session.h')
-rw-r--r--cast/streaming/receiver_session.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/cast/streaming/receiver_session.h b/cast/streaming/receiver_session.h
index b448bd00..b29b6d52 100644
--- a/cast/streaming/receiver_session.h
+++ b/cast/streaming/receiver_session.h
@@ -26,7 +26,7 @@ namespace cast {
class Environment;
class Receiver;
-class ReceiverSession final {
+class ReceiverSession final : public Environment::SocketSubscriber {
public:
// Upon successful negotiation, a set of configured receivers is constructed
// for handling audio and video. Note that either receiver may be null.
@@ -115,20 +115,37 @@ class ReceiverSession final {
const std::string& session_id() const { return session_id_; }
+ // Environment::SocketSubscriber event callbacks.
+ void OnSocketReady() override;
+ void OnSocketInvalid(Error error) override;
+
private:
+ struct SessionProperties {
+ std::unique_ptr<AudioStream> selected_audio;
+ std::unique_ptr<VideoStream> selected_video;
+ int sequence_number;
+
+ // To be valid either the audio or video must be selected, and we must
+ // have a sequence number we can reference.
+ bool IsValid() const;
+ };
+
// Specific message type handler methods.
void OnOffer(SenderMessage message);
+ // Creates receivers and sends an appropriate Answer message using the
+ // session properties.
+ void InitializeSession(const SessionProperties& properties);
+
// Used by SpawnReceivers to generate a receiver for a specific stream.
std::unique_ptr<Receiver> ConstructReceiver(const Stream& stream);
// Creates a set of configured receivers from a given pair of audio and
// video streams. NOTE: either audio or video may be null, but not both.
- ConfiguredReceivers SpawnReceivers(const AudioStream* audio,
- const VideoStream* video);
+ ConfiguredReceivers SpawnReceivers(const SessionProperties& properties);
// Callers of this method should ensure at least one stream is non-null.
- Answer ConstructAnswer(const AudioStream* audio, const VideoStream* video);
+ Answer ConstructAnswer(const SessionProperties& properties);
// Handles resetting receivers and notifying the client.
void ResetReceivers(Client::ReceiversDestroyingReason reason);
@@ -143,6 +160,12 @@ class ReceiverSession final {
const std::string session_id_;
ReceiverSessionMessager messager_;
+ // In some cases, the session initialization may be pending waiting for the
+ // UDP socket to be ready. In this case, the receivers and the answer
+ // message will not be configured and sent until the UDP socket has finished
+ // binding.
+ std::unique_ptr<SessionProperties> pending_session_;
+
bool supports_wifi_status_reporting_ = false;
ReceiverPacketRouter packet_router_;