123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- #ifndef CALL_VIDEO_RECEIVE_STREAM_H_
- #define CALL_VIDEO_RECEIVE_STREAM_H_
- #include <limits>
- #include <map>
- #include <set>
- #include <string>
- #include <utility>
- #include <vector>
- #include "api/call/transport.h"
- #include "api/crypto/crypto_options.h"
- #include "api/crypto/frame_decryptor_interface.h"
- #include "api/frame_transformer_interface.h"
- #include "api/rtp_headers.h"
- #include "api/rtp_parameters.h"
- #include "api/transport/rtp/rtp_source.h"
- #include "api/video/recordable_encoded_frame.h"
- #include "api/video/video_content_type.h"
- #include "api/video/video_frame.h"
- #include "api/video/video_sink_interface.h"
- #include "api/video/video_timing.h"
- #include "api/video_codecs/sdp_video_format.h"
- #include "call/rtp_config.h"
- #include "common_video/frame_counts.h"
- #include "modules/rtp_rtcp/include/rtcp_statistics.h"
- #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
- namespace webrtc {
- class RtpPacketSinkInterface;
- class VideoDecoderFactory;
- class VideoReceiveStream {
- public:
-
- struct RecordingState {
- RecordingState() = default;
- explicit RecordingState(
- std::function<void(const RecordableEncodedFrame&)> callback)
- : callback(std::move(callback)) {}
-
-
- std::function<void(const RecordableEncodedFrame&)> callback;
-
-
-
-
- bool keyframe_needed = false;
-
-
- absl::optional<int64_t> last_keyframe_request_ms;
- };
-
-
- struct Decoder {
- Decoder();
- Decoder(const Decoder&);
- ~Decoder();
- std::string ToString() const;
- SdpVideoFormat video_format;
-
-
- 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;
-
- 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;
-
- double jitter_buffer_delay_seconds = 0;
-
- uint64_t jitter_buffer_emitted_count = 0;
- int min_playout_delay_ms = 0;
- int render_delay_ms = 10;
- int64_t interframe_delay_max_ms = -1;
-
-
- uint32_t frames_dropped = 0;
- uint32_t frames_decoded = 0;
-
- uint64_t total_decode_time_ms = 0;
-
-
- double total_inter_frame_delay = 0;
-
-
- double total_squared_inter_frame_delay = 0;
- int64_t first_frame_received_to_decoded_ms = -1;
- absl::optional<uint64_t> qp_sum;
- int current_payload_type = -1;
- int total_bitrate_bps = 0;
- int width = 0;
- int height = 0;
- 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;
- VideoContentType content_type = VideoContentType::UNSPECIFIED;
-
- absl::optional<int64_t> estimated_playout_ntp_timestamp_ms;
- int sync_offset_ms = std::numeric_limits<int>::max();
- uint32_t ssrc = 0;
- std::string c_name;
- RtpReceiveStats rtp_stats;
- RtcpPacketTypeCounter rtcp_packet_type_counts;
-
-
- absl::optional<webrtc::TimingFrameInfo> timing_frame_info;
- };
- struct Config {
- private:
-
-
- Config(const Config&);
- public:
- Config() = delete;
- Config(Config&&);
- explicit Config(Transport* rtcp_send_transport);
- Config& operator=(Config&&);
- Config& operator=(const Config&) = delete;
- ~Config();
-
- Config Copy() const { return Config(*this); }
- std::string ToString() const;
-
- std::vector<Decoder> decoders;
-
- VideoDecoderFactory* decoder_factory = nullptr;
-
- struct Rtp {
- Rtp();
- Rtp(const Rtp&);
- ~Rtp();
- std::string ToString() const;
-
- uint32_t remote_ssrc = 0;
-
- uint32_t local_ssrc = 0;
-
- RtcpMode rtcp_mode = RtcpMode::kCompound;
-
- struct RtcpXr {
-
-
- bool receiver_reference_time_report = false;
- } rtcp_xr;
-
- bool transport_cc = false;
-
- LntfConfig lntf;
-
- NackConfig nack;
-
- int ulpfec_payload_type = -1;
- int red_payload_type = -1;
-
- uint32_t rtx_ssrc = 0;
-
- bool protected_by_flexfec = false;
-
-
- std::map<int, int> rtx_associated_payload_types;
-
-
-
-
- std::set<int> raw_payload_types;
-
- std::vector<RtpExtension> extensions;
- } rtp;
-
- Transport* rtcp_send_transport = nullptr;
-
- rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
-
-
- int render_delay_ms = 10;
-
-
- bool enable_prerenderer_smoothing = true;
-
-
-
- std::string sync_group;
-
-
- int target_delay_ms = 0;
-
-
- std::string stream_id;
-
-
-
- rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor;
-
- CryptoOptions crypto_options;
- rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer;
- };
-
-
- virtual void Start() = 0;
-
-
- virtual void Stop() = 0;
-
- virtual Stats GetStats() const = 0;
-
-
-
-
- virtual void AddSecondarySink(RtpPacketSinkInterface* sink) = 0;
- virtual void RemoveSecondarySink(const RtpPacketSinkInterface* sink) = 0;
- virtual std::vector<RtpSource> GetSources() const = 0;
-
-
-
-
- virtual bool SetBaseMinimumPlayoutDelayMs(int delay_ms) = 0;
-
- virtual int GetBaseMinimumPlayoutDelayMs() const = 0;
-
-
- virtual void SetFrameDecryptor(
- rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor) = 0;
-
-
- virtual void SetDepacketizerToDecoderFrameTransformer(
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
-
-
-
-
-
-
-
-
-
- virtual RecordingState SetAndGetRecordingState(RecordingState state,
- bool generate_key_frame) = 0;
-
- virtual void GenerateKeyFrame() = 0;
- protected:
- virtual ~VideoReceiveStream() {}
- };
- }
- #endif
|