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

Commit 7b2ae34b authored by Dongwon Kang's avatar Dongwon Kang Committed by Android (Google) Code Review
Browse files

Merge "Add onAudioStreamChanged and onClosedCaptionStreamChanged callbacks...

Merge "Add onAudioStreamChanged and onClosedCaptionStreamChanged callbacks from TIS to application." into lmp-preview-dev
parents 0aa54205 a3be12a2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -31,5 +31,7 @@ oneway interface ITvInputClient {
    void onAvailabilityChanged(in String inputId, boolean isAvailable);
    void onSessionReleased(int seq);
    void onSessionEvent(in String name, in Bundle args, int seq);
    void onVideoSizeChanged(int width, int height, int seq);
    void onVideoStreamChanged(int width, int height, boolean interlaced, int seq);
    void onAudioStreamChanged(int channelCount, int seq);
    void onClosedCaptionStreamChanged(boolean hasClosedCaption, int seq);
}
+3 −1
Original line number Diff line number Diff line
@@ -27,5 +27,7 @@ import android.os.Bundle;
oneway interface ITvInputSessionCallback {
    void onSessionCreated(ITvInputSession session);
    void onSessionEvent(in String name, in Bundle args);
    void onVideoSizeChanged(int width, int height);
    void onVideoStreamChanged(int width, int height, boolean interlaced);
    void onAudioStreamChanged(int channelCount);
    void onClosedCaptionStreamChanged(boolean hasClosedCaption);
}
+76 −9
Original line number Diff line number Diff line
@@ -88,15 +88,39 @@ public final class TvInputManager {
        }

        /**
         * This is called at the beginning of the playback of a channel and later when the size of
         * the video has been changed.
         * This is called at the beginning of the playback of a channel and later when the format of
         * the video stream has been changed.
         *
         * @param session A {@link TvInputManager.Session} associated with this callback
         * @param width the width of the video
         * @param height the height of the video
         * @param width The width of the video.
         * @param height The height of the video.
         * @param interlaced whether the video is interlaced mode or planer mode.
         * @hide
         */
        public void onVideoSizeChanged(Session session, int width, int height) {
        public void onVideoStreamChanged(Session session, int width, int height,
                boolean interlaced) {
        }

        /**
         * This is called at the beginning of the playback of a channel and later when the format of
         * the audio stream has been changed.
         *
         * @param session A {@link TvInputManager.Session} associated with this callback
         * @param channelCount The number of channels in the audio stream.
         * @hide
         */
        public void onAudioStreamChanged(Session session, int channelCount) {
        }

        /**
         * This is called at the beginning of the playback of a channel and later when the closed
         * caption stream has been changed.
         *
         * @param session A {@link TvInputManager.Session} associated with this callback
         * @param hasClosedCaption Whether the stream has closed caption or not.
         * @hide
         */
        public void onClosedCaptionStreamChanged(Session session, boolean hasClosedCaption) {
        }

        /**
@@ -141,11 +165,30 @@ public final class TvInputManager {
            });
        }

        public void postVideoSizeChanged(final int width, final int height) {
        public void postVideoStreamChanged(final int width, final int height,
                final boolean interlaced) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mSessionCallback.onVideoStreamChanged(mSession, width, height, interlaced);
                }
            });
        }

        public void postAudioStreamChanged(final int channelCount) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mSessionCallback.onAudioStreamChanged(mSession, channelCount);
                }
            });
        }

        public void postClosedCaptionStreamChanged(final boolean hasClosedCaption) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mSessionCallback.onVideoSizeChanged(mSession, width, height);
                    mSessionCallback.onClosedCaptionStreamChanged(mSession, hasClosedCaption);
                }
            });
        }
@@ -238,14 +281,38 @@ public final class TvInputManager {
            }

            @Override
            public void onVideoSizeChanged(int width, int height, int seq) {
            public void onVideoStreamChanged(int width, int height, boolean interlaced, int seq) {
                synchronized (mSessionCallbackRecordMap) {
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    if (record == null) {
                        Log.e(TAG, "Callback not found for seq " + seq);
                        return;
                    }
                    record.postVideoStreamChanged(width, height, interlaced);
                }
            }

            @Override
            public void onAudioStreamChanged(int channelCount, int seq) {
                synchronized (mSessionCallbackRecordMap) {
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    if (record == null) {
                        Log.e(TAG, "Callback not found for seq " + seq);
                        return;
                    }
                    record.postAudioStreamChanged(channelCount);
                }
            }

            @Override
            public void onClosedCaptionStreamChanged(boolean hasClosedCaption, int seq) {
                synchronized (mSessionCallbackRecordMap) {
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    if (record == null) {
                        Log.e(TAG, "Callback not found for seq " + seq);
                        return;
                    }
                    record.postVideoSizeChanged(width, height);
                    record.postClosedCaptionStreamChanged(hasClosedCaption);
                }
            }

+48 −4
Original line number Diff line number Diff line
@@ -223,20 +223,22 @@ public abstract class TvInputService extends Service {
        }

        /**
         * Sends the change on the size of the video. This is expected to be called at the
         * beginning of the playback and later when the size has been changed.
         * Sends the change on the format of the video stream. This is expected to be called at the
         * beginning of the playback and later when the format has been changed.
         *
         * @param width The width of the video.
         * @param height The height of the video.
         * @param interlaced Whether the video is interlaced mode or planer mode.
         * @hide
         */
        public void dispatchVideoSizeChanged(final int width, final int height) {
        public void dispatchVideoStreamChanged(final int width, final int height,
                final boolean interlaced) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (DEBUG) Log.d(TAG, "dispatchVideoSizeChanged");
                        mSessionCallback.onVideoSizeChanged(width, height);
                        mSessionCallback.onVideoStreamChanged(width, height, interlaced);
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in dispatchVideoSizeChanged");
                    }
@@ -244,6 +246,48 @@ public abstract class TvInputService extends Service {
            });
        }

        /**
         * Sends the change on the format of the audio stream. This is expected to be called at the
         * beginning of the playback and later when the format has been changed.
         *
         * @param channelNumber The number of channels in the audio stream.
         * @hide
         */
        public void dispatchAudioStreamChanged(final int channelNumber) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (DEBUG) Log.d(TAG, "dispatchAudioStreamChanged");
                        mSessionCallback.onAudioStreamChanged(channelNumber);
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in dispatchAudioStreamChanged");
                    }
                }
            });
        }

        /**
         * Sends the change on the closed caption stream. This is expected to be called at the
         * beginning of the playback and later when the stream has been changed.
         *
         * @param hasClosedCaption Whether the stream has closed caption or not.
         * @hide
         */
        public void dispatchClosedCaptionStreamChanged(final boolean hasClosedCaption) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (DEBUG) Log.d(TAG, "dispatchClosedCaptionStreamChanged");
                        mSessionCallback.onClosedCaptionStreamChanged(hasClosedCaption);
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in dispatchClosedCaptionStreamChanged");
                    }
                }
            });
        }

        /**
         * Called when the session is released.
         */
