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

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

Issue 1575023002: [rtp_rtcp] rtcp::Tmmbr moved into own file (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months 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
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
(...skipping 21 matching lines...) Expand all
32 using webrtc::RTCPUtility::RTCPPacketPSFBAPP; 32 using webrtc::RTCPUtility::RTCPPacketPSFBAPP;
33 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; 33 using webrtc::RTCPUtility::RTCPPacketPSFBFIR;
34 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; 34 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem;
35 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem; 35 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem;
36 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; 36 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
37 using webrtc::RTCPUtility::RTCPPacketPSFBSLI; 37 using webrtc::RTCPUtility::RTCPPacketPSFBSLI;
38 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem; 38 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem;
39 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; 39 using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; 40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; 41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR;
43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem;
44 using webrtc::RTCPUtility::RTCPPacketSR; 42 using webrtc::RTCPUtility::RTCPPacketSR;
45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; 43 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem;
46 using webrtc::RTCPUtility::RTCPPacketXR; 44 using webrtc::RTCPUtility::RTCPPacketXR;
47 45
48 namespace webrtc { 46 namespace webrtc {
49 namespace rtcp { 47 namespace rtcp {
50 namespace { 48 namespace {
51 // Unused SSRC of media source, set to 0. 49 // Unused SSRC of media source, set to 0.
52 const uint32_t kUnusedMediaSourceSsrc0 = 0; 50 const uint32_t kUnusedMediaSourceSsrc0 = 0;
53 51
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const RTCPPacketPSFBFIRItem& fir_item, 249 const RTCPPacketPSFBFIRItem& fir_item,
252 uint8_t* buffer, 250 uint8_t* buffer,
253 size_t* pos) { 251 size_t* pos) {
254 AssignUWord32(buffer, pos, fir.SenderSSRC); 252 AssignUWord32(buffer, pos, fir.SenderSSRC);
255 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); 253 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0);
256 AssignUWord32(buffer, pos, fir_item.SSRC); 254 AssignUWord32(buffer, pos, fir_item.SSRC);
257 AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber); 255 AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber);
258 AssignUWord24(buffer, pos, 0); 256 AssignUWord24(buffer, pos, 0);
259 } 257 }
260 258
261 void CreateTmmbrItem(const RTCPPacketRTPFBTMMBRItem& tmmbr_item,
262 uint8_t* buffer,
263 size_t* pos) {
264 uint32_t bitrate_bps = tmmbr_item.MaxTotalMediaBitRate * 1000;
265 uint32_t mantissa = 0;
266 uint8_t exp = 0;
267 ComputeMantissaAnd6bitBase2Exponent(bitrate_bps, 17, &mantissa, &exp);
268
269 AssignUWord32(buffer, pos, tmmbr_item.SSRC);
270 AssignUWord8(buffer, pos, (exp << 2) + ((mantissa >> 15) & 0x03));
271 AssignUWord8(buffer, pos, mantissa >> 7);
272 AssignUWord8(buffer, pos, (mantissa << 1) +
273 ((tmmbr_item.MeasuredOverhead >> 8) & 0x01));
274 AssignUWord8(buffer, pos, tmmbr_item.MeasuredOverhead);
275 }
276
277 // Temporary Maximum Media Stream Bit Rate Request (TMMBR) (RFC 5104).
278 //
279 // FCI:
280 //
281 // 0 1 2 3
282 // 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
283 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
284 // | SSRC |
285 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead|
287 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
288
289 void CreateTmmbr(const RTCPPacketRTPFBTMMBR& tmmbr,
290 const RTCPPacketRTPFBTMMBRItem& tmmbr_item,
291 uint8_t* buffer,
292 size_t* pos) {
293 AssignUWord32(buffer, pos, tmmbr.SenderSSRC);
294 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0);
295 CreateTmmbrItem(tmmbr_item, buffer, pos);
296 }
297
298 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). 259 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
299 // 260 //
300 // 0 1 2 3 261 // 0 1 2 3
301 // 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 262 // 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
302 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 263 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303 // |V=2|P| FMT=15 | PT=206 | length | 264 // |V=2|P| FMT=15 | PT=206 | length |
304 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 265 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305 // | SSRC of packet sender | 266 // | SSRC of packet sender |
306 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 267 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307 // | SSRC of media source | 268 // | SSRC of media source |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 579 }
619 580
620 void Remb::AppliesTo(uint32_t ssrc) { 581 void Remb::AppliesTo(uint32_t ssrc) {
621 if (remb_item_.NumberOfSSRCs >= kMaxNumberOfSsrcs) { 582 if (remb_item_.NumberOfSSRCs >= kMaxNumberOfSsrcs) {
622 LOG(LS_WARNING) << "Max number of REMB feedback SSRCs reached."; 583 LOG(LS_WARNING) << "Max number of REMB feedback SSRCs reached.";
623 return; 584 return;
624 } 585 }
625 remb_item_.SSRCs[remb_item_.NumberOfSSRCs++] = ssrc; 586 remb_item_.SSRCs[remb_item_.NumberOfSSRCs++] = ssrc;
626 } 587 }
627 588
628 bool Tmmbr::Create(uint8_t* packet,
629 size_t* index,
630 size_t max_length,
631 RtcpPacket::PacketReadyCallback* callback) const {
632 while (*index + BlockLength() > max_length) {
633 if (!OnBufferFull(packet, index, callback))
634 return false;
635 }
636 const uint8_t kFmt = 3;
637 CreateHeader(kFmt, PT_RTPFB, HeaderLength(), packet, index);
638 CreateTmmbr(tmmbr_, tmmbr_item_, packet, index);
639 return true;
640 }
641
642 bool Xr::Create(uint8_t* packet, 589 bool Xr::Create(uint8_t* packet,
643 size_t* index, 590 size_t* index,
644 size_t max_length, 591 size_t max_length,
645 RtcpPacket::PacketReadyCallback* callback) const { 592 RtcpPacket::PacketReadyCallback* callback) const {
646 while (*index + BlockLength() > max_length) { 593 while (*index + BlockLength() > max_length) {
647 if (!OnBufferFull(packet, index, callback)) 594 if (!OnBufferFull(packet, index, callback))
648 return false; 595 return false;
649 } 596 }
650 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); 597 CreateHeader(0U, PT_XR, HeaderLength(), packet, index);
651 CreateXrHeader(xr_header_, packet, index); 598 CreateXrHeader(xr_header_, packet, index);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return length_; 676 return length_;
730 } 677 }
731 678
732 void RawPacket::SetLength(size_t length) { 679 void RawPacket::SetLength(size_t length) {
733 assert(length <= buffer_length_); 680 assert(length <= buffer_length_);
734 length_ = length; 681 length_ = length;
735 } 682 }
736 683
737 } // namespace rtcp 684 } // namespace rtcp
738 } // namespace webrtc 685 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698