当前位置: 首页>>代码示例>>Java>>正文


Java Period类代码示例

本文整理汇总了Java中com.google.android.exoplayer2.source.dash.manifest.Period的典型用法代码示例。如果您正苦于以下问题:Java Period类的具体用法?Java Period怎么用?Java Period使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Period类属于com.google.android.exoplayer2.source.dash.manifest包,在下文中一共展示了Period类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPeriodSeekInfo

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
public static PeriodSeekInfo createPeriodSeekInfo(
    com.google.android.exoplayer2.source.dash.manifest.Period period, long durationUs) {
  int adaptationSetCount = period.adaptationSets.size();
  long availableStartTimeUs = 0;
  long availableEndTimeUs = Long.MAX_VALUE;
  boolean isIndexExplicit = false;
  for (int i = 0; i < adaptationSetCount; i++) {
    DashSegmentIndex index = period.adaptationSets.get(i).representations.get(0).getIndex();
    if (index == null) {
      return new PeriodSeekInfo(true, 0, durationUs);
    }
    int firstSegmentNum = index.getFirstSegmentNum();
    int lastSegmentNum = index.getLastSegmentNum(durationUs);
    isIndexExplicit |= index.isExplicit();
    long adaptationSetAvailableStartTimeUs = index.getTimeUs(firstSegmentNum);
    availableStartTimeUs = Math.max(availableStartTimeUs, adaptationSetAvailableStartTimeUs);
    if (lastSegmentNum != DashSegmentIndex.INDEX_UNBOUNDED) {
      long adaptationSetAvailableEndTimeUs = index.getTimeUs(lastSegmentNum)
          + index.getDurationUs(lastSegmentNum, durationUs);
      availableEndTimeUs = Math.min(availableEndTimeUs, adaptationSetAvailableEndTimeUs);
    } else {
      // The available end time is unmodified, because this index is unbounded.
    }
  }
  return new PeriodSeekInfo(isIndexExplicit, availableStartTimeUs, availableEndTimeUs);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:27,代码来源:DashMediaSource.java

示例2: loadDrmInitData

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
public static DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  DrmInitData drmInitData = representation.format.drmInitData;
  if (drmInitData != null) {
    // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
    // as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    return drmInitData;
  }
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null ? null : sampleFormat.drmInitData;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:30,代码来源:DashUtil.java

示例3: download

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
/**
 * Downloads an offline license.
 *
 * @param dataSource The {@link HttpDataSource} to be used for download.
 * @param dashManifest The {@link DashManifest} of the DASH content.
 * @return The downloaded offline license key set id.
 * @throws IOException If an error occurs reading data from the stream.
 * @throws InterruptedException If the thread has been interrupted.
 * @throws DrmSessionException Thrown when there is an error during DRM session.
 */
public byte[] download(HttpDataSource dataSource, DashManifest dashManifest)
    throws IOException, InterruptedException, DrmSessionException {
  // Get DrmInitData
  // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
  // as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
  if (dashManifest.getPeriodCount() < 1) {
    return null;
  }
  Period period = dashManifest.getPeriod(0);
  int adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_VIDEO);
  if (adaptationSetIndex == C.INDEX_UNSET) {
    adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_AUDIO);
    if (adaptationSetIndex == C.INDEX_UNSET) {
      return null;
    }
  }
  AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
  if (adaptationSet.representations.isEmpty()) {
    return null;
  }
  Representation representation = adaptationSet.representations.get(0);
  DrmInitData drmInitData = representation.format.drmInitData;
  if (drmInitData == null) {
    Format sampleFormat = DashUtil.loadSampleFormat(dataSource, representation);
    if (sampleFormat != null) {
      drmInitData = sampleFormat.drmInitData;
    }
    if (drmInitData == null) {
      return null;
    }
  }
  blockingKeyRequest(DefaultDrmSessionManager.MODE_DOWNLOAD, null, drmInitData);
  return drmSessionManager.getOfflineLicenseKeySetId();
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:45,代码来源:OfflineLicenseHelper.java

示例4: getPeriod

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
@Override
public Period getPeriod(int periodIndex, Period period, boolean setIdentifiers) {
  Assertions.checkIndex(periodIndex, 0, manifest.getPeriodCount());
  Object id = setIdentifiers ? manifest.getPeriod(periodIndex).id : null;
  Object uid = setIdentifiers ? firstPeriodId
      + Assertions.checkIndex(periodIndex, 0, manifest.getPeriodCount()) : null;
  return period.set(id, uid, 0, manifest.getPeriodDurationUs(periodIndex),
      C.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs)
          - offsetInFirstPeriodUs);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:11,代码来源:DashMediaSource.java

