Example usage for android.media MediaFormat KEY_HEIGHT

List of usage examples for android.media MediaFormat KEY_HEIGHT

Introduction

In this page you can find the example usage for android.media MediaFormat KEY_HEIGHT.

Prototype

String KEY_HEIGHT

To view the source code for android.media MediaFormat KEY_HEIGHT.

Click Source Link

Document

A key describing the height of the content in a video format.

Usage

From source file:ca.frozen.rpicameraviewer.activities.VideoFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    // configure the activity
    super.onCreate(savedInstanceState);

    // load the settings and cameras
    Utils.loadData();//from w w  w .  j  a  v a 2 s.co  m

    // get the parameters
    camera = getArguments().getParcelable(CAMERA);
    fullScreen = getArguments().getBoolean(FULL_SCREEN);

    // create the fade in handler and runnable
    fadeInHandler = new Handler();
    fadeInRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeInName = new AlphaAnimation(0, 1);
            fadeInName.setDuration(FADEIN_ANIMATION_TIME);
            fadeInName.setFillAfter(true);
            Animation fadeInSnapshot = new AlphaAnimation(0, 1);
            fadeInSnapshot.setDuration(FADEIN_ANIMATION_TIME);
            fadeInSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeInName);
            snapshotButton.startAnimation(fadeInSnapshot);
            fadeListener.onStartFadeIn();
        }
    };

    // create the fade out handler and runnable
    fadeOutHandler = new Handler();
    fadeOutRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeOutName = new AlphaAnimation(1, 0);
            fadeOutName.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutName.setFillAfter(true);
            Animation fadeOutSnapshot = new AlphaAnimation(1, 0);
            fadeOutSnapshot.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeOutName);
            snapshotButton.startAnimation(fadeOutSnapshot);
            fadeListener.onStartFadeOut();
        }
    };

    // create the finish handler and runnable
    finishHandler = new Handler();
    finishRunner = new Runnable() {
        @Override
        public void run() {
            getActivity().finish();
        }
    };

    // create the start video handler and runnable
    startVideoHandler = new Handler();
    startVideoRunner = new Runnable() {
        @Override
        public void run() {
            MediaFormat format = decoder.getMediaFormat();
            int videoWidth = format.getInteger(MediaFormat.KEY_WIDTH);
            int videoHeight = format.getInteger(MediaFormat.KEY_HEIGHT);
            textureView.setVideoSize(videoWidth, videoHeight);
        }
    };
}

From source file:com.serenegiant.media.TLMediaEncoder.java

private static final String asString(final MediaFormat format) {
    final JSONObject map = new JSONObject();
    try {//from   w  ww  . ja  va  2  s  .com
        if (format.containsKey(MediaFormat.KEY_MIME))
            map.put(MediaFormat.KEY_MIME, format.getString(MediaFormat.KEY_MIME));
        if (format.containsKey(MediaFormat.KEY_WIDTH))
            map.put(MediaFormat.KEY_WIDTH, format.getInteger(MediaFormat.KEY_WIDTH));
        if (format.containsKey(MediaFormat.KEY_HEIGHT))
            map.put(MediaFormat.KEY_HEIGHT, format.getInteger(MediaFormat.KEY_HEIGHT));
        if (format.containsKey(MediaFormat.KEY_BIT_RATE))
            map.put(MediaFormat.KEY_BIT_RATE, format.getInteger(MediaFormat.KEY_BIT_RATE));
        if (format.containsKey(MediaFormat.KEY_COLOR_FORMAT))
            map.put(MediaFormat.KEY_COLOR_FORMAT, format.getInteger(MediaFormat.KEY_COLOR_FORMAT));
        if (format.containsKey(MediaFormat.KEY_FRAME_RATE))
            map.put(MediaFormat.KEY_FRAME_RATE, format.getInteger(MediaFormat.KEY_FRAME_RATE));
        if (format.containsKey(MediaFormat.KEY_I_FRAME_INTERVAL))
            map.put(MediaFormat.KEY_I_FRAME_INTERVAL, format.getInteger(MediaFormat.KEY_I_FRAME_INTERVAL));
        if (format.containsKey(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER))
            map.put(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER,
                    format.getLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER));
        if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE))
            map.put(MediaFormat.KEY_MAX_INPUT_SIZE, format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE));
        if (format.containsKey(MediaFormat.KEY_DURATION))
            map.put(MediaFormat.KEY_DURATION, format.getInteger(MediaFormat.KEY_DURATION));
        if (format.containsKey(MediaFormat.KEY_CHANNEL_COUNT))
            map.put(MediaFormat.KEY_CHANNEL_COUNT, format.getInteger(MediaFormat.KEY_CHANNEL_COUNT));
        if (format.containsKey(MediaFormat.KEY_SAMPLE_RATE))
            map.put(MediaFormat.KEY_SAMPLE_RATE, format.getInteger(MediaFormat.KEY_SAMPLE_RATE));
        if (format.containsKey(MediaFormat.KEY_CHANNEL_MASK))
            map.put(MediaFormat.KEY_CHANNEL_MASK, format.getInteger(MediaFormat.KEY_CHANNEL_MASK));
        if (format.containsKey(MediaFormat.KEY_AAC_PROFILE))
            map.put(MediaFormat.KEY_AAC_PROFILE, format.getInteger(MediaFormat.KEY_AAC_PROFILE));
        if (format.containsKey(MediaFormat.KEY_AAC_SBR_MODE))
            map.put(MediaFormat.KEY_AAC_SBR_MODE, format.getInteger(MediaFormat.KEY_AAC_SBR_MODE));
        if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE))
            map.put(MediaFormat.KEY_MAX_INPUT_SIZE, format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE));
        if (format.containsKey(MediaFormat.KEY_IS_ADTS))
            map.put(MediaFormat.KEY_IS_ADTS, format.getInteger(MediaFormat.KEY_IS_ADTS));
        if (format.containsKey("what"))
            map.put("what", format.getInteger("what"));
        if (format.containsKey("csd-0"))
            map.put("csd-0", asString(format.getByteBuffer("csd-0")));
        if (format.containsKey("csd-1"))
            map.put("csd-1", asString(format.getByteBuffer("csd-1")));
    } catch (JSONException e) {
        Log.e(TAG_STATIC, "writeFormat:", e);
    }

    return map.toString();
}

