Search in sources :

Example 1 with Log

use of androidx.media3.common.util.Log in project media by androidx.

the class MediaSessionImpl method dispatchRemoteControllerTask.

private ListenableFuture<SessionResult> dispatchRemoteControllerTask(ControllerInfo controller, RemoteControllerTask task) {
    try {
        ListenableFuture<SessionResult> future;
        int seq;
        @Nullable SequencedFutureManager manager = sessionStub.getConnectedControllersManager().getSequencedFutureManager(controller);
        if (manager != null) {
            future = manager.createSequencedFuture(RESULT_WHEN_CLOSED);
            seq = ((SequencedFuture<SessionResult>) future).getSequenceNumber();
        } else {
            if (!isConnected(controller)) {
                return Futures.immediateFuture(new SessionResult(RESULT_ERROR_SESSION_DISCONNECTED));
            }
            // 0 is OK for legacy controllers, because they didn't have sequence numbers.
            seq = 0;
            // Tell that operation is successful, although we don't know the actual result.
            future = Futures.immediateFuture(new SessionResult(SessionResult.RESULT_SUCCESS));
        }
        ControllerCb cb = controller.getControllerCb();
        if (cb != null) {
            task.run(cb, seq);
        }
        return future;
    } catch (DeadObjectException e) {
        onDeadObjectException(controller, e);
        return Futures.immediateFuture(new SessionResult(RESULT_ERROR_SESSION_DISCONNECTED));
    } catch (RemoteException e) {
        // Currently it's TransactionTooLargeException or DeadSystemException.
        // We'd better to leave log for those cases because
        // - TransactionTooLargeException means that we may need to fix our code.
        // (e.g. add pagination or special way to deliver Bitmap)
        // - DeadSystemException means that errors around it can be ignored.
        Log.w(TAG, "Exception in " + controller.toString(), e);
    }
    return Futures.immediateFuture(new SessionResult(RESULT_ERROR_UNKNOWN));
}
Also used : ControllerCb(androidx.media3.session.MediaSession.ControllerCb) DeadObjectException(android.os.DeadObjectException) RemoteException(android.os.RemoteException) Nullable(androidx.annotation.Nullable)

Example 2 with Log

use of androidx.media3.common.util.Log in project media by androidx.

the class MediaSessionLegacyStub method dispatchSessionTaskWithPlayerCommand.

private void dispatchSessionTaskWithPlayerCommand(@Player.Command int command, SessionTask task, @Nullable RemoteUserInfo remoteUserInfo) {
    if (sessionImpl.isReleased()) {
        return;
    }
    if (remoteUserInfo == null) {
        Log.d(TAG, "RemoteUserInfo is null, ignoring command=" + command);
        return;
    }
    postOrRun(sessionImpl.getApplicationHandler(), () -> {
        if (sessionImpl.isReleased()) {
            return;
        }
        if (!sessionCompat.isActive()) {
            Log.w(TAG, "Ignore incoming player command before initialization. command=" + command + ", pid=" + remoteUserInfo.getPid());
            return;
        }
        @Nullable ControllerInfo controller = tryGetController(remoteUserInfo);
        if (controller == null) {
            // Failed to get controller since connection was rejected.
            return;
        }
        if (!connectedControllersManager.isPlayerCommandAvailable(controller, command)) {
            return;
        }
        int resultCode = sessionImpl.onPlayerCommandRequestOnHandler(controller, command);
        if (resultCode != RESULT_SUCCESS) {
            // Don't run rejected command.
            return;
        }
        try {
            task.run(controller);
        } catch (RemoteException e) {
            // Currently it's TransactionTooLargeException or DeadSystemException.
            // We'd better to leave log for those cases because
            // - TransactionTooLargeException means that we may need to fix our code.
            // (e.g. add pagination or special way to deliver Bitmap)
            // - DeadSystemException means that errors around it can be ignored.
            Log.w(TAG, "Exception in " + controller, e);
        }
    });
}
Also used : RemoteException(android.os.RemoteException) Nullable(androidx.annotation.Nullable) ControllerInfo(androidx.media3.session.MediaSession.ControllerInfo)

