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

Commit 450758a5 authored by Dongwon Kang's avatar Dongwon Kang Committed by Android Git Automerger
Browse files

am 65d95bfa: Merge "Add onAudioStreamChanged and onClosedCaptionStreamChanged...

am 65d95bfa: Merge "Add onAudioStreamChanged and onClosedCaptionStreamChanged callbacks from TIS to application." into lmp-preview-dev

* commit '65d95bfa011fa50e50403f41e08afa2af5d9746e':
  Add onAudioStreamChanged and onClosedCaptionStreamChanged callbacks from TIS to application.
parents 78b13b21 7b2ae34b
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -31,5 +31,7 @@ oneway interface ITvInputClient {
    void onAvailabilityChanged(in String inputId, boolean isAvailable);
    void onAvailabilityChanged(in String inputId, boolean isAvailable);
    void onSessionReleased(int seq);
    void onSessionReleased(int seq);
    void onSessionEvent(in String name, in Bundle args, 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 Original line Diff line number Diff line
@@ -27,5 +27,7 @@ import android.os.Bundle;
oneway interface ITvInputSessionCallback {
oneway interface ITvInputSessionCallback {
    void onSessionCreated(ITvInputSession session);
    void onSessionCreated(ITvInputSession session);
    void onSessionEvent(in String name, in Bundle args);
    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 Original line 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
         * This is called at the beginning of the playback of a channel and later when the format of
         * the video has been changed.
         * the video stream has been changed.
         *
         *
         * @param session A {@link TvInputManager.Session} associated with this callback
         * @param session A {@link TvInputManager.Session} associated with this callback
         * @param width the width of the video
         * @param width The width of the video.
         * @param height the height of the video
         * @param height The height of the video.
         * @param interlaced whether the video is interlaced mode or planer mode.
         * @hide
         * @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() {
            mHandler.post(new Runnable() {
                @Override
                @Override
                public void run() {
                public void run() {
                    mSessionCallback.onVideoSizeChanged(mSession, width, height);
                    mSessionCallback.onClosedCaptionStreamChanged(mSession, hasClosedCaption);
                }
                }
            });
            });
        }
        }
@@ -238,14 +281,38 @@ public final class TvInputManager {
            }
            }


            @Override
            @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) {
                synchronized (mSessionCallbackRecordMap) {
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    if (record == null) {
                    if (record == null) {
                        Log.e(TAG, "Callback not found for seq " + seq);
                        Log.e(TAG, "Callback not found for seq " + seq);
                        return;
                        return;
                    }
                    }
                    record.postVideoSizeChanged(width, height);
                    record.postClosedCaptionStreamChanged(hasClosedCaption);
                }
                }
            }
            }


+48 −4
Original line number Original line 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
         * 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 size has been changed.
         * beginning of the playback and later when the format has been changed.
         *
         *
         * @param width The width of the video.
         * @param width The width of the video.
         * @param height The height of the video.
         * @param height The height of the video.
         * @param interlaced Whether the video is interlaced mode or planer mode.
         * @hide
         * @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() {
            mHandler.post(new Runnable() {
                @Override
                @Override
                public void run() {
                public void run() {
                    try {
                    try {
                        if (DEBUG) Log.d(TAG, "dispatchVideoSizeChanged");
                        if (DEBUG) Log.d(TAG, "dispatchVideoSizeChanged");
                        mSessionCallback.onVideoSizeChanged(width, height);
                        mSessionCallback.onVideoStreamChanged(width, height, interlaced);
                    } catch (RemoteException e) {
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in dispatchVideoSizeChanged");
                        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.
         * Called when the session is released.
         */
         */
+23 −2
Original line number Original line Diff line number Diff line
@@ -382,12 +382,33 @@ public class TvView extends SurfaceView {
        }
        }


        @Override
        @Override
        public void onVideoSizeChanged(Session session, int width, int height) {
        public void onVideoStreamChanged(Session session, int width, int height,
                boolean interlaced) {
            if (DEBUG) {
            if (DEBUG) {
                Log.d(TAG, "onVideoSizeChanged(" + width + ", " + height + ")");
                Log.d(TAG, "onVideoSizeChanged(" + width + ", " + height + ")");
            }
            }
            if (mExternalCallback != null) {
            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