From source file:com.serenegiant.media.TLMediaEncoder.java

private static final MediaFormat asMediaFormat(final String format_str) {
    MediaFormat format = new MediaFormat();
    try {//from   ww  w.  j  a  v a2s  .co m
        final JSONObject map = new JSONObject(format_str);
        if (map.has(MediaFormat.KEY_MIME))
            format.setString(MediaFormat.KEY_MIME, (String) map.get(MediaFormat.KEY_MIME));
        if (map.has(MediaFormat.KEY_WIDTH))
            format.setInteger(MediaFormat.KEY_WIDTH, (Integer) map.get(MediaFormat.KEY_WIDTH));
        if (map.has(MediaFormat.KEY_HEIGHT))
            format.setInteger(MediaFormat.KEY_HEIGHT, (Integer) map.get(MediaFormat.KEY_HEIGHT));
        if (map.has(MediaFormat.KEY_BIT_RATE))
            format.setInteger(MediaFormat.KEY_BIT_RATE, (Integer) map.get(MediaFormat.KEY_BIT_RATE));
        if (map.has(MediaFormat.KEY_COLOR_FORMAT))
            format.setInteger(MediaFormat.KEY_COLOR_FORMAT, (Integer) map.get(MediaFormat.KEY_COLOR_FORMAT));
        if (map.has(MediaFormat.KEY_FRAME_RATE))
            format.setInteger(MediaFormat.KEY_FRAME_RATE, (Integer) map.get(MediaFormat.KEY_FRAME_RATE));
        if (map.has(MediaFormat.KEY_I_FRAME_INTERVAL))
            format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL,
                    (Integer) map.get(MediaFormat.KEY_I_FRAME_INTERVAL));
        if (map.has(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER))
            format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER,
                    (Long) map.get(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER));
        if (map.has(MediaFormat.KEY_MAX_INPUT_SIZE))
            format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE,
                    (Integer) map.get(MediaFormat.KEY_MAX_INPUT_SIZE));
        if (map.has(MediaFormat.KEY_DURATION))
            format.setInteger(MediaFormat.KEY_DURATION, (Integer) map.get(MediaFormat.KEY_DURATION));
        if (map.has(MediaFormat.KEY_CHANNEL_COUNT))
            format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, (Integer) map.get(MediaFormat.KEY_CHANNEL_COUNT));
        if (map.has(MediaFormat.KEY_SAMPLE_RATE))
            format.setInteger(MediaFormat.KEY_SAMPLE_RATE, (Integer) map.get(MediaFormat.KEY_SAMPLE_RATE));
        if (map.has(MediaFormat.KEY_CHANNEL_MASK))
            format.setInteger(MediaFormat.KEY_CHANNEL_MASK, (Integer) map.get(MediaFormat.KEY_CHANNEL_MASK));
        if (map.has(MediaFormat.KEY_AAC_PROFILE))
            format.setInteger(MediaFormat.KEY_AAC_PROFILE, (Integer) map.get(MediaFormat.KEY_AAC_PROFILE));
        if (map.has(MediaFormat.KEY_AAC_SBR_MODE))
            format.setInteger(MediaFormat.KEY_AAC_SBR_MODE, (Integer) map.get(MediaFormat.KEY_AAC_SBR_MODE));
        if (map.has(MediaFormat.KEY_MAX_INPUT_SIZE))
            format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE,
                    (Integer) map.get(MediaFormat.KEY_MAX_INPUT_SIZE));
        if (map.has(MediaFormat.KEY_IS_ADTS))
            format.setInteger(MediaFormat.KEY_IS_ADTS, (Integer) map.get(MediaFormat.KEY_IS_ADTS));
        if (map.has("what"))
            format.setInteger("what", (Integer) map.get("what"));
        if (map.has("csd-0"))
            format.setByteBuffer("csd-0", asByteBuffer((String) map.get("csd-0")));
        if (map.has("csd-1"))
            format.setByteBuffer("csd-1", asByteBuffer((String) map.get("csd-1")));
    } catch (JSONException e) {
        Log.e(TAG_STATIC, "writeFormat:" + format_str, e);
        format = null;
    }
    return format;
}

