#include "components/mirroring/service/remoting_sender.h"
#include <algorithm>
#include "base/dcheck_is_on.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_switches.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/constants.h"
#include "media/cast/openscreen/decoder_buffer_reader.h"
#include "media/cast/openscreen/remoting_proto_utils.h"
#include "media/cast/sender/openscreen_frame_sender.h"
#include "third_party/openscreen/src/cast/streaming/encoded_frame.h"
#include "third_party/openscreen/src/cast/streaming/sender.h"
Dependency;
namespace mirroring {
namespace {
constexpr char kHistogramDroppedAudioFrames[] = …;
constexpr char kHistogramDroppedVideoFrames[] = …;
constexpr char kHistogramAudioFrameDropped[] = …;
constexpr char kHistogramVideoFrameDropped[] = …;
constexpr int kMaxEnqueueFrameFailures = …;
}
class RemotingSender::SenderEncodedFrameFactory { … };
RemotingSender::RemotingSender(
scoped_refptr<media::cast::CastEnvironment> cast_environment,
std::unique_ptr<openscreen::cast::Sender> sender,
const media::cast::FrameSenderConfig& config,
mojo::ScopedDataPipeConsumerHandle pipe,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender> stream_sender,
base::OnceClosure error_callback)
: … { … }
RemotingSender::RemotingSender(
scoped_refptr<media::cast::CastEnvironment> cast_environment,
std::unique_ptr<media::cast::FrameSender> frame_sender,
const media::cast::FrameSenderConfig& config,
mojo::ScopedDataPipeConsumerHandle pipe,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender> stream_sender,
base::OnceClosure error_callback)
: … { … }
RemotingSender::~RemotingSender() { … }
void RemotingSender::SendFrame(media::mojom::DecoderBufferPtr buffer,
SendFrameCallback callback) { … }
void RemotingSender::CancelInFlightData() { … }
int RemotingSender::GetNumberOfFramesInEncoder() const { … }
base::TimeDelta RemotingSender::GetEncoderBacklogDuration() const { … }
void RemotingSender::OnFrameCanceled(media::cast::FrameId frame_id) { … }
void RemotingSender::TrySendFrame() { … }
void RemotingSender::OnFrameRead(scoped_refptr<media::DecoderBuffer> buffer) { … }
void RemotingSender::OnRemotingDataStreamError() { … }
void RemotingSender::ClearCurrentFrame() { … }
}