Java 类com.google.android.exoplayer2.util.TraceUtil 实例源码

项目:videoPickPlayer    文件:MediaCodecRenderer.java   
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (format == null) {
    readFormat();
  }
  maybeInitCodec();
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    while (feedInputBuffer()) {}
    TraceUtil.endSection();
  } else if (format != null) {
    skipToKeyframeBefore(positionUs);
  }
  decoderCounters.ensureUpdated();
}
项目:Exoplayer2Radio    文件:SimpleDecoderAudioRenderer.java   
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    @DrmSession.State int drmSessionState = drmSession.getState();
    if (drmSessionState == DrmSession.STATE_ERROR) {
      throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
    } else if (drmSessionState == DrmSession.STATE_OPENED
        || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
      mediaCrypto = drmSession.getMediaCrypto();
    } else {
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createAudioDecoder");
    decoder = createDecoder(inputFormat, mediaCrypto);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (AudioDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
项目:Exoplayer2Radio    文件:MediaCodecVideoRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.droppedOutputBufferCount++;
  droppedFrames++;
  consecutiveDroppedFrameCount++;
  decoderCounters.maxConsecutiveDroppedOutputBufferCount = Math.max(consecutiveDroppedFrameCount,
      decoderCounters.maxConsecutiveDroppedOutputBufferCount);
  if (droppedFrames == maxDroppedFramesToNotify) {
    maybeNotifyDroppedFrames();
  }
}
项目:Exoplayer2Radio    文件:MediaCodecVideoRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:Exoplayer2Radio    文件:MediaCodecVideoRenderer.java   
@TargetApi(21)
private void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:K-Sonic    文件:MediaCodecRenderer.java   
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (outputStreamEnded) {
    renderToEndOfStream();
    return;
  }
  if (format == null) {
    // We don't have a format yet, so try and read one.
    buffer.clear();
    int result = readSource(formatHolder, buffer, true);
    if (result == C.RESULT_FORMAT_READ) {
      onInputFormatChanged(formatHolder.format);
    } else if (result == C.RESULT_BUFFER_READ) {
      // End of stream read having not read a format.
      Assertions.checkState(buffer.isEndOfStream());
      inputStreamEnded = true;
      processEndOfStream();
      return;
    } else {
      // We still don't have a format and can't make progress without one.
      return;
    }
  }
  maybeInitCodec();
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    while (feedInputBuffer()) {}
    TraceUtil.endSection();
  } else if (format != null) {
    skipToKeyframeBefore(positionUs);
  }
  decoderCounters.ensureUpdated();
}
项目:K-Sonic    文件:SimpleDecoderAudioRenderer.java   
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    @DrmSession.State int drmSessionState = drmSession.getState();
    if (drmSessionState == DrmSession.STATE_ERROR) {
      throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
    } else if (drmSessionState == DrmSession.STATE_OPENED
        || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
      mediaCrypto = drmSession.getMediaCrypto();
    } else {
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createAudioDecoder");
    decoder = createDecoder(inputFormat, mediaCrypto);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (AudioDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
项目:K-Sonic    文件:MediaCodecVideoRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.droppedOutputBufferCount++;
  droppedFrames++;
  consecutiveDroppedFrameCount++;
  decoderCounters.maxConsecutiveDroppedOutputBufferCount = Math.max(consecutiveDroppedFrameCount,
      decoderCounters.maxConsecutiveDroppedOutputBufferCount);
  if (droppedFrames == maxDroppedFramesToNotify) {
    maybeNotifyDroppedFrames();
  }
}
项目:K-Sonic    文件:MediaCodecVideoRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:K-Sonic    文件:MediaCodecVideoRenderer.java   
@TargetApi(21)
private void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:videoPickPlayer    文件:MediaCodecVideoRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.droppedOutputBufferCount++;
  droppedFrames++;
  consecutiveDroppedFrameCount++;
  decoderCounters.maxConsecutiveDroppedOutputBufferCount = Math.max(consecutiveDroppedFrameCount,
      decoderCounters.maxConsecutiveDroppedOutputBufferCount);
  if (droppedFrames == maxDroppedFramesToNotify) {
    maybeNotifyDroppedFrames();
  }
}
项目:videoPickPlayer    文件:MediaCodecVideoRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  if (!renderedFirstFrame) {
    renderedFirstFrame = true;
    eventDispatcher.renderedFirstFrame(surface);
  }
}
项目:videoPickPlayer    文件:MediaCodecVideoRenderer.java   
@TargetApi(21)
private void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  if (!renderedFirstFrame) {
    renderedFirstFrame = true;
    eventDispatcher.renderedFirstFrame(surface);
  }
}
项目:transistor    文件:LibvpxVideoRenderer.java   
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (outputStreamEnded) {
    return;
  }

  if (format == null) {
    // We don't have a format yet, so try and read one.
    flagsOnlyBuffer.clear();
    int result = readSource(formatHolder, flagsOnlyBuffer, true);
    if (result == C.RESULT_FORMAT_READ) {
      onInputFormatChanged(formatHolder.format);
    } else if (result == C.RESULT_BUFFER_READ) {
      // End of stream read having not read a format.
      Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
      inputStreamEnded = true;
      outputStreamEnded = true;
      return;
    } else {
      // We still don't have a format and can't make progress without one.
      return;
    }
  }

  // If we don't have a decoder yet, we need to instantiate one.
  maybeInitDecoder();

  if (decoder != null) {
    try {
      // Rendering loop.
      TraceUtil.beginSection("drainAndFeed");
      while (drainOutputBuffer(positionUs)) {}
      while (feedInputBuffer()) {}
      TraceUtil.endSection();
    } catch (VpxDecoderException e) {
      throw ExoPlaybackException.createForRenderer(e, getIndex());
    }
    decoderCounters.ensureUpdated();
  }
}
项目:transistor    文件:LibvpxVideoRenderer.java   
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        throw ExoPlaybackException.createForRenderer(drmError, getIndex());
      }
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createVpxDecoder");
    decoder = new VpxDecoder(NUM_INPUT_BUFFERS, NUM_OUTPUT_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
        mediaCrypto);
    decoder.setOutputMode(outputMode);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (VpxDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
项目:transistor    文件:SimpleDecoderAudioRenderer.java   
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        throw ExoPlaybackException.createForRenderer(drmError, getIndex());
      }
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createAudioDecoder");
    decoder = createDecoder(inputFormat, mediaCrypto);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (AudioDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
项目:transistor    文件:MediaCodecVideoRenderer.java   
/**
 * Renders the output buffer with the specified index. This method is only called if the platform
 * API version of the device is less than 21.
 *
 * @param codec The codec that owns the output buffer.
 * @param index The index of the output buffer to drop.
 * @param presentationTimeUs The presentation time of the output buffer, in microseconds.
 */
protected void renderOutputBuffer(MediaCodec codec, int index, long presentationTimeUs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(index, true);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:transistor    文件:MediaCodecVideoRenderer.java   
/**
 * Renders the output buffer with the specified index. This method is only called if the platform
 * API version of the device is 21 or later.
 *
 * @param codec The codec that owns the output buffer.
 * @param index The index of the output buffer to drop.
 * @param presentationTimeUs The presentation time of the output buffer, in microseconds.
 * @param releaseTimeNs The wallclock time at which the frame should be displayed, in nanoseconds.
 */
@TargetApi(21)
protected void renderOutputBufferV21(MediaCodec codec, int index, long presentationTimeUs,
    long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(index, releaseTimeNs);
  TraceUtil.endSection();
  decoderCounters.renderedOutputBufferCount++;
  consecutiveDroppedFrameCount = 0;
  maybeNotifyRenderedFirstFrame();
}
项目:Exoplayer2Radio    文件:MediaCodecVideoRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.skippedOutputBufferCount++;
}
项目:K-Sonic    文件:MediaCodecVideoRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.skippedOutputBufferCount++;
}
项目:videoPickPlayer    文件:MediaCodecVideoRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  decoderCounters.skippedOutputBufferCount++;
}
项目:Komica    文件:LibvpxVideoRenderer.java   
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (outputStreamEnded) {
    return;
  }

  // Try and read a format if we don't have one already.
  if (format == null && !readFormat()) {
    // We can't make progress without one.
    return;
  }

  if (isRendererAvailable()) {
    drmSession = pendingDrmSession;
    ExoMediaCrypto mediaCrypto = null;
    if (drmSession != null) {
      int drmSessionState = drmSession.getState();
      if (drmSessionState == DrmSession.STATE_ERROR) {
        throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
      } else if (drmSessionState == DrmSession.STATE_OPENED
          || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
        mediaCrypto = drmSession.getMediaCrypto();
      } else {
        // The drm session isn't open yet.
        return;
      }
    }
    try {
      if (decoder == null) {
        // If we don't have a decoder yet, we need to instantiate one.
        long codecInitializingTimestamp = SystemClock.elapsedRealtime();
        TraceUtil.beginSection("createVpxDecoder");
        decoder = new VpxDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
            mediaCrypto);
        decoder.setOutputMode(outputMode);
        TraceUtil.endSection();
        long codecInitializedTimestamp = SystemClock.elapsedRealtime();
        eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
            codecInitializedTimestamp - codecInitializingTimestamp);
        decoderCounters.decoderInitCount++;
      }
      TraceUtil.beginSection("drainAndFeed");
      while (drainOutputBuffer(positionUs)) {}
      while (feedInputBuffer()) {}
      TraceUtil.endSection();
    } catch (VpxDecoderException e) {
      throw ExoPlaybackException.createForRenderer(e, getIndex());
    }
  } else {
    skipToKeyframeBefore(positionUs);
  }
  decoderCounters.ensureUpdated();
}
项目:transistor    文件:MediaCodecVideoRenderer.java   
/**
 * Skips the output buffer with the specified index.
 *
 * @param codec The codec that owns the output buffer.
 * @param index The index of the output buffer to skip.
 * @param presentationTimeUs The presentation time of the output buffer, in microseconds.
 */
protected void skipOutputBuffer(MediaCodec codec, int index, long presentationTimeUs) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(index, false);
  TraceUtil.endSection();
  decoderCounters.skippedOutputBufferCount++;
}
项目:transistor    文件:MediaCodecVideoRenderer.java   
/**
 * Drops the output buffer with the specified index.
 *
 * @param codec The codec that owns the output buffer.
 * @param index The index of the output buffer to drop.
 * @param presentationTimeUs The presentation time of the output buffer, in microseconds.
 */
protected void dropOutputBuffer(MediaCodec codec, int index, long presentationTimeUs) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(index, false);
  TraceUtil.endSection();
  updateDroppedBufferCounters(1);
}