chromium/media/cast/sender/video_sender.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// The following two constants are used to adjust the target
// playout delay (when allowed). They were calculated using
// a combination of cast_benchmark runs and manual testing.
//
// This is how many round trips we think we need on the network.
constexpr int kRoundTripsNeeded =;

// This is an estimate of all the the constant time needed independent of
// network quality (e.g., additional time that accounts for encode and decode
// time).
constexpr int kConstantTimeMs =;

// The target maximum utilization of the encoder and network resources.  This is
// used to attenuate the actual measured utilization values in order to provide
// "breathing room" (i.e., to ensure there will be sufficient CPU and bandwidth
// available to handle the occasional more-complex frames).
constexpr int kTargetUtilizationPercentage =;

// This is the minimum duration that the sender sends key frame to the encoder
// on receiving Pli messages. This is used to prevent sending multiple requests
// while the sender is waiting for an encoded key frame or receiving multiple
// Pli messages in a short period.
constexpr base::TimeDelta kMinKeyFrameRequestInterval =;

// This is the minimum amount of frames between issuing key frame requests.
constexpr int kMinKeyFrameRequestFrameInterval =;

// UMA histogram name for video bitrate setting.
constexpr char kHistogramBitrate[] =;

// UMA histogram for the percentage of dropped video frames.
constexpr char kHistogramDroppedFrames[] =;

// UMA histogram for recording when a frame is dropped.
constexpr char kHistogramFrameDropped[] =;

// Extract capture begin/end timestamps from |video_frame|'s metadata and log
// it.
void LogVideoCaptureTimestamps(CastEnvironment* cast_environment,
                               const media::VideoFrame& video_frame,
                               RtpTimeTicks rtp_timestamp) {}

}  // namespace

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) {}

}  // namespace media::cast