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

Add insertedSamplesForDeceleration and removedSamplesForAcceleration #408

Merged
merged 6 commits into from
Apr 3, 2019
Merged

Add insertedSamplesForDeceleration and removedSamplesForAcceleration #408

merged 6 commits into from
Apr 3, 2019

Conversation

henbos
Copy link
Collaborator

@henbos henbos commented Mar 18, 2019

Fixes #407.

@henbos henbos requested a review from alvestrand March 18, 2019 09:47
@vr000m
Copy link
Contributor

vr000m commented Mar 18, 2019

Why would the JB not playout packets slowly instead of inserting fake samples? what about video?

@vr000m vr000m assigned vr000m and unassigned vr000m Mar 18, 2019
@vr000m vr000m self-requested a review March 18, 2019 12:12
@ivocreusen
Copy link
Contributor

ivocreusen commented Mar 18, 2019 via email

@vr000m
Copy link
Contributor

vr000m commented Mar 18, 2019

I thought most Jitter Buffer (JB) were timestamp oriented, i.e., the JB would push out to the decoder at the indicated timestamp. My understanding was as follows -- If a JB is going to underflow (assume there is a low water mark threshold which triggers before underflow actually occurs), the JB would add a constant delay to each audio packet/ video frame, thus slowing down the time to underflow because the JB is not triggering at the intended timeout but delaying it.

The way I read the proposal here is suggesting (AFAICT) that the JB sends the audio packets out for decoding at the intended and in the Playout Buffer (PB) where data is played out at the sampling rate, silent samples are added to slow down playback?

Is my understanding of your proposal correct?

@vr000m
Copy link
Contributor

vr000m commented Mar 18, 2019

Why do we need acceleratedSamples? would the jitter buffer (JB) not discard the packet earlier before sending it to playout? Is there a reason to send the packet from the JB even though it was late? simply put, why wouldn't packetsDiscarded not work for this case?

@vr000m
Copy link
Contributor

vr000m commented Mar 18, 2019

How is deceleratedSamples different from concealedSamples?

@ivocreusen
Copy link
Contributor

ivocreusen commented Mar 18, 2019 via email

@henbos
Copy link
Collaborator Author

henbos commented Mar 19, 2019

Please take another look @vr000m, see Ivo's comment.

Repeating some key points of the above:

  • This is not implementation-specific: "The one thing that any method of increasing or reducing the speed of audio has in common is that samples must be added/removed, which is what the stats are supposed to reflect."
  • Packet loss concealment happen when we have no samples for playout, whereas deceleratedSamples are samples added to prevent us from reaching such a state. There is an audible difference, and they are not the same thing.
  • It is useful to know all of these different metrics, which is one of the reasons people still use legacy goog-stats.

<dd>
<p>
The total number of samples inserted in order to decelerate playout speed. This
can happen to prevent the jitter buffer from becoming empty.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternate text: "When playout is slowed down, this counter is increased by the difference between the number of samples received and the number of samples played out in the interval. If playout is slowed down by inserting samples, this will be the number of inserted samples."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name: insertedSamples
Rephrase: Decelerating is a consequence, not a definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with Chen and things to note:

  • Samples added or removed for acceleration/deceleration may be based on true samples. When "removing samples" we are not simply discarding samples, how we end up with less samples is up to the implementation and may involve analysing all of the samples that we did receive.
  • If the name is as vague as "insert/add" it sounds like this would include concealedSamples, which is not the case.
  • If the name is as vague as "remove/discard" this sounds like it would include buffer flushes, which is not the case.
  • We are talking about samples for playout, not adding or removing to the jitter buffer per-se.

Conclusion:

  • Harald's definition is good.
  • The name should include "accelerate/decelerate" or similar, to avoid confusion with other reasons for adding or removing.

Copy link
Collaborator Author

@henbos henbos Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

Name: insertedDeceleratedSamples
Description: Harald's definition

<dd>
<p>
The total number of samples discarded in order to accelerate playout speed. This
can happen to prevent the jitter buffer from becoming full.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When playout is speeded up, this counter is increased by the difference between the number of samples received and the number of samples played out. If speedup is achieved by discarding samples, this will be the count of samples discarded."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name: removedSamples
Rephrase: Accelerate is a consequence, not a definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relating to my comment above, saying "removed" is better than saying "discarded", because discarded sounds like that data was not examined at all.

Copy link
Collaborator Author

@henbos henbos Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

Name: removedAcceleratedSamples
Description: Harald's definition but replace "discarded" with "removed"

@henbos
Copy link
Collaborator Author

henbos commented Mar 20, 2019

@vr000m to please make suggestions

@henbos henbos changed the title Add deceleratedSamples and acceleratedSamples Add insertedSamplesForDeceleration and removedSamplesForAcceleration Mar 21, 2019
@henbos
Copy link
Collaborator Author

henbos commented Mar 21, 2019

Based on input from comments and Chen Xing the PR is updated. Please take another look. @alvestrand

@vr000m note that the case discussed of "what if samples are inserted only to be removed?" is not applicable, as this happens after the jitter buffer. You might add or remove before playout, but not both. The new definition is also more flexible about implementation strategy.

The new names still make it clear that these counters have to do with acceleration and deceleration, which is necessary as to not include concealedSamples or jitter buffer flushes as "inserted" or "removed" samples.

@vr000m
Copy link
Contributor

vr000m commented Apr 1, 2019

@henbos thanks for the update, these definitions make more sense to me and allay my concerns. Do we really need For* in the metric names?

@vr000m
Copy link
Contributor

vr000m commented Apr 1, 2019

I have another question, are the insertions and removals happening at playback clockrate or at packet arrival, the reason for asking is -- "would make sense to count the number of times the decision to accelerate/decelerate is made?"

to calculate something like average number of insertions or removals?

Copy link
Contributor

@vr000m vr000m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need For* in the names? otherwise LGTM

Copy link
Collaborator Author

@henbos henbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need For* in the names? otherwise LGTM

I think so. For example, if the acceleration name is "removedSamples" instead of "removedSamplesForAcceleration" it sounds by the name like this applies to any removed samples, but we don't want this to include jitter buffer flushes. This specifically measures sample differences related to acceleration and deceleration, so this should be called out in the name.

@vr000m Requesting that you merge this. I fixed the nit, but did not change the names.

webrtc-stats.html Show resolved Hide resolved
@henbos
Copy link
Collaborator Author

henbos commented Apr 2, 2019

I have another question, are the insertions and removals happening at playback clockrate or at packet arrival, the reason for asking is -- "would make sense to count the number of times the decision to accelerate/decelerate is made?"

to calculate something like average number of insertions or removals?

I would discuss this separately, but I don't think so. I think the number of times a decision is made to accelerate or decelerate would be implementation specific and if acceleration/deceleration is tiny I think the number of times it happens doesn't tell you anything, versus it happening not very often but happening at a great magnitude.

I think what is interesting to calculate is the average number of accelerated/decelerated samples compared to the number of samples received, and that does not require any new counters, we already have samplesReceived.

Copy link
Contributor

@alvestrand alvestrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks Good Enough now.

@vr000m
Copy link
Contributor

vr000m commented Apr 3, 2019

if the behaviour is unknown for how often it happens, we should indeed wait for deployment experience for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants