OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 | 11 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
14 | 14 |
15 #include <map> | 15 #include <map> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
25 #include "webrtc/typedefs.h" | 26 #include "webrtc/typedefs.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 namespace rtcp { | 29 namespace rtcp { |
29 | 30 |
30 static const int kCommonFbFmtLength = 12; | 31 static const int kCommonFbFmtLength = 12; |
31 static const int kReportBlockLength = 24; | 32 static const int kReportBlockLength = 24; |
32 | 33 |
33 class Dlrr; | |
34 class RawPacket; | 34 class RawPacket; |
35 | 35 |
36 // Class for building RTCP packets. | 36 // Class for building RTCP packets. |
37 // | 37 // |
38 // Example: | 38 // Example: |
39 // ReportBlock report_block; | 39 // ReportBlock report_block; |
40 // report_block.To(234) | 40 // report_block.To(234) |
41 // report_block.FractionLost(10); | 41 // report_block.FractionLost(10); |
42 // | 42 // |
43 // ReceiverReport rr; | 43 // ReceiverReport rr; |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } | 672 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } |
673 | 673 |
674 size_t DlrrLength() const; | 674 size_t DlrrLength() const; |
675 | 675 |
676 size_t VoipMetricLength() const { | 676 size_t VoipMetricLength() const { |
677 return VoipMetric::kLength * voip_metric_blocks_.size(); | 677 return VoipMetric::kLength * voip_metric_blocks_.size(); |
678 } | 678 } |
679 | 679 |
680 RTCPUtility::RTCPPacketXR xr_header_; | 680 RTCPUtility::RTCPPacketXR xr_header_; |
681 std::vector<Rrtr> rrtr_blocks_; | 681 std::vector<Rrtr> rrtr_blocks_; |
682 std::vector<DlrrBlock> dlrr_blocks_; | 682 std::vector<Dlrr> dlrr_blocks_; |
683 std::vector<VoipMetric> voip_metric_blocks_; | 683 std::vector<VoipMetric> voip_metric_blocks_; |
684 | 684 |
685 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); | 685 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); |
686 }; | 686 }; |
687 | 687 |
688 // DLRR Report Block (RFC 3611). | |
689 // | |
690 // 0 1 2 3 | |
691 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
692 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
693 // | BT=5 | reserved | block length | | |
694 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
695 // | SSRC_1 (SSRC of first receiver) | sub- | |
696 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block | |
697 // | last RR (LRR) | 1 | |
698 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
699 // | delay since last RR (DLRR) | | |
700 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
701 // | SSRC_2 (SSRC of second receiver) | sub- | |
702 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block | |
703 // : ... : 2 | |
704 | |
705 class Dlrr { | |
706 public: | |
707 Dlrr() {} | |
708 ~Dlrr() {} | |
709 | |
710 // Max 100 DLRR Items can be added per DLRR report block. | |
711 bool WithDlrrItem(uint32_t ssrc, uint32_t last_rr, uint32_t delay_last_rr); | |
712 | |
713 private: | |
714 friend class Xr; | |
715 static const int kMaxNumberOfDlrrItems = 100; | |
716 | |
717 std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> dlrr_block_; | |
718 | |
719 RTC_DISALLOW_COPY_AND_ASSIGN(Dlrr); | |
720 }; | |
721 | |
722 // Class holding a RTCP packet. | 688 // Class holding a RTCP packet. |
723 // | 689 // |
724 // Takes a built rtcp packet. | 690 // Takes a built rtcp packet. |
725 // RawPacket raw_packet(buffer, length); | 691 // RawPacket raw_packet(buffer, length); |
726 // | 692 // |
727 // To access the raw packet: | 693 // To access the raw packet: |
728 // raw_packet.Buffer(); - pointer to the raw packet | 694 // raw_packet.Buffer(); - pointer to the raw packet |
729 // raw_packet.BufferLength(); - the length of the raw packet | 695 // raw_packet.BufferLength(); - the length of the raw packet |
730 | 696 |
731 class RawPacket { | 697 class RawPacket { |
732 public: | 698 public: |
733 explicit RawPacket(size_t buffer_length); | 699 explicit RawPacket(size_t buffer_length); |
734 RawPacket(const uint8_t* packet, size_t packet_length); | 700 RawPacket(const uint8_t* packet, size_t packet_length); |
735 | 701 |
736 const uint8_t* Buffer() const; | 702 const uint8_t* Buffer() const; |
737 uint8_t* MutableBuffer(); | 703 uint8_t* MutableBuffer(); |
738 size_t BufferLength() const; | 704 size_t BufferLength() const; |
739 size_t Length() const; | 705 size_t Length() const; |
740 void SetLength(size_t length); | 706 void SetLength(size_t length); |
741 | 707 |
742 private: | 708 private: |
743 const size_t buffer_length_; | 709 const size_t buffer_length_; |
744 size_t length_; | 710 size_t length_; |
745 rtc::scoped_ptr<uint8_t[]> buffer_; | 711 rtc::scoped_ptr<uint8_t[]> buffer_; |
746 }; | 712 }; |
747 | 713 |
748 } // namespace rtcp | 714 } // namespace rtcp |
749 } // namespace webrtc | 715 } // namespace webrtc |
750 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 716 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
OLD | NEW |