2017-08-22 05:43:23 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef CALL_VIDEO_RECEIVE_STREAM_H_
|
|
|
|
|
#define CALL_VIDEO_RECEIVE_STREAM_H_
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
#include <map>
|
2019-05-23 13:21:12 +02:00
|
|
|
#include <set>
|
2017-08-22 05:43:23 -07:00
|
|
|
#include <string>
|
2019-12-03 14:31:45 +01:00
|
|
|
#include <utility>
|
2017-08-22 05:43:23 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/call/transport.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/crypto_options.h"
|
2017-12-15 14:40:10 +01:00
|
|
|
#include "api/rtp_headers.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/rtp_parameters.h"
|
2019-12-03 14:31:45 +01:00
|
|
|
#include "api/video/recordable_encoded_frame.h"
|
2017-12-15 14:40:10 +01:00
|
|
|
#include "api/video/video_content_type.h"
|
2019-09-02 15:16:49 +02:00
|
|
|
#include "api/video/video_frame.h"
|
2018-05-11 11:15:30 +02:00
|
|
|
#include "api/video/video_sink_interface.h"
|
2017-12-15 14:40:10 +01:00
|
|
|
#include "api/video/video_timing.h"
|
2018-09-11 15:56:04 +02:00
|
|
|
#include "api/video_codecs/sdp_video_format.h"
|
2021-06-14 10:54:20 +02:00
|
|
|
#include "call/receive_stream.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/rtp_config.h"
|
2020-08-25 10:28:50 +02:00
|
|
|
#include "common_video/frame_counts.h"
|
2018-11-27 14:05:08 +01:00
|
|
|
#include "modules/rtp_rtcp/include/rtcp_statistics.h"
|
2017-12-15 14:40:10 +01:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class RtpPacketSinkInterface;
|
2018-09-28 09:07:24 +02:00
|
|
|
class VideoDecoderFactory;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
class VideoReceiveStream : public MediaReceiveStream {
|
2017-08-22 05:43:23 -07:00
|
|
|
public:
|
2019-12-03 14:31:45 +01:00
|
|
|
// Class for handling moving in/out recording state.
|
|
|
|
|
struct RecordingState {
|
|
|
|
|
RecordingState() = default;
|
|
|
|
|
explicit RecordingState(
|
|
|
|
|
std::function<void(const RecordableEncodedFrame&)> callback)
|
|
|
|
|
: callback(std::move(callback)) {}
|
|
|
|
|
|
|
|
|
|
// Callback stored from the VideoReceiveStream. The VideoReceiveStream
|
|
|
|
|
// client should not interpret the attribute.
|
|
|
|
|
std::function<void(const RecordableEncodedFrame&)> callback;
|
|
|
|
|
// Memento of when a keyframe request was last sent. The VideoReceiveStream
|
|
|
|
|
// client should not interpret the attribute.
|
|
|
|
|
absl::optional<int64_t> last_keyframe_request_ms;
|
|
|
|
|
};
|
|
|
|
|
|
2017-08-22 05:43:23 -07:00
|
|
|
// TODO(mflodman) Move all these settings to VideoDecoder and move the
|
|
|
|
|
// declaration to common_types.h.
|
|
|
|
|
struct Decoder {
|
2021-07-01 12:21:21 +02:00
|
|
|
Decoder(SdpVideoFormat video_format, int payload_type);
|
2017-08-22 05:43:23 -07:00
|
|
|
Decoder();
|
|
|
|
|
Decoder(const Decoder&);
|
|
|
|
|
~Decoder();
|
2021-07-01 12:21:21 +02:00
|
|
|
|
|
|
|
|
bool operator==(const Decoder& other) const;
|
|
|
|
|
|
2017-08-22 05:43:23 -07:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2018-09-11 15:56:04 +02:00
|
|
|
SdpVideoFormat video_format;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
// Received RTP packets with this payload type will be sent to this decoder
|
|
|
|
|
// instance.
|
|
|
|
|
int payload_type = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Stats {
|
|
|
|
|
Stats();
|
|
|
|
|
~Stats();
|
|
|
|
|
std::string ToString(int64_t time_ms) const;
|
|
|
|
|
|
|
|
|
|
int network_frame_rate = 0;
|
|
|
|
|
int decode_frame_rate = 0;
|
|
|
|
|
int render_frame_rate = 0;
|
|
|
|
|
uint32_t frames_rendered = 0;
|
|
|
|
|
|
|
|
|
|
// Decoder stats.
|
|
|
|
|
std::string decoder_implementation_name = "unknown";
|
|
|
|
|
FrameCounts frame_counts;
|
|
|
|
|
int decode_ms = 0;
|
|
|
|
|
int max_decode_ms = 0;
|
|
|
|
|
int current_delay_ms = 0;
|
|
|
|
|
int target_delay_ms = 0;
|
|
|
|
|
int jitter_buffer_ms = 0;
|
2019-05-28 17:38:08 +02:00
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferdelay
|
|
|
|
|
double jitter_buffer_delay_seconds = 0;
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferemittedcount
|
|
|
|
|
uint64_t jitter_buffer_emitted_count = 0;
|
2017-08-22 05:43:23 -07:00
|
|
|
int min_playout_delay_ms = 0;
|
|
|
|
|
int render_delay_ms = 10;
|
2017-08-23 05:24:10 -07:00
|
|
|
int64_t interframe_delay_max_ms = -1;
|
2019-08-26 15:04:43 +02:00
|
|
|
// Frames dropped due to decoding failures or if the system is too slow.
|
|
|
|
|
// https://www.w3.org/TR/webrtc-stats/#dom-rtcvideoreceiverstats-framesdropped
|
|
|
|
|
uint32_t frames_dropped = 0;
|
2017-08-22 05:43:23 -07:00
|
|
|
uint32_t frames_decoded = 0;
|
2019-07-01 10:07:50 +02:00
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
|
|
|
|
|
uint64_t total_decode_time_ms = 0;
|
2019-11-25 10:25:42 +01:00
|
|
|
// Total inter frame delay in seconds.
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalinterframedelay
|
|
|
|
|
double total_inter_frame_delay = 0;
|
|
|
|
|
// Total squared inter frame delay in seconds^2.
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalsqauredinterframedelay
|
|
|
|
|
double total_squared_inter_frame_delay = 0;
|
2018-12-10 09:55:17 -08:00
|
|
|
int64_t first_frame_received_to_decoded_ms = -1;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<uint64_t> qp_sum;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
int current_payload_type = -1;
|
|
|
|
|
|
|
|
|
|
int total_bitrate_bps = 0;
|
|
|
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
|
int height = 0;
|
|
|
|
|
|
2019-01-31 16:45:42 +01:00
|
|
|
uint32_t freeze_count = 0;
|
|
|
|
|
uint32_t pause_count = 0;
|
|
|
|
|
uint32_t total_freezes_duration_ms = 0;
|
|
|
|
|
uint32_t total_pauses_duration_ms = 0;
|
|
|
|
|
uint32_t total_frames_duration_ms = 0;
|
|
|
|
|
double sum_squared_frame_durations = 0.0;
|
|
|
|
|
|
2017-09-04 07:57:17 -07:00
|
|
|
VideoContentType content_type = VideoContentType::UNSPECIFIED;
|
|
|
|
|
|
2019-10-22 15:23:44 +02:00
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp
|
|
|
|
|
absl::optional<int64_t> estimated_playout_ntp_timestamp_ms;
|
2017-08-22 05:43:23 -07:00
|
|
|
int sync_offset_ms = std::numeric_limits<int>::max();
|
|
|
|
|
|
|
|
|
|
uint32_t ssrc = 0;
|
|
|
|
|
std::string c_name;
|
2019-08-22 09:40:25 +02:00
|
|
|
RtpReceiveStats rtp_stats;
|
2017-08-22 05:43:23 -07:00
|
|
|
RtcpPacketTypeCounter rtcp_packet_type_counts;
|
2017-09-04 03:35:40 -07:00
|
|
|
|
|
|
|
|
// Timing frame info: all important timestamps for a full lifetime of a
|
|
|
|
|
// single 'timing frame'.
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<webrtc::TimingFrameInfo> timing_frame_info;
|
2017-08-22 05:43:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Config {
|
|
|
|
|
private:
|
|
|
|
|
// Access to the copy constructor is private to force use of the Copy()
|
|
|
|
|
// method for those exceptional cases where we do use it.
|
|
|
|
|
Config(const Config&);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Config() = delete;
|
|
|
|
|
Config(Config&&);
|
2021-06-21 22:15:39 +02:00
|
|
|
Config(Transport* rtcp_send_transport,
|
|
|
|
|
VideoDecoderFactory* decoder_factory = nullptr);
|
2017-08-22 05:43:23 -07:00
|
|
|
Config& operator=(Config&&);
|
|
|
|
|
Config& operator=(const Config&) = delete;
|
|
|
|
|
~Config();
|
|
|
|
|
|
|
|
|
|
// Mostly used by tests. Avoid creating copies if you can.
|
|
|
|
|
Config Copy() const { return Config(*this); }
|
|
|
|
|
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
// Decoders for every payload that we can receive.
|
|
|
|
|
std::vector<Decoder> decoders;
|
|
|
|
|
|
2020-08-03 15:55:10 +00:00
|
|
|
// Ownership stays with WebrtcVideoEngine (delegated from PeerConnection).
|
|
|
|
|
VideoDecoderFactory* decoder_factory = nullptr;
|
|
|
|
|
|
2017-08-22 05:43:23 -07:00
|
|
|
// Receive-stream specific RTP settings.
|
2021-06-14 10:54:20 +02:00
|
|
|
struct Rtp : public RtpConfig {
|
2017-08-22 05:43:23 -07:00
|
|
|
Rtp();
|
|
|
|
|
Rtp(const Rtp&);
|
|
|
|
|
~Rtp();
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2021-06-14 10:54:20 +02:00
|
|
|
// See NackConfig for description.
|
|
|
|
|
NackConfig nack;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
// See RtcpMode for description.
|
|
|
|
|
RtcpMode rtcp_mode = RtcpMode::kCompound;
|
|
|
|
|
|
|
|
|
|
// Extended RTCP settings.
|
|
|
|
|
struct RtcpXr {
|
|
|
|
|
// True if RTCP Receiver Reference Time Report Block extension
|
|
|
|
|
// (RFC 3611) should be enabled.
|
|
|
|
|
bool receiver_reference_time_report = false;
|
|
|
|
|
} rtcp_xr;
|
|
|
|
|
|
2021-12-08 20:59:31 -08:00
|
|
|
// How to request keyframes from a remote sender. Applies only if lntf is
|
|
|
|
|
// disabled.
|
|
|
|
|
KeyFrameReqMethod keyframe_method = KeyFrameReqMethod::kPliRtcp;
|
|
|
|
|
|
2019-05-24 13:40:02 +02:00
|
|
|
// See LntfConfig for description.
|
|
|
|
|
LntfConfig lntf;
|
|
|
|
|
|
2017-09-26 02:49:21 -07:00
|
|
|
// Payload types for ULPFEC and RED, respectively.
|
|
|
|
|
int ulpfec_payload_type = -1;
|
|
|
|
|
int red_payload_type = -1;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
// SSRC for retransmissions.
|
|
|
|
|
uint32_t rtx_ssrc = 0;
|
|
|
|
|
|
|
|
|
|
// Set if the stream is protected using FlexFEC.
|
|
|
|
|
bool protected_by_flexfec = false;
|
|
|
|
|
|
2021-02-14 14:19:12 +01:00
|
|
|
// Optional callback sink to support additional packet handlsers such as
|
|
|
|
|
// FlexFec.
|
|
|
|
|
RtpPacketSinkInterface* packet_sink_ = nullptr;
|
|
|
|
|
|
2017-08-25 04:44:25 -07:00
|
|
|
// Map from rtx payload type -> media payload type.
|
2017-08-22 05:43:23 -07:00
|
|
|
// For RTX to be enabled, both an SSRC and this mapping are needed.
|
2017-08-25 04:44:25 -07:00
|
|
|
std::map<int, int> rtx_associated_payload_types;
|
|
|
|
|
|
2019-05-23 13:21:12 +02:00
|
|
|
// Payload types that should be depacketized using raw depacketizer
|
|
|
|
|
// (payload header will not be parsed and must not be present, additional
|
|
|
|
|
// meta data is expected to be present in generic frame descriptor
|
|
|
|
|
// RTP header extension).
|
|
|
|
|
std::set<int> raw_payload_types;
|
2017-08-22 05:43:23 -07:00
|
|
|
} rtp;
|
|
|
|
|
|
|
|
|
|
// Transport for outgoing packets (RTCP).
|
|
|
|
|
Transport* rtcp_send_transport = nullptr;
|
|
|
|
|
|
2019-01-23 09:47:50 +01:00
|
|
|
// Must always be set.
|
2017-08-22 05:43:23 -07:00
|
|
|
rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
|
|
|
|
|
|
|
|
|
|
// Expected delay needed by the renderer, i.e. the frame will be delivered
|
|
|
|
|
// this many milliseconds, if possible, earlier than the ideal render time.
|
|
|
|
|
int render_delay_ms = 10;
|
|
|
|
|
|
2019-01-23 09:47:50 +01:00
|
|
|
// If false, pass frames on to the renderer as soon as they are
|
2017-08-22 05:43:23 -07:00
|
|
|
// available.
|
2019-01-23 09:47:50 +01:00
|
|
|
bool enable_prerenderer_smoothing = true;
|
2017-08-22 05:43:23 -07:00
|
|
|
|
|
|
|
|
// Identifier for an A/V synchronization group. Empty string to disable.
|
|
|
|
|
// TODO(pbos): Synchronize streams in a sync group, not just video streams
|
|
|
|
|
// to one of the audio streams.
|
|
|
|
|
std::string sync_group;
|
|
|
|
|
|
|
|
|
|
// Target delay in milliseconds. A positive value indicates this stream is
|
|
|
|
|
// used for streaming instead of a real-time call.
|
|
|
|
|
int target_delay_ms = 0;
|
2018-09-28 09:07:24 +02:00
|
|
|
|
2018-10-17 17:27:25 -07:00
|
|
|
// An optional custom frame decryptor that allows the entire frame to be
|
|
|
|
|
// decrypted in whatever way the caller choses. This is not required by
|
|
|
|
|
// default.
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor;
|
|
|
|
|
|
|
|
|
|
// Per PeerConnection cryptography options.
|
|
|
|
|
CryptoOptions crypto_options;
|
2020-02-28 16:02:06 +01:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer;
|
2017-08-22 05:43:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TODO(pbos): Add info on currently-received codec to Stats.
|
|
|
|
|
virtual Stats GetStats() const = 0;
|
|
|
|
|
|
2019-02-27 15:32:48 +01:00
|
|
|
// Sets a base minimum for the playout delay. Base minimum delay sets lower
|
|
|
|
|
// bound on minimum delay value determining lower bound on playout delay.
|
|
|
|
|
//
|
|
|
|
|
// Returns true if value was successfully set, false overwise.
|
|
|
|
|
virtual bool SetBaseMinimumPlayoutDelayMs(int delay_ms) = 0;
|
|
|
|
|
|
|
|
|
|
// Returns current value of base minimum delay in milliseconds.
|
|
|
|
|
virtual int GetBaseMinimumPlayoutDelayMs() const = 0;
|
|
|
|
|
|
2019-12-03 14:31:45 +01:00
|
|
|
// Sets and returns recording state. The old state is moved out
|
2021-07-26 12:40:21 +02:00
|
|
|
// of the video receive stream and returned to the caller, and `state`
|
2019-12-03 14:31:45 +01:00
|
|
|
// is moved in. If the state's callback is set, it will be called with
|
|
|
|
|
// recordable encoded frames as they arrive.
|
2021-07-26 12:40:21 +02:00
|
|
|
// If `generate_key_frame` is true, the method will generate a key frame.
|
2019-12-03 14:31:45 +01:00
|
|
|
// When the function returns, it's guaranteed that all old callouts
|
|
|
|
|
// to the returned callback has ceased.
|
|
|
|
|
// Note: the client should not interpret the returned state's attributes, but
|
|
|
|
|
// instead treat it as opaque data.
|
|
|
|
|
virtual RecordingState SetAndGetRecordingState(RecordingState state,
|
|
|
|
|
bool generate_key_frame) = 0;
|
|
|
|
|
|
|
|
|
|
// Cause eventual generation of a key frame from the sender.
|
|
|
|
|
virtual void GenerateKeyFrame() = 0;
|
|
|
|
|
|
2017-08-22 05:43:23 -07:00
|
|
|
protected:
|
|
|
|
|
virtual ~VideoReceiveStream() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // CALL_VIDEO_RECEIVE_STREAM_H_
|