mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add some missing @Nullable to public API to improve Kotlin compatiblity.
Kotlin will throw NPE whenever a method returns null or an interface is called with a null parameter and the respective values are not marked as @Nullable. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=213262886
This commit is contained in:
parent
76255dfae7
commit
c18ee3f96d
5 changed files with 28 additions and 39 deletions
|
|
@ -296,7 +296,7 @@ public class SimpleExoPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVideoSurface(Surface surface) {
|
public void setVideoSurface(@Nullable Surface surface) {
|
||||||
removeSurfaceCallbacks();
|
removeSurfaceCallbacks();
|
||||||
setVideoSurfaceInternal(surface, false);
|
setVideoSurfaceInternal(surface, false);
|
||||||
int newSurfaceSize = surface == null ? 0 : C.LENGTH_UNSET;
|
int newSurfaceSize = surface == null ? 0 : C.LENGTH_UNSET;
|
||||||
|
|
@ -828,7 +828,7 @@ public class SimpleExoPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExoPlaybackException getPlaybackError() {
|
public @Nullable ExoPlaybackException getPlaybackError() {
|
||||||
return player.getPlaybackError();
|
return player.getPlaybackError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1028,7 +1028,7 @@ public class SimpleExoPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCurrentManifest() {
|
public @Nullable Object getCurrentManifest() {
|
||||||
return player.getCurrentManifest();
|
return player.getCurrentManifest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1134,7 +1134,7 @@ public class SimpleExoPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVideoSurfaceInternal(Surface surface, boolean ownsSurface) {
|
private void setVideoSurfaceInternal(@Nullable Surface surface, boolean ownsSurface) {
|
||||||
// Note: We don't turn this method into a no-op if the surface is being replaced with itself
|
// Note: We don't turn this method into a no-op if the surface is being replaced with itself
|
||||||
// so as to ensure onRenderedFirstFrame callbacks are still called in this case.
|
// so as to ensure onRenderedFirstFrame callbacks are still called in this case.
|
||||||
List<PlayerMessage> messages = new ArrayList<>();
|
List<PlayerMessage> messages = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ public class AnalyticsCollector
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onRenderedFirstFrame(Surface surface) {
|
public final void onRenderedFirstFrame(@Nullable Surface surface) {
|
||||||
EventTime eventTime = generateReadingMediaPeriodEventTime();
|
EventTime eventTime = generateReadingMediaPeriodEventTime();
|
||||||
for (AnalyticsListener listener : listeners) {
|
for (AnalyticsListener listener : listeners) {
|
||||||
listener.onRenderedFirstFrame(eventTime, surface);
|
listener.onRenderedFirstFrame(eventTime, surface);
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ public interface AnalyticsListener {
|
||||||
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if
|
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if
|
||||||
* the renderer renders to something that isn't a {@link Surface}.
|
* the renderer renders to something that isn't a {@link Surface}.
|
||||||
*/
|
*/
|
||||||
default void onRenderedFirstFrame(EventTime eventTime, Surface surface) {}
|
default void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called each time a drm session is acquired.
|
* Called each time a drm session is acquired.
|
||||||
|
|
|
||||||
|
|
@ -323,8 +323,8 @@ public class EventLogger implements AnalyticsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderedFirstFrame(EventTime eventTime, Surface surface) {
|
public void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {
|
||||||
logd(eventTime, "renderedFirstFrame", surface.toString());
|
logd(eventTime, "renderedFirstFrame", String.valueOf(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public interface VideoRendererEventListener {
|
||||||
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if
|
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if
|
||||||
* the renderer renders to something that isn't a {@link Surface}.
|
* the renderer renders to something that isn't a {@link Surface}.
|
||||||
*/
|
*/
|
||||||
void onRenderedFirstFrame(Surface surface);
|
void onRenderedFirstFrame(@Nullable Surface surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the renderer is disabled.
|
* Called when the renderer is disabled.
|
||||||
|
|
@ -124,20 +124,16 @@ public interface VideoRendererEventListener {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onVideoEnabled(DecoderCounters)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onVideoEnabled(DecoderCounters)}.
|
public void enabled(DecoderCounters decoderCounters) {
|
||||||
*/
|
|
||||||
public void enabled(final DecoderCounters decoderCounters) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(() -> listener.onVideoEnabled(decoderCounters));
|
handler.post(() -> listener.onVideoEnabled(decoderCounters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onVideoDecoderInitialized(String, long, long)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onVideoDecoderInitialized(String, long, long)}.
|
public void decoderInitialized(
|
||||||
*/
|
String decoderName, long initializedTimestampMs, long initializationDurationMs) {
|
||||||
public void decoderInitialized(final String decoderName,
|
|
||||||
final long initializedTimestampMs, final long initializationDurationMs) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(
|
handler.post(
|
||||||
() ->
|
() ->
|
||||||
|
|
@ -146,29 +142,26 @@ public interface VideoRendererEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onVideoInputFormatChanged(Format)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onVideoInputFormatChanged(Format)}.
|
public void inputFormatChanged(Format format) {
|
||||||
*/
|
|
||||||
public void inputFormatChanged(final Format format) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(() -> listener.onVideoInputFormatChanged(format));
|
handler.post(() -> listener.onVideoInputFormatChanged(format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onDroppedFrames(int, long)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
|
public void droppedFrames(int droppedFrameCount, long elapsedMs) {
|
||||||
*/
|
|
||||||
public void droppedFrames(final int droppedFrameCount, final long elapsedMs) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(() -> listener.onDroppedFrames(droppedFrameCount, elapsedMs));
|
handler.post(() -> listener.onDroppedFrames(droppedFrameCount, elapsedMs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onVideoSizeChanged(int, int, int, float)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onVideoSizeChanged(int, int, int, float)}.
|
public void videoSizeChanged(
|
||||||
*/
|
int width,
|
||||||
public void videoSizeChanged(final int width, final int height,
|
int height,
|
||||||
final int unappliedRotationDegrees, final float pixelWidthHeightRatio) {
|
final int unappliedRotationDegrees,
|
||||||
|
final float pixelWidthHeightRatio) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(
|
handler.post(
|
||||||
() ->
|
() ->
|
||||||
|
|
@ -177,19 +170,15 @@ public interface VideoRendererEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onRenderedFirstFrame(Surface)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onRenderedFirstFrame(Surface)}.
|
public void renderedFirstFrame(@Nullable Surface surface) {
|
||||||
*/
|
|
||||||
public void renderedFirstFrame(final Surface surface) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(() -> listener.onRenderedFirstFrame(surface));
|
handler.post(() -> listener.onRenderedFirstFrame(surface));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Invokes {@link VideoRendererEventListener#onVideoDisabled(DecoderCounters)}. */
|
||||||
* Invokes {@link VideoRendererEventListener#onVideoDisabled(DecoderCounters)}.
|
public void disabled(DecoderCounters counters) {
|
||||||
*/
|
|
||||||
public void disabled(final DecoderCounters counters) {
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
handler.post(
|
handler.post(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue