當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTrackOutput類代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.extractor.DefaultTrackOutput的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTrackOutput類的具體用法?Java DefaultTrackOutput怎麽用?Java DefaultTrackOutput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultTrackOutput類屬於com.google.android.exoplayer2.extractor包,在下文中一共展示了DefaultTrackOutput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    // Create and open the input.
    long length = dataSource.open(loadDataSpec);
    if (length != C.LENGTH_UNSET) {
      length += bytesLoaded;
    }
    ExtractorInput extractorInput = new DefaultExtractorInput(dataSource, bytesLoaded, length);
    DefaultTrackOutput trackOutput = getTrackOutput();
    trackOutput.formatWithOffset(sampleFormat, 0);
    // Load the sample data.
    int result = 0;
    while (result != C.RESULT_END_OF_INPUT) {
      bytesLoaded += result;
      result = trackOutput.sampleData(extractorInput, Integer.MAX_VALUE, true);
    }
    int sampleSize = bytesLoaded;
    trackOutput.sampleMetadata(startTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0, null);
  } finally {
    dataSource.close();
  }
  loadCompleted = true;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:27,代碼來源:SingleSampleMediaChunk.java

示例2: ChunkSampleStream

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * @param trackType The type of the track. One of the {@link C} {@code TRACK_TYPE_*} constants.
 * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
 * @param callback An {@link Callback} for the stream.
 * @param allocator An {@link Allocator} from which allocations can be obtained.
 * @param positionUs The position from which to start loading media.
 * @param minLoadableRetryCount The minimum number of times that the source should retry a load
 *     before propagating an error.
 * @param eventDispatcher A dispatcher to notify of events.
 */
public ChunkSampleStream(int trackType, T chunkSource,
    SequenceableLoader.Callback<ChunkSampleStream<T>> callback, Allocator allocator,
    long positionUs, int minLoadableRetryCount, EventDispatcher eventDispatcher) {
  this.trackType = trackType;
  this.chunkSource = chunkSource;
  this.callback = callback;
  this.eventDispatcher = eventDispatcher;
  this.minLoadableRetryCount = minLoadableRetryCount;
  loader = new Loader("Loader:ChunkSampleStream");
  nextChunkHolder = new ChunkHolder();
  mediaChunks = new LinkedList<>();
  readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
  sampleQueue = new DefaultTrackOutput(allocator);
  lastSeekPositionUs = positionUs;
  pendingResetPositionUs = positionUs;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:27,代碼來源:ChunkSampleStream.java

示例3: skipData

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
void skipData(int group, long positionUs) {
  DefaultTrackOutput sampleQueue = sampleQueues.valueAt(group);
  if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) {
    sampleQueue.skipAll();
  } else {
    sampleQueue.skipToKeyframeBefore(positionUs, true);
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:9,代碼來源:HlsSampleStreamWrapper.java

示例4: track

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
@Override
public DefaultTrackOutput track(int id, int type) {
  if (sampleQueues.indexOfKey(id) >= 0) {
    return sampleQueues.get(id);
  }
  DefaultTrackOutput trackOutput = new DefaultTrackOutput(allocator);
  trackOutput.setUpstreamFormatChangeListener(this);
  trackOutput.sourceId(upstreamChunkUid);
  sampleQueues.put(id, trackOutput);
  return trackOutput;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:12,代碼來源:HlsSampleStreamWrapper.java

示例5: skipData

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
void skipData(int track, long positionUs) {
  DefaultTrackOutput sampleQueue = sampleQueues.valueAt(track);
  if (loadingFinished && positionUs > sampleQueue.getLargestQueuedTimestampUs()) {
    sampleQueue.skipAll();
  } else {
    sampleQueue.skipToKeyframeBefore(positionUs, true);
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:9,代碼來源:ExtractorMediaPeriod.java

示例6: setSampleOffsetUs

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * Sets an offset that will be added to the timestamps (and sub-sample timestamps) of samples
 * subsequently written to the track outputs.
 */
public void setSampleOffsetUs(long sampleOffsetUs) {
  for (DefaultTrackOutput trackOutput : trackOutputs) {
    if (trackOutput != null) {
      trackOutput.setSampleOffsetUs(sampleOffsetUs);
    }
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:12,代碼來源:BaseMediaChunkOutput.java

示例7: ChunkSampleStream

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * @param primaryTrackType The type of the primary track. One of the {@link C}
 *     {@code TRACK_TYPE_*} constants.
 * @param embeddedTrackTypes The types of any embedded tracks, or null.
 * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
 * @param callback An {@link Callback} for the stream.
 * @param allocator An {@link Allocator} from which allocations can be obtained.
 * @param positionUs The position from which to start loading media.
 * @param minLoadableRetryCount The minimum number of times that the source should retry a load
 *     before propagating an error.
 * @param eventDispatcher A dispatcher to notify of events.
 */
public ChunkSampleStream(int primaryTrackType, int[] embeddedTrackTypes, T chunkSource,
    Callback<ChunkSampleStream<T>> callback, Allocator allocator, long positionUs,
    int minLoadableRetryCount, EventDispatcher eventDispatcher) {
  this.primaryTrackType = primaryTrackType;
  this.embeddedTrackTypes = embeddedTrackTypes;
  this.chunkSource = chunkSource;
  this.callback = callback;
  this.eventDispatcher = eventDispatcher;
  this.minLoadableRetryCount = minLoadableRetryCount;
  loader = new Loader("Loader:ChunkSampleStream");
  nextChunkHolder = new ChunkHolder();
  mediaChunks = new LinkedList<>();
  readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);

  int embeddedTrackCount = embeddedTrackTypes == null ? 0 : embeddedTrackTypes.length;
  embeddedSampleQueues = new DefaultTrackOutput[embeddedTrackCount];
  embeddedTracksSelected = new boolean[embeddedTrackCount];
  int[] trackTypes = new int[1 + embeddedTrackCount];
  DefaultTrackOutput[] sampleQueues = new DefaultTrackOutput[1 + embeddedTrackCount];

  primarySampleQueue = new DefaultTrackOutput(allocator);
  trackTypes[0] = primaryTrackType;
  sampleQueues[0] = primarySampleQueue;

  for (int i = 0; i < embeddedTrackCount; i++) {
    DefaultTrackOutput trackOutput = new DefaultTrackOutput(allocator);
    embeddedSampleQueues[i] = trackOutput;
    sampleQueues[i + 1] = trackOutput;
    trackTypes[i + 1] = embeddedTrackTypes[i];
  }

  mediaChunkOutput = new BaseMediaChunkOutput(trackTypes, sampleQueues);
  pendingResetPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:48,代碼來源:ChunkSampleStream.java

示例8: release

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * Releases the stream.
 * <p>
 * This method should be called when the stream is no longer required.
 */
public void release() {
  primarySampleQueue.disable();
  for (DefaultTrackOutput embeddedSampleQueue : embeddedSampleQueues) {
    embeddedSampleQueue.disable();
  }
  loader.release();
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:13,代碼來源:ChunkSampleStream.java

示例9: onLoadCanceled

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
@Override
public void onLoadCanceled(Chunk loadable, long elapsedRealtimeMs, long loadDurationMs,
    boolean released) {
  eventDispatcher.loadCanceled(loadable.dataSpec, loadable.type, primaryTrackType,
      loadable.trackFormat, loadable.trackSelectionReason, loadable.trackSelectionData,
      loadable.startTimeUs, loadable.endTimeUs, elapsedRealtimeMs, loadDurationMs,
      loadable.bytesLoaded());
  if (!released) {
    primarySampleQueue.reset(true);
    for (DefaultTrackOutput embeddedSampleQueue : embeddedSampleQueues) {
      embeddedSampleQueue.reset(true);
    }
    callback.onContinueLoadingRequested(this);
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:16,代碼來源:ChunkSampleStream.java

示例10: track

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
@Override
public DefaultTrackOutput track(int id) {
  if (sampleQueues.indexOfKey(id) >= 0) {
    return sampleQueues.get(id);
  }
  DefaultTrackOutput trackOutput = new DefaultTrackOutput(allocator);
  trackOutput.setUpstreamFormatChangeListener(this);
  trackOutput.sourceId(upstreamChunkUid);
  sampleQueues.put(id, trackOutput);
  return trackOutput;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:12,代碼來源:HlsSampleStreamWrapper.java

示例11: load

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public final void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    // Create and open the input.
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    if (bytesLoaded == 0) {
      // Set the target to ourselves.
      DefaultTrackOutput trackOutput = getTrackOutput();
      trackOutput.formatWithOffset(sampleFormat, sampleOffsetUs);
      extractorWrapper.init(this, trackOutput);
    }
    // Load and decode the sample data.
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractorWrapper.read(input);
      }
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    dataSource.close();
  }
  loadCompleted = true;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:29,代碼來源:ContainerMediaChunk.java

示例12: BaseMediaChunkOutput

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * @param trackTypes The track types of the individual track outputs.
 * @param trackOutputs The individual track outputs.
 */
public BaseMediaChunkOutput(int[] trackTypes, DefaultTrackOutput[] trackOutputs) {
  this.trackTypes = trackTypes;
  this.trackOutputs = trackOutputs;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:9,代碼來源:BaseMediaChunkOutput.java

示例13: EmbeddedSampleStream

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
public EmbeddedSampleStream(ChunkSampleStream<T> parent, DefaultTrackOutput sampleQueue,
    int index) {
  this.parent = parent;
  this.sampleQueue = sampleQueue;
  this.index = index;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:7,代碼來源:ChunkSampleStream.java

示例14: getTrackOutput

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * Returns the track output most recently passed to {@link #init(DefaultTrackOutput)}.
 */
protected final DefaultTrackOutput getTrackOutput() {
  return trackOutput;
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:7,代碼來源:BaseMediaChunk.java

示例15: init

import com.google.android.exoplayer2.extractor.DefaultTrackOutput; //導入依賴的package包/類
/**
 * Initializes the chunk for loading, setting the {@link DefaultTrackOutput} that will receive
 * samples as they are loaded.
 *
 * @param trackOutput The output that will receive the loaded samples.
 */
public void init(DefaultTrackOutput trackOutput) {
  this.trackOutput = trackOutput;
  this.firstSampleIndex = trackOutput.getWriteIndex();
}
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:11,代碼來源:BaseMediaChunk.java


注:本文中的com.google.android.exoplayer2.extractor.DefaultTrackOutput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。