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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 enum { | 70 enum { |
71 kRtcpExpectedVersion = 2, | 71 kRtcpExpectedVersion = 2, |
72 kRtcpMinHeaderLength = 4, | 72 kRtcpMinHeaderLength = 4, |
73 kRtcpMinParseLength = 8, | 73 kRtcpMinParseLength = 8, |
74 | 74 |
75 kRtpExpectedVersion = 2, | 75 kRtpExpectedVersion = 2, |
76 kRtpMinParseLength = 12 | 76 kRtpMinParseLength = 12 |
77 }; | 77 }; |
78 | 78 |
79 /* | 79 /* |
80 * Time routines. | |
81 */ | |
82 | |
83 uint32_t GetCurrentRTP(Clock* clock, uint32_t freq) { | |
84 const bool use_global_clock = (clock == NULL); | |
85 Clock* local_clock = clock; | |
86 if (use_global_clock) { | |
87 local_clock = Clock::GetRealTimeClock(); | |
88 } | |
89 uint32_t secs = 0, frac = 0; | |
90 local_clock->CurrentNtp(secs, frac); | |
91 if (use_global_clock) { | |
92 delete local_clock; | |
93 } | |
94 return ConvertNTPTimeToRTP(secs, frac, freq); | |
95 } | |
96 | |
97 uint32_t ConvertNTPTimeToRTP(uint32_t NTPsec, uint32_t NTPfrac, uint32_t freq) { | |
98 float ftemp = (float)NTPfrac / (float)NTP_FRAC; | |
99 uint32_t tmp = (uint32_t)(ftemp * freq); | |
100 return NTPsec * freq + tmp; | |
101 } | |
102 | |
103 uint32_t ConvertNTPTimeToMS(uint32_t NTPsec, uint32_t NTPfrac) { | |
104 int freq = 1000; | |
105 float ftemp = (float)NTPfrac / (float)NTP_FRAC; | |
106 uint32_t tmp = (uint32_t)(ftemp * freq); | |
107 uint32_t MStime = NTPsec * freq + tmp; | |
108 return MStime; | |
109 } | |
110 | |
111 /* | |
112 * Misc utility routines | 80 * Misc utility routines |
113 */ | 81 */ |
114 | 82 |
115 #if defined(_WIN32) | 83 #if defined(_WIN32) |
116 bool StringCompare(const char* str1, const char* str2, | 84 bool StringCompare(const char* str1, const char* str2, |
117 const uint32_t length) { | 85 const uint32_t length) { |
118 return (_strnicmp(str1, str2, length) == 0) ? true : false; | 86 return (_strnicmp(str1, str2, length) == 0) ? true : false; |
119 } | 87 } |
120 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) | 88 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) |
121 bool StringCompare(const char* str1, const char* str2, | 89 bool StringCompare(const char* str1, const char* str2, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return num_zero_bytes; | 465 return num_zero_bytes; |
498 } | 466 } |
499 ptr++; | 467 ptr++; |
500 num_zero_bytes++; | 468 num_zero_bytes++; |
501 } | 469 } |
502 return num_zero_bytes; | 470 return num_zero_bytes; |
503 } | 471 } |
504 } // namespace RtpUtility | 472 } // namespace RtpUtility |
505 | 473 |
506 } // namespace webrtc | 474 } // namespace webrtc |
OLD | NEW |