示例5: buildTrackGroups

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
private static TrackGroupArray buildTrackGroups(Period period) {
  TrackGroup[] trackGroupArray = new TrackGroup[period.adaptationSets.size()];
  for (int i = 0; i < period.adaptationSets.size(); i++) {
    AdaptationSet adaptationSet = period.adaptationSets.get(i);
    List<Representation> representations = adaptationSet.representations;
    Format[] formats = new Format[representations.size()];
    for (int j = 0; j < formats.length; j++) {
      formats[j] = representations.get(j).format;
    }
    trackGroupArray[i] = new TrackGroup(formats);
  }
  return new TrackGroupArray(trackGroupArray);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:14,代码来源:DashMediaPeriod.java

示例6: getFirstRepresentation

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
private static Representation getFirstRepresentation(Period period, int type) {
  int index = period.getAdaptationSetIndex(type);
  if (index == C.INDEX_UNSET) {
    return null;
  }
  List<Representation> representations = period.adaptationSets.get(index).representations;
  return representations.isEmpty() ? null : representations.get(0);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:9,代码来源:DashUtil.java

示例7: getSegments

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
@Override
protected List<Segment> getSegments(DataSource dataSource, DashManifest manifest,
    RepresentationKey[] keys, boolean allowIndexLoadErrors)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (RepresentationKey key : keys) {
    DashSegmentIndex index;
    try {
      index = getSegmentIndex(dataSource, manifest, key);
      if (index == null) {
        // Loading succeeded but there was no index. This is always a failure.
        throw new DownloadException("No index for representation: " + key);
      }
    } catch (IOException e) {
      if (allowIndexLoadErrors) {
        // Loading failed, but load errors are allowed. Advance to the next key.
        continue;
      } else {
        throw e;
      }
    }

    int segmentCount = index.getSegmentCount(C.TIME_UNSET);
    if (segmentCount == DashSegmentIndex.INDEX_UNBOUNDED) {
      throw new DownloadException("Unbounded index for representation: " + key);
    }

    Period period = manifest.getPeriod(key.periodIndex);
    Representation representation = period.adaptationSets.get(key.adaptationSetIndex)
        .representations.get(key.representationIndex);
    long startUs = C.msToUs(period.startMs);
    String baseUrl = representation.baseUrl;
    RangedUri initializationUri = representation.getInitializationUri();
    if (initializationUri != null) {
      addSegment(segments, startUs, baseUrl, initializationUri);
    }
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri != null) {
      addSegment(segments, startUs, baseUrl, indexUri);
    }

    int firstSegmentNum = index.getFirstSegmentNum();
    int lastSegmentNum = firstSegmentNum + segmentCount - 1;
    for (int j = firstSegmentNum; j <= lastSegmentNum; j++) {
      addSegment(segments, startUs + index.getTimeUs(j), baseUrl, index.getSegmentUrl(j));
    }
  }
  return segments;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:50,代码来源:DashDownloader.java

示例8: testLoadDrmInitDataFromManifest

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
public void testLoadDrmInitDataFromManifest() throws Exception {
  Period period = newPeriod(newAdaptationSets(newRepresentations(newDrmInitData())));
  DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period);
  assertEquals(newDrmInitData(), drmInitData);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:6,代码来源:DashUtilTest.java

示例9: testLoadDrmInitDataMissing

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
public void testLoadDrmInitDataMissing() throws Exception {
  Period period = newPeriod(newAdaptationSets(newRepresentations(null /* no init data */)));
  DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period);
  assertNull(drmInitData);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:6,代码来源:DashUtilTest.java

示例10: testLoadDrmInitDataNoRepresentations

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
public void testLoadDrmInitDataNoRepresentations() throws Exception {
  Period period = newPeriod(newAdaptationSets(/* no representation */));
  DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period);
  assertNull(drmInitData);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:6,代码来源:DashUtilTest.java

示例11: testLoadDrmInitDataNoAdaptationSets

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
public void testLoadDrmInitDataNoAdaptationSets() throws Exception {
  Period period = newPeriod(/* no adaptation set */);
  DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period);
  assertNull(drmInitData);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:6,代码来源:DashUtilTest.java

示例12: newPeriod

import com.google.android.exoplayer2.source.dash.manifest.Period; //导入依赖的package包/类
private static Period newPeriod(AdaptationSet... adaptationSets) {
  return new Period("", 0, Arrays.asList(adaptationSets));
}
 
开发者ID:y20k,项目名称:transistor,代码行数:4,代码来源:DashUtilTest.java


注:本文中的com.google.android.exoplayer2.source.dash.manifest.Period类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。