#include "media/cast/sender/video_sender.h"
#include <stdint.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/trace_event/trace_event.h"
#include "media/base/media_switches.h"
#include "media/base/video_encoder_metrics_provider.h"
#include "media/cast/common/openscreen_conversion_helpers.h"
#include "media/cast/common/rtp_time.h"
#include "media/cast/common/sender_encoded_frame.h"
#include "media/cast/encoding/video_encoder.h"
#include "media/cast/sender/openscreen_frame_sender.h"
#include "media/cast/sender/performance_metrics_overlay.h"
#include "third_party/openscreen/src/cast/streaming/encoded_frame.h"
#include "third_party/openscreen/src/cast/streaming/sender.h"
namespace media::cast {
namespace {
constexpr int kRoundTripsNeeded = …;
constexpr int kConstantTimeMs = …;
constexpr int kTargetUtilizationPercentage = …;
constexpr base::TimeDelta kMinKeyFrameRequestInterval = …;
constexpr int kMinKeyFrameRequestFrameInterval = …;
constexpr char kHistogramBitrate[] = …;
constexpr char kHistogramDroppedFrames[] = …;
constexpr char kHistogramFrameDropped[] = …;
void LogVideoCaptureTimestamps(CastEnvironment* cast_environment,
const media::VideoFrame& video_frame,
RtpTimeTicks rtp_timestamp) { … }
}
VideoSender::VideoSender(
scoped_refptr<CastEnvironment> cast_environment,
const FrameSenderConfig& video_config,
StatusChangeCallback status_change_cb,
const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
std::unique_ptr<openscreen::cast::Sender> sender,
std::unique_ptr<media::VideoEncoderMetricsProvider>
encoder_metrics_provider,
PlayoutDelayChangeCB playout_delay_change_cb,
media::VideoCaptureFeedbackCB feedback_cb,
FrameSender::GetSuggestedVideoBitrateCB get_bitrate_cb)
: … { … }
VideoSender::~VideoSender() { … }
void VideoSender::InsertRawVideoFrame(
scoped_refptr<media::VideoFrame> video_frame,
base::TimeTicks reference_time) { … }
std::unique_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() { … }
void VideoSender::SetTargetPlayoutDelay(
base::TimeDelta new_target_playout_delay) { … }
base::TimeDelta VideoSender::GetTargetPlayoutDelay() const { … }
base::WeakPtr<VideoSender> VideoSender::AsWeakPtr() { … }
VideoSender::VideoSender() = default;
int VideoSender::GetNumberOfFramesInEncoder() const { … }
base::TimeDelta VideoSender::GetEncoderBacklogDuration() const { … }
void VideoSender::OnEncodedVideoFrame(
scoped_refptr<media::VideoFrame> video_frame,
const base::TimeTicks reference_time,
std::unique_ptr<SenderEncodedFrame> encoded_frame) { … }
}