com.google.android.exoplayer2.video.VideoRendererEventListener Java Examples

The following examples show how to use com.google.android.exoplayer2.video.VideoRendererEventListener. 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: SoftVideoRenderer.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
/**
 * @param scaleToFit Whether video frames should be scaled to fit when rendering.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public SoftVideoRenderer(boolean scaleToFit, long allowedJoiningTimeMs,
                         Handler eventHandler, VideoRendererEventListener eventListener,
                         int maxDroppedFramesToNotify, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
                         boolean playClearSamplesWithoutKeys) {
  super(C.TRACK_TYPE_VIDEO);
  this.scaleToFit = scaleToFit;
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  this.outputBufferRenderer = new FrameRenderer();
  joiningDeadlineMs = C.TIME_UNSET;
  clearReportedVideoSize();
  formatHolder = new FormatHolder();
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  decoderReinitializationState = REINITIALIZATION_STATE_NONE;
}
 
Example #2
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
    float pixelWidthHeightRatio) {
  for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
    // Prevent duplicate notification if a listener is both a VideoRendererEventListener and
    // a VideoListener, as they have the same method signature.
    if (!videoDebugListeners.contains(videoListener)) {
      videoListener.onVideoSizeChanged(
          width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoSizeChanged(width, height, unappliedRotationDegrees,
        pixelWidthHeightRatio);
  }
}
 
Example #3
Source File: SimpleRenderersFactory.java    From no-player with Apache License 2.0 6 votes vote down vote up
@Override
public Renderer[] createRenderers(Handler eventHandler,
                                  VideoRendererEventListener videoRendererEventListener,
                                  AudioRendererEventListener audioRendererEventListener,
                                  TextOutput textRendererOutput,
                                  MetadataOutput metadataRendererOutput,
                                  @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
    ArrayList<Renderer> renderersList = new ArrayList<>();
    buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
            eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
    buildAudioRenderers(context, drmSessionManager, buildAudioProcessors(),
            eventHandler, audioRendererEventListener, extensionRendererMode, renderersList);
    buildTextRenderers(textRendererOutput, eventHandler.getLooper(), renderersList, subtitleDecoderFactory);
    buildMetadataRenderers(metadataRendererOutput, eventHandler.getLooper(),
            renderersList);
    buildMiscellaneousRenderers();
    return renderersList.toArray(new Renderer[renderersList.size()]);
}
 
Example #4
Source File: DefaultRenderersFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Renderer[] createRenderers(
    Handler eventHandler,
    VideoRendererEventListener videoRendererEventListener,
    AudioRendererEventListener audioRendererEventListener,
    TextOutput textRendererOutput,
    MetadataOutput metadataRendererOutput,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  if (drmSessionManager == null) {
    drmSessionManager = this.drmSessionManager;
  }
  ArrayList<Renderer> renderersList = new ArrayList<>();
  buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
      eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
  buildAudioRenderers(context, drmSessionManager, buildAudioProcessors(),
      eventHandler, audioRendererEventListener, extensionRendererMode, renderersList);
  buildTextRenderers(context, textRendererOutput, eventHandler.getLooper(),
      extensionRendererMode, renderersList);
  buildMetadataRenderers(context, metadataRendererOutput, eventHandler.getLooper(),
      extensionRendererMode, renderersList);
  buildMiscellaneousRenderers(context, eventHandler, extensionRendererMode, renderersList);
  return renderersList.toArray(new Renderer[renderersList.size()]);
}
 
Example #5
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
    float pixelWidthHeightRatio) {
  for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
    // Prevent duplicate notification if a listener is both a VideoRendererEventListener and
    // a VideoListener, as they have the same method signature.
    if (!videoDebugListeners.contains(videoListener)) {
      videoListener.onVideoSizeChanged(
          width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoSizeChanged(width, height, unappliedRotationDegrees,
        pixelWidthHeightRatio);
  }
}
 
Example #6
Source File: RendererProvider.java    From ExoMedia with Apache License 2.0 6 votes vote down vote up
@NonNull
protected List<Renderer> buildVideoRenderers() {
    List<Renderer> renderers = new ArrayList<>();

    renderers.add(new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT, videoJoiningTimeMs, drmSessionManager, false, handler, videoRendererEventListener, droppedFrameNotificationAmount));

    // Adds any registered classes
    List<String> classNames = ExoMedia.Data.registeredRendererClasses.get(ExoMedia.RendererType.VIDEO);
    if (classNames != null) {
        for (String className: classNames) {
            try {
                Class<?> clazz = Class.forName(className);
                Constructor<?> constructor = clazz.getConstructor(boolean.class, long.class, Handler.class, VideoRendererEventListener.class, int.class);
                Renderer renderer = (Renderer) constructor.newInstance(true, videoJoiningTimeMs, handler, videoRendererEventListener, droppedFrameNotificationAmount);
                renderers.add(renderer);
            } catch (Exception e) {
                // Purposefully left blank
            }
        }
    }

    return renderers;
}
 
Example #7
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public void onVideoSizeChanged(
    int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
  for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
    // Prevent duplicate notification if a listener is both a VideoRendererEventListener and
    // a VideoListener, as they have the same method signature.
    if (!videoDebugListeners.contains(videoListener)) {
      videoListener.onVideoSizeChanged(
          width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoSizeChanged(
        width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
  }
}
 
Example #8
Source File: Util.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Extract renderer capabilities for the renderers created by the provided renderers factory.
 *
 * @param renderersFactory A {@link RenderersFactory}.
 * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers.
 * @return The {@link RendererCapabilities} for each renderer created by the {@code
 *     renderersFactory}.
 */
