Skip to content

Commit

Permalink
Move static constants inside class; use .value() to check optional
Browse files Browse the repository at this point in the history
  • Loading branch information
francisyyan committed Jan 15, 2019
1 parent 85a0a11 commit d044f80
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/abr/puffer_raw.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PUFFERRAW_HH
#define PUFFERRAW_HH
#ifndef PUFFER_RAW_HH
#define PUFFER_RAW_HH

#include "puffer.hh"

Expand All @@ -20,4 +20,4 @@ private:
void reinit_sending_time() override;
};

#endif /* PUFFERRAW_HH */
#endif /* PUFFER_RAW_HH */
8 changes: 1 addition & 7 deletions src/abr/puffer_ttp.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#include "puffer_ttp.hh"
#include "ws_client.hh"
#include "torch/script.h"

using namespace std;

const size_t TTP_INPUT_DIM = 62;
const size_t TTP_CURR_DIFF_POS = 5;

PufferTTP::PufferTTP(const WebSocketClient & client,
const string & abr_name, const YAML::Node & abr_config)
: Puffer(client, abr_name, abr_config)
Expand Down Expand Up @@ -51,10 +47,8 @@ void PufferTTP::normalize_in_place(size_t i, vector<double> & input)

void PufferTTP::reinit_sending_time()
{
assert(client_.tcp_info());

/* prepare the raw inputs for ttp */
auto curr_tcp_info = client_.tcp_info().value();
const auto & curr_tcp_info = client_.tcp_info().value();
vector<double> raw_input {(double) curr_tcp_info.delivery_rate,
(double) curr_tcp_info.cwnd,
(double) curr_tcp_info.in_flight,
Expand Down
8 changes: 5 additions & 3 deletions src/abr/puffer_ttp.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PUFFERTTP_HH
#define PUFFERTTP_HH
#ifndef PUFFER_TTP_HH
#define PUFFER_TTP_HH

#include "puffer.hh"
#include "torch/script.h"
Expand All @@ -13,6 +13,8 @@ public:
const std::string & abr_name, const YAML::Node & abr_config);
private:
static constexpr double BAN_PROB_ = 0.5;
static constexpr size_t TTP_INPUT_DIM = 62;
static constexpr size_t TTP_CURR_DIFF_POS = 5;

double ban_prob_ {BAN_PROB_};

Expand All @@ -28,4 +30,4 @@ private:
void reinit_sending_time() override;
};

#endif /* PUFFERTTP_HH */
#endif /* PUFFER_TTP_HH */
9 changes: 5 additions & 4 deletions src/media-server/ws_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ void WebSocketClient::video_chunk_acked(const VideoFormat & format,
const uint64_t transmission_time)
{
try {
assert(tcp_info_);
const auto & ti = tcp_info_.value();

abr_algo_->video_chunk_acked({format, ssim, chunk_size, transmission_time,
(*tcp_info_).cwnd, (*tcp_info_).in_flight, (*tcp_info_).min_rtt,
(*tcp_info_).rtt, (*tcp_info_).delivery_rate});
abr_algo_->video_chunk_acked({
format, ssim, chunk_size, transmission_time,
ti.cwnd, ti.in_flight, ti.min_rtt, ti.rtt, ti.delivery_rate
});
} catch (const exception & e) {
print_exception("video_chunk_acked", e);
throw runtime_error("Error: video_chunk_acked failed with " + abr_name_);
Expand Down

0 comments on commit d044f80

Please sign in to comment.