#include "cast/streaming/public/sender_session.h"
#include <openssl/rand.h>
#include <stdint.h>
#include <algorithm>
#include <iterator>
#include <string>
#include <utility>
#include "cast/streaming/impl/clock_offset_estimator.h"
#include "cast/streaming/message_fields.h"
#include "cast/streaming/public/capture_recommendations.h"
#include "cast/streaming/public/environment.h"
#include "cast/streaming/public/offer_messages.h"
#include "cast/streaming/public/sender.h"
#include "cast/streaming/sender_message.h"
#include "util/crypto/random_bytes.h"
#include "util/json/json_helpers.h"
#include "util/json/json_serialization.h"
#include "util/osp_logging.h"
#include "util/stringprintf.h"
namespace openscreen::cast {
namespace {
const Error& InvalidCapabilitiesResponseError() { … }
const Error& InvalidAnswerError() { … }
const Error& AnswerTimeoutError() { … }
const Error& InvalidRpcError() { … }
AudioStream CreateStream(int index,
const AudioCaptureConfig& config,
bool use_android_rtp_hack) { … }
VideoStream CreateStream(int index,
const VideoCaptureConfig& config,
bool use_android_rtp_hack) { … }
template <typename S, typename C>
void CreateStreamList(int offset_index,
const std::vector<C>& configs,
bool use_android_rtp_hack,
std::vector<S>* out) { … }
Offer CreateMirroringOffer(const std::vector<AudioCaptureConfig>& audio_configs,
const std::vector<VideoCaptureConfig>& video_configs,
bool use_android_rtp_hack) { … }
Offer CreateRemotingOffer(const AudioCaptureConfig& audio_config,
const VideoCaptureConfig& video_config,
bool use_android_rtp_hack) { … }
bool IsValidAudioCaptureConfig(const AudioCaptureConfig& config) { … }
bool IsSupportedResolution(const Resolution& resolution) { … }
bool IsValidVideoCaptureConfig(const VideoCaptureConfig& config) { … }
bool AreAllValid(const std::vector<AudioCaptureConfig>& audio_configs,
const std::vector<VideoCaptureConfig>& video_configs) { … }
RemotingCapabilities ToCapabilities(const ReceiverCapability& capability) { … }
}
SenderSession::Client::~Client() = default;
SenderSession::SenderSession(Configuration config)
: … { … }
SenderSession::~SenderSession() = default;
Error SenderSession::Negotiate(std::vector<AudioCaptureConfig> audio_configs,
std::vector<VideoCaptureConfig> video_configs) { … }
Error SenderSession::NegotiateRemoting(AudioCaptureConfig audio_config,
VideoCaptureConfig video_config) { … }
Error SenderSession::RequestCapabilities() { … }
int SenderSession::GetEstimatedNetworkBandwidth() const { … }
void SenderSession::SetStatsClient(SenderStatsClient* client) { … }
void SenderSession::ResetState() { … }
Error SenderSession::StartNegotiation(
std::vector<AudioCaptureConfig> audio_configs,
std::vector<VideoCaptureConfig> video_configs,
Offer offer) { … }
void SenderSession::OnAnswer(ErrorOr<ReceiverMessage> message) { … }
void SenderSession::OnCapabilitiesResponse(ErrorOr<ReceiverMessage> message) { … }
void SenderSession::OnRpcMessage(ErrorOr<ReceiverMessage> message) { … }
void SenderSession::HandleErrorMessage(ReceiverMessage message,
const Error& default_error) { … }
std::unique_ptr<Sender> SenderSession::CreateSender(Ssrc receiver_ssrc,
const Stream& stream,
RtpPayloadType type) { … }
void SenderSession::SpawnAudioSender(ConfiguredSenders* senders,
Ssrc receiver_ssrc,
int send_index,
int config_index) { … }
void SenderSession::SpawnVideoSender(ConfiguredSenders* senders,
Ssrc receiver_ssrc,
int send_index,
int config_index) { … }
SenderSession::ConfiguredSenders SenderSession::SelectSenders(
const Answer& answer) { … }
void SenderSession::SendRpcMessage(std::vector<uint8_t> message_body) { … }
}