From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java

protected void parseVisualSampleEntry(byte[] data) {
    /*/*from   w  w w. j  a v  a  2  s .co  m*/
     * VisualSampleEntry extends SampleEntry in ISO/IEC 14496 part 12, see
     * section 8.5.2.2 for structure
     */
    mCurrentOffset += data.length;
    // SampleEntry
    // skip 6 for reserved
    // skip 2 for data_reference_index
    // VisualSampleEntry
    // skip 2 for pre_defined
    // skip 2 for reserved
    // skip 12 for pre_defined
    int width = ((data[24] & 0xFF) << 8 | data[25] & 0xFF) & 0x0000FFFF;
    int height = ((data[26] & 0xFF) << 8 | data[27] & 0xFF) & 0x0000FFFF;
    // skip 4 for horizresolution
    // skip 4 for vertresolution
    // skip 4 for reserved
    // skip 2 for frame_count
    // skip 32 for compressorname
    // skip 2 for depth
    // skip 2 for pre_defined
    mCurrentMediaFormat.setInteger(MediaFormat.KEY_WIDTH, width);
    mCurrentTrack.getMetaData().addValue(KEY_WIDTH, width);
    mCurrentMediaFormat.setInteger(MediaFormat.KEY_HEIGHT, height);
    mCurrentTrack.getMetaData().addValue(KEY_HEIGHT, height);
    int maxSize = ((width + 15) / 16) * ((height + 15) / 16) * 192;
    mCurrentMediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, maxSize);
    addMetaDataValue(KEY_WIDTH, width);
    addMetaDataValue(KEY_HEIGHT, height);
}

From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java

@Override
public TrackInfo[] getTrackInfo() {
    int numTracks = mTracks.size();
    TrackInfo[] trackInfos = new TrackInfo[numTracks];

    for (int i = 0; i < numTracks; i++) {
        IsoTrack track = (IsoTrack) mTracks.get(i);
        TrackType trackType = track.getTrackType();
        if (trackType != TrackType.UNKNOWN) {
            MediaFormat mediaFormat = track.getMediaFormat();
            String mimeType = mediaFormat.getString(MediaFormat.KEY_MIME);
            long durationUs = track.getDurationUs();
            String language = track.getLanguage();

            TrackRepresentation representation = null;

            if (trackType == TrackType.AUDIO) {
                int channelCount = mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
                int sampleRate = mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE);
                representation = new AudioTrackRepresentation(-1, channelCount, "", sampleRate);
            } else if (trackType == TrackType.VIDEO) {
                int width = mediaFormat.getInteger(MediaFormat.KEY_WIDTH);
                int height = mediaFormat.getInteger(MediaFormat.KEY_HEIGHT);
                representation = new VideoTrackRepresentation(-1, width, height, -1f);
            } else { // SUBTITLE, UNKNOWN
                representation = new TrackRepresentation(-1);
            }//from   w w  w .j av  a2 s. c  o m

            TrackInfo trackInfo = new TrackInfo(trackType, mimeType, durationUs, language);
            TrackRepresentation[] representations = new TrackRepresentation[1];
            representations[0] = representation;
            trackInfo.setRepresentations(representations);
            trackInfos[i] = trackInfo;
        } else {
            trackInfos[i] = new TrackInfo(TrackType.UNKNOWN, "", 0, "");
        }
    }

    return trackInfos;
}