Example 3 with Log

use of androidx.media3.common.util.Log in project media by androidx.

the class EventLogger method onTracksChanged.

@Override
public void onTracksChanged(EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    MappedTrackInfo mappedTrackInfo = trackSelector != null ? trackSelector.getCurrentMappedTrackInfo() : null;
    if (mappedTrackInfo == null) {
        logd(eventTime, "tracks", "[]");
        return;
    }
    logd("tracks [" + getEventTimeString(eventTime));
    // Log tracks associated to renderers.
    int rendererCount = mappedTrackInfo.getRendererCount();
    for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
        TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
        TrackSelection trackSelection = trackSelections.get(rendererIndex);
        if (rendererTrackGroups.length == 0) {
            logd("  " + mappedTrackInfo.getRendererName(rendererIndex) + " []");
        } else {
            logd("  " + mappedTrackInfo.getRendererName(rendererIndex) + " [");
            for (int groupIndex = 0; groupIndex < rendererTrackGroups.length; groupIndex++) {
                TrackGroup trackGroup = rendererTrackGroups.get(groupIndex);
                String adaptiveSupport = getAdaptiveSupportString(trackGroup.length, mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, /* includeCapabilitiesExceededTracks= */
                false));
                logd("    Group:" + trackGroup.id + ", adaptive_supported=" + adaptiveSupport + " [");
                for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
                    String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
                    @Capabilities int capabilities = mappedTrackInfo.getCapabilities(rendererIndex, groupIndex, trackIndex);
                    String formatSupport = getFormatSupportString(getFormatSupport(capabilities));
                    String hardwareAccelerationSupport = getHardwareAccelerationSupport(capabilities) == HARDWARE_ACCELERATION_SUPPORTED ? ", accelerated=YES" : "";
                    String decoderSupport = getDecoderSupport(capabilities) == DECODER_SUPPORT_FALLBACK ? ", fallback=YES" : "";
                    logd("      " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport + hardwareAccelerationSupport + decoderSupport);
                }
                logd("    ]");
            }
            // Log metadata for at most one of the tracks selected for the renderer.
            if (trackSelection != null) {
                for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
                    Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
                    if (metadata != null) {
                        logd("    Metadata [");
                        printMetadata(metadata, "      ");
                        logd("    ]");
                        break;
                    }
                }
            }
            logd("  ]");
        }
    }
    // Log tracks not associated with a renderer.
    TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
    if (unassociatedTrackGroups.length > 0) {
        logd("  Unmapped [");
        for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
            logd("    Group:" + groupIndex + " [");
            TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
            for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
                String status = getTrackStatusString(false);
                String formatSupport = getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
                logd("      " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
            }
            logd("    ]");
        }
        logd("  ]");
    }
    logd("]");
}
Also used : TrackGroup(androidx.media3.common.TrackGroup) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Capabilities(androidx.media3.exoplayer.RendererCapabilities.Capabilities) TrackGroupArray(androidx.media3.common.TrackGroupArray) Metadata(androidx.media3.common.Metadata) Util.getFormatSupportString(androidx.media3.common.util.Util.getFormatSupportString) MappedTrackInfo(androidx.media3.exoplayer.trackselection.MappingTrackSelector.MappedTrackInfo) TrackSelection(androidx.media3.common.TrackSelection)

Example 4 with Log

use of androidx.media3.common.util.Log in project media by androidx.

the class MediaSessionImpl method dispatchRemoteControllerTaskWithoutReturn.

