123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- #ifndef API_RTP_PARAMETERS_H_
- #define API_RTP_PARAMETERS_H_
- #include <stdint.h>
- #include <map>
- #include <string>
- #include <vector>
- #include "absl/strings/string_view.h"
- #include "absl/types/optional.h"
- #include "api/media_types.h"
- #include "api/priority.h"
- #include "api/rtp_transceiver_direction.h"
- #include "rtc_base/system/rtc_export.h"
- namespace webrtc {
- enum class FecMechanism {
- RED,
- RED_AND_ULPFEC,
- FLEXFEC,
- };
- enum class RtcpFeedbackType {
- CCM,
- LNTF,
- NACK,
- REMB,
- TRANSPORT_CC,
- };
- enum class RtcpFeedbackMessageType {
-
- GENERIC_NACK,
- PLI,
- FIR,
- };
- enum class DtxStatus {
- DISABLED,
- ENABLED,
- };
- enum class DegradationPreference {
-
-
- DISABLED,
-
- MAINTAIN_FRAMERATE,
-
- MAINTAIN_RESOLUTION,
-
- BALANCED,
- };
- RTC_EXPORT const char* DegradationPreferenceToString(
- DegradationPreference degradation_preference);
- RTC_EXPORT extern const double kDefaultBitratePriority;
- struct RTC_EXPORT RtcpFeedback {
- RtcpFeedbackType type = RtcpFeedbackType::CCM;
-
-
-
-
- absl::optional<RtcpFeedbackMessageType> message_type;
-
- RtcpFeedback();
- explicit RtcpFeedback(RtcpFeedbackType type);
- RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
- RtcpFeedback(const RtcpFeedback&);
- ~RtcpFeedback();
- bool operator==(const RtcpFeedback& o) const {
- return type == o.type && message_type == o.message_type;
- }
- bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpCodecCapability {
- RtpCodecCapability();
- ~RtpCodecCapability();
-
- std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
-
- std::string name;
-
- cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
-
- absl::optional<int> clock_rate;
-
-
- absl::optional<int> preferred_payload_type;
-
-
- absl::optional<int> max_ptime;
-
-
- absl::optional<int> ptime;
-
- absl::optional<int> num_channels;
-
- std::vector<RtcpFeedback> rtcp_feedback;
-
-
-
-
-
-
-
- std::map<std::string, std::string> parameters;
-
-
-
- std::map<std::string, std::string> options;
-
-
-
- int max_temporal_layer_extensions = 0;
-
-
-
- int max_spatial_layer_extensions = 0;
-
-
-
-
- bool svc_multi_stream_support = false;
- bool operator==(const RtpCodecCapability& o) const {
- return name == o.name && kind == o.kind && clock_rate == o.clock_rate &&
- preferred_payload_type == o.preferred_payload_type &&
- max_ptime == o.max_ptime && ptime == o.ptime &&
- num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback &&
- parameters == o.parameters && options == o.options &&
- max_temporal_layer_extensions == o.max_temporal_layer_extensions &&
- max_spatial_layer_extensions == o.max_spatial_layer_extensions &&
- svc_multi_stream_support == o.svc_multi_stream_support;
- }
- bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpHeaderExtensionCapability {
-
- std::string uri;
-
- absl::optional<int> preferred_id;
-
-
- bool preferred_encrypt = false;
-
-
-
- RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv;
-
- RtpHeaderExtensionCapability();
- explicit RtpHeaderExtensionCapability(absl::string_view uri);
- RtpHeaderExtensionCapability(absl::string_view uri, int preferred_id);
- RtpHeaderExtensionCapability(absl::string_view uri,
- int preferred_id,
- RtpTransceiverDirection direction);
- ~RtpHeaderExtensionCapability();
- bool operator==(const RtpHeaderExtensionCapability& o) const {
- return uri == o.uri && preferred_id == o.preferred_id &&
- preferred_encrypt == o.preferred_encrypt && direction == o.direction;
- }
- bool operator!=(const RtpHeaderExtensionCapability& o) const {
- return !(*this == o);
- }
- };
- struct RTC_EXPORT RtpExtension {
- RtpExtension();
- RtpExtension(absl::string_view uri, int id);
- RtpExtension(absl::string_view uri, int id, bool encrypt);
- ~RtpExtension();
- std::string ToString() const;
- bool operator==(const RtpExtension& rhs) const {
- return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
- }
- static bool IsSupportedForAudio(absl::string_view uri);
- static bool IsSupportedForVideo(absl::string_view uri);
-
- static bool IsEncryptionSupported(absl::string_view uri);
-
-
- static const RtpExtension* FindHeaderExtensionByUri(
- const std::vector<RtpExtension>& extensions,
- absl::string_view uri);
-
-
-
- static std::vector<RtpExtension> FilterDuplicateNonEncrypted(
- const std::vector<RtpExtension>& extensions);
-
-
- static constexpr char kEncryptHeaderExtensionsUri[] =
- "urn:ietf:params:rtp-hdrext:encrypt";
-
-
- static constexpr char kAudioLevelUri[] =
- "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
-
-
- static constexpr char kTimestampOffsetUri[] =
- "urn:ietf:params:rtp-hdrext:toffset";
-
-
- static constexpr char kAbsSendTimeUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
-
-
- static constexpr char kAbsoluteCaptureTimeUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time";
-
-
-
- static constexpr char kVideoRotationUri[] = "urn:3gpp:video-orientation";
-
- static constexpr char kVideoContentTypeUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type";
-
- static constexpr char kVideoTimingUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/video-timing";
-
- static constexpr char kGenericFrameDescriptorUri00[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/"
- "generic-frame-descriptor-00";
- static constexpr char kDependencyDescriptorUri[] =
- "https://aomediacodec.github.io/av1-rtp-spec/"
- "#dependency-descriptor-rtp-header-extension";
-
-
- static constexpr char kTransportSequenceNumberUri[] =
- "http://www.ietf.org/id/"
- "draft-holmer-rmcat-transport-wide-cc-extensions-01";
- static constexpr char kTransportSequenceNumberV2Uri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/transport-wide-cc-02";
-
-
-
-
- static constexpr char kPlayoutDelayUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
-
- static constexpr char kColorSpaceUri[] =
- "http://www.webrtc.org/experiments/rtp-hdrext/color-space";
-
-
- static constexpr char kMidUri[] = "urn:ietf:params:rtp-hdrext:sdes:mid";
-
-
-
- static constexpr char kRidUri[] =
- "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id";
- static constexpr char kRepairedRidUri[] =
- "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id";
-
-
- static constexpr int kMinId = 1;
- static constexpr int kMaxId = 255;
- static constexpr int kMaxValueSize = 255;
- static constexpr int kOneByteHeaderExtensionMaxId = 14;
- static constexpr int kOneByteHeaderExtensionMaxValueSize = 16;
- std::string uri;
- int id = 0;
- bool encrypt = false;
- };
- struct RTC_EXPORT RtpFecParameters {
-
-
- absl::optional<uint32_t> ssrc;
- FecMechanism mechanism = FecMechanism::RED;
-
- RtpFecParameters();
- explicit RtpFecParameters(FecMechanism mechanism);
- RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
- RtpFecParameters(const RtpFecParameters&);
- ~RtpFecParameters();
- bool operator==(const RtpFecParameters& o) const {
- return ssrc == o.ssrc && mechanism == o.mechanism;
- }
- bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpRtxParameters {
-
-
- absl::optional<uint32_t> ssrc;
-
- RtpRtxParameters();
- explicit RtpRtxParameters(uint32_t ssrc);
- RtpRtxParameters(const RtpRtxParameters&);
- ~RtpRtxParameters();
- bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
- bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpEncodingParameters {
- RtpEncodingParameters();
- RtpEncodingParameters(const RtpEncodingParameters&);
- ~RtpEncodingParameters();
-
-
-
-
-
-
- absl::optional<uint32_t> ssrc;
-
-
-
-
-
-
-
-
-
-
-
-
- double bitrate_priority = kDefaultBitratePriority;
-
-
-
-
-
-
- Priority network_priority = Priority::kLow;
-
-
-
-
-
-
-
-
-
-
-
- absl::optional<int> max_bitrate_bps;
-
- absl::optional<int> min_bitrate_bps;
-
- absl::optional<double> max_framerate;
-
-
-
-
-
- absl::optional<int> num_temporal_layers;
-
- absl::optional<double> scale_resolution_down_by;
-
-
-
-
-
-
- bool active = true;
-
-
- std::string rid;
-
-
- bool adaptive_ptime = false;
- bool operator==(const RtpEncodingParameters& o) const {
- return ssrc == o.ssrc && bitrate_priority == o.bitrate_priority &&
- network_priority == o.network_priority &&
- max_bitrate_bps == o.max_bitrate_bps &&
- min_bitrate_bps == o.min_bitrate_bps &&
- max_framerate == o.max_framerate &&
- num_temporal_layers == o.num_temporal_layers &&
- scale_resolution_down_by == o.scale_resolution_down_by &&
- active == o.active && rid == o.rid &&
- adaptive_ptime == o.adaptive_ptime;
- }
- bool operator!=(const RtpEncodingParameters& o) const {
- return !(*this == o);
- }
- };
- struct RTC_EXPORT RtpCodecParameters {
- RtpCodecParameters();
- RtpCodecParameters(const RtpCodecParameters&);
- ~RtpCodecParameters();
-
- std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
-
- std::string name;
-
- cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
-
-
-
- int payload_type = 0;
-
- absl::optional<int> clock_rate;
-
-
-
-
-
- absl::optional<int> num_channels;
-
-
-
- absl::optional<int> max_ptime;
-
-
-
- absl::optional<int> ptime;
-
-
- std::vector<RtcpFeedback> rtcp_feedback;
-
-
-
-
-
-
-
- std::map<std::string, std::string> parameters;
- bool operator==(const RtpCodecParameters& o) const {
- return name == o.name && kind == o.kind && payload_type == o.payload_type &&
- clock_rate == o.clock_rate && num_channels == o.num_channels &&
- max_ptime == o.max_ptime && ptime == o.ptime &&
- rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
- }
- bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpCapabilities {
- RtpCapabilities();
- ~RtpCapabilities();
-
- std::vector<RtpCodecCapability> codecs;
-
- std::vector<RtpHeaderExtensionCapability> header_extensions;
-
-
-
- std::vector<FecMechanism> fec;
- bool operator==(const RtpCapabilities& o) const {
- return codecs == o.codecs && header_extensions == o.header_extensions &&
- fec == o.fec;
- }
- bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
- };
- struct RtcpParameters final {
- RtcpParameters();
- RtcpParameters(const RtcpParameters&);
- ~RtcpParameters();
-
-
-
- absl::optional<uint32_t> ssrc;
-
-
-
-
-
-
-
-
-
- std::string cname;
-
- bool reduced_size = false;
-
-
- bool mux = true;
- bool operator==(const RtcpParameters& o) const {
- return ssrc == o.ssrc && cname == o.cname &&
- reduced_size == o.reduced_size && mux == o.mux;
- }
- bool operator!=(const RtcpParameters& o) const { return !(*this == o); }
- };
- struct RTC_EXPORT RtpParameters {
- RtpParameters();
- RtpParameters(const RtpParameters&);
- ~RtpParameters();
-
-
-
- std::string transaction_id;
-
-
-
- std::string mid;
- std::vector<RtpCodecParameters> codecs;
- std::vector<RtpExtension> header_extensions;
- std::vector<RtpEncodingParameters> encodings;
-
-
-
- RtcpParameters rtcp;
-
-
-
- absl::optional<DegradationPreference> degradation_preference;
- bool operator==(const RtpParameters& o) const {
- return mid == o.mid && codecs == o.codecs &&
- header_extensions == o.header_extensions &&
- encodings == o.encodings && rtcp == o.rtcp &&
- degradation_preference == o.degradation_preference;
- }
- bool operator!=(const RtpParameters& o) const { return !(*this == o); }
- };
- }
- #endif
|