From dc775c66bf52d998e6cc37a0ba1ec3b12607fac4 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Thu, 15 Aug 2013 11:35:14 -0700 Subject: [PATCH] MediaFormat: added subtitle format Added KEY_LANGUAGE that for now only refers to subtitles. Added createSubtitleFormat() method to create base format. Signed-off-by: Lajos Molnar Change-Id: I344c36a3fd0d88c285cdebf3f67e549553b37a8e Bug: 10326117 --- api/current.txt | 2 ++ media/java/android/media/MediaFormat.java | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 6235addaffce..a1b95ac41d69 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12375,6 +12375,7 @@ package android.media { ctor public MediaFormat(); method public final boolean containsKey(java.lang.String); method public static final android.media.MediaFormat createAudioFormat(java.lang.String, int, int); + method public static final android.media.MediaFormat createSubtitleFormat(java.lang.String, java.lang.String); method public static final android.media.MediaFormat createVideoFormat(java.lang.String, int, int); method public final java.nio.ByteBuffer getByteBuffer(java.lang.String); method public final float getFloat(java.lang.String); @@ -12397,6 +12398,7 @@ package android.media { field public static final java.lang.String KEY_HEIGHT = "height"; field public static final java.lang.String KEY_IS_ADTS = "is-adts"; field public static final java.lang.String KEY_I_FRAME_INTERVAL = "i-frame-interval"; + field public static final java.lang.String KEY_LANGUAGE = "language"; field public static final java.lang.String KEY_MAX_INPUT_SIZE = "max-input-size"; field public static final java.lang.String KEY_MIME = "mime"; field public static final java.lang.String KEY_SAMPLE_RATE = "sample-rate"; diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index 3fbaf69576fe..278d6616da48 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -26,7 +26,7 @@ import java.util.Map; * * The format of the media data is specified as string/value pairs. * - * Keys common to all formats, all keys not marked optional are mandatory: + * Keys common to all audio/video formats, all keys not marked optional are mandatory: * * * @@ -57,6 +57,11 @@ import java.util.Map; * *
NameValue TypeDescription
{@link #KEY_FLAC_COMPRESSION_LEVEL}Integerencoder-only, optional, if content is FLAC audio, specifies the desired compression level.
* + * Subtitle formats have the following keys: + * + * + * + *
{@link #KEY_MIME}StringThe type of the format.
{@link #KEY_LANGUAGE}StringThe language of the content.
*/ public final class MediaFormat { private Map mMap; @@ -68,6 +73,12 @@ public final class MediaFormat { public static final String KEY_MIME = "mime"; /** + * A key describing the language of the content. + * The associated value is a string. + */ + public static final String KEY_LANGUAGE = "language"; + + /** * A key describing the sample rate of an audio format. * The associated value is an integer */ @@ -277,6 +288,23 @@ public final class MediaFormat { } /** + * Creates a minimal subtitle format. + * @param mime The mime type of the content. + * @param language The language of the content. Specify "und" if language + * information is only included in the content (similarly, if there + * are multiple language tracks in the content.) + */ + public static final MediaFormat createSubtitleFormat( + String mime, + String language) { + MediaFormat format = new MediaFormat(); + format.setString(KEY_MIME, mime); + format.setString(KEY_LANGUAGE, language); + + return format; + } + + /** * Creates a minimal video format. * @param mime The mime type of the content. * @param width The width of the content (in pixels) -- 2.11.0