protected void dispatchRemoteControllerTaskWithoutReturn(ControllerInfo controller, RemoteControllerTask task) {
    try {
        int seq;
        @Nullable SequencedFutureManager manager = sessionStub.getConnectedControllersManager().getSequencedFutureManager(controller);
        if (manager != null) {
            seq = manager.obtainNextSequenceNumber();
        } else {
            if (!isConnected(controller)) {
                return;
            }
            // 0 is OK for legacy controllers, because they didn't have sequence numbers.
            seq = 0;
        }
        ControllerCb cb = controller.getControllerCb();
        if (cb != null) {
            task.run(cb, seq);
        }
    } catch (DeadObjectException e) {
        onDeadObjectException(controller, e);
    } catch (RemoteException e) {
        // Currently it's TransactionTooLargeException or DeadSystemException.
        // We'd better to leave log for those cases because
        // - TransactionTooLargeException means that we may need to fix our code.
        // (e.g. add pagination or special way to deliver Bitmap)
        // - DeadSystemException means that errors around it can be ignored.
        Log.w(TAG, "Exception in " + controller.toString(), e);
    }
}
Also used : ControllerCb(androidx.media3.session.MediaSession.ControllerCb) DeadObjectException(android.os.DeadObjectException) RemoteException(android.os.RemoteException) Nullable(androidx.annotation.Nullable)

Example 5 with Log

use of androidx.media3.common.util.Log in project media by androidx.

the class MediaSessionImpl method dispatchOnPlayerInfoChanged.

private void dispatchOnPlayerInfoChanged(boolean excludeTimeline) {
    lastPlayerInfo = playerInfo;
    List<ControllerInfo> controllers = sessionStub.getConnectedControllersManager().getConnectedControllers();
    for (int i = 0; i < controllers.size(); i++) {
        ControllerInfo controller = controllers.get(i);
        try {
            int seq;
            SequencedFutureManager manager = sessionStub.getConnectedControllersManager().getSequencedFutureManager(controller);
            if (manager != null) {
                seq = manager.obtainNextSequenceNumber();
            } else {
                if (!isConnected(controller)) {
                    return;
                }
                // 0 is OK for legacy controllers, because they didn't have sequence numbers.
                seq = 0;
            }
            checkStateNotNull(controller.getControllerCb()).onPlayerInfoChanged(seq, playerInfo, !sessionStub.getConnectedControllersManager().isPlayerCommandAvailable(controller, Player.COMMAND_GET_TIMELINE), !sessionStub.getConnectedControllersManager().isPlayerCommandAvailable(controller, Player.COMMAND_GET_MEDIA_ITEMS_METADATA), !sessionStub.getConnectedControllersManager().isPlayerCommandAvailable(controller, Player.COMMAND_GET_TEXT), excludeTimeline);
        } catch (DeadObjectException e) {
            onDeadObjectException(controller, e);
        } catch (RemoteException e) {
            // Currently it's TransactionTooLargeException or DeadSystemException.
            // We'd better to leave log for those cases because
            // - TransactionTooLargeException means that we may need to fix our code.
            // (e.g. add pagination or special way to deliver Bitmap)
            // - DeadSystemException means that errors around it can be ignored.
            Log.w(TAG, "Exception in " + controller.toString(), e);
        }
    }
}
Also used : DeadObjectException(android.os.DeadObjectException) RemoteException(android.os.RemoteException) ControllerInfo(androidx.media3.session.MediaSession.ControllerInfo)

Aggregations

RemoteException (android.os.RemoteException)4 DeadObjectException (android.os.DeadObjectException)3 Nullable (androidx.annotation.Nullable)3 ControllerCb (androidx.media3.session.MediaSession.ControllerCb)2 ControllerInfo (androidx.media3.session.MediaSession.ControllerInfo)2 Metadata (androidx.media3.common.Metadata)1 TrackGroup (androidx.media3.common.TrackGroup)1 TrackGroupArray (androidx.media3.common.TrackGroupArray)1 TrackSelection (androidx.media3.common.TrackSelection)1 Util.getFormatSupportString (androidx.media3.common.util.Util.getFormatSupportString)1 RendererCapabilities (androidx.media3.exoplayer.RendererCapabilities)1 Capabilities (androidx.media3.exoplayer.RendererCapabilities.Capabilities)1 MappedTrackInfo (androidx.media3.exoplayer.trackselection.MappingTrackSelector.MappedTrackInfo)1