OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace { | 22 namespace { |
23 static const int kRtpSsrcOffset = 8; | 23 static const int kRtpSsrcOffset = 8; |
24 const int kWarnSlowWritesDelayMs = 50; | 24 const int kWarnSlowWritesDelayMs = 50; |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 namespace cricket { | 27 namespace cricket { |
28 | 28 |
29 const char RtpDumpFileHeader::kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n"; | 29 const char RtpDumpFileHeader::kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n"; |
30 | 30 |
31 RtpDumpFileHeader::RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p) | 31 RtpDumpFileHeader::RtpDumpFileHeader(int64_t start_ms, uint32_t s, uint16_t p) |
32 : start_sec(start_ms / 1000), | 32 : start_sec(static_cast<uint32_t>(start_ms / 1000)), |
33 start_usec(start_ms % 1000 * 1000), | 33 start_usec(static_cast<uint32_t>(start_ms % 1000 * 1000)), |
34 source(s), | 34 source(s), |
35 port(p), | 35 port(p), |
36 padding(0) { | 36 padding(0) {} |
37 } | |
38 | 37 |
39 void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBufferWriter* buf) { | 38 void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBufferWriter* buf) { |
40 buf->WriteUInt32(start_sec); | 39 buf->WriteUInt32(start_sec); |
41 buf->WriteUInt32(start_usec); | 40 buf->WriteUInt32(start_usec); |
42 buf->WriteUInt32(source); | 41 buf->WriteUInt32(source); |
43 buf->WriteUInt16(port); | 42 buf->WriteUInt16(port); |
44 buf->WriteUInt16(padding); | 43 buf->WriteUInt16(padding); |
45 } | 44 } |
46 | 45 |
47 static const uint32_t kDefaultTimeIncrease = 30; | 46 static const int kDefaultTimeIncrease = 30; |
48 | 47 |
49 bool RtpDumpPacket::IsValidRtpPacket() const { | 48 bool RtpDumpPacket::IsValidRtpPacket() const { |
50 return original_data_len >= data.size() && | 49 return original_data_len >= data.size() && |
51 data.size() >= kMinRtpPacketLen; | 50 data.size() >= kMinRtpPacketLen; |
52 } | 51 } |
53 | 52 |
54 bool RtpDumpPacket::IsValidRtcpPacket() const { | 53 bool RtpDumpPacket::IsValidRtcpPacket() const { |
55 return original_data_len == 0 && | 54 return original_data_len == 0 && |
56 data.size() >= kMinRtcpPacketLen; | 55 data.size() >= kMinRtcpPacketLen; |
57 } | 56 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 start_time_ms_(rtc::Time()), | 307 start_time_ms_(rtc::Time()), |
309 warn_slow_writes_delay_(kWarnSlowWritesDelayMs) { | 308 warn_slow_writes_delay_(kWarnSlowWritesDelayMs) { |
310 } | 309 } |
311 | 310 |
312 void RtpDumpWriter::set_packet_filter(int filter) { | 311 void RtpDumpWriter::set_packet_filter(int filter) { |
313 packet_filter_ = filter; | 312 packet_filter_ = filter; |
314 LOG(LS_INFO) << "RtpDumpWriter set_packet_filter to " << packet_filter_; | 313 LOG(LS_INFO) << "RtpDumpWriter set_packet_filter to " << packet_filter_; |
315 } | 314 } |
316 | 315 |
317 uint32_t RtpDumpWriter::GetElapsedTime() const { | 316 uint32_t RtpDumpWriter::GetElapsedTime() const { |
318 return rtc::TimeSince(start_time_ms_); | 317 return static_cast<uint32_t>(rtc::TimeSince(start_time_ms_)); |
319 } | 318 } |
320 | 319 |
321 rtc::StreamResult RtpDumpWriter::WriteFileHeader() { | 320 rtc::StreamResult RtpDumpWriter::WriteFileHeader() { |
322 rtc::StreamResult res = WriteToStream( | 321 rtc::StreamResult res = WriteToStream( |
323 RtpDumpFileHeader::kFirstLine, | 322 RtpDumpFileHeader::kFirstLine, |
324 strlen(RtpDumpFileHeader::kFirstLine)); | 323 strlen(RtpDumpFileHeader::kFirstLine)); |
325 if (res != rtc::SR_SUCCESS) { | 324 if (res != rtc::SR_SUCCESS) { |
326 return res; | 325 return res; |
327 } | 326 } |
328 | 327 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // RTCP header + payload | 387 // RTCP header + payload |
389 filtered_len = data_len; | 388 filtered_len = data_len; |
390 } | 389 } |
391 } | 390 } |
392 | 391 |
393 return filtered_len; | 392 return filtered_len; |
394 } | 393 } |
395 | 394 |
396 rtc::StreamResult RtpDumpWriter::WriteToStream( | 395 rtc::StreamResult RtpDumpWriter::WriteToStream( |
397 const void* data, size_t data_len) { | 396 const void* data, size_t data_len) { |
398 uint32_t before = rtc::Time(); | 397 int64_t before = rtc::Time(); |
399 rtc::StreamResult result = | 398 rtc::StreamResult result = |
400 stream_->WriteAll(data, data_len, NULL, NULL); | 399 stream_->WriteAll(data, data_len, NULL, NULL); |
401 uint32_t delay = rtc::TimeSince(before); | 400 uint32_t delay = static_cast<uint32_t>(rtc::TimeSince(before)); |
402 if (delay >= warn_slow_writes_delay_) { | 401 if (delay >= warn_slow_writes_delay_) { |
pthatcher1
2016/05/02 16:57:56
Why not change warn_slow_writes_delay_ to a uint64
honghaiz3
2016/05/03 21:18:26
Done.
| |
403 LOG(LS_WARNING) << "Slow RtpDump: took " << delay << "ms to write " | 402 LOG(LS_WARNING) << "Slow RtpDump: took " << delay << "ms to write " |
404 << data_len << " bytes."; | 403 << data_len << " bytes."; |
405 } | 404 } |
406 return result; | 405 return result; |
407 } | 406 } |
408 | 407 |
409 } // namespace cricket | 408 } // namespace cricket |
OLD | NEW |