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 |
(...skipping 21 matching lines...) Expand all Loading... |
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::RTCPPacketRTPFBTMMBN; | |
43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; | |
44 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; | 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; |
45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; | 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; |
46 using webrtc::RTCPUtility::RTCPPacketSR; | 44 using webrtc::RTCPUtility::RTCPPacketSR; |
47 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; | 45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; |
48 using webrtc::RTCPUtility::RTCPPacketXR; | 46 using webrtc::RTCPUtility::RTCPPacketXR; |
49 | 47 |
50 namespace webrtc { | 48 namespace webrtc { |
51 namespace rtcp { | 49 namespace rtcp { |
52 namespace { | 50 namespace { |
53 // Unused SSRC of media source, set to 0. | 51 // Unused SSRC of media source, set to 0. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 288 |
291 void CreateTmmbr(const RTCPPacketRTPFBTMMBR& tmmbr, | 289 void CreateTmmbr(const RTCPPacketRTPFBTMMBR& tmmbr, |
292 const RTCPPacketRTPFBTMMBRItem& tmmbr_item, | 290 const RTCPPacketRTPFBTMMBRItem& tmmbr_item, |
293 uint8_t* buffer, | 291 uint8_t* buffer, |
294 size_t* pos) { | 292 size_t* pos) { |
295 AssignUWord32(buffer, pos, tmmbr.SenderSSRC); | 293 AssignUWord32(buffer, pos, tmmbr.SenderSSRC); |
296 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); | 294 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); |
297 CreateTmmbrItem(tmmbr_item, buffer, pos); | 295 CreateTmmbrItem(tmmbr_item, buffer, pos); |
298 } | 296 } |
299 | 297 |
300 // Temporary Maximum Media Stream Bit Rate Notification (TMMBN) (RFC 5104). | |
301 // | |
302 // FCI: | |
303 // | |
304 // 0 1 2 3 | |
305 // 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 | |
306 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
307 // | SSRC | | |
308 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
309 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead| | |
310 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
311 | |
312 void CreateTmmbn(const RTCPPacketRTPFBTMMBN& tmmbn, | |
313 const std::vector<RTCPPacketRTPFBTMMBRItem>& tmmbn_items, | |
314 uint8_t* buffer, | |
315 size_t* pos) { | |
316 AssignUWord32(buffer, pos, tmmbn.SenderSSRC); | |
317 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); | |
318 for (uint8_t i = 0; i < tmmbn_items.size(); ++i) { | |
319 CreateTmmbrItem(tmmbn_items[i], buffer, pos); | |
320 } | |
321 } | |
322 | |
323 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). | 298 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). |
324 // | 299 // |
325 // 0 1 2 3 | 300 // 0 1 2 3 |
326 // 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 | 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 |
327 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 302 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
328 // |V=2|P| FMT=15 | PT=206 | length | | 303 // |V=2|P| FMT=15 | PT=206 | length | |
329 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 304 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
330 // | SSRC of packet sender | | 305 // | SSRC of packet sender | |
331 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 306 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
332 // | SSRC of media source | | 307 // | SSRC of media source | |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 while (*index + BlockLength() > max_length) { | 632 while (*index + BlockLength() > max_length) { |
658 if (!OnBufferFull(packet, index, callback)) | 633 if (!OnBufferFull(packet, index, callback)) |
659 return false; | 634 return false; |
660 } | 635 } |
661 const uint8_t kFmt = 3; | 636 const uint8_t kFmt = 3; |
662 CreateHeader(kFmt, PT_RTPFB, HeaderLength(), packet, index); | 637 CreateHeader(kFmt, PT_RTPFB, HeaderLength(), packet, index); |
663 CreateTmmbr(tmmbr_, tmmbr_item_, packet, index); | 638 CreateTmmbr(tmmbr_, tmmbr_item_, packet, index); |
664 return true; | 639 return true; |
665 } | 640 } |
666 | 641 |
667 bool Tmmbn::WithTmmbr(uint32_t ssrc, uint32_t bitrate_kbps, uint16_t overhead) { | |
668 assert(overhead <= 0x1ff); | |
669 if (tmmbn_items_.size() >= kMaxNumberOfTmmbrs) { | |
670 LOG(LS_WARNING) << "Max TMMBN size reached."; | |
671 return false; | |
672 } | |
673 RTCPPacketRTPFBTMMBRItem tmmbn_item; | |
674 tmmbn_item.SSRC = ssrc; | |
675 tmmbn_item.MaxTotalMediaBitRate = bitrate_kbps; | |
676 tmmbn_item.MeasuredOverhead = overhead; | |
677 tmmbn_items_.push_back(tmmbn_item); | |
678 return true; | |
679 } | |
680 | |
681 bool Tmmbn::Create(uint8_t* packet, | |
682 size_t* index, | |
683 size_t max_length, | |
684 RtcpPacket::PacketReadyCallback* callback) const { | |
685 while (*index + BlockLength() > max_length) { | |
686 if (!OnBufferFull(packet, index, callback)) | |
687 return false; | |
688 } | |
689 const uint8_t kFmt = 4; | |
690 CreateHeader(kFmt, PT_RTPFB, HeaderLength(), packet, index); | |
691 CreateTmmbn(tmmbn_, tmmbn_items_, packet, index); | |
692 return true; | |
693 } | |
694 | |
695 bool Xr::Create(uint8_t* packet, | 642 bool Xr::Create(uint8_t* packet, |
696 size_t* index, | 643 size_t* index, |
697 size_t max_length, | 644 size_t max_length, |
698 RtcpPacket::PacketReadyCallback* callback) const { | 645 RtcpPacket::PacketReadyCallback* callback) const { |
699 while (*index + BlockLength() > max_length) { | 646 while (*index + BlockLength() > max_length) { |
700 if (!OnBufferFull(packet, index, callback)) | 647 if (!OnBufferFull(packet, index, callback)) |
701 return false; | 648 return false; |
702 } | 649 } |
703 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); | 650 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); |
704 CreateXrHeader(xr_header_, packet, index); | 651 CreateXrHeader(xr_header_, packet, index); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 return length_; | 729 return length_; |
783 } | 730 } |
784 | 731 |
785 void RawPacket::SetLength(size_t length) { | 732 void RawPacket::SetLength(size_t length) { |
786 assert(length <= buffer_length_); | 733 assert(length <= buffer_length_); |
787 length_ = length; | 734 length_ = length; |
788 } | 735 } |
789 | 736 |
790 } // namespace rtcp | 737 } // namespace rtcp |
791 } // namespace webrtc | 738 } // namespace webrtc |
OLD | NEW |