public static RendererCapabilities[] getRendererCapabilities(
    RenderersFactory renderersFactory,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  Renderer[] renderers =
      renderersFactory.createRenderers(
          new Handler(),
          new VideoRendererEventListener() {},
          new AudioRendererEventListener() {},
          (cues) -> {},
          (metadata) -> {},
          drmSessionManager);
  RendererCapabilities[] capabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    capabilities[i] = renderers[i].getCapabilities();
  }
  return capabilities;
}
 
Example #9
Source File: DefaultRenderersFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Renderer[] createRenderers(
    Handler eventHandler,
    VideoRendererEventListener videoRendererEventListener,
    AudioRendererEventListener audioRendererEventListener,
    TextOutput textRendererOutput,
    MetadataOutput metadataRendererOutput,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  if (drmSessionManager == null) {
    drmSessionManager = this.drmSessionManager;
  }
  ArrayList<Renderer> renderersList = new ArrayList<>();
  buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
      eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
  buildAudioRenderers(context, drmSessionManager, buildAudioProcessors(),
      eventHandler, audioRendererEventListener, extensionRendererMode, renderersList);
  buildTextRenderers(context, textRendererOutput, eventHandler.getLooper(),
      extensionRendererMode, renderersList);
  buildMetadataRenderers(context, metadataRendererOutput, eventHandler.getLooper(),
      extensionRendererMode, renderersList);
  buildMiscellaneousRenderers(context, eventHandler, extensionRendererMode, renderersList);
  return renderersList.toArray(new Renderer[renderersList.size()]);
}
 
Example #10
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Extract renderer capabilities for the renderers created by the provided renderers factory.
 *
 * @param renderersFactory A {@link RenderersFactory}.
 * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers.
 * @return The {@link RendererCapabilities} for each renderer created by the {@code
 *     renderersFactory}.
 */
public static RendererCapabilities[] getRendererCapabilities(
    RenderersFactory renderersFactory,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  Renderer[] renderers =
      renderersFactory.createRenderers(
          new Handler(),
          new VideoRendererEventListener() {},
          new AudioRendererEventListener() {},
          (cues) -> {},
          (metadata) -> {},
          drmSessionManager);
  RendererCapabilities[] capabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    capabilities[i] = renderers[i].getCapabilities();
  }
  return capabilities;
}
 
Example #11
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
    float pixelWidthHeightRatio) {
  for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
    // Prevent duplicate notification if a listener is both a VideoRendererEventListener and
    // a VideoListener, as they have the same method signature.
    if (!videoDebugListeners.contains(videoListener)) {
      videoListener.onVideoSizeChanged(
          width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoSizeChanged(width, height, unappliedRotationDegrees,
        pixelWidthHeightRatio);
  }
}
 
Example #12
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
    float pixelWidthHeightRatio) {
  for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
    // Prevent duplicate notification if a listener is both a VideoRendererEventListener and
    // a VideoListener, as they have the same method signature.
    if (!videoDebugListeners.contains(videoListener)) {
      videoListener.onVideoSizeChanged(
          width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoSizeChanged(width, height, unappliedRotationDegrees,
        pixelWidthHeightRatio);
  }
}
 
Example #13
Source File: Util.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Extract renderer capabilities for the renderers created by the provided renderers factory.
 *
 * @param renderersFactory A {@link RenderersFactory}.
 * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers.
 * @return The {@link RendererCapabilities} for each renderer created by the {@code
 *     renderersFactory}.
 */
public static RendererCapabilities[] getRendererCapabilities(
    RenderersFactory renderersFactory,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  Renderer[] renderers =
      renderersFactory.createRenderers(
          new Handler(),
          new VideoRendererEventListener() {},
          new AudioRendererEventListener() {},
          (cues) -> {},
          (metadata) -> {},
          drmSessionManager);
  RendererCapabilities[] capabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    capabilities[i] = renderers[i].getCapabilities();
  }
  return capabilities;
}
 
Example #14
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoInputFormatChanged(Format format) {
  videoFormat = format;
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoInputFormatChanged(format);
  }
}
 
Example #15
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoInputFormatChanged(Format format) {
  videoFormat = format;
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoInputFormatChanged(format);
  }
}
 
