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 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | defined per codec ... | Padding (0) | | 617 | defined per codec ... | Padding (0) | |
618 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 618 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
619 */ | 619 */ |
620 /* | 620 /* |
621 * Note: not generic made for VP8 | 621 * Note: not generic made for VP8 |
622 */ | 622 */ |
623 RTCPSender::BuildResult RTCPSender::BuildRPSI(RtcpContext* ctx) { | 623 RTCPSender::BuildResult RTCPSender::BuildRPSI(RtcpContext* ctx) { |
624 if (ctx->feedback_state.send_payload_type == 0xFF) | 624 if (ctx->feedback_state.send_payload_type == 0xFF) |
625 return BuildResult::kError; | 625 return BuildResult::kError; |
626 | 626 |
627 // sanity | 627 rtcp::Rpsi rpsi; |
628 if (ctx->position + 24 >= IP_PACKET_SIZE) | 628 rpsi.From(ssrc_); |
| 629 rpsi.To(remote_ssrc_); |
| 630 rpsi.WithPayloadType(ctx->feedback_state.send_payload_type); |
| 631 rpsi.WithPictureId(ctx->picture_id); |
| 632 |
| 633 PacketBuiltCallback callback(ctx); |
| 634 if (!callback.BuildPacket(rpsi)) |
629 return BuildResult::kTruncated; | 635 return BuildResult::kTruncated; |
630 | 636 |
631 // add Reference Picture Selection Indication | |
632 uint8_t FMT = 3; | |
633 *ctx->AllocateData(1) = 0x80 + FMT; | |
634 *ctx->AllocateData(1) = 206; | |
635 | |
636 // calc length | |
637 uint32_t bitsRequired = 7; | |
638 uint8_t bytesRequired = 1; | |
639 while ((ctx->picture_id >> bitsRequired) > 0) { | |
640 bitsRequired += 7; | |
641 bytesRequired++; | |
642 } | |
643 | |
644 uint8_t size = 3; | |
645 if (bytesRequired > 6) { | |
646 size = 5; | |
647 } else if (bytesRequired > 2) { | |
648 size = 4; | |
649 } | |
650 *ctx->AllocateData(1) = 0; | |
651 *ctx->AllocateData(1) = size; | |
652 | |
653 // Add our own SSRC | |
654 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_); | |
655 | |
656 // Add the remote SSRC | |
657 ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), remote_ssrc_); | |
658 | |
659 // calc padding length | |
660 uint8_t paddingBytes = 4 - ((2 + bytesRequired) % 4); | |
661 if (paddingBytes == 4) | |
662 paddingBytes = 0; | |
663 // add padding length in bits | |
664 *ctx->AllocateData(1) = paddingBytes * 8; // padding can be 0, 8, 16 or 24 | |
665 | |
666 // add payload type | |
667 *ctx->AllocateData(1) = ctx->feedback_state.send_payload_type; | |
668 | |
669 // add picture ID | |
670 for (int i = bytesRequired - 1; i > 0; --i) { | |
671 *ctx->AllocateData(1) = | |
672 0x80 | static_cast<uint8_t>(ctx->picture_id >> (i * 7)); | |
673 } | |
674 // add last byte of picture ID | |
675 *ctx->AllocateData(1) = static_cast<uint8_t>(ctx->picture_id & 0x7f); | |
676 | |
677 // add padding | |
678 for (int j = 0; j < paddingBytes; j++) { | |
679 *ctx->AllocateData(1) = 0; | |
680 } | |
681 | |
682 return BuildResult::kSuccess; | 637 return BuildResult::kSuccess; |
683 } | 638 } |
684 | 639 |
685 RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) { | 640 RTCPSender::BuildResult RTCPSender::BuildREMB(RtcpContext* ctx) { |
686 // sanity | 641 // sanity |
687 if (ctx->position + 20 + 4 * remb_ssrcs_.size() >= IP_PACKET_SIZE) | 642 if (ctx->position + 20 + 4 * remb_ssrcs_.size() >= IP_PACKET_SIZE) |
688 return BuildResult::kTruncated; | 643 return BuildResult::kTruncated; |
689 | 644 |
690 // add application layer feedback | 645 // add application layer feedback |
691 uint8_t FMT = 15; | 646 uint8_t FMT = 15; |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 | 1411 |
1457 bool RTCPSender::AllVolatileFlagsConsumed() const { | 1412 bool RTCPSender::AllVolatileFlagsConsumed() const { |
1458 for (const ReportFlag& flag : report_flags_) { | 1413 for (const ReportFlag& flag : report_flags_) { |
1459 if (flag.is_volatile) | 1414 if (flag.is_volatile) |
1460 return false; | 1415 return false; |
1461 } | 1416 } |
1462 return true; | 1417 return true; |
1463 } | 1418 } |
1464 | 1419 |
1465 } // namespace webrtc | 1420 } // namespace webrtc |
OLD | NEW |