#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/cast/sender/openscreen_frame_sender.h"
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
#include "media/base/media_switches.h"
#include "media/cast/common/openscreen_conversion_helpers.h"
#include "media/cast/common/sender_encoded_frame.h"
#include "media/cast/constants.h"
#include "third_party/openscreen/src/cast/streaming/encoded_frame.h"
namespace media::cast {
namespace {
static constexpr int kMaxFrameBurst = …;
EnqueueFrameResult;
CastStreamingFrameDropReason ToFrameDropReason(EnqueueFrameResult result) { … }
}
std::unique_ptr<FrameSender> FrameSender::Create(
scoped_refptr<CastEnvironment> cast_environment,
const FrameSenderConfig& config,
std::unique_ptr<openscreen::cast::Sender> sender,
Client& client,
FrameSender::GetSuggestedVideoBitrateCB get_bitrate_cb) { … }
#define VLOG_WITH_SSRC(N) …
OpenscreenFrameSender::OpenscreenFrameSender(
scoped_refptr<CastEnvironment> cast_environment,
const FrameSenderConfig& config,
std::unique_ptr<openscreen::cast::Sender> sender,
Client& client,
FrameSender::GetSuggestedVideoBitrateCB get_bitrate_cb)
: … { … }
OpenscreenFrameSender::~OpenscreenFrameSender() { … }
bool OpenscreenFrameSender::NeedsKeyFrame() const { … }
void OpenscreenFrameSender::SetTargetPlayoutDelay(
base::TimeDelta new_target_playout_delay) { … }
base::TimeDelta OpenscreenFrameSender::GetTargetPlayoutDelay() const { … }
void OpenscreenFrameSender::OnFrameCanceled(
openscreen::cast::FrameId frame_id) { … }
void OpenscreenFrameSender::OnPictureLost() { … }
void OpenscreenFrameSender::RecordLatestFrameTimestamps(
FrameId frame_id,
base::TimeTicks reference_time,
RtpTimeTicks rtp_timestamp) { … }
base::TimeDelta OpenscreenFrameSender::GetInFlightMediaDuration() const { … }
RtpTimeTicks OpenscreenFrameSender::GetRecordedRtpTimestamp(
FrameId frame_id) const { … }
int OpenscreenFrameSender::GetUnacknowledgedFrameCount() const { … }
int OpenscreenFrameSender::GetSuggestedBitrate(base::TimeTicks playout_time,
base::TimeDelta playout_delay) { … }
double OpenscreenFrameSender::MaxFrameRate() const { … }
void OpenscreenFrameSender::SetMaxFrameRate(double max_frame_rate) { … }
base::TimeDelta OpenscreenFrameSender::TargetPlayoutDelay() const { … }
base::TimeDelta OpenscreenFrameSender::CurrentRoundTripTime() const { … }
base::TimeTicks OpenscreenFrameSender::LastSendTime() const { … }
FrameId OpenscreenFrameSender::LastAckedFrameId() const { … }
base::TimeDelta OpenscreenFrameSender::GetAllowedInFlightMediaDuration() const { … }
CastStreamingFrameDropReason OpenscreenFrameSender::EnqueueFrame(
std::unique_ptr<SenderEncodedFrame> encoded_frame) { … }
CastStreamingFrameDropReason OpenscreenFrameSender::ShouldDropNextFrame(
base::TimeDelta frame_duration) { … }
void OpenscreenFrameSender::RecordShouldDropNextFrame(bool should_drop) { … }
}