| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 5 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/cast/cast_defines.h" | 8 #include "media/cast/cast_defines.h" |
| 9 #include "media/cast/pacing/paced_sender.h" | 9 #include "media/cast/pacing/paced_sender.h" |
| 10 #include "net/base/big_endian.h" | 10 #include "net/base/big_endian.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (time_last_sent_rtp_timestamp_.is_null()) return false; | 74 if (time_last_sent_rtp_timestamp_.is_null()) return false; |
| 75 | 75 |
| 76 *time_sent = time_last_sent_rtp_timestamp_; | 76 *time_sent = time_last_sent_rtp_timestamp_; |
| 77 *rtp_timestamp = rtp_timestamp_; | 77 *rtp_timestamp = rtp_timestamp_; |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void RtpPacketizer::Cast(bool is_key, | 81 void RtpPacketizer::Cast(bool is_key, |
| 82 uint8 reference_frame_id, | 82 uint8 reference_frame_id, |
| 83 uint32 timestamp, | 83 uint32 timestamp, |
| 84 Packet data) { | 84 const std::string& data) { |
| 85 uint16 rtp_header_length = kCommonRtpHeaderLength + kCastRtpHeaderLength; | 85 uint16 rtp_header_length = kCommonRtpHeaderLength + kCastRtpHeaderLength; |
| 86 uint16 max_length = config_.max_payload_length - rtp_header_length - 1; | 86 uint16 max_length = config_.max_payload_length - rtp_header_length - 1; |
| 87 | 87 |
| 88 // Split the payload evenly (round number up). | 88 // Split the payload evenly (round number up). |
| 89 size_t num_packets = (data.size() + max_length) / max_length; | 89 size_t num_packets = (data.size() + max_length) / max_length; |
| 90 size_t payload_length = (data.size() + num_packets) / num_packets; | 90 size_t payload_length = (data.size() + num_packets) / num_packets; |
| 91 DCHECK_LE(payload_length, max_length) << "Invalid argument"; | 91 DCHECK_LE(payload_length, max_length) << "Invalid argument"; |
| 92 | 92 |
| 93 PacketList packets; | 93 PacketList packets; |
| 94 | 94 |
| 95 size_t remaining_size = data.size(); | 95 size_t remaining_size = data.size(); |
| 96 Packet::iterator data_iter = data.begin(); | 96 std::string::const_iterator data_iter = data.begin(); |
| 97 while (remaining_size > 0) { | 97 while (remaining_size > 0) { |
| 98 Packet packet; | 98 Packet packet; |
| 99 | 99 |
| 100 if (remaining_size < payload_length) { | 100 if (remaining_size < payload_length) { |
| 101 payload_length = remaining_size; | 101 payload_length = remaining_size; |
| 102 } | 102 } |
| 103 remaining_size -= payload_length; | 103 remaining_size -= payload_length; |
| 104 BuildCommonRTPheader(&packet, remaining_size == 0, timestamp); | 104 BuildCommonRTPheader(&packet, remaining_size == 0, timestamp); |
| 105 | 105 |
| 106 // Build Cast header. | 106 // Build Cast header. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 packet->resize(start_size + 10); | 146 packet->resize(start_size + 10); |
| 147 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 10); | 147 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 10); |
| 148 big_endian_writer.WriteU16(sequence_number_); | 148 big_endian_writer.WriteU16(sequence_number_); |
| 149 big_endian_writer.WriteU32(time_stamp); | 149 big_endian_writer.WriteU32(time_stamp); |
| 150 big_endian_writer.WriteU32(config_.ssrc); | 150 big_endian_writer.WriteU32(config_.ssrc); |
| 151 ++sequence_number_; | 151 ++sequence_number_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace cast | 154 } // namespace cast |
| 155 } // namespace media | 155 } // namespace media |
| OLD | NEW |