Refactor method CmcdLog.createInstance
to accept bufferedDurationUs
Instead of providing `playbackDurationUs` and `loadPositionUs` individually, which are used to calculate the buffer duration for CMCD logging, we can directly pass the pre-calculated `bufferedDurationUs` available in the `getNextChunk` method of the chunk source classes. Issue: google/ExoPlayer#8699 #minor-release PiperOrigin-RevId: 540630112
This commit is contained in:
parent
18bc893210
commit
be9b057dda
@ -42,14 +42,13 @@ public final class CmcdLog {
|
||||
*
|
||||
* @param cmcdConfiguration The {@link CmcdConfiguration} for this chunk source.
|
||||
* @param trackSelection The {@linkplain ExoTrackSelection track selection}.
|
||||
* @param playbackPositionUs The current playback position in microseconds.
|
||||
* @param loadPositionUs The current load position in microseconds.
|
||||
* @param bufferedDurationUs The duration of media currently buffered from the current playback
|
||||
* position, in microseconds.
|
||||
*/
|
||||
public static CmcdLog createInstance(
|
||||
CmcdConfiguration cmcdConfiguration,
|
||||
ExoTrackSelection trackSelection,
|
||||
long playbackPositionUs,
|
||||
long loadPositionUs) {
|
||||
long bufferedDurationUs) {
|
||||
ImmutableMap<@CmcdConfiguration.HeaderKey String, String> customData =
|
||||
cmcdConfiguration.requestConfig.getCustomData();
|
||||
int bitrateKbps = trackSelection.getSelectedFormat().bitrate / 1000;
|
||||
@ -65,8 +64,7 @@ public final class CmcdLog {
|
||||
new CmcdLog.CmcdRequest.Builder()
|
||||
.setCustomData(customData.get(CmcdConfiguration.KEY_CMCD_REQUEST));
|
||||
if (cmcdConfiguration.isBufferLengthLoggingAllowed()) {
|
||||
cmcdRequest.setBufferLengthMs(
|
||||
loadPositionUs == C.TIME_UNSET ? 0 : (loadPositionUs - playbackPositionUs) / 1000);
|
||||
cmcdRequest.setBufferLengthMs(bufferedDurationUs / 1000);
|
||||
}
|
||||
|
||||
CmcdLog.CmcdSession.Builder cmcdSession =
|
||||
|
@ -60,10 +60,7 @@ public class CmcdLogTest {
|
||||
.thenReturn(new Format.Builder().setPeakBitrate(840_000).build());
|
||||
CmcdLog cmcdLog =
|
||||
CmcdLog.createInstance(
|
||||
cmcdConfiguration,
|
||||
trackSelection,
|
||||
/* playbackPositionUs= */ 1_000_000,
|
||||
/* loadPositionUs= */ 2_760_000);
|
||||
cmcdConfiguration, trackSelection, /* bufferedDurationUs= */ 1_760_000);
|
||||
|
||||
ImmutableMap<@CmcdConfiguration.HeaderKey String, String> requestHeaders =
|
||||
cmcdLog.getHttpRequestHeaders();
|
||||
|
@ -374,8 +374,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
||||
CmcdLog cmcdLog =
|
||||
cmcdConfiguration == null
|
||||
? null
|
||||
: CmcdLog.createInstance(
|
||||
cmcdConfiguration, trackSelection, playbackPositionUs, loadPositionUs);
|
||||
: CmcdLog.createInstance(cmcdConfiguration, trackSelection, bufferedDurationUs);
|
||||
|
||||
RepresentationHolder representationHolder =
|
||||
updateSelectedBaseUrl(trackSelection.getSelectedIndex());
|
||||
|
@ -483,8 +483,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
CmcdLog cmcdLog =
|
||||
cmcdConfiguration == null
|
||||
? null
|
||||
: CmcdLog.createInstance(
|
||||
cmcdConfiguration, trackSelection, playbackPositionUs, loadPositionUs);
|
||||
: CmcdLog.createInstance(cmcdConfiguration, trackSelection, bufferedDurationUs);
|
||||
|
||||
// Check if the media segment or its initialization segment are fully encrypted.
|
||||
@Nullable
|
||||
|
@ -284,9 +284,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
|
||||
CmcdLog cmcdLog =
|
||||
cmcdConfiguration == null
|
||||
? null
|
||||
: CmcdLog.createInstance(
|
||||
cmcdConfiguration, trackSelection, playbackPositionUs, loadPositionUs);
|
||||
;
|
||||
: CmcdLog.createInstance(cmcdConfiguration, trackSelection, bufferedDurationUs);
|
||||
|
||||
out.chunk =
|
||||
newMediaChunk(
|
||||
|
Loading…
x
Reference in New Issue
Block a user