diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioRecord.java | 20 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputManager.aidl | 2 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputSession.aidl | 2 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputSessionWrapper.java | 8 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputManager.java | 14 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputService.java | 54 | ||||
-rw-r--r-- | media/java/android/media/tv/TvView.java | 18 |
7 files changed, 77 insertions, 41 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 216d9b9..c0bc6d6 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -416,7 +416,8 @@ public class AudioRecord * <br>If the audio format is not specified or is incomplete, its sample rate will be the * default output sample rate of the device (see * {@link AudioManager#PROPERTY_OUTPUT_SAMPLE_RATE}), its channel configuration will be - * {@link AudioFormat#CHANNEL_IN_DEFAULT}. + * {@link AudioFormat#CHANNEL_IN_MONO}, and the encoding will be + * {@link AudioFormat#ENCODING_PCM_16BIT}. * <br>If the buffer size is not specified with {@link #setBufferSizeInBytes(int)}, * the minimum buffer size for the source is used. */ @@ -533,7 +534,22 @@ public class AudioRecord */ public AudioRecord build() throws UnsupportedOperationException { if (mFormat == null) { - mFormat = new AudioFormat.Builder().build(); + mFormat = new AudioFormat.Builder() + .setEncoding(AudioFormat.ENCODING_PCM_16BIT) + .setChannelMask(AudioFormat.CHANNEL_IN_MONO) + .build(); + } else { + if (mFormat.getEncoding() == AudioFormat.ENCODING_INVALID) { + mFormat = new AudioFormat.Builder(mFormat) + .setEncoding(AudioFormat.ENCODING_PCM_16BIT) + .build(); + } + if (mFormat.getChannelMask() == AudioFormat.CHANNEL_INVALID + && mFormat.getChannelIndexMask() == AudioFormat.CHANNEL_INVALID) { + mFormat = new AudioFormat.Builder(mFormat) + .setChannelMask(AudioFormat.CHANNEL_IN_MONO) + .build(); + } } if (mAttributes == null) { mAttributes = new AudioAttributes.Builder() diff --git a/media/java/android/media/tv/ITvInputManager.aidl b/media/java/android/media/tv/ITvInputManager.aidl index b6491d8..078fb2f 100644 --- a/media/java/android/media/tv/ITvInputManager.aidl +++ b/media/java/android/media/tv/ITvInputManager.aidl @@ -72,7 +72,7 @@ interface ITvInputManager { void relayoutOverlayView(in IBinder sessionToken, in Rect frame, int userId); void removeOverlayView(in IBinder sessionToken, int userId); - void requestUnblockContent(in IBinder sessionToken, in String unblockedRating, int userId); + void unblockContent(in IBinder sessionToken, in String unblockedRating, int userId); void timeShiftPause(in IBinder sessionToken, int userId); void timeShiftResume(in IBinder sessionToken, int userId); diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl index a054200..17f3984 100644 --- a/media/java/android/media/tv/ITvInputSession.aidl +++ b/media/java/android/media/tv/ITvInputSession.aidl @@ -45,7 +45,7 @@ oneway interface ITvInputSession { void relayoutOverlayView(in Rect frame); void removeOverlayView(); - void requestUnblockContent(in String unblockedRating); + void unblockContent(in String unblockedRating); void timeShiftPause(); void timeShiftResume(); diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java index 95aaa7f..0191652 100644 --- a/media/java/android/media/tv/ITvInputSessionWrapper.java +++ b/media/java/android/media/tv/ITvInputSessionWrapper.java @@ -57,7 +57,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand private static final int DO_CREATE_OVERLAY_VIEW = 10; private static final int DO_RELAYOUT_OVERLAY_VIEW = 11; private static final int DO_REMOVE_OVERLAY_VIEW = 12; - private static final int DO_REQUEST_UNBLOCK_CONTENT = 13; + private static final int DO_UNBLOCK_CONTENT = 13; private static final int DO_TIME_SHIFT_PAUSE = 14; private static final int DO_TIME_SHIFT_RESUME = 15; private static final int DO_TIME_SHIFT_SEEK_TO = 16; @@ -155,7 +155,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand mTvInputSessionImpl.removeOverlayView(true); break; } - case DO_REQUEST_UNBLOCK_CONTENT: { + case DO_UNBLOCK_CONTENT: { mTvInputSessionImpl.unblockContent((String) msg.obj); break; } @@ -267,9 +267,9 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand } @Override - public void requestUnblockContent(String unblockedRating) { + public void unblockContent(String unblockedRating) { mCaller.executeOrSendMessage(mCaller.obtainMessageO( - DO_REQUEST_UNBLOCK_CONTENT, unblockedRating)); + DO_UNBLOCK_CONTENT, unblockedRating)); } @Override diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index dca0631..705aa3d6 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -1367,12 +1367,12 @@ public final class TvInputManager { } /** - * Notifies of any structural changes (format or size) of the {@link Surface} - * passed by {@link #setSurface}. + * Notifies of any structural changes (format or size) of the surface passed in + * {@link #setSurface}. * - * @param format The new PixelFormat of the {@link Surface}. - * @param width The new width of the {@link Surface}. - * @param height The new height of the {@link Surface}. + * @param format The new PixelFormat of the surface. + * @param width The new width of the surface. + * @param height The new height of the surface. * @hide */ @SystemApi @@ -1820,14 +1820,14 @@ public final class TvInputManager { /** * Requests to unblock content blocked by parental controls. */ - void requestUnblockContent(@NonNull TvContentRating unblockedRating) { + void unblockContent(@NonNull TvContentRating unblockedRating) { Preconditions.checkNotNull(unblockedRating); if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { - mService.requestUnblockContent(mToken, unblockedRating.flattenToString(), mUserId); + mService.unblockContent(mToken, unblockedRating.flattenToString(), mUserId); } catch (RemoteException e) { throw new RuntimeException(e); } diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index c1035b0..8b0472a 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -281,8 +281,15 @@ public abstract class TvInputService extends Service { } /** - * Enables or disables the overlay view. By default, the overlay view is disabled. Must be - * called explicitly after the session is created to enable the overlay view. + * Enables or disables the overlay view. + * + * <p>By default, the overlay view is disabled. Must be called explicitly after the + * session is created to enable the overlay view. + * + * <p>The TV input service can disable its overlay view when the size of the overlay view is + * insufficient to display the whole information, such as when used in Picture-in-picture. + * Override {@link #onOverlayViewSizeChanged} to get the size of the overlay view, which + * then can be used to determine whether to enable/disable the overlay view. * * @param enable {@code true} if you want to enable the overlay view. {@code false} * otherwise. @@ -637,17 +644,15 @@ public abstract class TvInputService extends Service { } /** - * Assigns a position of the {@link Surface} passed by {@link #onSetSurface}. The position - * is relative to an overlay view. + * Assigns a size and position to the surface passed in {@link #onSetSurface}. The position + * is relative to the overlay view that sits on top of this surface. * * @param left Left position in pixels, relative to the overlay view. * @param top Top position in pixels, relative to the overlay view. * @param right Right position in pixels, relative to the overlay view. * @param bottom Bottom position in pixels, relative to the overlay view. * @see #onOverlayViewSizeChanged - * @hide */ - @SystemApi public void layoutSurface(final int left, final int top, final int right, final int bottom) { if (left > right || top > bottom) { @@ -701,41 +706,40 @@ public abstract class TvInputService extends Service { } /** - * Sets the {@link Surface} for the current input session on which the TV input renders - * video. + * Called when the application sets the surface. * - * <p>When {@code setSurface(null)} is called, the implementation should stop using the - * Surface object previously given and release any references to it. + * <p>The TV input service should render video onto the given surface. When called with + * {@code null}, the input service should immediately release any references to the + * currently set surface and stop using it. * - * @param surface possibly {@code null} {@link Surface} the application passes to this TV - * input session. - * @return {@code true} if the surface was set, {@code false} otherwise. + * @param surface The surface to be used for video rendering. Can be {@code null}. + * @return {@code true} if the surface was set successfully, {@code false} otherwise. */ public abstract boolean onSetSurface(@Nullable Surface surface); /** - * Called after any structural changes (format or size) have been made to the - * {@link Surface} passed by {@link #onSetSurface}. This method is always called - * at least once, after {@link #onSetSurface} with non-null {@link Surface} is called. + * Called after any structural changes (format or size) have been made to the surface passed + * in {@link #onSetSurface}. This method is always called at least once, after + * {@link #onSetSurface} is called with non-null surface. * - * @param format The new PixelFormat of the {@link Surface}. - * @param width The new width of the {@link Surface}. - * @param height The new height of the {@link Surface}. + * @param format The new PixelFormat of the surface. + * @param width The new width of the surface. + * @param height The new height of the surface. */ public void onSurfaceChanged(int format, int width, int height) { } /** - * Called when a size of an overlay view is changed by the application. Even when the - * overlay view is disabled by {@link #setOverlayViewEnabled}, this is called. The size is - * same as the size of {@link Surface} in general. Once {@link #layoutSurface} is called, - * the sizes of {@link Surface} and the overlay view can be different. + * Called when the size of the overlay view is changed by the application. + * + * <p>This is always called at least once when the session is created regardless of whether + * the overlay view is enabled or not. The overlay view size is the same as the containing + * {@link TvView}. Note that the size of the underlying surface can be different if the + * surface was changed by calling {@link #layoutSurface}. * * @param width The width of the overlay view. * @param height The height of the overlay view. - * @hide */ - @SystemApi public void onOverlayViewSizeChanged(int width, int height) { } diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java index 7e64b17..ebe281f 100644 --- a/media/java/android/media/tv/TvView.java +++ b/media/java/android/media/tv/TvView.java @@ -350,11 +350,27 @@ public class TvView extends ViewGroup { * @param unblockedRating A TvContentRating to unblock. * @see TvInputService.Session#notifyContentBlocked(TvContentRating) * @hide + * @deprecated Use {@link #unblockContent} instead. */ + @Deprecated @SystemApi public void requestUnblockContent(TvContentRating unblockedRating) { + unblockContent(unblockedRating); + } + + /** + * Requests to unblock TV content according to the given rating. + * + * <p>This notifies TV input that blocked content is now OK to play. + * + * @param unblockedRating A TvContentRating to unblock. + * @see TvInputService.Session#notifyContentBlocked(TvContentRating) + * @hide + */ + @SystemApi + public void unblockContent(TvContentRating unblockedRating) { if (mSession != null) { - mSession.requestUnblockContent(unblockedRating); + mSession.unblockContent(unblockedRating); } } |