Have ViE sender also use the last encoded frame timestamp when determining if the video stream is paused/muted, for purposes of padding.
Without this, external encoders with internal sources (i.e. don't use the normal camera path) won't trigger ViEEncoder::DeliverFrame, so time_of_last_incoming_frame_ms_ will always be 0. BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/44099004 Cr-Commit-Position: refs/heads/master@{#9010}
This commit is contained in:
parent
352b2d7a19
commit
099323e39b
@ -122,7 +122,7 @@ ViEEncoder::ViEEncoder(int32_t channel_id,
|
|||||||
pacer_(pacer),
|
pacer_(pacer),
|
||||||
bitrate_allocator_(bitrate_allocator),
|
bitrate_allocator_(bitrate_allocator),
|
||||||
bitrate_controller_(bitrate_controller),
|
bitrate_controller_(bitrate_controller),
|
||||||
time_of_last_incoming_frame_ms_(0),
|
time_of_last_frame_activity_ms_(0),
|
||||||
send_padding_(false),
|
send_padding_(false),
|
||||||
min_transmit_bitrate_kbps_(0),
|
min_transmit_bitrate_kbps_(0),
|
||||||
last_observed_bitrate_bps_(0),
|
last_observed_bitrate_bps_(0),
|
||||||
@ -398,7 +398,7 @@ int32_t ViEEncoder::ScaleInputImage(bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ViEEncoder::GetPaddingNeededBps(int bitrate_bps) const {
|
int ViEEncoder::GetPaddingNeededBps(int bitrate_bps) const {
|
||||||
int64_t time_of_last_incoming_frame_ms;
|
int64_t time_of_last_frame_activity_ms;
|
||||||
int min_transmit_bitrate_bps;
|
int min_transmit_bitrate_bps;
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(data_cs_.get());
|
CriticalSectionScoped cs(data_cs_.get());
|
||||||
@ -406,7 +406,7 @@ int ViEEncoder::GetPaddingNeededBps(int bitrate_bps) const {
|
|||||||
send_padding_ || video_suspended_ || min_transmit_bitrate_kbps_ > 0;
|
send_padding_ || video_suspended_ || min_transmit_bitrate_kbps_ > 0;
|
||||||
if (!send_padding)
|
if (!send_padding)
|
||||||
return 0;
|
return 0;
|
||||||
time_of_last_incoming_frame_ms = time_of_last_incoming_frame_ms_;
|
time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_;
|
||||||
min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_;
|
min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,9 +441,9 @@ int ViEEncoder::GetPaddingNeededBps(int bitrate_bps) const {
|
|||||||
pad_up_to_bitrate_bps = 0;
|
pad_up_to_bitrate_bps = 0;
|
||||||
|
|
||||||
// The amount of padding should decay to zero if no frames are being
|
// The amount of padding should decay to zero if no frames are being
|
||||||
// captured unless a min-transmit bitrate is used.
|
// captured/encoded unless a min-transmit bitrate is used.
|
||||||
int64_t now_ms = TickTime::MillisecondTimestamp();
|
int64_t now_ms = TickTime::MillisecondTimestamp();
|
||||||
if (now_ms - time_of_last_incoming_frame_ms > kStopPaddingThresholdMs)
|
if (now_ms - time_of_last_frame_activity_ms > kStopPaddingThresholdMs)
|
||||||
pad_up_to_bitrate_bps = 0;
|
pad_up_to_bitrate_bps = 0;
|
||||||
|
|
||||||
// Pad up to min bitrate.
|
// Pad up to min bitrate.
|
||||||
@ -508,7 +508,7 @@ void ViEEncoder::DeliverFrame(int id,
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(data_cs_.get());
|
CriticalSectionScoped cs(data_cs_.get());
|
||||||
time_of_last_incoming_frame_ms_ = TickTime::MillisecondTimestamp();
|
time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
|
||||||
if (EncoderPaused()) {
|
if (EncoderPaused()) {
|
||||||
TraceFrameDropStart();
|
TraceFrameDropStart();
|
||||||
return;
|
return;
|
||||||
@ -712,6 +712,11 @@ int32_t ViEEncoder::SendData(
|
|||||||
const RTPVideoHeader* rtp_video_hdr) {
|
const RTPVideoHeader* rtp_video_hdr) {
|
||||||
DCHECK(send_payload_router_ != NULL);
|
DCHECK(send_payload_router_ != NULL);
|
||||||
|
|
||||||
|
{
|
||||||
|
CriticalSectionScoped cs(data_cs_.get());
|
||||||
|
time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(callback_cs_.get());
|
CriticalSectionScoped cs(callback_cs_.get());
|
||||||
if (send_statistics_proxy_ != NULL)
|
if (send_statistics_proxy_ != NULL)
|
||||||
|
@ -210,7 +210,10 @@ class ViEEncoder
|
|||||||
BitrateAllocator* const bitrate_allocator_;
|
BitrateAllocator* const bitrate_allocator_;
|
||||||
BitrateController* const bitrate_controller_;
|
BitrateController* const bitrate_controller_;
|
||||||
|
|
||||||
int64_t time_of_last_incoming_frame_ms_ GUARDED_BY(data_cs_);
|
// The time we last received an input frame or encoded frame. This is used to
|
||||||
|
// track when video is stopped long enough that we also want to stop sending
|
||||||
|
// padding.
|
||||||
|
int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_);
|
||||||
bool send_padding_ GUARDED_BY(data_cs_);
|
bool send_padding_ GUARDED_BY(data_cs_);
|
||||||
int min_transmit_bitrate_kbps_ GUARDED_BY(data_cs_);
|
int min_transmit_bitrate_kbps_ GUARDED_BY(data_cs_);
|
||||||
uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
|
uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user