Commit e0e77cb5 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

Remove VideoEditor

remove android.media.videoeditor.*

No longer supported and should not be used.

Bug: 13542518
Change-Id: I12de122443f0289ab1dfdd8b553e572a830cf412
parent 3fafb4eb
This diff is collapsed.
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
/**
* This is the super class for all effects. An effect can only be applied to a
* single media item.
* {@hide}
*/
public abstract class Effect {
/**
* Instance variables
*/
private final String mUniqueId;
/**
* The effect owner
*/
private final MediaItem mMediaItem;
protected long mDurationMs;
/**
* The start time of the effect relative to the beginning
* of the media item
*/
protected long mStartTimeMs;
/**
* Default constructor
*/
@SuppressWarnings("unused")
private Effect() {
mMediaItem = null;
mUniqueId = null;
mStartTimeMs = 0;
mDurationMs = 0;
}
/**
* Constructor
*
* @param mediaItem The media item owner
* @param effectId The effect id
* @param startTimeMs The start time relative to the media item to which it
* is applied
* @param durationMs The effect duration in milliseconds
*/
public Effect(MediaItem mediaItem, String effectId, long startTimeMs,
long durationMs) {
if (mediaItem == null) {
throw new IllegalArgumentException("Media item cannot be null");
}
if ((startTimeMs < 0) || (durationMs < 0)) {
throw new IllegalArgumentException("Invalid start time Or/And Duration");
}
if (startTimeMs + durationMs > mediaItem.getDuration()) {
throw new IllegalArgumentException("Invalid start time and duration");
}
mMediaItem = mediaItem;
mUniqueId = effectId;
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
}
/**
* Get the id of the effect.
*
* @return The id of the effect
*/
public String getId() {
return mUniqueId;
}
/**
* Set the duration of the effect. If a preview or export is in progress,
* then this change is effective for next preview or export session.
*
* @param durationMs of the effect in milliseconds
*/
public void setDuration(long durationMs) {
if (durationMs <0) {
throw new IllegalArgumentException("Invalid duration");
}
if (mStartTimeMs + durationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Duration is too large");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldDurationMs = mDurationMs;
mDurationMs = durationMs;
mMediaItem.invalidateTransitions(mStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Get the duration of the effect
*
* @return The duration of the effect in milliseconds
*/
public long getDuration() {
return mDurationMs;
}
/**
* Set start time of the effect. If a preview or export is in progress, then
* this change is effective for next preview or export session.
*
* @param startTimeMs The start time of the effect relative to the beginning
* of the media item in milliseconds
*/
public void setStartTime(long startTimeMs) {
if (startTimeMs + mDurationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Start time is too large");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldStartTimeMs = mStartTimeMs;
mStartTimeMs = startTimeMs;
mMediaItem.invalidateTransitions(oldStartTimeMs, mDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Get the start time of the effect
*
* @return The start time in milliseconds
*/
public long getStartTime() {
return mStartTimeMs;
}
/**
* Set the start time and duration
*
* @param startTimeMs start time in milliseconds
* @param durationMs The duration in milliseconds
*/
public void setStartTimeAndDuration(long startTimeMs, long durationMs) {
if (startTimeMs + durationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Invalid start time or duration");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldStartTimeMs = mStartTimeMs;
final long oldDurationMs = mDurationMs;
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
mMediaItem.invalidateTransitions(oldStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Get the media item owner.
*
* @return The media item owner
*/
public MediaItem getMediaItem() {
return mMediaItem;
}
/*
* {@inheritDoc}
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof Effect)) {
return false;
}
return mUniqueId.equals(((Effect)object).mUniqueId);
}
/*
* {@inheritDoc}
*/
@Override
public int hashCode() {
return mUniqueId.hashCode();
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
/**
* This class allows to apply color effect on a media item.
* {@hide}
*/
public class EffectColor extends Effect {
/**
* Change the video frame color to the RGB color value provided
*/
public static final int TYPE_COLOR = 1;
/**
* Change the video frame color to a gradation from RGB color (at the top of
* the frame) to black (at the bottom of the frame).
*/
public static final int TYPE_GRADIENT = 2;
/**
* Change the video frame color to sepia
*/
public static final int TYPE_SEPIA = 3;
/**
* Invert the video frame color
*/
public static final int TYPE_NEGATIVE = 4;
/**
* Make the video look like as if it was recorded in 50's
*/
public static final int TYPE_FIFTIES = 5;
/**
* Change the video frame color to the RGB color value GREEN
*/
public static final int GREEN = 0x0000ff00;
/**
* Change the video frame color to the RGB color value PINK
*/
public static final int PINK = 0x00ff66cc;
/**
* Change the video frame color to the RGB color value GRAY
*/
public static final int GRAY = 0x007f7f7f;
/**
* The effect type
*/
private final int mType;
/**
* The effect color
*/
private final int mColor;
/**
* An object of this type cannot be instantiated by using the default
* constructor
*/
@SuppressWarnings("unused")
private EffectColor() {
this(null, null, 0, 0, 0, 0);
}
/**
* Constructor
*
* @param mediaItem The media item owner
* @param effectId The effect id
* @param startTimeMs The start time relative to the media item to which it
* is applied
* @param durationMs The duration of this effect in milliseconds
* @param type type of the effect. type is one of: TYPE_COLOR,
* TYPE_GRADIENT, TYPE_SEPIA, TYPE_NEGATIVE, TYPE_FIFTIES.
* @param color If type is TYPE_COLOR, color is the RGB color as 888.
* If type is TYPE_GRADIENT, color is the RGB color at the
* top of the frame. Otherwise, color is ignored
*/
public EffectColor(MediaItem mediaItem, String effectId, long startTimeMs,
long durationMs, int type, int color) {
super(mediaItem, effectId, startTimeMs, durationMs);
switch (type) {
case TYPE_COLOR:
case TYPE_GRADIENT: {
switch (color) {
case GREEN:
case PINK:
case GRAY:
mColor = color;
break;
default:
throw new IllegalArgumentException("Invalid Color: " + color);
}
break;
}
case TYPE_SEPIA:
case TYPE_NEGATIVE:
case TYPE_FIFTIES: {
mColor = -1;
break;
}
default: {
throw new IllegalArgumentException("Invalid type: " + type);
}
}
mType = type;
}
/**
* Get the effect type.
*
* @return The effect type
*/
public int getType() {
return mType;
}
/**
* Get the color if effect type is TYPE_COLOR or TYPE_GRADIENT.
*
* @return the color as RGB 888 if type is TYPE_COLOR or TYPE_GRADIENT.
*/
public int getColor() {
return mColor;
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
import android.graphics.Rect;
/**
* This class represents a Ken Burns effect.
* {@hide}
*/
public class EffectKenBurns extends Effect {
/**
* Instance variables
*/
private Rect mStartRect;
private Rect mEndRect;
/**
* Objects of this type cannot be instantiated by using the default
* constructor
*/
@SuppressWarnings("unused")
private EffectKenBurns() {
this(null, null, null, null, 0, 0);
}
/**
* Constructor
*
* @param mediaItem The media item owner
* @param effectId The effect id
* @param startRect The start rectangle
* @param endRect The end rectangle
* @param startTimeMs The start time
* @param durationMs The duration of the Ken Burns effect in milliseconds
*/
public EffectKenBurns(MediaItem mediaItem, String effectId, Rect startRect,
Rect endRect, long startTimeMs, long durationMs) {
super(mediaItem, effectId, startTimeMs, durationMs);
if ( (startRect.width() <= 0) || (startRect.height() <= 0) ) {
throw new IllegalArgumentException("Invalid Start rectangle");
}
if ( (endRect.width() <= 0) || (endRect.height() <= 0) ) {
throw new IllegalArgumentException("Invalid End rectangle");
}
mStartRect = startRect;
mEndRect = endRect;
}
/**
* Get the start rectangle.
*
* @return The start rectangle
*/
public Rect getStartRect() {
return mStartRect;
}
/**
* Get the end rectangle.
*
* @return The end rectangle
*/
public Rect getEndRect() {
return mEndRect;
}
/**
* Get the KenBurn effect start and end rectangle coordinates
* @param start The rect object to be populated with start
* rectangle coordinates
*
* @param end The rect object to be populated with end
* rectangle coordinates
*/
void getKenBurnsSettings(Rect start, Rect end) {
start.left = getStartRect().left;
start.top = getStartRect().top;
start.right = getStartRect().right;
start.bottom = getStartRect().bottom;
end.left = getEndRect().left;
end.top = getEndRect().top;
end.right = getEndRect().right;
end.bottom = getEndRect().bottom;
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
/**
* This listener interface is used by
* {@link MediaVideoItem#extractAudioWaveform(ExtractAudioWaveformProgressListener listener)}
* or
* {@link AudioTrack#extractAudioWaveform(ExtractAudioWaveformProgressListener listener)}
* {@hide}
*/
public interface ExtractAudioWaveformProgressListener {
/**
* This method notifies the listener of the progress status of
* an extractAudioWaveform operation.
* This method may be called maximum 100 times for one operation.
*
* @param progress The progress in %. At the beginning of the operation,
* this value is set to 0; at the end, the value is set to 100.
*/
public void onProgress(int progress);
}
This diff is collapsed.
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
import android.media.videoeditor.VideoEditorProfile;
import android.util.Pair;
import java.lang.System;
/**
* This class defines all properties of a media file such as supported height,
* aspect ratio, bitrate for export function.
* {@hide}
*/
public class MediaProperties {
/**
* Supported heights
*/
public static final int HEIGHT_144 = 144;
public static final int HEIGHT_288 = 288;
public static final int HEIGHT_360 = 360;
public static final int HEIGHT_480 = 480;
public static final int HEIGHT_720 = 720;
public static final int HEIGHT_1080 = 1080;
/**
* Supported aspect ratios
*/
public static final int ASPECT_RATIO_UNDEFINED = 0;
public static final int ASPECT_RATIO_3_2 = 1;
public static final int ASPECT_RATIO_16_9 = 2;
public static final int ASPECT_RATIO_4_3 = 3;
public static final int ASPECT_RATIO_5_3 = 4;
public static final int ASPECT_RATIO_11_9 = 5;
/**
* The array of supported aspect ratios
*/
private static final int[] ASPECT_RATIOS = new int[] {
ASPECT_RATIO_3_2,
ASPECT_RATIO_16_9,
ASPECT_RATIO_4_3,
ASPECT_RATIO_5_3,
ASPECT_RATIO_11_9
};
/**
* Supported resolutions for specific aspect ratios
*/
@SuppressWarnings({"unchecked"})
private static final Pair<Integer, Integer>[] ASPECT_RATIO_3_2_RESOLUTIONS =
new Pair[] {
new Pair<Integer, Integer>(720, HEIGHT_480),
new Pair<Integer, Integer>(1080, HEIGHT_720)
};
@SuppressWarnings({"unchecked"})
private static final Pair<Integer, Integer>[] ASPECT_RATIO_4_3_RESOLUTIONS =
new Pair[] {
new Pair<Integer, Integer>(640, HEIGHT_480),
new Pair<Integer, Integer>(960, HEIGHT_720)
};
@SuppressWarnings({"unchecked"})
private static final Pair<Integer, Integer>[] ASPECT_RATIO_5_3_RESOLUTIONS =
new Pair[] {
new Pair<Integer, Integer>(800, HEIGHT_480)
};
@SuppressWarnings({"unchecked"})
private static final Pair<Integer, Integer>[] ASPECT_RATIO_11_9_RESOLUTIONS =
new Pair[] {
new Pair<Integer, Integer>(176, HEIGHT_144),
new Pair<Integer, Integer>(352, HEIGHT_288)
};
@SuppressWarnings({"unchecked"})
private static final Pair<Integer, Integer>[] ASPECT_RATIO_16_9_RESOLUTIONS =
new Pair[] {
new Pair<Integer, Integer>(848, HEIGHT_480),
new Pair<Integer, Integer>(1280, HEIGHT_720),
new Pair<Integer, Integer>(1920, HEIGHT_1080),
};
/**
* Bitrate values (in bits per second)
*/
public static final int BITRATE_28K = 28000;
public static final int BITRATE_40K = 40000;
public static final int BITRATE_64K = 64000;
public static final int BITRATE_96K = 96000;
public static final int BITRATE_128K = 128000;
public static final int BITRATE_192K = 192000;
public static final int BITRATE_256K = 256000;
public static final int BITRATE_384K = 384000;
public static final int BITRATE_512K = 512000;
public static final int BITRATE_800K = 800000;
public static final int BITRATE_2M = 2000000;
public static final int BITRATE_5M = 5000000;
public static final int BITRATE_8M = 8000000;
/**
* The array of supported bitrates
*/
private static final int[] SUPPORTED_BITRATES = new int[] {
BITRATE_28K,
BITRATE_40K,
BITRATE_64K,
BITRATE_96K,
BITRATE_128K,
BITRATE_192K,
BITRATE_256K,
BITRATE_384K,
BITRATE_512K,
BITRATE_800K,
BITRATE_2M,
BITRATE_5M,
BITRATE_8M
};
/**
* Video codec types
*/
public static final int VCODEC_H263 = 1;
public static final int VCODEC_H264 = 2;
public static final int VCODEC_MPEG4 = 3;
/**
* The array of supported video codecs
*/
private static final int[] SUPPORTED_VCODECS = new int[] {
VCODEC_H264,
VCODEC_H263,
VCODEC_MPEG4,
};
/**
* The H264 profile, the values are same as the one in OMX_Video.h
*/
public final class H264Profile {
public static final int H264ProfileBaseline = 0x01; /**< Baseline profile */
public static final int H264ProfileMain = 0x02; /**< Main profile */
public static final int H264ProfileExtended = 0x04; /**< Extended profile */
public static final int H264ProfileHigh = 0x08; /**< High profile */
public static final int H264ProfileHigh10 = 0x10; /**< High 10 profile */
public static final int H264ProfileHigh422 = 0x20; /**< High 4:2:2 profile */
public static final int H264ProfileHigh444 = 0x40; /**< High 4:4:4 profile */
public static final int H264ProfileUnknown = 0x7FFFFFFF;
}
/**
* The H264 level, the values are same as the one in OMX_Video.h
*/
public final class H264Level {
public static final int H264Level1 = 0x01; /**< Level 1 */
public static final int H264Level1b = 0x02; /**< Level 1b */
public static final int H264Level11 = 0x04; /**< Level 1.1 */
public static final int H264Level12 = 0x08; /**< Level 1.2 */
public static final int H264Level13 = 0x10; /**< Level 1.3 */
public static final int H264Level2 = 0x20; /**< Level 2 */
public static final int H264Level21 = 0x40; /**< Level 2.1 */
public static final int H264Level22 = 0x80; /**< Level 2.2 */
public static final int H264Level3 = 0x100; /**< Level 3 */
public static final int H264Level31 = 0x200; /**< Level 3.1 */
public static final int H264Level32 = 0x400; /**< Level 3.2 */
public static final int H264Level4 = 0x800; /**< Level 4 */
public static final int H264Level41 = 0x1000; /**< Level 4.1 */
public static final int H264Level42 = 0x2000; /**< Level 4.2 */
public static final int H264Level5 = 0x4000; /**< Level 5 */
public static final int H264Level51 = 0x8000; /**< Level 5.1 */
public static final int H264LevelUnknown = 0x7FFFFFFF;
}
/**
* The H263 profile, the values are same as the one in OMX_Video.h
*/
public final class H263Profile {
public static final int H263ProfileBaseline = 0x01;
public static final int H263ProfileH320Coding = 0x02;
public static final int H263ProfileBackwardCompatible = 0x04;
public static final int H263ProfileISWV2 = 0x08;
public static final int H263ProfileISWV3 = 0x10;
public static final int H263ProfileHighCompression = 0x20;
public static final int H263ProfileInternet = 0x40;
public static final int H263ProfileInterlace = 0x80;
public static final int H263ProfileHighLatency = 0x100;
public static final int H263ProfileUnknown = 0x7FFFFFFF;
}
/**
* The H263 level, the values are same as the one in OMX_Video.h
*/
public final class H263Level {
public static final int H263Level10 = 0x01;
public static final int H263Level20 = 0x02;
public static final int H263Level30 = 0x04;
public static final int H263Level40 = 0x08;
public static final int H263Level45 = 0x10;
public static final int H263Level50 = 0x20;
public static final int H263Level60 = 0x40;
public static final int H263Level70 = 0x80;
public static final int H263LevelUnknown = 0x7FFFFFFF;
}
/**
* The mpeg4 profile, the values are same as the one in OMX_Video.h
*/
public final class MPEG4Profile {
public static final int MPEG4ProfileSimple = 0x01;
public static final int MPEG4ProfileSimpleScalable = 0x02;
public static final int MPEG4ProfileCore = 0x04;
public static final int MPEG4ProfileMain = 0x08;
public static final int MPEG4ProfileNbit = 0x10;
public static final int MPEG4ProfileScalableTexture = 0x20;
public static final int MPEG4ProfileSimpleFace = 0x40;
public static final int MPEG4ProfileSimpleFBA = 0x80;
public static final int MPEG4ProfileBasicAnimated = 0x100;
public static final int MPEG4ProfileHybrid = 0x200;
public static final int MPEG4ProfileAdvancedRealTime = 0x400;
public static final int MPEG4ProfileCoreScalable = 0x800;
public static final int MPEG4ProfileAdvancedCoding = 0x1000;
public static final int MPEG4ProfileAdvancedCore = 0x2000;
public static final int MPEG4ProfileAdvancedScalable = 0x4000;
public static final int MPEG4ProfileAdvancedSimple = 0x8000;
public static final int MPEG4ProfileUnknown = 0x7FFFFFFF;
}
/**
* The mpeg4 level, the values are same as the one in OMX_Video.h
*/
public final class MPEG4Level {
public static final int MPEG4Level0 = 0x01; /**< Level 0 */
public static final int MPEG4Level0b = 0x02; /**< Level 0b */
public static final int MPEG4Level1 = 0x04; /**< Level 1 */
public static final int MPEG4Level2 = 0x08; /**< Level 2 */
public static final int MPEG4Level3 = 0x10; /**< Level 3 */
public static final int MPEG4Level4 = 0x20; /**< Level 4 */
public static final int MPEG4Level4a = 0x40; /**< Level 4a */
public static final int MPEG4Level5 = 0x80; /**< Level 5 */
public static final int MPEG4LevelUnknown = 0x7FFFFFFF;
}
/**
* Audio codec types
*/
public static final int ACODEC_NO_AUDIO = 0;
public static final int ACODEC_AMRNB = 1;
public static final int ACODEC_AAC_LC = 2;
public static final int ACODEC_AAC_PLUS = 3;
public static final int ACODEC_ENHANCED_AAC_PLUS = 4;
public static final int ACODEC_MP3 = 5;
public static final int ACODEC_EVRC = 6;
// 7 value is used for PCM
public static final int ACODEC_AMRWB = 8;
public static final int ACODEC_OGG = 9;
/**
* The array of supported audio codecs
*/
private static final int[] SUPPORTED_ACODECS = new int[] {
ACODEC_AAC_LC,
ACODEC_AMRNB,
ACODEC_AMRWB
};
/**
* Samples per frame for each audio codec
*/
public static final int SAMPLES_PER_FRAME_AAC = 1024;
public static final int SAMPLES_PER_FRAME_MP3 = 1152;
public static final int SAMPLES_PER_FRAME_AMRNB = 160;
public static final int SAMPLES_PER_FRAME_AMRWB = 320;
public static final int DEFAULT_SAMPLING_FREQUENCY = 32000;
public static final int DEFAULT_CHANNEL_COUNT = 2;
/**
* File format types
*/
public static final int FILE_3GP = 0;
public static final int FILE_MP4 = 1;
public static final int FILE_AMR = 2;
public static final int FILE_MP3 = 3;
// 4 is for PCM
public static final int FILE_JPEG = 5;
// 6 is for BMP
// 7 is for GIF
public static final int FILE_PNG = 8;
// 9 is for ARGB8888
public static final int FILE_M4V = 10;
public static final int FILE_UNSUPPORTED = 255;
/**
* Undefined video codec profiles
*/
public static final int UNDEFINED_VIDEO_PROFILE = 255;
/**
* The array of the supported file formats
*/
private static final int[] SUPPORTED_VIDEO_FILE_FORMATS = new int[] {
FILE_3GP,
FILE_MP4,
FILE_M4V
};
/**
* The maximum count of audio tracks supported
*/
public static final int AUDIO_MAX_TRACK_COUNT = 1;
/** The maximum volume supported (100 means that no amplification is
* supported, i.e. attenuation only)
*/
public static final int AUDIO_MAX_VOLUME_PERCENT = 100;
/**
* This class cannot be instantiated
*/
private MediaProperties() {
}
/**
* @return The array of supported aspect ratios
*/
public static int[] getAllSupportedAspectRatios() {
return ASPECT_RATIOS;
}
/**
* Get the supported resolutions for the specified aspect ratio.
*
* @param aspectRatio The aspect ratio for which the resolutions are
* requested
* @return The array of width and height pairs
*/
public static Pair<Integer, Integer>[] getSupportedResolutions(int aspectRatio) {
final Pair<Integer, Integer>[] resolutions;
switch (aspectRatio) {
case ASPECT_RATIO_3_2: {
resolutions = ASPECT_RATIO_3_2_RESOLUTIONS;
break;
}
case ASPECT_RATIO_4_3: {
resolutions = ASPECT_RATIO_4_3_RESOLUTIONS;
break;
}
case ASPECT_RATIO_5_3: {
resolutions = ASPECT_RATIO_5_3_RESOLUTIONS;
break;
}
case ASPECT_RATIO_11_9: {
resolutions = ASPECT_RATIO_11_9_RESOLUTIONS;
break;
}
case ASPECT_RATIO_16_9: {
resolutions = ASPECT_RATIO_16_9_RESOLUTIONS;
break;
}
default: {
throw new IllegalArgumentException("Unknown aspect ratio: " + aspectRatio);
}
}
/** Check the platform specific maximum export resolution */
VideoEditorProfile veProfile = VideoEditorProfile.get();
if (veProfile == null) {
throw new RuntimeException("Can't get the video editor profile");
}
final int maxWidth = veProfile.maxOutputVideoFrameWidth;
final int maxHeight = veProfile.maxOutputVideoFrameHeight;
Pair<Integer, Integer>[] tmpResolutions = new Pair[resolutions.length];
int numSupportedResolution = 0;
int i = 0;
/** Get supported resolution list */
for (i = 0; i < resolutions.length; i++) {
if ((resolutions[i].first <= maxWidth) &&
(resolutions[i].second <= maxHeight)) {
tmpResolutions[numSupportedResolution] = resolutions[i];
numSupportedResolution++;
}
}
final Pair<Integer, Integer>[] supportedResolutions =
new Pair[numSupportedResolution];
System.arraycopy(tmpResolutions, 0,
supportedResolutions, 0, numSupportedResolution);
return supportedResolutions;
}
/**
* @return The array of supported video codecs
*/
public static int[] getSupportedVideoCodecs() {
return SUPPORTED_VCODECS;
}
/**
* @return The array of supported audio codecs
*/
public static int[] getSupportedAudioCodecs() {
return SUPPORTED_ACODECS;
}
/**
* @return The array of supported file formats
*/
public static int[] getSupportedVideoFileFormat() {
return SUPPORTED_VIDEO_FILE_FORMATS;
}
/**
* @return The array of supported video bitrates
*/
public static int[] getSupportedVideoBitrates() {
return SUPPORTED_BITRATES;
}
/**
* @return The maximum value for the audio volume
*/
public static int getSupportedMaxVolume() {
return MediaProperties.AUDIO_MAX_VOLUME_PERCENT;
}
/**
* @return The maximum number of audio tracks supported
*/
public static int getSupportedAudioTrackCount() {
return MediaProperties.AUDIO_MAX_TRACK_COUNT;
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
import java.util.HashMap;
import java.util.Map;
/**
* This is the super class for all Overlay classes.
* {@hide}
*/
public abstract class Overlay {
/**
* Instance variables
*/
private final String mUniqueId;
/**
* The overlay owner
*/
private final MediaItem mMediaItem;
/**
* user attributes
*/
private final Map<String, String> mUserAttributes;
protected long mStartTimeMs;
protected long mDurationMs;
/**
* Default constructor
*/
@SuppressWarnings("unused")
private Overlay() {
this(null, null, 0, 0);
}
/**
* Constructor
*
* @param mediaItem The media item owner
* @param overlayId The overlay id
* @param startTimeMs The start time relative to the media item start time
* @param durationMs The duration
*
* @throws IllegalArgumentException if the file type is not PNG or the
* startTimeMs and durationMs are incorrect.
*/
public Overlay(MediaItem mediaItem, String overlayId, long startTimeMs,
long durationMs) {
if (mediaItem == null) {
throw new IllegalArgumentException("Media item cannot be null");
}
if ((startTimeMs<0) || (durationMs<0) ) {
throw new IllegalArgumentException("Invalid start time and/OR duration");
}
if (startTimeMs + durationMs > mediaItem.getDuration()) {
throw new IllegalArgumentException("Invalid start time and duration");
}
mMediaItem = mediaItem;
mUniqueId = overlayId;
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
mUserAttributes = new HashMap<String, String>();
}
/**
* Get the overlay ID.
*
* @return The of the overlay
*/
public String getId() {
return mUniqueId;
}
/**
* Get the duration of overlay.
*
* @return The duration of the overlay effect
*/
public long getDuration() {
return mDurationMs;
}
/**
* If a preview or export is in progress, then this change is effective for
* next preview or export session.
*
* @param durationMs The duration in milliseconds
*/
public void setDuration(long durationMs) {
if (durationMs < 0) {
throw new IllegalArgumentException("Invalid duration");
}
if (mStartTimeMs + durationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Duration is too large");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldDurationMs = mDurationMs;
mDurationMs = durationMs;
mMediaItem.invalidateTransitions(mStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Get the start time of overlay.
*
* @return the start time of the overlay
*/
public long getStartTime() {
return mStartTimeMs;
}
/**
* Set the start time for the overlay. If a preview or export is in
* progress, then this change is effective for next preview or export
* session.
*
* @param startTimeMs start time in milliseconds
*/
public void setStartTime(long startTimeMs) {
if (startTimeMs + mDurationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Start time is too large");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldStartTimeMs = mStartTimeMs;
mStartTimeMs = startTimeMs;
mMediaItem.invalidateTransitions(oldStartTimeMs, mDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Set the start time and duration
*
* @param startTimeMs start time in milliseconds
* @param durationMs The duration in milliseconds
*/
public void setStartTimeAndDuration(long startTimeMs, long durationMs) {
if (startTimeMs + durationMs > mMediaItem.getDuration()) {
throw new IllegalArgumentException("Invalid start time or duration");
}
getMediaItem().getNativeContext().setGeneratePreview(true);
final long oldStartTimeMs = mStartTimeMs;
final long oldDurationMs = mDurationMs;
mStartTimeMs = startTimeMs;
mDurationMs = durationMs;
mMediaItem.invalidateTransitions(oldStartTimeMs, oldDurationMs, mStartTimeMs, mDurationMs);
}
/**
* Get the media item owner.
*
* @return The media item owner.
*/
public MediaItem getMediaItem() {
return mMediaItem;
}
/**
* Set a user attribute
*
* @param name The attribute name
* @param value The attribute value
*/
public void setUserAttribute(String name, String value) {
mUserAttributes.put(name, value);
}
/**
* Get the current user attributes set.
*
* @return The user attributes
*/
public Map<String, String> getUserAttributes() {
return mUserAttributes;
}
/*
* {@inheritDoc}
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof Overlay)) {
return false;
}
return mUniqueId.equals(((Overlay)object).mUniqueId);
}
/*
* {@inheritDoc}
*/
@Override
public int hashCode() {
return mUniqueId.hashCode();
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.DataOutputStream;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.util.Pair;
/**
* This class is used to overlay an image on top of a media item.
* {@hide}
*/
public class OverlayFrame extends Overlay {
/**
* Instance variables
*/
private Bitmap mBitmap;
private String mFilename;
private String mBitmapFileName;
private int mOFWidth;
private int mOFHeight;
/**
* resized RGB Image dimensions
*/
private int mResizedRGBWidth;
private int mResizedRGBHeight;
/**
* The resize paint
*/
private static final Paint sResizePaint = new Paint(Paint.FILTER_BITMAP_FLAG);
/**
* An object of this type cannot be instantiated by using the default
* constructor
*/
@SuppressWarnings("unused")
private OverlayFrame() {
this(null, null, (String)null, 0, 0);
}
/**
* Constructor for an OverlayFrame
*
* @param mediaItem The media item owner
* @param overlayId The overlay id
* @param bitmap The bitmap to be used as an overlay. The size of the
* bitmap must equal to the size of the media item to which it is
* added. The bitmap is typically a decoded PNG file.
* @param startTimeMs The overlay start time in milliseconds
* @param durationMs The overlay duration in milliseconds
*
* @throws IllegalArgumentException if the file type is not PNG or the
* startTimeMs and durationMs are incorrect.
*/
public OverlayFrame(MediaItem mediaItem, String overlayId, Bitmap bitmap,
long startTimeMs,long durationMs) {
super(mediaItem, overlayId, startTimeMs, durationMs);
mBitmap = bitmap;
mFilename = null;
mBitmapFileName = null;
mResizedRGBWidth = 0;
mResizedRGBHeight = 0;
}
/**
* Constructor for an OverlayFrame. This constructor can be used to
* restore the overlay after it was saved internally by the video editor.
*
* @param mediaItem The media item owner
* @param overlayId The overlay id
* @param filename The file name that contains the overlay.
* @param startTimeMs The overlay start time in milliseconds
* @param durationMs The overlay duration in milliseconds
*
* @throws IllegalArgumentException if the file type is not PNG or the
* startTimeMs and durationMs are incorrect.
*/
OverlayFrame(MediaItem mediaItem, String overlayId, String filename,
long startTimeMs,long durationMs) {
super(mediaItem, overlayId, startTimeMs, durationMs);
mBitmapFileName = filename;
mBitmap = BitmapFactory.decodeFile(mBitmapFileName);
mFilename = null;
mResizedRGBWidth = 0;
mResizedRGBHeight = 0;
}
/**
* Get the overlay bitmap.
*
* @return Get the overlay bitmap
*/
public Bitmap getBitmap() {
return mBitmap;
}
/**
* Get the overlay bitmap.
*
* @return Get the overlay bitmap as png file.
*/
String getBitmapImageFileName() {
return mBitmapFileName;
}
/**
* Set the overlay bitmap.
*
* @param bitmap The overlay bitmap.
*/
public void setBitmap(Bitmap bitmap) {
getMediaItem().getNativeContext().setGeneratePreview(true);
invalidate();
mBitmap = bitmap;
if (mFilename != null) {
/**
* Delete the file
*/
new File(mFilename).delete();
/**
* Invalidate the filename
*/
mFilename = null;
}
/**
* Invalidate the transitions if necessary
*/
getMediaItem().invalidateTransitions(mStartTimeMs, mDurationMs);
}
/**
* Get the file name of this overlay
*/
String getFilename() {
return mFilename;
}
/*
* Set the file name of this overlay
*/
void setFilename(String filename) {
mFilename = filename;
}
/**
* Save the overlay to the project folder
*
* @param path The path where the overlay will be saved
*
* @return The filename
* @throws FileNotFoundException if the bitmap cannot be saved
* @throws IOException if the bitmap file cannot be saved
*/
String save(String path) throws FileNotFoundException, IOException {
if (mFilename != null) {
return mFilename;
}
// Create the compressed PNG file
mBitmapFileName = path + "/" + "Overlay" + getId() + ".png";
if (!(new File(mBitmapFileName).exists())) {
final FileOutputStream out = new FileOutputStream (mBitmapFileName);
mBitmap.compress(CompressFormat.PNG, 100, out);
out.flush();
out.close();
}
mOFWidth = mBitmap.getWidth();
mOFHeight = mBitmap.getHeight();
mFilename = path + "/" + "Overlay" + getId() + ".rgb";
/* resize and save rgb as per project aspect ratio */
MediaArtistNativeHelper nativeHelper = (super.getMediaItem()).getNativeContext();
/* get height and width for story board aspect ratio */
final Pair<Integer, Integer> maxResolution;
final Pair<Integer, Integer>[] resolutions;
resolutions = MediaProperties.getSupportedResolutions(nativeHelper.nativeHelperGetAspectRatio());
// Get the highest resolution
maxResolution = resolutions[resolutions.length - 1];
/* Generate the rgb file with rendering mode */
generateOverlayWithRenderingMode (super.getMediaItem(), this,
maxResolution.second /* max Height */ ,
maxResolution.first /* max Width */);
return mFilename;
}
/**
* Get the OverlayFrame Height
*/
int getOverlayFrameHeight() {
return mOFHeight;
}
/**
* Get the OverlayFrame Width
*/
int getOverlayFrameWidth() {
return mOFWidth;
}
/*
* Set the OverlayFrame Height
*/
void setOverlayFrameHeight(int height) {
mOFHeight = height;
}
/*
* Set the OverlayFrame Width
*/
void setOverlayFrameWidth(int width) {
mOFWidth = width;
}
/*
* Set the resized RGB widht and height
*/
void setResizedRGBSize(int width, int height) {
mResizedRGBWidth = width;
mResizedRGBHeight = height;
}
/*
* Get the resized RGB Height
*/
int getResizedRGBSizeHeight() {
return mResizedRGBHeight;
}
/*
* Get the resized RGB Width
*/
int getResizedRGBSizeWidth() {
return mResizedRGBWidth;
}
/**
* Delete the overlay files
*/
void invalidate() {
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
if (mFilename != null) {
new File(mFilename).delete();
mFilename = null;
}
if (mBitmapFileName != null) {
new File(mBitmapFileName).delete();
mBitmapFileName = null;
}
}
/**
* Delete the overlay related files
*/
void invalidateGeneratedFiles() {
if (mFilename != null) {
new File(mFilename).delete();
mFilename = null;
}
if (mBitmapFileName != null) {
new File(mBitmapFileName).delete();
mBitmapFileName = null;
}
}
void generateOverlayWithRenderingMode (MediaItem mediaItemsList, OverlayFrame overlay, int height , int width)
throws FileNotFoundException, IOException {
final MediaItem t = mediaItemsList;
/* get the rendering mode */
int renderMode = t.getRenderingMode();
Bitmap overlayBitmap = ((OverlayFrame)overlay).getBitmap();
/*
* Check if the resize of Overlay is needed with rendering mode applied
* because of change in export dimensions
*/
int resizedRGBFileHeight = ((OverlayFrame)overlay).getResizedRGBSizeHeight();
int resizedRGBFileWidth = ((OverlayFrame)overlay).getResizedRGBSizeWidth();
/* Get original bitmap width if it is not resized */
if(resizedRGBFileWidth == 0) {
resizedRGBFileWidth = overlayBitmap.getWidth();
}
/* Get original bitmap height if it is not resized */
if(resizedRGBFileHeight == 0) {
resizedRGBFileHeight = overlayBitmap.getHeight();
}
if (resizedRGBFileWidth != width || resizedRGBFileHeight != height
|| (!(new File(((OverlayFrame)overlay).getFilename()).exists()))) {
/*
* Create the canvas bitmap
*/
final Bitmap destBitmap = Bitmap.createBitmap((int)width,
(int)height,
Bitmap.Config.ARGB_8888);
final Canvas overlayCanvas = new Canvas(destBitmap);
final Rect destRect;
final Rect srcRect;
switch (renderMode) {
case MediaItem.RENDERING_MODE_STRETCH: {
destRect = new Rect(0, 0, overlayCanvas.getWidth(),
overlayCanvas.getHeight());
srcRect = new Rect(0, 0, overlayBitmap.getWidth(),
overlayBitmap.getHeight());
break;
}
case MediaItem.RENDERING_MODE_BLACK_BORDER: {
int left, right, top, bottom;
float aROverlayImage, aRCanvas;
aROverlayImage = (float)(overlayBitmap.getWidth()) /
(float)(overlayBitmap.getHeight());
aRCanvas = (float)(overlayCanvas.getWidth()) /
(float)(overlayCanvas.getHeight());
if (aROverlayImage > aRCanvas) {
int newHeight = ((overlayCanvas.getWidth() * overlayBitmap.getHeight())
/ overlayBitmap.getWidth());
left = 0;
top = (overlayCanvas.getHeight() - newHeight) / 2;
right = overlayCanvas.getWidth();
bottom = top + newHeight;
} else {
int newWidth = ((overlayCanvas.getHeight() * overlayBitmap.getWidth())
/ overlayBitmap.getHeight());
left = (overlayCanvas.getWidth() - newWidth) / 2;
top = 0;
right = left + newWidth;
bottom = overlayCanvas.getHeight();
}
destRect = new Rect(left, top, right, bottom);
srcRect = new Rect(0, 0, overlayBitmap.getWidth(), overlayBitmap.getHeight());
break;
}
case MediaItem.RENDERING_MODE_CROPPING: {
// Calculate the source rect
int left, right, top, bottom;
float aROverlayImage, aRCanvas;
aROverlayImage = (float)(overlayBitmap.getWidth()) /
(float)(overlayBitmap.getHeight());
aRCanvas = (float)(overlayCanvas.getWidth()) /
(float)(overlayCanvas.getHeight());
if (aROverlayImage < aRCanvas) {
int newHeight = ((overlayBitmap.getWidth() * overlayCanvas.getHeight())
/ overlayCanvas.getWidth());
left = 0;
top = (overlayBitmap.getHeight() - newHeight) / 2;
right = overlayBitmap.getWidth();
bottom = top + newHeight;
} else {
int newWidth = ((overlayBitmap.getHeight() * overlayCanvas.getWidth())
/ overlayCanvas.getHeight());
left = (overlayBitmap.getWidth() - newWidth) / 2;
top = 0;
right = left + newWidth;
bottom = overlayBitmap.getHeight();
}
srcRect = new Rect(left, top, right, bottom);
destRect = new Rect(0, 0, overlayCanvas.getWidth(), overlayCanvas.getHeight());
break;
}
default: {
throw new IllegalStateException("Rendering mode: " + renderMode);
}
}
overlayCanvas.drawBitmap(overlayBitmap, srcRect, destRect, sResizePaint);
overlayCanvas.setBitmap(null);
/*
* Write to the dest file
*/
String outFileName = ((OverlayFrame)overlay).getFilename();
/*
* Save the image to same rgb file
*/
if (outFileName != null) {
new File(outFileName).delete();
}
final FileOutputStream fl = new FileOutputStream(outFileName);
final DataOutputStream dos = new DataOutputStream(fl);
/*
* Populate the rgb file with bitmap data
*/
final int [] framingBuffer = new int[width];
ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4);
IntBuffer intBuffer;
byte[] array = byteBuffer.array();
int tmp = 0;
while(tmp < height) {
destBitmap.getPixels(framingBuffer,0,width,0,tmp,width,1);
intBuffer = byteBuffer.asIntBuffer();
intBuffer.put(framingBuffer,0,width);
dos.write(array);
tmp += 1;
}
fl.flush();
fl.close();
/*
* Set the resized RGB width and height
*/
((OverlayFrame)overlay).setResizedRGBSize(width, height);
}
}
}
This diff is collapsed.
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
/**
* This class allows to render a crossfade (dissolve) effect transition between
* two videos
* {@hide}
*/
public class TransitionCrossfade extends Transition {
/**
* An object of this type cannot be instantiated by using the default
* constructor
*/
@SuppressWarnings("unused")
private TransitionCrossfade() {
this(null, null, null, 0, 0);
}
/**
* Constructor
*
* @param transitionId The transition id
* @param afterMediaItem The transition is applied to the end of this
* media item
* @param beforeMediaItem The transition is applied to the beginning of
* this media item
* @param durationMs duration of the transition in milliseconds
* @param behavior behavior is one of the behavior defined in Transition
* class
*
* @throws IllegalArgumentException if behavior is not supported.
*/
public TransitionCrossfade(String transitionId, MediaItem afterMediaItem,
MediaItem beforeMediaItem, long durationMs, int behavior) {
super(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior);
}
/*
* {@inheritDoc}
*/
@Override
void generate() {
super.generate();
}
}
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.media.videoeditor;
/**
* This class is used to render a fade to black and fade from black transition
* between two media items.
* {@hide}
*/
public class TransitionFadeBlack extends Transition {
/**
* An object of this type cannot be instantiated by using the default
* constructor
*/
@SuppressWarnings("unused")
private TransitionFadeBlack() {
this(null, null, null, 0, 0);
}
/**
* Constructor
*
* @param transitionId The transition id
* @param afterMediaItem The transition is applied to the end of this
* media item
* @param beforeMediaItem The transition is applied to the beginning of
* this media item
* @param durationMs duration of the transition
* @param behavior behavior is one of the behavior defined in Transition
* class
*
* @throws IllegalArgumentException if behavior is not supported.
*/
public TransitionFadeBlack(String transitionId, MediaItem afterMediaItem,
MediaItem beforeMediaItem, long durationMs, int behavior) {
super(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior);
}
/*
* {@inheritDoc}
*/
@Override
void generate() {
super.generate();
}
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment