Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet.h

Issue 1452733002: rtcp::VoipMetric block moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/report_block.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
24 #include "webrtc/typedefs.h" 25 #include "webrtc/typedefs.h"
25 26
26 namespace webrtc { 27 namespace webrtc {
27 namespace rtcp { 28 namespace rtcp {
28 29
29 static const int kCommonFbFmtLength = 12; 30 static const int kCommonFbFmtLength = 12;
30 static const int kReportBlockLength = 24; 31 static const int kReportBlockLength = 24;
31 32
32 class Dlrr; 33 class Dlrr;
33 class RawPacket; 34 class RawPacket;
34 class VoipMetric;
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;
44 // rr.From(123); 44 // rr.From(123);
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 size_t BlockLength() const { 667 size_t BlockLength() const {
668 const size_t kXrHeaderLength = 8; 668 const size_t kXrHeaderLength = 8;
669 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength(); 669 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength();
670 } 670 }
671 671
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 const size_t kVoipMetricBlockLength = 36; 677 return VoipMetric::kLength * voip_metric_blocks_.size();
678 return kVoipMetricBlockLength * voip_metric_blocks_.size();
679 } 678 }
680 679
681 RTCPUtility::RTCPPacketXR xr_header_; 680 RTCPUtility::RTCPPacketXR xr_header_;
682 std::vector<Rrtr> rrtr_blocks_; 681 std::vector<Rrtr> rrtr_blocks_;
683 std::vector<DlrrBlock> dlrr_blocks_; 682 std::vector<DlrrBlock> dlrr_blocks_;
684 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_; 683 std::vector<VoipMetric> voip_metric_blocks_;
685 684
686 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); 685 RTC_DISALLOW_COPY_AND_ASSIGN(Xr);
687 }; 686 };
688 687
689 // DLRR Report Block (RFC 3611). 688 // DLRR Report Block (RFC 3611).
690 // 689 //
691 // 0 1 2 3 690 // 0 1 2 3
692 // 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 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
693 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 692 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
694 // | BT=5 | reserved | block length | 693 // | BT=5 | reserved | block length |
(...skipping 18 matching lines...) Expand all
713 712
714 private: 713 private:
715 friend class Xr; 714 friend class Xr;
716 static const int kMaxNumberOfDlrrItems = 100; 715 static const int kMaxNumberOfDlrrItems = 100;
717 716
718 std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> dlrr_block_; 717 std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> dlrr_block_;
719 718
720 RTC_DISALLOW_COPY_AND_ASSIGN(Dlrr); 719 RTC_DISALLOW_COPY_AND_ASSIGN(Dlrr);
721 }; 720 };
722 721
723 // VoIP Metrics Report Block (RFC 3611).
724 //
725 // 0 1 2 3
726 // 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
727 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
728 // | BT=7 | reserved | block length = 8 |
729 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
730 // | SSRC of source |
731 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
732 // | loss rate | discard rate | burst density | gap density |
733 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
734 // | burst duration | gap duration |
735 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
736 // | round trip delay | end system delay |
737 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
738 // | signal level | noise level | RERL | Gmin |
739 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
740 // | R factor | ext. R factor | MOS-LQ | MOS-CQ |
741 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
742 // | RX config | reserved | JB nominal |
743 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
744 // | JB maximum | JB abs max |
745 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
746
747 class VoipMetric {
748 public:
749 VoipMetric() {
750 memset(&metric_, 0, sizeof(metric_));
751 }
752 ~VoipMetric() {}
753
754 void To(uint32_t ssrc) { metric_.SSRC = ssrc; }
755 void LossRate(uint8_t loss_rate) { metric_.lossRate = loss_rate; }
756 void DiscardRate(uint8_t discard_rate) { metric_.discardRate = discard_rate; }
757 void BurstDensity(uint8_t burst_density) {
758 metric_.burstDensity = burst_density;
759 }
760 void GapDensity(uint8_t gap_density) { metric_.gapDensity = gap_density; }
761 void BurstDuration(uint16_t burst_duration) {
762 metric_.burstDuration = burst_duration;
763 }
764 void GapDuration(uint16_t gap_duration) {
765 metric_.gapDuration = gap_duration;
766 }
767 void RoundTripDelay(uint16_t round_trip_delay) {
768 metric_.roundTripDelay = round_trip_delay;
769 }
770 void EndSystemDelay(uint16_t end_system_delay) {
771 metric_.endSystemDelay = end_system_delay;
772 }
773 void SignalLevel(uint8_t signal_level) { metric_.signalLevel = signal_level; }
774 void NoiseLevel(uint8_t noise_level) { metric_.noiseLevel = noise_level; }
775 void Rerl(uint8_t rerl) { metric_.RERL = rerl; }
776 void Gmin(uint8_t gmin) { metric_.Gmin = gmin; }
777 void Rfactor(uint8_t rfactor) { metric_.Rfactor = rfactor; }
778 void ExtRfactor(uint8_t extrfactor) { metric_.extRfactor = extrfactor; }
779 void MosLq(uint8_t moslq) { metric_.MOSLQ = moslq; }
780 void MosCq(uint8_t moscq) { metric_.MOSCQ = moscq; }
781 void RxConfig(uint8_t rxconfig) { metric_.RXconfig = rxconfig; }
782 void JbNominal(uint16_t jbnominal) { metric_.JBnominal = jbnominal; }
783 void JbMax(uint16_t jbmax) { metric_.JBmax = jbmax; }
784 void JbAbsMax(uint16_t jbabsmax) { metric_.JBabsMax = jbabsmax; }
785
786 private:
787 friend class Xr;
788 RTCPUtility::RTCPPacketXRVOIPMetricItem metric_;
789
790 RTC_DISALLOW_COPY_AND_ASSIGN(VoipMetric);
791 };
792
793 // Class holding a RTCP packet. 722 // Class holding a RTCP packet.
794 // 723 //
795 // Takes a built rtcp packet. 724 // Takes a built rtcp packet.
796 // RawPacket raw_packet(buffer, length); 725 // RawPacket raw_packet(buffer, length);
797 // 726 //
798 // To access the raw packet: 727 // To access the raw packet:
799 // raw_packet.Buffer(); - pointer to the raw packet 728 // raw_packet.Buffer(); - pointer to the raw packet
800 // raw_packet.BufferLength(); - the length of the raw packet 729 // raw_packet.BufferLength(); - the length of the raw packet
801 730
802 class RawPacket { 731 class RawPacket {
803 public: 732 public:
804 explicit RawPacket(size_t buffer_length); 733 explicit RawPacket(size_t buffer_length);
805 RawPacket(const uint8_t* packet, size_t packet_length); 734 RawPacket(const uint8_t* packet, size_t packet_length);
806 735
807 const uint8_t* Buffer() const; 736 const uint8_t* Buffer() const;
808 uint8_t* MutableBuffer(); 737 uint8_t* MutableBuffer();
809 size_t BufferLength() const; 738 size_t BufferLength() const;
810 size_t Length() const; 739 size_t Length() const;
811 void SetLength(size_t length); 740 void SetLength(size_t length);
812 741
813 private: 742 private:
814 const size_t buffer_length_; 743 const size_t buffer_length_;
815 size_t length_; 744 size_t length_;
816 rtc::scoped_ptr<uint8_t[]> buffer_; 745 rtc::scoped_ptr<uint8_t[]> buffer_;
817 }; 746 };
818 747
819 } // namespace rtcp 748 } // namespace rtcp
820 } // namespace webrtc 749 } // namespace webrtc
821 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 750 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698