#include "video/video_receive_stream2.h"
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/task_queue/task_queue_base.h"
#include "api/units/frequency.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "api/video/encoded_image.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "call/rtp_stream_receiver_controller_interface.h"
#include "call/rtx_receive_stream.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/include/video_coding_defines.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "modules/video_coding/timing/timing.h"
#include "modules/video_coding/utility/vp8_header_parser.h"
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "video/call_stats2.h"
#include "video/frame_dumping_decoder.h"
#include "video/receive_statistics_proxy.h"
#include "video/render/incoming_video_stream.h"
#include "video/task_queue_frame_decode_scheduler.h"
namespace webrtc {
namespace internal {
namespace {
constexpr TimeDelta kMinBaseMinimumDelay = …;
constexpr TimeDelta kMaxBaseMinimumDelay = …;
class WebRtcRecordableEncodedFrame : public RecordableEncodedFrame { … };
RenderResolution InitialDecoderResolution(const FieldTrialsView& field_trials) { … }
class NullVideoDecoder : public webrtc::VideoDecoder { … };
bool IsKeyFrameAndUnspecifiedResolution(const EncodedFrame& frame) { … }
std::string OptionalDelayToLogString(const absl::optional<TimeDelta> opt) { … }
}
TimeDelta DetermineMaxWaitForFrame(TimeDelta rtp_history, bool is_keyframe) { … }
VideoReceiveStream2::VideoReceiveStream2(
const Environment& env,
Call* call,
int num_cpu_cores,
PacketRouter* packet_router,
VideoReceiveStreamInterface::Config config,
CallStats* call_stats,
std::unique_ptr<VCMTiming> timing,
NackPeriodicProcessor* nack_periodic_processor,
DecodeSynchronizer* decode_sync)
: … { … }
VideoReceiveStream2::~VideoReceiveStream2() { … }
void VideoReceiveStream2::RegisterWithTransport(
RtpStreamReceiverControllerInterface* receiver_controller) { … }
void VideoReceiveStream2::UnregisterFromTransport() { … }
const std::string& VideoReceiveStream2::sync_group() const { … }
void VideoReceiveStream2::SignalNetworkState(NetworkState state) { … }
bool VideoReceiveStream2::DeliverRtcp(const uint8_t* packet, size_t length) { … }
void VideoReceiveStream2::SetSync(Syncable* audio_syncable) { … }
void VideoReceiveStream2::SetLocalSsrc(uint32_t local_ssrc) { … }
void VideoReceiveStream2::Start() { … }
void VideoReceiveStream2::Stop() { … }
void VideoReceiveStream2::SetRtcpMode(RtcpMode mode) { … }
void VideoReceiveStream2::SetFlexFecProtection(
RtpPacketSinkInterface* flexfec_sink) { … }
void VideoReceiveStream2::SetLossNotificationEnabled(bool enabled) { … }
void VideoReceiveStream2::SetNackHistory(TimeDelta history) { … }
void VideoReceiveStream2::SetProtectionPayloadTypes(int red_payload_type,
int ulpfec_payload_type) { … }
void VideoReceiveStream2::SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) { … }
void VideoReceiveStream2::SetAssociatedPayloadTypes(
std::map<int, int> associated_payload_types) { … }
void VideoReceiveStream2::CreateAndRegisterExternalDecoder(
const Decoder& decoder) { … }
VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { … }
void VideoReceiveStream2::UpdateHistograms() { … }
bool VideoReceiveStream2::SetBaseMinimumPlayoutDelayMs(int delay_ms) { … }
int VideoReceiveStream2::GetBaseMinimumPlayoutDelayMs() const { … }
void VideoReceiveStream2::OnFrame(const VideoFrame& video_frame) { … }
void VideoReceiveStream2::SetFrameDecryptor(
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) { … }
void VideoReceiveStream2::SetDepacketizerToDecoderFrameTransformer(
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) { … }
void VideoReceiveStream2::RequestKeyFrame(Timestamp now) { … }
void VideoReceiveStream2::OnCompleteFrame(std::unique_ptr<EncodedFrame> frame) { … }
void VideoReceiveStream2::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { … }
uint32_t VideoReceiveStream2::id() const { … }
absl::optional<Syncable::Info> VideoReceiveStream2::GetInfo() const { … }
bool VideoReceiveStream2::GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp,
int64_t* time_ms) const { … }
void VideoReceiveStream2::SetEstimatedPlayoutNtpTimestampMs(
int64_t ntp_timestamp_ms,
int64_t time_ms) { … }
bool VideoReceiveStream2::SetMinimumPlayoutDelay(int delay_ms) { … }
void VideoReceiveStream2::OnEncodedFrame(std::unique_ptr<EncodedFrame> frame) { … }
void VideoReceiveStream2::OnDecodableFrameTimeout(TimeDelta wait) { … }
VideoReceiveStream2::DecodeFrameResult
VideoReceiveStream2::HandleEncodedFrameOnDecodeQueue(
std::unique_ptr<EncodedFrame> frame,
bool keyframe_request_is_due,
bool keyframe_required) { … }
int VideoReceiveStream2::DecodeAndMaybeDispatchEncodedFrame(
std::unique_ptr<EncodedFrame> frame) { … }
void VideoReceiveStream2::HandleKeyFrameGeneration(
bool received_frame_is_keyframe,
Timestamp now,
bool always_request_key_frame,
bool keyframe_request_is_due) { … }
bool VideoReceiveStream2::IsReceivingKeyFrame(Timestamp now) const { … }
void VideoReceiveStream2::UpdatePlayoutDelays() const { … }
std::vector<webrtc::RtpSource> VideoReceiveStream2::GetSources() const { … }
VideoReceiveStream2::RecordingState
VideoReceiveStream2::SetAndGetRecordingState(RecordingState state,
bool generate_key_frame) { … }
void VideoReceiveStream2::GenerateKeyFrame() { … }
void VideoReceiveStream2::UpdateRtxSsrc(uint32_t ssrc) { … }
}
}