Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc6ca765 authored by David Zhao's avatar David Zhao Committed by Android (Google) Code Review
Browse files

Merge "Reapply "Implement Start/Stop Playback APIs"" into main

parents 6d9ba3a7 9fde926e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@ interface ITvInputManager {
    void pauseRecording(in IBinder sessionToken, in Bundle params, int userId);
    void resumeRecording(in IBinder sessionToken, in Bundle params, int userId);

    // For playback control
    void startPlayback(in IBinder sessionToken, int userId);
    void stopPlayback(in IBinder sessionToken, int mode, int userId);

    // For broadcast info
    void requestBroadcastInfo(in IBinder sessionToken, in BroadcastInfoRequest request, int userId);
    void removeBroadcastInfo(in IBinder sessionToken, int id, int userId);
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ oneway interface ITvInputSession {
    void timeShiftSetMode(int mode);
    void timeShiftEnablePositionTracking(boolean enable);

    void startPlayback();
    void stopPlayback(int mode);

    // For the recording session
    void startRecording(in Uri programUri, in Bundle params);
    void stopRecording();
+21 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    private static final int DO_TIME_SHIFT_SET_MODE = 30;
    private static final int DO_SET_TV_MESSAGE_ENABLED = 31;
    private static final int DO_NOTIFY_TV_MESSAGE = 32;
    private static final int DO_STOP_PLAYBACK = 33;
    private static final int DO_START_PLAYBACK = 34;

    private final boolean mIsRecordingSession;
    private final HandlerCaller mCaller;
@@ -286,6 +288,14 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
                mTvInputSessionImpl.onTvMessageReceived((Integer) args.arg1, (Bundle) args.arg2);
                break;
            }
            case DO_STOP_PLAYBACK: {
                mTvInputSessionImpl.stopPlayback(msg.arg1);
                break;
            }
            case DO_START_PLAYBACK: {
                mTvInputSessionImpl.startPlayback();
                break;
            }
            default: {
                Log.w(TAG, "Unhandled message code: " + msg.what);
                break;
@@ -483,6 +493,17 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
                enabled));
    }

    @Override
    public void stopPlayback(int mode) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_STOP_PLAYBACK, mode));
    }

    @Override
    public void startPlayback() {
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_START_PLAYBACK));
    }


    private final class TvInputEventReceiver extends InputEventReceiver {
        TvInputEventReceiver(InputChannel inputChannel, Looper looper) {
            super(inputChannel, looper);
+32 −0
Original line number Diff line number Diff line
@@ -339,6 +339,14 @@ public final class TvInputManager {
     */
    public static final int VIDEO_UNAVAILABLE_REASON_CAS_UNKNOWN = VIDEO_UNAVAILABLE_REASON_END;

    /**
     * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
     * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable because
     * it has been stopped by stopPlayback.
     * @hide
     */
    public static final int VIDEO_UNAVAILABLE_REASON_STOPPED = 19;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({TIME_SHIFT_STATUS_UNKNOWN, TIME_SHIFT_STATUS_UNSUPPORTED,
@@ -3302,6 +3310,30 @@ public final class TvInputManager {
            }
        }

        void stopPlayback(int mode) {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.stopPlayback(mToken, mode, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        void startPlayback() {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.startPlayback(mToken, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        /**
         * Sends TV messages to the service for testing purposes
         */
+41 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.graphics.Rect;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.media.AudioPresentation;
import android.media.PlaybackParams;
import android.media.tv.interactive.TvInteractiveAppService;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@@ -1530,6 +1531,32 @@ public abstract class TvInputService extends Service {
                @NonNull Bundle data) {
        }

        /**
         * Called when the application requests playback of the Audio, Video, and CC streams to be
         * stopped, but the metadata should continue to be filtered.
         *
         * <p>The metadata that will continue to be filtered includes the PSI
         * (Program specific information) and SI (Service Information), part of ISO/IEC 13818-1.
         *
         * <p> Note that this is different form {@link #timeShiftPause()} as should release the
         * stream, making it impossible to resume from this position again.
         * @param mode
         * @hide
         */
        public void onStopPlayback(@TvInteractiveAppService.PlaybackCommandStopMode int mode) {
        }

        /**
         * Starts playback of the Audio, Video, and CC streams.
         *
         * <p> Note that this is different form {@link #timeShiftResume()} as this is intended to be
         * used after stopping playback. This is used to restart playback from the current position
         * in the live broadcast.
         * @hide
         */
        public void onStartPlayback() {
        }

        /**
         * Called when the application requests to play a given recorded TV program.
         *
@@ -1992,6 +2019,20 @@ public abstract class TvInputService extends Service {
            }
        }

        /**
         * Calls {@link #onStopPlayback(int)}.
         */
        void stopPlayback(int mode) {
            onStopPlayback(mode);
        }

        /**
         * Calls {@link #onStartPlayback()}.
         */
        void startPlayback() {
            onStartPlayback();
        }

        /**
         * Calls {@link #onTimeShiftPlay(Uri)}.
         */
Loading