public final class

DashWrappingSegmentIndex

extends java.lang.Object

implements DashSegmentIndex

 java.lang.Object

↳androidx.media3.exoplayer.dash.DashWrappingSegmentIndex

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-exoplayer-dash', version: '1.5.0-alpha01'

  • groupId: androidx.media3
  • artifactId: media3-exoplayer-dash
  • version: 1.5.0-alpha01

Artifact androidx.media3:media3-exoplayer-dash:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

An implementation of DashSegmentIndex that wraps a ChunkIndex parsed from a media stream.

Summary

Constructors
publicDashWrappingSegmentIndex(ChunkIndex chunkIndex, long timeOffsetUs)

Methods
public longgetAvailableSegmentCount(long periodDurationUs, long nowUnixTimeUs)

public longgetDurationUs(long segmentNum, long periodDurationUs)

public longgetFirstAvailableSegmentNum(long periodDurationUs, long nowUnixTimeUs)

public longgetFirstSegmentNum()

public longgetNextSegmentAvailableTimeUs(long periodDurationUs, long nowUnixTimeUs)

public longgetSegmentCount(long periodDurationUs)

public longgetSegmentNum(long timeUs, long periodDurationUs)

public RangedUrigetSegmentUrl(long segmentNum)

public longgetTimeUs(long segmentNum)

public booleanisExplicit()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public DashWrappingSegmentIndex(ChunkIndex chunkIndex, long timeOffsetUs)

Parameters:

chunkIndex: The ChunkIndex to wrap.
timeOffsetUs: An offset to subtract from the times in the wrapped index, in microseconds.

Methods

public long getFirstSegmentNum()

public long getFirstAvailableSegmentNum(long periodDurationUs, long nowUnixTimeUs)

public long getSegmentCount(long periodDurationUs)

public long getAvailableSegmentCount(long periodDurationUs, long nowUnixTimeUs)

public long getNextSegmentAvailableTimeUs(long periodDurationUs, long nowUnixTimeUs)

public long getTimeUs(long segmentNum)

public long getDurationUs(long segmentNum, long periodDurationUs)

public RangedUri getSegmentUrl(long segmentNum)

public long getSegmentNum(long timeUs, long periodDurationUs)

public boolean isExplicit()

Source

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.exoplayer.dash;

import androidx.media3.common.C;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.exoplayer.dash.manifest.RangedUri;
import androidx.media3.extractor.ChunkIndex;

/**
 * An implementation of {@link DashSegmentIndex} that wraps a {@link ChunkIndex} parsed from a media
 * stream.
 */
@UnstableApi
public final class DashWrappingSegmentIndex implements DashSegmentIndex {

  private final ChunkIndex chunkIndex;
  private final long timeOffsetUs;

  /**
   * @param chunkIndex The {@link ChunkIndex} to wrap.
   * @param timeOffsetUs An offset to subtract from the times in the wrapped index, in microseconds.
   */
  public DashWrappingSegmentIndex(ChunkIndex chunkIndex, long timeOffsetUs) {
    this.chunkIndex = chunkIndex;
    this.timeOffsetUs = timeOffsetUs;
  }

  @Override
  public long getFirstSegmentNum() {
    return 0;
  }

  @Override
  public long getFirstAvailableSegmentNum(long periodDurationUs, long nowUnixTimeUs) {
    return 0;
  }

  @Override
  public long getSegmentCount(long periodDurationUs) {
    return chunkIndex.length;
  }

  @Override
  public long getAvailableSegmentCount(long periodDurationUs, long nowUnixTimeUs) {
    return chunkIndex.length;
  }

  @Override
  public long getNextSegmentAvailableTimeUs(long periodDurationUs, long nowUnixTimeUs) {
    return C.TIME_UNSET;
  }

  @Override
  public long getTimeUs(long segmentNum) {
    return chunkIndex.timesUs[(int) segmentNum] - timeOffsetUs;
  }

  @Override
  public long getDurationUs(long segmentNum, long periodDurationUs) {
    return chunkIndex.durationsUs[(int) segmentNum];
  }

  @Override
  public RangedUri getSegmentUrl(long segmentNum) {
    return new RangedUri(
        null, chunkIndex.offsets[(int) segmentNum], chunkIndex.sizes[(int) segmentNum]);
  }

  @Override
  public long getSegmentNum(long timeUs, long periodDurationUs) {
    return chunkIndex.getChunkIndex(timeUs + timeOffsetUs);
  }

  @Override
  public boolean isExplicit() {
    return true;
  }
}