1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.exoplayer2.analytics; 17 18 import android.view.Surface; 19 import androidx.annotation.Nullable; 20 import com.google.android.exoplayer2.C; 21 import com.google.android.exoplayer2.ExoPlaybackException; 22 import com.google.android.exoplayer2.Format; 23 import com.google.android.exoplayer2.PlaybackParameters; 24 import com.google.android.exoplayer2.Player; 25 import com.google.android.exoplayer2.Player.DiscontinuityReason; 26 import com.google.android.exoplayer2.Player.PlaybackSuppressionReason; 27 import com.google.android.exoplayer2.Player.TimelineChangeReason; 28 import com.google.android.exoplayer2.Timeline; 29 import com.google.android.exoplayer2.audio.AudioAttributes; 30 import com.google.android.exoplayer2.audio.AudioSink; 31 import com.google.android.exoplayer2.decoder.DecoderCounters; 32 import com.google.android.exoplayer2.metadata.Metadata; 33 import com.google.android.exoplayer2.source.LoadEventInfo; 34 import com.google.android.exoplayer2.source.MediaLoadData; 35 import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; 36 import com.google.android.exoplayer2.source.TrackGroupArray; 37 import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 38 import java.io.IOException; 39 40 /** 41 * A listener for analytics events. 42 * 43 * <p>All events are recorded with an {@link EventTime} specifying the elapsed real time and media 44 * time at the time of the event. 45 * 46 * <p>All methods have no-op default implementations to allow selective overrides. 47 */ 48 public interface AnalyticsListener { 49 50 /** Time information of an event. */ 51 final class EventTime { 52 53 /** 54 * Elapsed real-time as returned by {@code SystemClock.elapsedRealtime()} at the time of the 55 * event, in milliseconds. 56 */ 57 public final long realtimeMs; 58 59 /** Timeline at the time of the event. */ 60 public final Timeline timeline; 61 62 /** 63 * Window index in the {@link #timeline} this event belongs to, or the prospective window index 64 * if the timeline is not yet known and empty. 65 */ 66 public final int windowIndex; 67 68 /** 69 * Media period identifier for the media period this event belongs to, or {@code null} if the 70 * event is not associated with a specific media period. 71 */ 72 @Nullable public final MediaPeriodId mediaPeriodId; 73 74 /** 75 * Position in the window or ad this event belongs to at the time of the event, in milliseconds. 76 */ 77 public final long eventPlaybackPositionMs; 78 79 /** 80 * Position in the current timeline window ({@link Player#getCurrentWindowIndex()}) or the 81 * currently playing ad at the time of the event, in milliseconds. 82 */ 83 public final long currentPlaybackPositionMs; 84 85 /** 86 * Total buffered duration from {@link #currentPlaybackPositionMs} at the time of the event, in 87 * milliseconds. This includes pre-buffered data for subsequent ads and windows. 88 */ 89 public final long totalBufferedDurationMs; 90 91 /** 92 * @param realtimeMs Elapsed real-time as returned by {@code SystemClock.elapsedRealtime()} at 93 * the time of the event, in milliseconds. 94 * @param timeline Timeline at the time of the event. 95 * @param windowIndex Window index in the {@link #timeline} this event belongs to, or the 96 * prospective window index if the timeline is not yet known and empty. 97 * @param mediaPeriodId Media period identifier for the media period this event belongs to, or 98 * {@code null} if the event is not associated with a specific media period. 99 * @param eventPlaybackPositionMs Position in the window or ad this event belongs to at the time 100 * of the event, in milliseconds. 101 * @param currentPlaybackPositionMs Position in the current timeline window ({@link 102 * Player#getCurrentWindowIndex()}) or the currently playing ad at the time of the event, in 103 * milliseconds. 104 * @param totalBufferedDurationMs Total buffered duration from {@link 105 * #currentPlaybackPositionMs} at the time of the event, in milliseconds. This includes 106 * pre-buffered data for subsequent ads and windows. 107 */ EventTime( long realtimeMs, Timeline timeline, int windowIndex, @Nullable MediaPeriodId mediaPeriodId, long eventPlaybackPositionMs, long currentPlaybackPositionMs, long totalBufferedDurationMs)108 public EventTime( 109 long realtimeMs, 110 Timeline timeline, 111 int windowIndex, 112 @Nullable MediaPeriodId mediaPeriodId, 113 long eventPlaybackPositionMs, 114 long currentPlaybackPositionMs, 115 long totalBufferedDurationMs) { 116 this.realtimeMs = realtimeMs; 117 this.timeline = timeline; 118 this.windowIndex = windowIndex; 119 this.mediaPeriodId = mediaPeriodId; 120 this.eventPlaybackPositionMs = eventPlaybackPositionMs; 121 this.currentPlaybackPositionMs = currentPlaybackPositionMs; 122 this.totalBufferedDurationMs = totalBufferedDurationMs; 123 } 124 } 125 126 /** 127 * @deprecated Use {@link #onPlaybackStateChanged(EventTime, int)} and {@link 128 * #onPlayWhenReadyChanged(EventTime, boolean, int)} instead. 129 */ 130 @Deprecated onPlayerStateChanged( EventTime eventTime, boolean playWhenReady, @Player.State int playbackState)131 default void onPlayerStateChanged( 132 EventTime eventTime, boolean playWhenReady, @Player.State int playbackState) {} 133 134 /** 135 * Called when the playback state changed. 136 * 137 * @param eventTime The event time. 138 * @param state The new {@link Player.State playback state}. 139 */ onPlaybackStateChanged(EventTime eventTime, @Player.State int state)140 default void onPlaybackStateChanged(EventTime eventTime, @Player.State int state) {} 141 142 /** 143 * Called when the value changed that indicates whether playback will proceed when ready. 144 * 145 * @param eventTime The event time. 146 * @param playWhenReady Whether playback will proceed when ready. 147 * @param reason The {@link Player.PlayWhenReadyChangeReason reason} of the change. 148 */ onPlayWhenReadyChanged( EventTime eventTime, boolean playWhenReady, @Player.PlayWhenReadyChangeReason int reason)149 default void onPlayWhenReadyChanged( 150 EventTime eventTime, boolean playWhenReady, @Player.PlayWhenReadyChangeReason int reason) {} 151 152 /** 153 * Called when playback suppression reason changed. 154 * 155 * @param eventTime The event time. 156 * @param playbackSuppressionReason The new {@link PlaybackSuppressionReason}. 157 */ onPlaybackSuppressionReasonChanged( EventTime eventTime, @PlaybackSuppressionReason int playbackSuppressionReason)158 default void onPlaybackSuppressionReasonChanged( 159 EventTime eventTime, @PlaybackSuppressionReason int playbackSuppressionReason) {} 160 161 /** 162 * Called when the player starts or stops playing. 163 * 164 * @param eventTime The event time. 165 * @param isPlaying Whether the player is playing. 166 */ onIsPlayingChanged(EventTime eventTime, boolean isPlaying)167 default void onIsPlayingChanged(EventTime eventTime, boolean isPlaying) {} 168 169 /** 170 * Called when the timeline changed. 171 * 172 * @param eventTime The event time. 173 * @param reason The reason for the timeline change. 174 */ onTimelineChanged(EventTime eventTime, @TimelineChangeReason int reason)175 default void onTimelineChanged(EventTime eventTime, @TimelineChangeReason int reason) {} 176 177 /** 178 * Called when a position discontinuity occurred. 179 * 180 * @param eventTime The event time. 181 * @param reason The reason for the position discontinuity. 182 */ onPositionDiscontinuity(EventTime eventTime, @DiscontinuityReason int reason)183 default void onPositionDiscontinuity(EventTime eventTime, @DiscontinuityReason int reason) {} 184 185 /** 186 * Called when a seek operation started. 187 * 188 * @param eventTime The event time. 189 */ onSeekStarted(EventTime eventTime)190 default void onSeekStarted(EventTime eventTime) {} 191 192 /** 193 * @deprecated Seeks are processed without delay. Listen to {@link 194 * #onPositionDiscontinuity(EventTime, int)} with reason {@link 195 * Player#DISCONTINUITY_REASON_SEEK} instead. 196 */ 197 @Deprecated onSeekProcessed(EventTime eventTime)198 default void onSeekProcessed(EventTime eventTime) {} 199 200 /** 201 * @deprecated Use {@link #onPlaybackSpeedChanged(EventTime, float)} and {@link 202 * #onSkipSilenceEnabledChanged(EventTime, boolean)} instead. 203 */ 204 @SuppressWarnings("deprecation") 205 @Deprecated onPlaybackParametersChanged( EventTime eventTime, PlaybackParameters playbackParameters)206 default void onPlaybackParametersChanged( 207 EventTime eventTime, PlaybackParameters playbackParameters) {} 208 209 /** 210 * Called when the playback speed changes. 211 * 212 * @param eventTime The event time. 213 * @param playbackSpeed The playback speed. 214 */ onPlaybackSpeedChanged(EventTime eventTime, float playbackSpeed)215 default void onPlaybackSpeedChanged(EventTime eventTime, float playbackSpeed) {} 216 217 /** 218 * Called when the repeat mode changed. 219 * 220 * @param eventTime The event time. 221 * @param repeatMode The new repeat mode. 222 */ onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode)223 default void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {} 224 225 /** 226 * Called when the shuffle mode changed. 227 * 228 * @param eventTime The event time. 229 * @param shuffleModeEnabled Whether the shuffle mode is enabled. 230 */ onShuffleModeChanged(EventTime eventTime, boolean shuffleModeEnabled)231 default void onShuffleModeChanged(EventTime eventTime, boolean shuffleModeEnabled) {} 232 233 /** 234 * Called when the player starts or stops loading data from a source. 235 * 236 * @param eventTime The event time. 237 * @param isLoading Whether the player is loading. 238 */ 239 @SuppressWarnings("deprecation") onIsLoadingChanged(EventTime eventTime, boolean isLoading)240 default void onIsLoadingChanged(EventTime eventTime, boolean isLoading) { 241 onLoadingChanged(eventTime, isLoading); 242 } 243 244 /** @deprecated Use {@link #onIsLoadingChanged(EventTime, boolean)} instead. */ 245 @Deprecated onLoadingChanged(EventTime eventTime, boolean isLoading)246 default void onLoadingChanged(EventTime eventTime, boolean isLoading) {} 247 248 /** 249 * Called when a fatal player error occurred. 250 * 251 * @param eventTime The event time. 252 * @param error The error. 253 */ onPlayerError(EventTime eventTime, ExoPlaybackException error)254 default void onPlayerError(EventTime eventTime, ExoPlaybackException error) {} 255 256 /** 257 * Called when the available or selected tracks for the renderers changed. 258 * 259 * @param eventTime The event time. 260 * @param trackGroups The available tracks. May be empty. 261 * @param trackSelections The track selections for each renderer. May contain null elements. 262 */ onTracksChanged( EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections)263 default void onTracksChanged( 264 EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {} 265 266 /** 267 * Called when a media source started loading data. 268 * 269 * @param eventTime The event time. 270 * @param loadEventInfo The {@link LoadEventInfo} defining the load event. 271 * @param mediaLoadData The {@link MediaLoadData} defining the data being loaded. 272 */ onLoadStarted( EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)273 default void onLoadStarted( 274 EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {} 275 276 /** 277 * Called when a media source completed loading data. 278 * 279 * @param eventTime The event time. 280 * @param loadEventInfo The {@link LoadEventInfo} defining the load event. 281 * @param mediaLoadData The {@link MediaLoadData} defining the data being loaded. 282 */ onLoadCompleted( EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)283 default void onLoadCompleted( 284 EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {} 285 286 /** 287 * Called when a media source canceled loading data. 288 * 289 * @param eventTime The event time. 290 * @param loadEventInfo The {@link LoadEventInfo} defining the load event. 291 * @param mediaLoadData The {@link MediaLoadData} defining the data being loaded. 292 */ onLoadCanceled( EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)293 default void onLoadCanceled( 294 EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {} 295 296 /** 297 * Called when a media source loading error occurred. These errors are just for informational 298 * purposes and the player may recover. 299 * 300 * @param eventTime The event time. 301 * @param loadEventInfo The {@link LoadEventInfo} defining the load event. 302 * @param mediaLoadData The {@link MediaLoadData} defining the data being loaded. 303 * @param error The load error. 304 * @param wasCanceled Whether the load was canceled as a result of the error. 305 */ onLoadError( EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException error, boolean wasCanceled)306 default void onLoadError( 307 EventTime eventTime, 308 LoadEventInfo loadEventInfo, 309 MediaLoadData mediaLoadData, 310 IOException error, 311 boolean wasCanceled) {} 312 313 /** 314 * Called when the downstream format sent to the renderers changed. 315 * 316 * @param eventTime The event time. 317 * @param mediaLoadData The {@link MediaLoadData} defining the newly selected media data. 318 */ onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData)319 default void onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData) {} 320 321 /** 322 * Called when data is removed from the back of a media buffer, typically so that it can be 323 * re-buffered in a different format. 324 * 325 * @param eventTime The event time. 326 * @param mediaLoadData The {@link MediaLoadData} defining the media being discarded. 327 */ onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData)328 default void onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData) {} 329 330 /** 331 * Called when a media source created a media period. 332 * 333 * @param eventTime The event time. 334 */ onMediaPeriodCreated(EventTime eventTime)335 default void onMediaPeriodCreated(EventTime eventTime) {} 336 337 /** 338 * Called when a media source released a media period. 339 * 340 * @param eventTime The event time. 341 */ onMediaPeriodReleased(EventTime eventTime)342 default void onMediaPeriodReleased(EventTime eventTime) {} 343 344 /** 345 * Called when the player started reading a media period. 346 * 347 * @param eventTime The event time. 348 */ onReadingStarted(EventTime eventTime)349 default void onReadingStarted(EventTime eventTime) {} 350 351 /** 352 * Called when the bandwidth estimate for the current data source has been updated. 353 * 354 * @param eventTime The event time. 355 * @param totalLoadTimeMs The total time spend loading this update is based on, in milliseconds. 356 * @param totalBytesLoaded The total bytes loaded this update is based on. 357 * @param bitrateEstimate The bandwidth estimate, in bits per second. 358 */ onBandwidthEstimate( EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate)359 default void onBandwidthEstimate( 360 EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) {} 361 362 /** 363 * Called when the output surface size changed. 364 * 365 * @param eventTime The event time. 366 * @param width The surface width in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if the 367 * video is not rendered onto a surface. 368 * @param height The surface height in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if 369 * the video is not rendered onto a surface. 370 */ onSurfaceSizeChanged(EventTime eventTime, int width, int height)371 default void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {} 372 373 /** 374 * Called when there is {@link Metadata} associated with the current playback time. 375 * 376 * @param eventTime The event time. 377 * @param metadata The metadata. 378 */ onMetadata(EventTime eventTime, Metadata metadata)379 default void onMetadata(EventTime eventTime, Metadata metadata) {} 380 381 /** 382 * Called when an audio or video decoder has been enabled. 383 * 384 * @param eventTime The event time. 385 * @param trackType The track type of the enabled decoder. Either {@link C#TRACK_TYPE_AUDIO} or 386 * {@link C#TRACK_TYPE_VIDEO}. 387 * @param decoderCounters The accumulated event counters associated with this decoder. 388 */ onDecoderEnabled( EventTime eventTime, int trackType, DecoderCounters decoderCounters)389 default void onDecoderEnabled( 390 EventTime eventTime, int trackType, DecoderCounters decoderCounters) {} 391 392 /** 393 * Called when an audio or video decoder has been initialized. 394 * 395 * @param eventTime The event time. 396 * @param trackType The track type of the initialized decoder. Either {@link C#TRACK_TYPE_AUDIO} 397 * or {@link C#TRACK_TYPE_VIDEO}. 398 * @param decoderName The decoder that was created. 399 * @param initializationDurationMs Time taken to initialize the decoder, in milliseconds. 400 */ onDecoderInitialized( EventTime eventTime, int trackType, String decoderName, long initializationDurationMs)401 default void onDecoderInitialized( 402 EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {} 403 404 /** 405 * Called when an audio or video decoder input format changed. 406 * 407 * @param eventTime The event time. 408 * @param trackType The track type of the decoder whose format changed. Either {@link 409 * C#TRACK_TYPE_AUDIO} or {@link C#TRACK_TYPE_VIDEO}. 410 * @param format The new input format for the decoder. 411 */ onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format)412 default void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {} 413 414 /** 415 * Called when an audio or video decoder has been disabled. 416 * 417 * @param eventTime The event time. 418 * @param trackType The track type of the disabled decoder. Either {@link C#TRACK_TYPE_AUDIO} or 419 * {@link C#TRACK_TYPE_VIDEO}. 420 * @param decoderCounters The accumulated event counters associated with this decoder. 421 */ onDecoderDisabled( EventTime eventTime, int trackType, DecoderCounters decoderCounters)422 default void onDecoderDisabled( 423 EventTime eventTime, int trackType, DecoderCounters decoderCounters) {} 424 425 /** 426 * Called when the audio session id is set. 427 * 428 * @param eventTime The event time. 429 * @param audioSessionId The audio session id. 430 */ onAudioSessionId(EventTime eventTime, int audioSessionId)431 default void onAudioSessionId(EventTime eventTime, int audioSessionId) {} 432 433 /** 434 * Called when the audio attributes change. 435 * 436 * @param eventTime The event time. 437 * @param audioAttributes The audio attributes. 438 */ onAudioAttributesChanged(EventTime eventTime, AudioAttributes audioAttributes)439 default void onAudioAttributesChanged(EventTime eventTime, AudioAttributes audioAttributes) {} 440 441 /** 442 * Called when the volume changes. 443 * 444 * @param eventTime The event time. 445 * @param volume The new volume, with 0 being silence and 1 being unity gain. 446 */ onVolumeChanged(EventTime eventTime, float volume)447 default void onVolumeChanged(EventTime eventTime, float volume) {} 448 449 /** 450 * Called when an audio underrun occurred. 451 * 452 * @param eventTime The event time. 453 * @param bufferSize The size of the {@link AudioSink}'s buffer, in bytes. 454 * @param bufferSizeMs The size of the {@link AudioSink}'s buffer, in milliseconds, if it is 455 * configured for PCM output. {@link C#TIME_UNSET} if it is configured for passthrough output, 456 * as the buffered media can have a variable bitrate so the duration may be unknown. 457 * @param elapsedSinceLastFeedMs The time since the {@link AudioSink} was last fed data. 458 */ onAudioUnderrun( EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs)459 default void onAudioUnderrun( 460 EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {} 461 462 /** 463 * Called when skipping silences is enabled or disabled in the audio stream. 464 * 465 * @param eventTime The event time. 466 * @param skipSilenceEnabled Whether skipping silences in the audio stream is enabled. 467 */ onSkipSilenceEnabledChanged(EventTime eventTime, boolean skipSilenceEnabled)468 default void onSkipSilenceEnabledChanged(EventTime eventTime, boolean skipSilenceEnabled) {} 469 470 /** 471 * Called after video frames have been dropped. 472 * 473 * @param eventTime The event time. 474 * @param droppedFrames The number of dropped frames since the last call to this method. 475 * @param elapsedMs The duration in milliseconds over which the frames were dropped. This duration 476 * is timed from when the renderer was started or from when dropped frames were last reported 477 * (whichever was more recent), and not from when the first of the reported drops occurred. 478 */ onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs)479 default void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {} 480 481 /** 482 * Called when there is an update to the video frame processing offset reported by a video 483 * renderer. 484 * 485 * <p>Video processing offset represents how early a video frame is processed compared to the 486 * player's current position. For each video frame, the offset is calculated as <em>P<sub>vf</sub> 487 * - P<sub>pl</sub></em> where <em>P<sub>vf</sub></em> is the presentation timestamp of the video 488 * frame and <em>P<sub>pl</sub></em> is the current position of the player. Positive values 489 * indicate the frame was processed early enough whereas negative values indicate that the 490 * player's position had progressed beyond the frame's timestamp when the frame was processed (and 491 * the frame was probably dropped). 492 * 493 * <p>The renderer reports the sum of video processing offset samples (one sample per processed 494 * video frame: dropped, skipped or rendered) and the total number of samples (frames). 495 * 496 * @param eventTime The event time. 497 * @param totalProcessingOffsetUs The sum of video frame processing offset samples for all video 498 * frames processed by the renderer in microseconds. 499 * @param frameCount The number to samples included in the {@code totalProcessingOffsetUs}. 500 * @param format The current output {@link Format} rendered by the video renderer. 501 */ onVideoFrameProcessingOffset( EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format)502 default void onVideoFrameProcessingOffset( 503 EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format) {} 504 505 /** 506 * Called before a frame is rendered for the first time since setting the surface, and each time 507 * there's a change in the size or pixel aspect ratio of the video being rendered. 508 * 509 * @param eventTime The event time. 510 * @param width The width of the video. 511 * @param height The height of the video. 512 * @param unappliedRotationDegrees For videos that require a rotation, this is the clockwise 513 * rotation in degrees that the application should apply for the video for it to be rendered 514 * in the correct orientation. This value will always be zero on API levels 21 and above, 515 * since the renderer will apply all necessary rotations internally. 516 * @param pixelWidthHeightRatio The width to height ratio of each pixel. 517 */ onVideoSizeChanged( EventTime eventTime, int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio)518 default void onVideoSizeChanged( 519 EventTime eventTime, 520 int width, 521 int height, 522 int unappliedRotationDegrees, 523 float pixelWidthHeightRatio) {} 524 525 /** 526 * Called when a frame is rendered for the first time since setting the surface, and when a frame 527 * is rendered for the first time since the renderer was reset. 528 * 529 * @param eventTime The event time. 530 * @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if 531 * the renderer renders to something that isn't a {@link Surface}. 532 */ onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface)533 default void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {} 534 535 /** 536 * Called each time a drm session is acquired. 537 * 538 * @param eventTime The event time. 539 */ onDrmSessionAcquired(EventTime eventTime)540 default void onDrmSessionAcquired(EventTime eventTime) {} 541 542 /** 543 * Called each time drm keys are loaded. 544 * 545 * @param eventTime The event time. 546 */ onDrmKeysLoaded(EventTime eventTime)547 default void onDrmKeysLoaded(EventTime eventTime) {} 548 549 /** 550 * Called when a drm error occurs. These errors are just for informational purposes and the player 551 * may recover. 552 * 553 * @param eventTime The event time. 554 * @param error The error. 555 */ onDrmSessionManagerError(EventTime eventTime, Exception error)556 default void onDrmSessionManagerError(EventTime eventTime, Exception error) {} 557 558 /** 559 * Called each time offline drm keys are restored. 560 * 561 * @param eventTime The event time. 562 */ onDrmKeysRestored(EventTime eventTime)563 default void onDrmKeysRestored(EventTime eventTime) {} 564 565 /** 566 * Called each time offline drm keys are removed. 567 * 568 * @param eventTime The event time. 569 */ onDrmKeysRemoved(EventTime eventTime)570 default void onDrmKeysRemoved(EventTime eventTime) {} 571 572 /** 573 * Called each time a drm session is released. 574 * 575 * @param eventTime The event time. 576 */ onDrmSessionReleased(EventTime eventTime)577 default void onDrmSessionReleased(EventTime eventTime) {} 578 } 579