+23 −2
Original line number Diff line number Diff line
@@ -382,12 +382,33 @@ public class TvView extends SurfaceView {
        }

        @Override
        public void onVideoSizeChanged(Session session, int width, int height) {
        public void onVideoStreamChanged(Session session, int width, int height,
                boolean interlaced) {
            if (DEBUG) {
                Log.d(TAG, "onVideoSizeChanged(" + width + ", " + height + ")");
            }
            if (mExternalCallback != null) {
                mExternalCallback.onVideoSizeChanged(session, width, height);
                mExternalCallback.onVideoStreamChanged(session, width, height, interlaced);
            }
        }

        @Override
        public void onAudioStreamChanged(Session session, int channelCount) {
            if (DEBUG) {
                Log.d(TAG, "onAudioStreamChanged(" + channelCount + ")");
            }
            if (mExternalCallback != null) {
                mExternalCallback.onAudioStreamChanged(session, channelCount);
            }
        }

        @Override
        public void onClosedCaptionStreamChanged(Session session, boolean hasClosedCaption) {
            if (DEBUG) {
                Log.d(TAG, "onClosedCaptionStreamChanged(" + hasClosedCaption + ")");
            }
            if (mExternalCallback != null) {
                mExternalCallback.onClosedCaptionStreamChanged(session, hasClosedCaption);
            }
        }

Loading