Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from taste1981/cloudgaming
Browse files Browse the repository at this point in the history
changes for cloud gaming to enable low latency transport
  • Loading branch information
Chunbo authored May 13, 2019
2 parents 5d65b55 + f84ce74 commit da8eff5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions call/rtp_transport_controller_send.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ RtpTransportControllerSend::RtpTransportControllerSend(
TaskQueueExperimentEnabled(), controller_factory);

process_thread_->RegisterModule(&pacer_, RTC_FROM_HERE);
process_thread_->RegisterModule(send_side_cc_.get(), RTC_FROM_HERE);
//process_thread_->RegisterModule(send_side_cc_.get(), RTC_FROM_HERE);
if (!LowLatencyStreamingEnabled()) {
process_thread_->Start();
} else {
Expand All @@ -90,7 +90,7 @@ RtpTransportControllerSend::RtpTransportControllerSend(

RtpTransportControllerSend::~RtpTransportControllerSend() {
process_thread_->Stop();
process_thread_->DeRegisterModule(send_side_cc_.get());
//process_thread_->DeRegisterModule(send_side_cc_.get());
process_thread_->DeRegisterModule(&pacer_);
}

Expand Down
23 changes: 22 additions & 1 deletion modules/pacing/paced_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace webrtc {
const int64_t PacedSender::kMaxQueueLengthMs = 2000;
const float PacedSender::kDefaultPaceMultiplier = 2.5f;

int64_t capture_timestamp = 0;
int64_t end_timestamp = 0;
size_t total_size = 0;
int64_t frame_count = 0;
PacedSender::PacedSender(const Clock* clock,
PacketSender* packet_sender,
RtcEventLog* event_log)
Expand Down Expand Up @@ -92,6 +96,7 @@ PacedSender::PacedSender(const Clock* clock,
UpdateBudgetWithElapsedTime(kMinPacketLimitMs);
if (low_latency_mode_)
prober_->SetEnabled(false);
recorder = fopen("pacer.txt", "a+");
}

PacedSender::~PacedSender() {}
Expand Down Expand Up @@ -356,6 +361,22 @@ void PacedSender::Process() {
<< ",cu: " << clock_->TimeInMilliseconds()
<< ",sz: " << packet.bytes
<< ", q: " << packets_->SizeInPackets();

if (capture_timestamp != packet.capture_time_ms) { // New frame
int64_t last_frame_cost = end_timestamp - capture_timestamp;
int64_t time_since_last_frame =
clock_->TimeInMilliseconds() - end_timestamp;
fprintf(recorder, "%lld\t%lld\t%zd\t%lld\n", frame_count, last_frame_cost,
total_size, time_since_last_frame);
frame_count++;
total_size = 0;
end_timestamp = clock_->TimeInMilliseconds();
capture_timestamp = packet.capture_time_ms;
} else {
capture_timestamp = packet.capture_time_ms;
total_size += packet.bytes;
end_timestamp = clock_->TimeInMilliseconds();
}
if (is_probing && bytes_sent > recommended_probe_size)
break;
} else {
Expand Down Expand Up @@ -414,7 +435,7 @@ bool PacedSender::SendPacket(const PacketQueueInterface::Packet& packet,
packet.retransmission, pacing_info);
critsect_.Enter();
RTC_LOG(LS_ERROR) << "a:" << clock_->TimeInMilliseconds();
if (success) {
if (success && !IsLowLatencyMode()) {
if (first_sent_packet_ms_ == -1)
first_sent_packet_ms_ = clock_->TimeInMilliseconds();
if (!audio_packet || account_for_audio_) {
Expand Down
1 change: 1 addition & 0 deletions modules/pacing/paced_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class PacedSender : public Pacer {

int64_t queue_time_limit RTC_GUARDED_BY(critsect_);
bool account_for_audio_ RTC_GUARDED_BY(critsect_);
FILE* recorder;
};
} // namespace webrtc
#endif // MODULES_PACING_PACED_SENDER_H_
7 changes: 2 additions & 5 deletions modules/video_coding/video_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,13 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
if (_encoder == nullptr)
return VCM_UNINITIALIZED;
SetEncoderParameters(encoder_params, encoder_has_internal_source);
if (_mediaOpt.DropFrame()) {
if (_mediaOpt.DropFrame() && !field_trial::IsEnabled("OWT-LowLatencyMode")) {
RTC_LOG(LS_VERBOSE) << "Drop Frame "
<< "target bitrate "
<< encoder_params.target_bitrate.get_sum_bps()
<< " loss rate " << encoder_params.loss_rate << " rtt "
<< encoder_params.rtt << " input frame rate "
<< encoder_params.input_frame_rate;
// For low latency mode we don't drop.
if (field_trial::IsEnabled("OWT-LowLatencyMode"))
return VCM_OK;
post_encode_callback_->OnDroppedFrame(
EncodedImageCallback::DropReason::kDroppedByMediaOptimizations);
return VCM_OK;
Expand Down Expand Up @@ -304,7 +301,7 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
_encoder->Encode(converted_frame, codecSpecificInfo, next_frame_types);
if (ret < 0) {
RTC_LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
return ret;
//return ret;
}

{
Expand Down

0 comments on commit da8eff5

Please sign in to comment.