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 |
11 #include "webrtc/modules/audio_coding/test/Channel.h" | 11 #include "webrtc/modules/audio_coding/test/Channel.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <iostream> | 14 #include <iostream> |
15 | 15 |
16 #include "webrtc/base/format_macros.h" | 16 #include "webrtc/base/format_macros.h" |
17 #include "webrtc/system_wrappers/include/tick_util.h" | 17 #include "webrtc/base/timeutils.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 int32_t Channel::SendData(FrameType frameType, | 21 int32_t Channel::SendData(FrameType frameType, |
22 uint8_t payloadType, | 22 uint8_t payloadType, |
23 uint32_t timeStamp, | 23 uint32_t timeStamp, |
24 const uint8_t* payloadData, | 24 const uint8_t* payloadData, |
25 size_t payloadSize, | 25 size_t payloadSize, |
26 const RTPFragmentationHeader* fragmentation) { | 26 const RTPFragmentationHeader* fragmentation) { |
27 WebRtcRTPHeader rtpInfo; | 27 WebRtcRTPHeader rtpInfo; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 _bitStreamFile(NULL), | 227 _bitStreamFile(NULL), |
228 _saveBitStream(false), | 228 _saveBitStream(false), |
229 _lastPayloadType(-1), | 229 _lastPayloadType(-1), |
230 _isStereo(false), | 230 _isStereo(false), |
231 _leftChannel(true), | 231 _leftChannel(true), |
232 _lastInTimestamp(0), | 232 _lastInTimestamp(0), |
233 _useLastFrameSize(false), | 233 _useLastFrameSize(false), |
234 _lastFrameSizeSample(0), | 234 _lastFrameSizeSample(0), |
235 _packetLoss(0), | 235 _packetLoss(0), |
236 _useFECTestWithPacketLoss(false), | 236 _useFECTestWithPacketLoss(false), |
237 _beginTime(TickTime::MillisecondTimestamp()), | 237 _beginTime(rtc::TimeMillis()), |
238 _totalBytes(0), | 238 _totalBytes(0), |
239 external_send_timestamp_(-1), | 239 external_send_timestamp_(-1), |
240 external_sequence_number_(-1), | 240 external_sequence_number_(-1), |
241 num_packets_to_drop_(0) { | 241 num_packets_to_drop_(0) { |
242 int n; | 242 int n; |
243 int k; | 243 int k; |
244 for (n = 0; n < MAX_NUM_PAYLOADS; n++) { | 244 for (n = 0; n < MAX_NUM_PAYLOADS; n++) { |
245 _payloadStats[n].payloadType = -1; | 245 _payloadStats[n].payloadType = -1; |
246 _payloadStats[n].newPacket = true; | 246 _payloadStats[n].newPacket = true; |
247 for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { | 247 for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 _payloadStats[n].payloadType = -1; | 279 _payloadStats[n].payloadType = -1; |
280 _payloadStats[n].newPacket = true; | 280 _payloadStats[n].newPacket = true; |
281 for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { | 281 for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { |
282 _payloadStats[n].frameSizeStats[k].frameSizeSample = 0; | 282 _payloadStats[n].frameSizeStats[k].frameSizeSample = 0; |
283 _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; | 283 _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; |
284 _payloadStats[n].frameSizeStats[k].numPackets = 0; | 284 _payloadStats[n].frameSizeStats[k].numPackets = 0; |
285 _payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0; | 285 _payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0; |
286 _payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0; | 286 _payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0; |
287 } | 287 } |
288 } | 288 } |
289 _beginTime = TickTime::MillisecondTimestamp(); | 289 _beginTime = rtc::TimeMillis(); |
290 _totalBytes = 0; | 290 _totalBytes = 0; |
291 _channelCritSect.Leave(); | 291 _channelCritSect.Leave(); |
292 } | 292 } |
293 | 293 |
294 int16_t Channel::Stats(CodecInst& codecInst, | 294 int16_t Channel::Stats(CodecInst& codecInst, |
295 ACMTestPayloadStats& payloadStats) { | 295 ACMTestPayloadStats& payloadStats) { |
296 _channelCritSect.Enter(); | 296 _channelCritSect.Enter(); |
297 int n; | 297 int n; |
298 payloadStats.payloadType = -1; | 298 payloadStats.payloadType = -1; |
299 for (n = 0; n < MAX_NUM_PAYLOADS; n++) { | 299 for (n = 0; n < MAX_NUM_PAYLOADS; n++) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 uint32_t Channel::LastInTimestamp() { | 404 uint32_t Channel::LastInTimestamp() { |
405 uint32_t timestamp; | 405 uint32_t timestamp; |
406 _channelCritSect.Enter(); | 406 _channelCritSect.Enter(); |
407 timestamp = _lastInTimestamp; | 407 timestamp = _lastInTimestamp; |
408 _channelCritSect.Leave(); | 408 _channelCritSect.Leave(); |
409 return timestamp; | 409 return timestamp; |
410 } | 410 } |
411 | 411 |
412 double Channel::BitRate() { | 412 double Channel::BitRate() { |
413 double rate; | 413 double rate; |
414 uint64_t currTime = TickTime::MillisecondTimestamp(); | 414 uint64_t currTime = rtc::TimeMillis(); |
415 _channelCritSect.Enter(); | 415 _channelCritSect.Enter(); |
416 rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime); | 416 rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime); |
417 _channelCritSect.Leave(); | 417 _channelCritSect.Leave(); |
418 return rate; | 418 return rate; |
419 } | 419 } |
420 | 420 |
421 } // namespace webrtc | 421 } // namespace webrtc |
OLD | NEW |