diff options
author | Dongwon Kang <dwkang@google.com> | 2014-06-02 13:33:55 +0900 |
---|---|---|
committer | Dongwon Kang <dwkang@google.com> | 2014-06-03 09:53:05 +0900 |
commit | a3be12a236aef0d9c4ff1274075f1e7899d29153 (patch) | |
tree | 4effaecc291597c4b9d65ad039bbe49161377288 /media | |
parent | 6abd0d801b6772bb9d0fe6cd4c007dace2f38570 (diff) | |
download | frameworks_base-a3be12a236aef0d9c4ff1274075f1e7899d29153.zip frameworks_base-a3be12a236aef0d9c4ff1274075f1e7899d29153.tar.gz frameworks_base-a3be12a236aef0d9c4ff1274075f1e7899d29153.tar.bz2 |
Add onAudioStreamChanged and onClosedCaptionStreamChanged callbacks from TIS to application.
Bug: 14628404
Change-Id: I40abf647e9d608c2c793d007fd2fe0d511535bdd
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/tv/ITvInputClient.aidl | 4 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputSessionCallback.aidl | 4 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputManager.java | 85 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputService.java | 52 | ||||
-rw-r--r-- | media/java/android/media/tv/TvView.java | 25 |
5 files changed, 153 insertions, 17 deletions
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl index dc79a73..011da35 100644 --- a/media/java/android/media/tv/ITvInputClient.aidl +++ b/media/java/android/media/tv/ITvInputClient.aidl @@ -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); } diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl index 71f2d07..00f2922 100644 --- a/media/java/android/media/tv/ITvInputSessionCallback.aidl +++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl @@ -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); } diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 1335a1b..698a861 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -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); } } diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 3213019..8ba0e20 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -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"); } @@ -245,6 +247,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. */ public abstract void onRelease(); diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java index 126d739..d8b362d 100644 --- a/media/java/android/media/tv/TvView.java +++ b/media/java/android/media/tv/TvView.java @@ -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); } } |