Example #16
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs,
    long initializationDurationMs) {
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoDecoderInitialized(decoderName, initializedTimestampMs,
        initializationDurationMs);
  }
}
 
Example #17
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onRenderedFirstFrame(Surface surface) {
  if (SimpleExoPlayer.this.surface == surface) {
    for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
      videoListener.onRenderedFirstFrame();
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onRenderedFirstFrame(surface);
  }
}
 
Example #18
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoEnabled(DecoderCounters counters) {
  videoDecoderCounters = counters;
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoEnabled(counters);
  }
}
 
Example #19
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #addAnalyticsListener(AnalyticsListener)} to get more detailed debug
 *     information.
 */
@Deprecated
@SuppressWarnings("deprecation")
public void setVideoDebugListener(VideoRendererEventListener listener) {
  videoDebugListeners.retainAll(Collections.singleton(analyticsCollector));
  if (listener != null) {
    addVideoDebugListener(listener);
  }
}
 
Example #20
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoEnabled(DecoderCounters counters) {
  videoDecoderCounters = counters;
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoEnabled(counters);
  }
}
 
Example #21
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onRenderedFirstFrame(Surface surface) {
  if (SimpleExoPlayer.this.surface == surface) {
    for (com.google.android.exoplayer2.video.VideoListener videoListener : videoListeners) {
      videoListener.onRenderedFirstFrame();
    }
  }
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onRenderedFirstFrame(surface);
  }
}
 
Example #22
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs,
    long initializationDurationMs) {
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoDecoderInitialized(decoderName, initializedTimestampMs,
        initializationDurationMs);
  }
}
 
Example #23
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoDisabled(DecoderCounters counters) {
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoDisabled(counters);
  }
  videoFormat = null;
  videoDecoderCounters = null;
}
 
Example #24
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #addAnalyticsListener(AnalyticsListener)} to get more detailed debug
 *     information.
 */
@Deprecated
@SuppressWarnings("deprecation")
public void setVideoDebugListener(VideoRendererEventListener listener) {
  videoDebugListeners.retainAll(Collections.singleton(analyticsCollector));
  if (listener != null) {
    addVideoDebugListener(listener);
  }
}
 
Example #25
Source File: RendererProvider.java    From ExoMedia with Apache License 2.0 5 votes vote down vote up
public RendererProvider(@NonNull Context context, @NonNull Handler handler, @NonNull TextOutput captionListener, @NonNull MetadataOutput metadataListener,
                        @NonNull AudioRendererEventListener audioRendererEventListener, @NonNull VideoRendererEventListener videoRendererEventListener) {
    this.context = context;
    this.handler = handler;
    this.captionListener = captionListener;
    this.metadataListener = metadataListener;
    this.audioRendererEventListener = audioRendererEventListener;
    this.videoRendererEventListener = videoRendererEventListener;
}
 
Example #26
Source File: DebugSimpleExoPlayer.java    From ExoPlayer-Offline with Apache License 2.0 5 votes vote down vote up
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, Handler eventHandler,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    VideoRendererEventListener eventListener, int maxDroppedFrameCountToNotify) {
  super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
      eventHandler, eventListener, maxDroppedFrameCountToNotify);
}
 
Example #27
Source File: DebugSimpleExoPlayer.java    From ExoPlayer-Offline with Apache License 2.0 5 votes vote down vote up
@Override
protected void buildVideoRenderers(Context context, Handler mainHandler,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    @ExtensionRendererMode int extensionRendererMode, VideoRendererEventListener eventListener,
    long allowedVideoJoiningTimeMs, ArrayList<Renderer> out) {
  out.add(new DebugMediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT,
      allowedVideoJoiningTimeMs, mainHandler, drmSessionManager, eventListener,
      MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY));
}
 
Example #28
Source File: SimpleRendersFactory.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
protected void buildVideoRenderers(Context context, int extensionRendererMode, MediaCodecSelector mediaCodecSelector, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys, Handler eventHandler, VideoRendererEventListener eventListener, long allowedVideoJoiningTimeMs, ArrayList<Renderer> out) {
    BaseRenderer ffmpegRenderer = new SoftVideoRenderer(true,
            allowedVideoJoiningTimeMs, eventHandler, eventListener,
            MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY,
            drmSessionManager, false);
    out.add(ffmpegRenderer);
    super.buildVideoRenderers(context, extensionRendererMode, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys, eventHandler, eventListener, allowedVideoJoiningTimeMs, out);
}
 
Example #29
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoDisabled(DecoderCounters counters) {
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoDisabled(counters);
  }
  videoFormat = null;
  videoDecoderCounters = null;
}
 
Example #30
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVideoInputFormatChanged(Format format) {
  videoFormat = format;
  for (VideoRendererEventListener videoDebugListener : videoDebugListeners) {
    videoDebugListener.onVideoInputFormatChanged(format);
  }
}