aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.cc
blob: b7e4f971fa4cd368c59b342133c37ebd8151cbb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <algorithm>

#include "webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/common.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"

namespace webrtc {
namespace testing {
namespace bwe {

TcpBweReceiver::TcpBweReceiver(int flow_id)
    : BweReceiver(flow_id),
      last_feedback_ms_(0),
      latest_owd_ms_(0) {
}

TcpBweReceiver::~TcpBweReceiver() {
}

void TcpBweReceiver::ReceivePacket(int64_t arrival_time_ms,
                                   const MediaPacket& media_packet) {
  latest_owd_ms_ = arrival_time_ms - media_packet.sender_timestamp_ms() / 1000;
  acks_.push_back(media_packet.header().sequenceNumber);

  // Log received packet information.
  BweReceiver::ReceivePacket(arrival_time_ms, media_packet);
}

FeedbackPacket* TcpBweReceiver::GetFeedback(int64_t now_ms) {
  int64_t corrected_send_time_ms = now_ms - latest_owd_ms_;
  FeedbackPacket* fb =
      new TcpFeedback(flow_id_, now_ms * 1000, corrected_send_time_ms, acks_);
  last_feedback_ms_ = now_ms;
  acks_.clear();
  return fb;
}

}  // namespace bwe
}  // namespace testing
}  // namespace webrtc