OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_COMMON_TYPES_H_ | 11 #ifndef WEBRTC_COMMON_TYPES_H_ |
12 #define WEBRTC_COMMON_TYPES_H_ | 12 #define WEBRTC_COMMON_TYPES_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 #include <string.h> | 15 #include <string.h> |
16 | 16 |
17 #include <ostream> | 17 #include <ostream> |
18 #include <string> | 18 #include <string> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "webrtc/api/video/video_content_type.h" | 21 #include "webrtc/api/video/video_content_type.h" |
22 #include "webrtc/api/video/video_rotation.h" | 22 #include "webrtc/api/video/video_rotation.h" |
| 23 #include "webrtc/base/array_view.h" |
23 #include "webrtc/base/checks.h" | 24 #include "webrtc/base/checks.h" |
24 #include "webrtc/base/optional.h" | 25 #include "webrtc/base/optional.h" |
25 #include "webrtc/typedefs.h" | 26 #include "webrtc/typedefs.h" |
26 | 27 |
27 #if defined(_MSC_VER) | 28 #if defined(_MSC_VER) |
28 // Disable "new behavior: elements of array will be default initialized" | 29 // Disable "new behavior: elements of array will be default initialized" |
29 // warning. Affects OverUseDetectorOptions. | 30 // warning. Affects OverUseDetectorOptions. |
30 #pragma warning(disable : 4351) | 31 #pragma warning(disable : 4351) |
31 #endif | 32 #endif |
32 | 33 |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // min = x, max = y indicates that the receiver is free to adapt | 689 // min = x, max = y indicates that the receiver is free to adapt |
689 // in the range (x, y) based on network jitter. | 690 // in the range (x, y) based on network jitter. |
690 // | 691 // |
691 // Note: Given that this gets embedded in a union, it is up-to the owner to | 692 // Note: Given that this gets embedded in a union, it is up-to the owner to |
692 // initialize these values. | 693 // initialize these values. |
693 struct PlayoutDelay { | 694 struct PlayoutDelay { |
694 int min_ms; | 695 int min_ms; |
695 int max_ms; | 696 int max_ms; |
696 }; | 697 }; |
697 | 698 |
| 699 // Class to represent RtpStreamId which is a string. |
| 700 // Unlike std::string, it can be copied with memcpy and cleared with memset. |
| 701 // Empty value represent unset RtpStreamId. |
| 702 class StreamId { |
| 703 public: |
| 704 // Stream id is limited to 16 bytes because it is the maximum length |
| 705 // that can be encoded with one-byte header extensions. |
| 706 static constexpr size_t kMaxSize = 16; |
| 707 |
| 708 StreamId() { value_[0] = 0; } |
| 709 explicit StreamId(rtc::ArrayView<const char> value) { |
| 710 Set(value.data(), value.size()); |
| 711 } |
| 712 StreamId(const StreamId&) = default; |
| 713 StreamId& operator=(const StreamId&) = default; |
| 714 |
| 715 bool empty() const { return value_[0] == 0; } |
| 716 const char* data() const { return value_; } |
| 717 size_t size() const { return strnlen(value_, kMaxSize); } |
| 718 |
| 719 void Set(rtc::ArrayView<const uint8_t> value) { |
| 720 Set(reinterpret_cast<const char*>(value.data()), value.size()); |
| 721 } |
| 722 void Set(const char* data, size_t size); |
| 723 |
| 724 friend bool operator==(const StreamId& lhs, const StreamId& rhs) { |
| 725 return strncmp(lhs.value_, rhs.value_, kMaxSize) == 0; |
| 726 } |
| 727 friend bool operator!=(const StreamId& lhs, const StreamId& rhs) { |
| 728 return !(lhs == rhs); |
| 729 } |
| 730 |
| 731 private: |
| 732 char value_[kMaxSize]; |
| 733 }; |
| 734 |
698 struct RTPHeaderExtension { | 735 struct RTPHeaderExtension { |
699 RTPHeaderExtension(); | 736 RTPHeaderExtension(); |
700 | 737 |
701 bool hasTransmissionTimeOffset; | 738 bool hasTransmissionTimeOffset; |
702 int32_t transmissionTimeOffset; | 739 int32_t transmissionTimeOffset; |
703 bool hasAbsoluteSendTime; | 740 bool hasAbsoluteSendTime; |
704 uint32_t absoluteSendTime; | 741 uint32_t absoluteSendTime; |
705 bool hasTransportSequenceNumber; | 742 bool hasTransportSequenceNumber; |
706 uint16_t transportSequenceNumber; | 743 uint16_t transportSequenceNumber; |
707 | 744 |
708 // Audio Level includes both level in dBov and voiced/unvoiced bit. See: | 745 // Audio Level includes both level in dBov and voiced/unvoiced bit. See: |
709 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ | 746 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
710 bool hasAudioLevel; | 747 bool hasAudioLevel; |
711 bool voiceActivity; | 748 bool voiceActivity; |
712 uint8_t audioLevel; | 749 uint8_t audioLevel; |
713 | 750 |
714 // For Coordination of Video Orientation. See | 751 // For Coordination of Video Orientation. See |
715 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 752 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
716 // ts_126114v120700p.pdf | 753 // ts_126114v120700p.pdf |
717 bool hasVideoRotation; | 754 bool hasVideoRotation; |
718 VideoRotation videoRotation; | 755 VideoRotation videoRotation; |
719 | 756 |
720 // TODO(ilnik): Refactor this and one above to be rtc::Optional() and remove | 757 // TODO(ilnik): Refactor this and one above to be rtc::Optional() and remove |
721 // a corresponding bool flag. | 758 // a corresponding bool flag. |
722 bool hasVideoContentType; | 759 bool hasVideoContentType; |
723 VideoContentType videoContentType; | 760 VideoContentType videoContentType; |
724 | 761 |
725 PlayoutDelay playout_delay = {-1, -1}; | 762 PlayoutDelay playout_delay = {-1, -1}; |
| 763 |
| 764 // For identification of a stream when ssrc is not signaled. See |
| 765 // https://tools.ietf.org/html/draft-ietf-avtext-rid-09 |
| 766 // TODO(danilchap): Update url from draft to release version. |
| 767 StreamId stream_id; |
| 768 StreamId repaired_stream_id; |
726 }; | 769 }; |
727 | 770 |
728 struct RTPHeader { | 771 struct RTPHeader { |
729 RTPHeader(); | 772 RTPHeader(); |
730 | 773 |
731 bool markerBit; | 774 bool markerBit; |
732 uint8_t payloadType; | 775 uint8_t payloadType; |
733 uint16_t sequenceNumber; | 776 uint16_t sequenceNumber; |
734 uint32_t timestamp; | 777 uint32_t timestamp; |
735 uint32_t ssrc; | 778 uint32_t ssrc; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 enum class RtcpMode { kOff, kCompound, kReducedSize }; | 884 enum class RtcpMode { kOff, kCompound, kReducedSize }; |
842 | 885 |
843 enum NetworkState { | 886 enum NetworkState { |
844 kNetworkUp, | 887 kNetworkUp, |
845 kNetworkDown, | 888 kNetworkDown, |
846 }; | 889 }; |
847 | 890 |
848 } // namespace webrtc | 891 } // namespace webrtc |
849 | 892 |
850 #endif // WEBRTC_COMMON_TYPES_H_ | 893 #endif // WEBRTC_COMMON_TYPES_H_ |
OLD | NEW |