Channel.cc revision 05db352f56b369444e1a83c5c85a4fb513bf60f0
1470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com/* 216b6b90a82b796460bb20762761182c7d104cd2dtina.legrand@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * 4470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * Use of this source code is governed by a BSD-style license 5470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * that can be found in the LICENSE file in the root of the source 6470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * tree. An additional intellectual property rights grant can be found 7470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * in the file PATENTS. All contributing project authors may 8470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * be found in the AUTHORS file in the root of the source tree. 9470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com */ 10470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 11a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org#include "webrtc/modules/audio_coding/main/test/Channel.h" 12a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org 13470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include <assert.h> 14470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include <iostream> 15470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 164591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org#include "webrtc/base/format_macros.h" 17a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org#include "webrtc/system_wrappers/interface/tick_util.h" 18a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 19470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 20554ae1ad4ed3e6d1d9d807f15324d2f875888d23tina.legrand@webrtc.orgnamespace webrtc { 21470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 224591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.orgint32_t Channel::SendData(FrameType frameType, 234591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org uint8_t payloadType, 244591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org uint32_t timeStamp, 254591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org const uint8_t* payloadData, 264591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org size_t payloadSize, 27d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org const RTPFragmentationHeader* fragmentation) { 28d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org WebRtcRTPHeader rtpInfo; 29d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int32_t status; 304591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org size_t payloadDataSize = payloadSize; 31d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 32d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.header.markerBit = false; 33d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.header.ssrc = 0; 34a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org rtpInfo.header.sequenceNumber = (external_sequence_number_ < 0) ? 35a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org _seqNo++ : static_cast<uint16_t>(external_sequence_number_); 36d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.header.payloadType = payloadType; 37a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org rtpInfo.header.timestamp = (external_send_timestamp_ < 0) ? timeStamp : 38a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org static_cast<uint32_t>(external_send_timestamp_); 39a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org 40d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (frameType == kAudioFrameCN) { 41d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.type.Audio.isCNG = true; 42d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 43d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.type.Audio.isCNG = false; 44d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 45d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (frameType == kFrameEmpty) { 46d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // Skip this frame 47d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return 0; 48d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 49d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 50d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.type.Audio.channel = 1; 51d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // Treat fragmentation separately 52d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (fragmentation != NULL) { 53d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // If silence for too long, send only new data. 5405db352f56b369444e1a83c5c85a4fb513bf60f0henrik.lundin@webrtc.org if ((fragmentation->fragmentationVectorSize == 2) && 5505db352f56b369444e1a83c5c85a4fb513bf60f0henrik.lundin@webrtc.org (fragmentation->fragmentationTimeDiff[1] <= 0x3fff)) { 56d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // only 0x80 if we have multiple blocks 57d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1]; 584591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) + 594591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org fragmentation->fragmentationLength[1]; 60d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF); 61d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF); 62d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadData[3] = uint8_t(REDheader & 0x000000FF); 63d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 64d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadData[4] = fragmentation->fragmentationPlType[0]; 65d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // copy the RED data 66d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(_payloadData + 5, 67d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadData + fragmentation->fragmentationOffset[1], 68d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org fragmentation->fragmentationLength[1]); 69d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // copy the normal data 70d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(_payloadData + 5 + fragmentation->fragmentationLength[1], 71d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadData + fragmentation->fragmentationOffset[0], 72d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org fragmentation->fragmentationLength[0]); 73d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadDataSize += 5; 74d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 75d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // single block (newest one) 76d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0], 77d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org fragmentation->fragmentationLength[0]); 784591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org payloadDataSize = fragmentation->fragmentationLength[0]; 79d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0]; 80470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 81d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 82d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(_payloadData, payloadData, payloadDataSize); 83d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_isStereo) { 84d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_leftChannel) { 85d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader)); 86d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _leftChannel = false; 87d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.type.Audio.channel = 1; 88d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 89d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader)); 90d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _leftChannel = true; 91d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rtpInfo.type.Audio.channel = 2; 92d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 93470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 94d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 95d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 96d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 97d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_saveBitStream) { 98d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org //fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile); 99d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 100d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 101d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (!_isStereo) { 102d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org CalcStatistics(rtpInfo, payloadSize); 103d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 104d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _lastInTimestamp = timeStamp; 105d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _totalBytes += payloadDataSize; 106d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 107d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 108d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_useFECTestWithPacketLoss) { 109d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _packetLoss += 1; 110d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_packetLoss == 3) { 111d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _packetLoss = 0; 112d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return 0; 113470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 114d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 115470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 116a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org if (num_packets_to_drop_ > 0) { 117a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org num_packets_to_drop_--; 118a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org return 0; 119a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org } 120a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org 121d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize, rtpInfo); 122470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 123d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return status; 124470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 125470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 126c2d69d3229329ebc74e9b559bb1154695246b47dturaj@webrtc.org// TODO(turajs): rewite this method. 1274591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.orgvoid Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { 128d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 129d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if ((rtpInfo.header.payloadType != _lastPayloadType) 130d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org && (_lastPayloadType != -1)) { 131d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // payload-type is changed. 132d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // we have to terminate the calculations on the previous payload type 133d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // we ignore the last packet in that payload type just to make things 134d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // easier. 135d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_PAYLOADS; n++) { 136d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_lastPayloadType == _payloadStats[n].payloadType) { 137d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].newPacket = true; 138d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 139d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 140470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 141d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 142d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _lastPayloadType = rtpInfo.header.payloadType; 143d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 144d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org bool newPayload = true; 145d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ACMTestPayloadStats* currentPayloadStr = NULL; 146d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_PAYLOADS; n++) { 147d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (rtpInfo.header.payloadType == _payloadStats[n].payloadType) { 148d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org newPayload = false; 149d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr = &_payloadStats[n]; 150d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 151470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 152d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 153d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 154d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (!newPayload) { 155d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (!currentPayloadStr->newPacket) { 156d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org uint32_t lastFrameSizeSample = (uint32_t)( 157d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org (uint32_t) rtpInfo.header.timestamp 158d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org - (uint32_t) currentPayloadStr->lastTimestamp); 159d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org assert(lastFrameSizeSample > 0); 160d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int k = 0; 161d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org while ((currentPayloadStr->frameSizeStats[k].frameSizeSample 162d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org != lastFrameSizeSample) 163d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org && (currentPayloadStr->frameSizeStats[k].frameSizeSample != 0)) { 164d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org k++; 165d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 166d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr 167d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ->frameSizeStats[k]); 168d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentFrameSizeStats->frameSizeSample = (int16_t) lastFrameSizeSample; 169d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 170d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // increment the number of encoded samples. 171d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentFrameSizeStats->totalEncodedSamples += lastFrameSizeSample; 172d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // increment the number of recveived packets 173d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentFrameSizeStats->numPackets++; 174d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // increment the total number of bytes (this is based on 175d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // the previous payload we don't know the frame-size of 176d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // the current payload. 177d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr 178d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ->lastPayloadLenByte; 179d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // store the maximum payload-size (this is based on 180d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // the previous payload we don't know the frame-size of 181d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // the current payload. 182d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (currentFrameSizeStats->maxPayloadLen 183d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org < currentPayloadStr->lastPayloadLenByte) { 184d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentFrameSizeStats->maxPayloadLen = currentPayloadStr 185d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ->lastPayloadLenByte; 186d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 187d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // store the current values for the next time 188d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; 189d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->lastPayloadLenByte = payloadSize; 190d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 191d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->newPacket = false; 192d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->lastPayloadLenByte = payloadSize; 193d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; 194d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org currentPayloadStr->payloadType = rtpInfo.header.payloadType; 19578f0db4710c7cf00830646c75d8782ab426d514cturaj@webrtc.org memset(currentPayloadStr->frameSizeStats, 0, MAX_NUM_FRAMESIZES * 19678f0db4710c7cf00830646c75d8782ab426d514cturaj@webrtc.org sizeof(ACMTestFrameSizeStats)); 197470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 198d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 199d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org n = 0; 200d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org while (_payloadStats[n].payloadType != -1) { 201d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org n++; 202470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 203d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org // first packet 204d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].newPacket = false; 205d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].lastPayloadLenByte = payloadSize; 206d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].lastTimestamp = rtpInfo.header.timestamp; 207d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].payloadType = rtpInfo.header.payloadType; 20878f0db4710c7cf00830646c75d8782ab426d514cturaj@webrtc.org memset(_payloadStats[n].frameSizeStats, 0, MAX_NUM_FRAMESIZES * 20978f0db4710c7cf00830646c75d8782ab426d514cturaj@webrtc.org sizeof(ACMTestFrameSizeStats)); 210d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 211470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 212470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 213d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgChannel::Channel(int16_t chID) 214d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org : _receiverACM(NULL), 215d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _seqNo(0), 216d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect(CriticalSectionWrapper::CreateCriticalSection()), 217d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _bitStreamFile(NULL), 218d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _saveBitStream(false), 219d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _lastPayloadType(-1), 220d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _isStereo(false), 221d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _leftChannel(true), 222d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _lastInTimestamp(0), 223d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _packetLoss(0), 224d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _useFECTestWithPacketLoss(false), 225d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _beginTime(TickTime::MillisecondTimestamp()), 226a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org _totalBytes(0), 227a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org external_send_timestamp_(-1), 228a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org external_sequence_number_(-1), 229a305e9612afb9feac6bdbced512beb3a2557c3e2turaj@webrtc.org num_packets_to_drop_(0) { 230d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 231d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int k; 232d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_PAYLOADS; n++) { 233d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].payloadType = -1; 234d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].newPacket = true; 235d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { 236d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].frameSizeSample = 0; 237d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; 238d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].numPackets = 0; 239d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0; 240d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0; 241470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 242d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 243d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (chID >= 0) { 244d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _saveBitStream = true; 245d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org char bitStreamFileName[500]; 246d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org sprintf(bitStreamFileName, "bitStream_%d.dat", chID); 247d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _bitStreamFile = fopen(bitStreamFileName, "wb"); 248d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } else { 249d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _saveBitStream = false; 250d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 251470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 252470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 253d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgChannel::~Channel() { 254d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org delete _channelCritSect; 255470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 256470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 257d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgvoid Channel::RegisterReceiverACM(AudioCodingModule* acm) { 258d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _receiverACM = acm; 259d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return; 260470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 261470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 262d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgvoid Channel::ResetStats() { 263d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 264d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int k; 265d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 266d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _lastPayloadType = -1; 267d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_PAYLOADS; n++) { 268d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].payloadType = -1; 269d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].newPacket = true; 270d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (k = 0; k < MAX_NUM_FRAMESIZES; k++) { 271d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].frameSizeSample = 0; 272d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; 273d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].numPackets = 0; 274d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0; 275d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0; 276470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 277d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 278d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _beginTime = TickTime::MillisecondTimestamp(); 279d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _totalBytes = 0; 280d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 281470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 282470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 283d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgint16_t Channel::Stats(CodecInst& codecInst, 284d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ACMTestPayloadStats& payloadStats) { 285d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 286d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 287d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.payloadType = -1; 288d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_PAYLOADS; n++) { 289d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_payloadStats[n].payloadType == codecInst.pltype) { 290d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memcpy(&payloadStats, &_payloadStats[n], sizeof(ACMTestPayloadStats)); 291d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 292470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 293d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 294d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (payloadStats.payloadType == -1) { 295d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 296d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return -1; 297d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 298d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_FRAMESIZES; n++) { 299d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (payloadStats.frameSizeStats[n].frameSizeSample == 0) { 300d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 301d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return 0; 302470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 303d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats 304d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org .frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq; 305470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 306d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[n].rateBitPerSec = 307d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 308d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org / payloadStats.frameSizeStats[n].usageLenSec; 309470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 310d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 311d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 312d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return 0; 313470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 314470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 315d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgvoid Channel::Stats(uint32_t* numPackets) { 316d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 317d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int k; 318d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 319d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t)); 320d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (k = 0; k < MAX_NUM_PAYLOADS; k++) { 321d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_payloadStats[k].payloadType == -1) { 322d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 323470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 324d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org numPackets[k] = 0; 325d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_FRAMESIZES; n++) { 326d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) { 327d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 328d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 329d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org numPackets[k] += _payloadStats[k].frameSizeStats[n].numPackets; 330d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 331d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 332d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 333470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 334470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 335d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgvoid Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) { 336d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 337470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 338d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int k; 339d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org int n; 340d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org memset(payloadLenByte, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t)); 341d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (k = 0; k < MAX_NUM_PAYLOADS; k++) { 342d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_payloadStats[k].payloadType == -1) { 343d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 344470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 345d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadType[k] = (uint8_t) _payloadStats[k].payloadType; 346d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadLenByte[k] = 0; 347d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (n = 0; n < MAX_NUM_FRAMESIZES; n++) { 348d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) { 349d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 350d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 351d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n] 352d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org .totalPayloadLenByte; 353d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 354d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 355d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 356d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 357d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org} 358470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 359d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgvoid Channel::PrintStats(CodecInst& codecInst) { 360d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ACMTestPayloadStats payloadStats; 361d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org Stats(codecInst, payloadStats); 362d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("%s %d kHz\n", codecInst.plname, codecInst.plfreq / 1000); 363d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("=====================================================\n"); 364d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (payloadStats.payloadType == -1) { 365d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("No Packets are sent with payload-type %d (%s)\n\n", 366d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org codecInst.pltype, codecInst.plname); 367d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return; 368d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 369d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org for (int k = 0; k < MAX_NUM_FRAMESIZES; k++) { 370d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org if (payloadStats.frameSizeStats[k].frameSizeSample == 0) { 371d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org break; 372470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 373d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("Frame-size.................... %d samples\n", 374d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[k].frameSizeSample); 375d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("Average Rate.................. %.0f bits/sec\n", 376d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[k].rateBitPerSec); 3774591fbd09f9cb6e83433c49a12dd8524c2806502pkasting@chromium.org printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n", 378d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[k].maxPayloadLen); 379d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf( 380d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org "Maximum Instantaneous Rate.... %.0f bits/sec\n", 381d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org ((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 382d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org * (double) codecInst.plfreq) 383d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org / (double) payloadStats.frameSizeStats[k].frameSizeSample); 384d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("Number of Packets............. %u\n", 385d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org (unsigned int) payloadStats.frameSizeStats[k].numPackets); 386d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org printf("Duration...................... %0.3f sec\n\n", 387d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org payloadStats.frameSizeStats[k].usageLenSec); 388d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org 389d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org } 390470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 391470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 392470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 393d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orguint32_t Channel::LastInTimestamp() { 394d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org uint32_t timestamp; 395d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 396d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org timestamp = _lastInTimestamp; 397d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 398d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return timestamp; 399470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 400470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 401d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.orgdouble Channel::BitRate() { 402d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org double rate; 403d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org uint64_t currTime = TickTime::MillisecondTimestamp(); 404d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Enter(); 405d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime); 406d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org _channelCritSect->Leave(); 407d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org return rate; 408d7a71d0719251db2a31b71a9d6e9fef4f60ba778andrew@webrtc.org} 409554ae1ad4ed3e6d1d9d807f15324d2f875888d23tina.legrand@webrtc.org 410d5726a1286ce53c47ebd2d21d61b2772fc24aaedtina.legrand@webrtc.org} // namespace webrtc 411