Java Code Examples for com.google.android.exoplayer2.C#VIDEO_OUTPUT_MODE_SURFACE_YUV

The following examples show how to use com.google.android.exoplayer2.C#VIDEO_OUTPUT_MODE_SURFACE_YUV . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleDecoderVideoRenderer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the specified output buffer.
 *
 * <p>The implementation of this method takes ownership of the output buffer and is responsible
 * for calling {@link VideoDecoderOutputBuffer#release()} either immediately or in the future.
 *
 * @param outputBuffer {@link VideoDecoderOutputBuffer} to render.
 * @param presentationTimeUs Presentation time in microseconds.
 * @param outputFormat Output {@link Format}.
 * @throws VideoDecoderException If an error occurs when rendering the output buffer.
 */
protected void renderOutputBuffer(
    VideoDecoderOutputBuffer outputBuffer, long presentationTimeUs, Format outputFormat)
    throws VideoDecoderException {
  lastRenderTimeUs = C.msToUs(SystemClock.elapsedRealtime() * 1000);
  int bufferMode = outputBuffer.mode;
  boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && surface != null;
  boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null;
  if (!renderYuv && !renderSurface) {
    dropOutputBuffer(outputBuffer);
  } else {
    maybeNotifyVideoSizeChanged(outputBuffer.width, outputBuffer.height);
    if (renderYuv) {
      outputBufferRenderer.setOutputBuffer(outputBuffer);
    } else {
      renderOutputBufferToSurface(outputBuffer, surface);
    }
    consecutiveDroppedFrameCount = 0;
    decoderCounters.renderedOutputBufferCount++;
    maybeNotifyRenderedFirstFrame();
  }
}
 
Example 2
Source File: SimpleDecoderVideoRenderer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Sets output surface.
 *
 * @param surface Surface.
 */
protected final void setOutputSurface(@Nullable Surface surface) {
  if (this.surface != surface) {
    // The output has changed.
    this.surface = surface;
    if (surface != null) {
      outputBufferRenderer = null;
      outputMode = C.VIDEO_OUTPUT_MODE_SURFACE_YUV;
      if (decoder != null) {
        setDecoderOutputMode(outputMode);
      }
      onOutputChanged();
    } else {
      // The output has been removed. We leave the outputMode of the underlying decoder unchanged
      // in anticipation that a subsequent output will likely be of the same type.
      outputMode = C.VIDEO_OUTPUT_MODE_NONE;
      onOutputRemoved();
    }
  } else if (surface != null) {
    // The output is unchanged and non-null.
    onOutputReset();
  }
}