Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with guides for GCC evaluation and docker-free compilations #103

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@
target/
src/
.gclient_entries
.gclient_previous_sync_commits
outaudio*
outvideo*
*.log
20 changes: 20 additions & 0 deletions BandwidthEstimator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

class Estimator(object):
def report_states(self, stats: dict):
'''
stats is a dict with the following items
{
"send_time_ms": uint,
"arrival_time_ms": uint,
"payload_type": int,
"sequence_number": uint,
"ssrc": int,
"padding_length": uint,
"header_length": uint,
"payload_size": uint
}
'''
pass

def get_estimated_bandwidth(self)->int:
return int(1e6) # 1Mbps
320 changes: 140 additions & 180 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ steps:
repository: 'alphartc'
command: 'push'
tags: 'latest'
displayName: "Push alphartc image"
displayName: "Push alphartc image"
4 changes: 2 additions & 2 deletions call/bitrate_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const int kDefaultBitrateBps = 300000;
const double kToggleFactor = 0.1;
const uint32_t kMinToggleBitrateBps = 20000;

const int64_t kBweLogIntervalMs = 5000;
const int64_t kBweLogIntervalMs = 200;

double MediaRatio(uint32_t allocated_bitrate, uint32_t protection_bitrate) {
RTC_DCHECK_GT(allocated_bitrate, 0);
Expand Down Expand Up @@ -391,7 +391,7 @@ void BitrateAllocator::OnNetworkEstimateChanged(TargetTransferRate msg) {
// Periodically log the incoming BWE.
int64_t now = msg.at_time.ms();
if (now > last_bwe_log_time_ + kBweLogIntervalMs) {
RTC_LOG(LS_INFO) << "Current BWE " << last_target_bps_;
RTC_LOG(LS_INFO) << "AlphaRTC: Current BWE " << last_target_bps_;
last_bwe_log_time_ = now;
}

Expand Down
57 changes: 57 additions & 0 deletions cmdinfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import json
import glob


RequestBandwidthCommand = "RequestBandwidth"


def fetch_stats(line: str)->dict:
line = line.strip()
try:
stats = json.loads(line)
return stats
except json.decoder.JSONDecodeError:
return None


def request_estimated_bandwidth(line: str)->bool:
line = line.strip()
if RequestBandwidthCommand == line:
return True
return False


def find_estimator_class():
import BandwidthEstimator
return BandwidthEstimator.Estimator


def main(ifd = sys.stdin, ofd = sys.stdout):
estimator_class = find_estimator_class()
estimator = estimator_class()
while True:
line = ifd.readline()
if not line:
break
if isinstance(line, bytes):
line = line.decode("utf-8")
stats = fetch_stats(line)
if stats:
estimator.report_states(stats)
continue
request = request_estimated_bandwidth(line)
if request:
bandwidth = estimator.get_estimated_bandwidth()
ofd.write("{}\n".format(int(bandwidth)).encode("utf-8"))
ofd.flush()
continue
sys.stdout.write(line)
sys.stdout.flush()


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config,
ParseFieldTrial(
{&safe_reset_on_route_change_, &safe_reset_acknowledged_rate_},
key_value_config_->Lookup("WebRTC-Bwe-SafeResetOnRouteChange"));
RTC_LOG(LS_INFO) << "Using AlphaRTC";
}

GoogCcNetworkController::~GoogCcNetworkController() {}
Expand Down Expand Up @@ -110,8 +111,9 @@ NetworkControlUpdate GoogCcNetworkController::OnTargetRateConstraints(

NetworkControlUpdate GoogCcNetworkController::GetDefaultState(
Timestamp at_time) {
RTC_LOG(LS_VERBOSE) << "AlphaRTC: GetDefaultState " << last_estimated_bitrate_bps_ << " bps";
//*-----Set target_rate-----*//
constexpr int32_t default_bitrate_bps = 300000; // default: 300000 bps = 300 kbps
int32_t default_bitrate_bps = last_estimated_bitrate_bps_; // default: 300000 bps = 300 kbps
DataRate bandwidth = DataRate::BitsPerSec(default_bitrate_bps);
TimeDelta rtt = TimeDelta::Millis(last_estimated_rtt_ms_);
NetworkControlUpdate update;
Expand Down Expand Up @@ -159,8 +161,10 @@ NetworkControlUpdate GoogCcNetworkController::GetDefaultState(
}

NetworkControlUpdate GoogCcNetworkController::OnReceiveBwe(BweMessage bwe) {
int32_t default_bitrate_bps = static_cast<int32_t>(bwe.target_rate); // default: 300000 bps = 300 kbps
int32_t default_bitrate_bps = static_cast<int32_t>(bwe.target_rate);
DataRate bandwidth = DataRate::BitsPerSec(default_bitrate_bps);
last_estimated_bitrate_bps_ = default_bitrate_bps;
RTC_LOG(LS_VERBOSE) << "AlphaRTC: OnReceiveBwe " << bwe.target_rate << " bandwidth " << bandwidth.bps() << " bps";
TimeDelta rtt = TimeDelta::Millis(last_estimated_rtt_ms_);
NetworkControlUpdate update;
update.target_rate = TargetTransferRate();
Expand All @@ -174,9 +178,10 @@ NetworkControlUpdate GoogCcNetworkController::OnReceiveBwe(BweMessage bwe) {
update.target_rate->network_estimate.bwe_period = default_bwe_period;
update.target_rate->at_time = Timestamp::Millis(bwe.timestamp_ms);
update.target_rate->target_rate = bandwidth;
update.target_rate->stable_target_rate = bandwidth;

//*-----Set pacing & padding_rate-----*//
int32_t default_pacing_rate = static_cast<int32_t>(bwe.pacing_rate);
int32_t default_pacing_rate = static_cast<int32_t>(bwe.pacing_rate);
int32_t default_padding_rate = 0; // default: 0bps = 0kbps
DataRate pacing_rate = DataRate::BitsPerSec(default_pacing_rate * pacing_factor_);
DataRate padding_rate = DataRate::BitsPerSec(default_padding_rate);
Expand Down
26 changes: 2 additions & 24 deletions modules/remote_bitrate_estimator/remote_estimator_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,13 @@ void RemoteEstimatorProxy::IncomingPacket(int64_t arrival_time_ms,
estimation = onnxinfer::GetBweEstimate(onnx_infer_);
} else {
estimation = cmdinfer::GetEstimatedBandwidth();
RTC_LOG(LS_VERBOSE) << "AlphaRTC: cmdinfer got " << estimation << " bps";
}
bwe.pacing_rate = bwe.padding_rate = bwe.target_rate = estimation;
RTC_LOG(LS_VERBOSE) << "AlphaRTC: bwe.target_rate set as " << bwe.target_rate << " bps";
bwe.timestamp_ms = clock_->TimeInMilliseconds();
SendbackBweEstimation(bwe);
}

// Save per-packet info locally on receiving
// ---------- Collect packet-related info into a local file ----------
double pacing_rate =
time_to_send_bew_message ? estimation : SC_PACER_PACING_RATE_EMPTY;
double padding_rate =
time_to_send_bew_message ? estimation : SC_PACER_PADDING_RATE_EMPTY;

// Save per-packet info locally on receiving
auto res = stats_collect_.StatsCollect(
pacing_rate, padding_rate, header.payloadType,
header.sequenceNumber, send_time_ms, header.ssrc,
header.paddingLength, header.headerLength,
arrival_time_ms, payload_size, 0);
if (res != StatCollect::SCResult::SC_SUCCESS)
{
RTC_LOG(LS_ERROR) << "Collect data failed";
}
std::string out_data = stats_collect_.DumpData();
if (out_data.empty())
{
RTC_LOG(LS_ERROR) << "Save data failed";
}
RTC_LOG(LS_INFO) << out_data;
}

bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs,
Expand Down
22 changes: 22 additions & 0 deletions onl-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [ ! -d "out" ]
then
mkdir out
mkdir out/Default
# Do gclient sync only for initial build,
# as it takes a long time to do for every build
gclient sync
mv -fvn src/* .
rm -rf src
sudo apt install ninja-build
fi


# Build AlphaRTC.
gn gen out/Default --args='is_debug=false'

# Build AlphaRTC e2e app (peerconnection_serverless).
# (check ninja project files for peerconnection_serverless executable under ./examples/BUILD.gn)
ninja -C out/Default peerconnection_serverless
cp out/Default/peerconnection_serverless peerconnection_serverless
Binary file added peerconnection_serverless
Binary file not shown.
44 changes: 44 additions & 0 deletions peerconnection_serverless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import os
import subprocess
import traceback
import json

sys.path.append(os.getcwd())

import cmdinfer


def main():
app = subprocess.Popen(
[f'peerconnection_serverless'] + sys.argv[1:],
bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
try:
cmdinfer.main(app.stdout, app.stdin)
app.wait()
except:
app.terminate()
app.wait()
error_message = traceback.format_exc()
error_message = "\n{}".format(error_message)
sys.stderr.write(error_message)
if len(sys.argv[1:]) == 0:
return
config_file = sys.argv[1]
config_file = json.load(open(config_file, "r"))
if "logging" not in config_file:
return
if "enabled" not in config_file["logging"] or not config_file["logging"]["enabled"]:
return
with open(config_file["logging"]["log_output_path"], "a") as log_file:
log_file.write(error_message)


if __name__ == "__main__":
main()
50 changes: 50 additions & 0 deletions receiver_360p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"serverless_connection": {
"autoclose": 30,
"sender": {
"enabled": false
},
"receiver": {
"enabled": true,
"listening_ip": "0.0.0.0",
"listening_port": 8000
}
},
"bwe_feedback_duration": 200,
"video_source": {
"video_disabled": {
"enabled": true
},
"webcam": {
"enabled": false
},
"video_file": {
"enabled": false
}
},
"audio_source": {
"microphone": {
"enabled": false
},
"audio_file": {
"enabled": true,
"file_path": "testmedia/test.wav"
}
},
"save_to_file": {
"enabled": true,
"audio": {
"file_path": "outaudio.wav"
},
"video": {
"width": 640,
"height": 360,
"fps": 25,
"file_path": "outvideo-360p.yuv"
}
},
"logging": {
"enabled": true,
"log_output_path": "receiver-360p.log"
}
}
50 changes: 50 additions & 0 deletions receiver_720p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"serverless_connection": {
"autoclose": 30,
"sender": {
"enabled": false
},
"receiver": {
"enabled": true,
"listening_ip": "0.0.0.0",
"listening_port": 8000
}
},
"bwe_feedback_duration": 200,
"video_source": {
"video_disabled": {
"enabled": true
},
"webcam": {
"enabled": false
},
"video_file": {
"enabled": false
}
},
"audio_source": {
"microphone": {
"enabled": false
},
"audio_file": {
"enabled": true,
"file_path": "testmedia/test.wav"
}
},
"save_to_file": {
"enabled": true,
"audio": {
"file_path": "outaudio.wav"
},
"video": {
"width": 1280,
"height": 720,
"fps": 25,
"file_path": "outvideo-720p.yuv"
}
},
"logging": {
"enabled": true,
"log_output_path": "receiver-720p.log"
}
}
Loading