mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Utilise existing rate unset representation C.RATE_UNSET_INT
Use `C.RATE_UNSET_INT` instead of introducing `Long.MIN_VALUE` as the default value for rate parameters. Modifies default behaviour of the `TrackSelection.getLatestBitrateEstimate()` method and the `measuredThroughputInKbps` parameter in `CmcdHeadersFactory.CmcdRequest`. PiperOrigin-RevId: 555939420
This commit is contained in:
parent
0466bd7957
commit
45348f1576
3 changed files with 11 additions and 10 deletions
|
|
@ -411,7 +411,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
|||
playbackSpeed = 1f;
|
||||
reason = C.SELECTION_REASON_UNKNOWN;
|
||||
lastBufferEvaluationMs = C.TIME_UNSET;
|
||||
latestBitrateEstimate = Long.MIN_VALUE;
|
||||
latestBitrateEstimate = C.RATE_UNSET_INT;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
|
|
|
|||
|
|
@ -296,10 +296,10 @@ public interface ExoTrackSelection extends TrackSelection {
|
|||
/**
|
||||
* Returns the most recent bitrate estimate utilised for track selection.
|
||||
*
|
||||
* <p>The default behavior is to return {@link Long#MIN_VALUE}, indicating that the bitrate
|
||||
* <p>The default behavior is to return {@link C#RATE_UNSET_INT}, indicating that the bitrate
|
||||
* estimate was not computed for the track selection decision.
|
||||
*/
|
||||
default long getLatestBitrateEstimate() {
|
||||
return Long.MIN_VALUE;
|
||||
return C.RATE_UNSET_INT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ public final class CmcdHeadersFactory {
|
|||
cmcdRequest.setBufferLengthMs(Util.usToMs(bufferedDurationUs));
|
||||
}
|
||||
if (cmcdConfiguration.isMeasuredThroughputLoggingAllowed()
|
||||
&& trackSelection.getLatestBitrateEstimate() != Long.MIN_VALUE) {
|
||||
&& trackSelection.getLatestBitrateEstimate() != C.RATE_UNSET_INT) {
|
||||
cmcdRequest.setMeasuredThroughputInKbps(
|
||||
Util.ceilDivide(trackSelection.getLatestBitrateEstimate(), 1000));
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ public final class CmcdHeadersFactory {
|
|||
/** Creates a new instance with default values. */
|
||||
public Builder() {
|
||||
this.bufferLengthMs = C.TIME_UNSET;
|
||||
this.measuredThroughputInKbps = Long.MIN_VALUE;
|
||||
this.measuredThroughputInKbps = C.RATE_UNSET_INT;
|
||||
this.deadlineMs = C.TIME_UNSET;
|
||||
}
|
||||
|
||||
|
|
@ -491,14 +491,15 @@ public final class CmcdHeadersFactory {
|
|||
|
||||
/**
|
||||
* Sets the {@link CmcdRequest#measuredThroughputInKbps}. Rounded to nearest 100 kbps. The
|
||||
* default value is {@link Long#MIN_VALUE}.
|
||||
* default value is {@link C#RATE_UNSET_INT}.
|
||||
*
|
||||
* @throws IllegalArgumentException If {@code measuredThroughputInKbps} is not equal to {@link
|
||||
* Long#MIN_VALUE} and is negative.
|
||||
* C#RATE_UNSET_INT} and is negative.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setMeasuredThroughputInKbps(long measuredThroughputInKbps) {
|
||||
checkArgument(measuredThroughputInKbps >= 0 || measuredThroughputInKbps == Long.MIN_VALUE);
|
||||
checkArgument(
|
||||
measuredThroughputInKbps >= 0 || measuredThroughputInKbps == C.RATE_UNSET_INT);
|
||||
this.measuredThroughputInKbps = ((measuredThroughputInKbps + 50) / 100) * 100;
|
||||
|
||||
return this;
|
||||
|
|
@ -551,7 +552,7 @@ public final class CmcdHeadersFactory {
|
|||
|
||||
/**
|
||||
* The throughput between client and server, as measured by the client, or {@link
|
||||
* Long#MIN_VALUE} if unset.
|
||||
* C#RATE_UNSET_INT} if unset.
|
||||
*
|
||||
* <p>This value MUST be rounded to the nearest 100 kbps. This value, however derived, SHOULD be
|
||||
* the value that the client is using to make its next Adaptive Bitrate switching decision. If
|
||||
|
|
@ -607,7 +608,7 @@ public final class CmcdHeadersFactory {
|
|||
if (bufferLengthMs != C.TIME_UNSET) {
|
||||
headerValueList.add(CmcdConfiguration.KEY_BUFFER_LENGTH + "=" + bufferLengthMs);
|
||||
}
|
||||
if (measuredThroughputInKbps != Long.MIN_VALUE) {
|
||||
if (measuredThroughputInKbps != C.RATE_UNSET_INT) {
|
||||
headerValueList.add(
|
||||
CmcdConfiguration.KEY_MEASURED_THROUGHPUT + "=" + measuredThroughputInKbps);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue