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/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 5 #include "media/cast/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
6 | 6 |
| 7 #include "base/big_endian.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "media/cast/transport/pacing/paced_sender.h" | 9 #include "media/cast/transport/pacing/paced_sender.h" |
9 #include "net/base/big_endian.h" | |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 namespace cast { | 12 namespace cast { |
13 namespace transport { | 13 namespace transport { |
14 | 14 |
15 static const uint16 kCommonRtpHeaderLength = 12; | 15 static const uint16 kCommonRtpHeaderLength = 12; |
16 static const uint16 kCastRtpHeaderLength = 7; | 16 static const uint16 kCastRtpHeaderLength = 7; |
17 static const uint8 kCastKeyFrameBitMask = 0x80; | 17 static const uint8 kCastKeyFrameBitMask = 0x80; |
18 static const uint8 kCastReferenceFrameIdBitMask = 0x40; | 18 static const uint8 kCastReferenceFrameIdBitMask = 0x40; |
19 static const uint8 kRtpMarkerBitMask = 0x80; | 19 static const uint8 kRtpMarkerBitMask = 0x80; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 remaining_size -= payload_length; | 118 remaining_size -= payload_length; |
119 BuildCommonRTPheader(&packet, remaining_size == 0, timestamp); | 119 BuildCommonRTPheader(&packet, remaining_size == 0, timestamp); |
120 | 120 |
121 // Build Cast header. | 121 // Build Cast header. |
122 packet.push_back((is_key ? kCastKeyFrameBitMask : 0) | | 122 packet.push_back((is_key ? kCastKeyFrameBitMask : 0) | |
123 kCastReferenceFrameIdBitMask); | 123 kCastReferenceFrameIdBitMask); |
124 packet.push_back(frame_id); | 124 packet.push_back(frame_id); |
125 size_t start_size = packet.size(); | 125 size_t start_size = packet.size(); |
126 packet.resize(start_size + 4); | 126 packet.resize(start_size + 4); |
127 net::BigEndianWriter big_endian_writer(&(packet[start_size]), 4); | 127 base::BigEndianWriter big_endian_writer( |
| 128 reinterpret_cast<char*>(&(packet[start_size])), 4); |
128 big_endian_writer.WriteU16(packet_id_); | 129 big_endian_writer.WriteU16(packet_id_); |
129 big_endian_writer.WriteU16(static_cast<uint16>(num_packets - 1)); | 130 big_endian_writer.WriteU16(static_cast<uint16>(num_packets - 1)); |
130 packet.push_back(static_cast<uint8>(reference_frame_id)); | 131 packet.push_back(static_cast<uint8>(reference_frame_id)); |
131 | 132 |
132 // Copy payload data. | 133 // Copy payload data. |
133 packet.insert(packet.end(), data_iter, data_iter + payload_length); | 134 packet.insert(packet.end(), data_iter, data_iter + payload_length); |
134 | 135 |
135 // Store packet. | 136 // Store packet. |
136 packet_storage_->StorePacket(frame_id, packet_id_, &packet); | 137 packet_storage_->StorePacket(frame_id, packet_id_, &packet); |
137 ++packet_id_; | 138 ++packet_id_; |
(...skipping 14 matching lines...) Expand all Loading... |
152 } | 153 } |
153 | 154 |
154 void RtpPacketizer::BuildCommonRTPheader(Packet* packet, | 155 void RtpPacketizer::BuildCommonRTPheader(Packet* packet, |
155 bool marker_bit, | 156 bool marker_bit, |
156 uint32 time_stamp) { | 157 uint32 time_stamp) { |
157 packet->push_back(0x80); | 158 packet->push_back(0x80); |
158 packet->push_back(static_cast<uint8>(config_.payload_type) | | 159 packet->push_back(static_cast<uint8>(config_.payload_type) | |
159 (marker_bit ? kRtpMarkerBitMask : 0)); | 160 (marker_bit ? kRtpMarkerBitMask : 0)); |
160 size_t start_size = packet->size(); | 161 size_t start_size = packet->size(); |
161 packet->resize(start_size + 10); | 162 packet->resize(start_size + 10); |
162 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 10); | 163 base::BigEndianWriter big_endian_writer( |
| 164 reinterpret_cast<char*>(&((*packet)[start_size])), 10); |
163 big_endian_writer.WriteU16(sequence_number_); | 165 big_endian_writer.WriteU16(sequence_number_); |
164 big_endian_writer.WriteU32(time_stamp); | 166 big_endian_writer.WriteU32(time_stamp); |
165 big_endian_writer.WriteU32(config_.ssrc); | 167 big_endian_writer.WriteU32(config_.ssrc); |
166 ++sequence_number_; | 168 ++sequence_number_; |
167 } | 169 } |
168 | 170 |
169 } // namespace transport | 171 } // namespace transport |
170 } // namespace cast | 172 } // namespace cast |
171 } // namespace media | 173 } // namespace media |
OLD | NEW |