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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 ByteWriter<uint32_t>::WriteBigEndian(ptr, csrcs[i]); | 1233 ByteWriter<uint32_t>::WriteBigEndian(ptr, csrcs[i]); |
1234 ptr += 4; | 1234 ptr += 4; |
1235 } | 1235 } |
1236 header[0] = (header[0] & 0xf0) | csrcs.size(); | 1236 header[0] = (header[0] & 0xf0) | csrcs.size(); |
1237 | 1237 |
1238 // Update length of header. | 1238 // Update length of header. |
1239 rtp_header_length += sizeof(uint32_t) * csrcs.size(); | 1239 rtp_header_length += sizeof(uint32_t) * csrcs.size(); |
1240 } | 1240 } |
1241 | 1241 |
1242 uint16_t len = | 1242 uint16_t len = |
1243 BuildRTPHeaderExtension(header + rtp_header_length, marker_bit); | 1243 BuildRtpHeaderExtension(header + rtp_header_length, marker_bit); |
1244 if (len > 0) { | 1244 if (len > 0) { |
1245 header[0] |= 0x10; // Set extension bit. | 1245 header[0] |= 0x10; // Set extension bit. |
1246 rtp_header_length += len; | 1246 rtp_header_length += len; |
1247 } | 1247 } |
1248 return rtp_header_length; | 1248 return rtp_header_length; |
1249 } | 1249 } |
1250 | 1250 |
1251 int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer, | 1251 int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer, |
1252 int8_t payload_type, | 1252 int8_t payload_type, |
1253 bool marker_bit, | 1253 bool marker_bit, |
1254 uint32_t capture_timestamp, | 1254 uint32_t capture_timestamp, |
1255 int64_t capture_time_ms, | 1255 int64_t capture_time_ms, |
1256 bool timestamp_provided, | 1256 bool timestamp_provided, |
1257 bool inc_sequence_number) { | 1257 bool inc_sequence_number) { |
1258 if (!timestamp_provided) { | |
1259 rtc::CritScope lock(&send_critsect_); | |
danilchap
2016/06/15 20:04:21
this is not a thread-safe way to keep old behavior
Sergey Ulanov
2016/06/15 20:53:24
Done.
| |
1260 // Calculate |capture_timestamp| so that BuildRtpHeader() effectively will | |
1261 // set timestamp_ = timestamp_ + 1. | |
1262 capture_timestamp = timestamp_ - start_timestamp_ + 1; | |
1263 } | |
1264 return BuildRtpHeader(data_buffer, payload_type, marker_bit, | |
1265 capture_timestamp, capture_time_ms); | |
1266 } | |
1267 | |
1268 int32_t RTPSender::BuildRtpHeader(uint8_t* data_buffer, | |
1269 int8_t payload_type, | |
1270 bool marker_bit, | |
1271 uint32_t capture_timestamp, | |
1272 int64_t capture_time_ms) { | |
1258 assert(payload_type >= 0); | 1273 assert(payload_type >= 0); |
1259 rtc::CritScope lock(&send_critsect_); | 1274 rtc::CritScope lock(&send_critsect_); |
1260 | 1275 |
1261 if (timestamp_provided) { | 1276 timestamp_ = start_timestamp_ + capture_timestamp; |
1262 timestamp_ = start_timestamp_ + capture_timestamp; | |
1263 } else { | |
1264 // Make a unique time stamp. | |
1265 // We can't inc by the actual time, since then we increase the risk of back | |
1266 // timing. | |
1267 timestamp_++; | |
1268 } | |
1269 last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); | 1277 last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); |
1270 uint32_t sequence_number = sequence_number_++; | 1278 uint32_t sequence_number = sequence_number_++; |
1271 capture_time_ms_ = capture_time_ms; | 1279 capture_time_ms_ = capture_time_ms; |
1272 last_packet_marker_bit_ = marker_bit; | 1280 last_packet_marker_bit_ = marker_bit; |
1273 return CreateRtpHeader(data_buffer, payload_type, ssrc_, marker_bit, | 1281 return CreateRtpHeader(data_buffer, payload_type, ssrc_, marker_bit, |
1274 timestamp_, sequence_number, csrcs_); | 1282 timestamp_, sequence_number, csrcs_); |
1275 } | 1283 } |
1276 | 1284 |
1277 uint16_t RTPSender::BuildRTPHeaderExtension(uint8_t* data_buffer, | 1285 uint16_t RTPSender::BuildRtpHeaderExtension(uint8_t* data_buffer, |
1278 bool marker_bit) const { | 1286 bool marker_bit) const { |
1279 if (rtp_header_extension_map_.Size() <= 0) { | 1287 if (rtp_header_extension_map_.Size() <= 0) { |
1280 return 0; | 1288 return 0; |
1281 } | 1289 } |
1282 // RTP header extension, RFC 3550. | 1290 // RTP header extension, RFC 3550. |
1283 // 0 1 2 3 | 1291 // 0 1 2 3 |
1284 // 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 | 1292 // 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 |
1285 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 1293 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
1286 // | defined by profile | length | | 1294 // | defined by profile | length | |
1287 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 1295 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1996 rtc::CritScope lock(&send_critsect_); | 2004 rtc::CritScope lock(&send_critsect_); |
1997 | 2005 |
1998 RtpState state; | 2006 RtpState state; |
1999 state.sequence_number = sequence_number_rtx_; | 2007 state.sequence_number = sequence_number_rtx_; |
2000 state.start_timestamp = start_timestamp_; | 2008 state.start_timestamp = start_timestamp_; |
2001 | 2009 |
2002 return state; | 2010 return state; |
2003 } | 2011 } |
2004 | 2012 |
2005 } // namespace webrtc | 2013 } // namespace webrtc |
OLD | NEW |