123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- #ifndef RTP_HEADER_EXTENSION_DEFINES_H_
- #define RTP_HEADER_EXTENSION_DEFINES_H_
- #include <stdint.h>
- #include <vector>
- #include <string>
- // This enum must not have any gaps, i.e., all integers between
- // kRtpExtensionNone and kRtpExtensionNumberOfExtensions must be valid enum
- // entries.
- enum RTPExtensionType {
- kRtpExtensionNone,
- kRtpExtensionTransmissionTimeOffset,
- kRtpExtensionAudioLevel,
- kRtpExtensionAbsoluteSendTime,
- kRtpExtensionVideoRotation,
- kRtpExtensionTransportSequenceNumber,
- kRtpExtensionPlayoutDelay,
- kRtpExtensionVideoContentType,
- kRtpExtensionRtpStreamId,
- kRtpExtensionRepairedRtpStreamId,
- kRtpExtensionMid,
- kRtpExtensionNumberOfExtensions // Must be the last entity in the enum.
- };
- // enum for clockwise rotation.
- enum VideoRotation {
- kVideoRotation_0 = 0,
- kVideoRotation_90 = 90,
- kVideoRotation_180 = 180,
- kVideoRotation_270 = 270
- };
- // Please refer to http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/
- // 12.07.00_60/ts_126114v120700p.pdf Section 7.4.5. The rotation of a frame is
- // the clockwise angle the frames must be rotated in order to display the frames
- // correctly if the display is rotated in its natural orientation.
- inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
- switch (rotation) {
- case kVideoRotation_0:
- return 0;
- case kVideoRotation_90:
- return 1;
- case kVideoRotation_180:
- return 2;
- case kVideoRotation_270:
- return 3;
- }
- return 0;
- }
- inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t cvo_byte) {
- // CVO byte: |0 0 0 0 C F R R|.
- const uint8_t rotation_bits = cvo_byte & 0x3;
- switch (rotation_bits) {
- case 0:
- return kVideoRotation_0;
- case 1:
- return kVideoRotation_90;
- case 2:
- return kVideoRotation_180;
- case 3:
- return kVideoRotation_270;
- default:
- return kVideoRotation_0;
- }
- }
- // Minimum and maximum playout delay values from capture to render.
- // These are best effort values.
- //
- // A value < 0 indicates no change from previous valid value.
- //
- // min = max = 0 indicates that the receiver should try and render
- // frame as soon as possible.
- //
- // min = x, max = y indicates that the receiver is free to adapt
- // in the range (x, y) based on network jitter.
- //
- // Note: Given that this gets embedded in a union, it is up-to the owner to
- // initialize these values.
- struct PlayoutDelay {
- int min_ms;
- int max_ms;
- };
- enum VideoContentType {
- UNSPECIFIED = 0,
- SCREENSHARE = 1,
- };
- struct RTPHeaderExtension {
- RTPHeaderExtension();
- bool hasTransmissionTimeOffset;
- int32_t transmissionTimeOffset;
- bool hasAbsoluteSendTime;
- uint32_t absoluteSendTime;
- bool hasTransportSequenceNumber;
- uint16_t transportSequenceNumber;
- // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
- // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
- bool hasAudioLevel;
- bool voiceActivity;
- uint8_t audioLevel;
- // For Coordination of Video Orientation. See
- // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
- // ts_126114v120700p.pdf
- bool hasVideoRotation;
- VideoRotation videoRotation;
- // TODO(ilnik): Refactor this and one above to be absl::optional() and remove
- // a corresponding bool flag.
- bool hasVideoContentType;
- VideoContentType videoContentType;
- PlayoutDelay playout_delay;
- // For identification of a stream when ssrc is not signaled. See
- // https://tools.ietf.org/html/draft-ietf-avtext-rid-09
- // TODO(danilchap): Update url from draft to release version.
- std::string stream_id;
- std::string repaired_stream_id;
- // For identifying the media section used to interpret this RTP packet. See
- // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-38
- std::string mid;
- };
- // RTP header extension, see RFC8285.
- struct RtpExtension {
- RtpExtension();
- RtpExtension(const std::string& uri, int id);
- RtpExtension(const std::string& uri, int id, bool encrypt);
- ~RtpExtension();
- bool operator==(const RtpExtension& rhs) const {
- return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
- }
- static bool IsSupportedForAudio(const std::string& uri);
- static bool IsSupportedForVideo(const std::string& uri);
- // Return "true" if the given RTP header extension URI may be encrypted.
- static bool IsEncryptionSupported(const std::string& uri);
- // Returns the named header extension if found among all extensions,
- // nullptr otherwise.
- static const RtpExtension* FindHeaderExtensionByUri(
- const std::vector<RtpExtension>& extensions,
- const std::string& uri);
- // Header extension for audio levels, as defined in:
- // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
- static const char kAudioLevelUri[];
- // Header extension for RTP timestamp offset, see RFC 5450 for details:
- // http://tools.ietf.org/html/rfc5450
- static const char kTimestampOffsetUri[];
- // Header extension for absolute send time, see url for details:
- // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
- static const char kAbsSendTimeUri[];
- // Header extension for coordination of video orientation, see url for
- // details:
- // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
- static const char kVideoRotationUri[];
- // Header extension for video content type. E.g. default or screenshare.
- static const char kVideoContentTypeUri[];
- // Header extension for transport sequence number, see url for details:
- // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
- static const char kTransportSequenceNumberUri[];
- static const char kPlayoutDelayUri[];
- // Header extension for identifying media section within a transport.
- // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-49#section-15
- static const char kMidUri[];
- // Encryption of Header Extensions, see RFC 6904 for details:
- // https://tools.ietf.org/html/rfc6904
- static const char kEncryptHeaderExtensionsUri[];
- // Header extension for RIDs and Repaired RIDs
- // https://tools.ietf.org/html/draft-ietf-avtext-rid-09
- // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15
- static const char kRidUri[];
- static const char kRepairedRidUri[];
- // Inclusive min and max IDs for two-byte header extensions and one-byte
- // header extensions, per RFC8285 Section 4.2-4.3.
- static const int kMinId = 1;
- static const int kMaxId = 255;
- static const int kMaxValueSize = 255;
- static const int kOneByteHeaderExtensionMaxId = 10;//14;
- static const int kOneByteHeaderExtensionMaxValueSize = 16;
- std::string uri;
- int id;
- bool encrypt;
- };
- #endif // RTP_HEADER_EXTENSION_DEFINES_H_
|