Loading media/java/android/media/videoeditor/AudioTrack.java +45 −1 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ public class AudioTrack { /** * Constructor * @param audioTrackId The AudioTrack id * @param audioTrackId The audio track id * @param filename The absolute file name * * @throws IOException if file is not found Loading Loading @@ -226,6 +226,50 @@ public class AudioTrack { mAudioWaveformFilename = null; } /** * Constructor * * @param audioTrackId The audio track id * @param filename The audio filename * @param startTimeMs the start time in milliseconds (relative to the * timeline) * @param beginMs start time in the audio track in milliseconds (relative to * the beginning of the audio track) * @param endMs end time in the audio track in milliseconds (relative to the * beginning of the audio track) * @param loop true to loop the audio track * @param volume The volume in percentage * @param audioWaveformFilename The name of the waveform file * * @throws IOException if file is not found */ AudioTrack(String audioTrackId, String filename, long startTimeMs, long beginMs, long endMs, boolean loop, int volume, String audioWaveformFilename) throws IOException { mUniqueId = audioTrackId; mFilename = filename; mStartTimeMs = startTimeMs; // TODO: This value represents to the duration of the audio file mDurationMs = 300000; // TODO: This value needs to be read from the audio track of the source // file mAudioChannels = 2; mAudioType = MediaProperties.ACODEC_AAC_LC; mAudioBitrate = 128000; mAudioSamplingFrequency = 44100; mTimelineDurationMs = endMs - beginMs; mVolumePercent = volume; mBeginBoundaryTimeMs = beginMs; mEndBoundaryTimeMs = endMs; mLoop = loop; mAudioWaveformFilename = audioWaveformFilename; } /** * @return The id of the audio track */ Loading media/java/android/media/videoeditor/MediaVideoItem.java +1 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.List; import android.graphics.Bitmap; import android.media.MediaRecorder; import android.util.Log; import android.view.SurfaceHolder; Loading Loading @@ -228,7 +227,7 @@ public class MediaVideoItem extends MediaItem { mHeight = 720; mAspectRatio = MediaProperties.ASPECT_RATIO_3_2; mFileType = MediaProperties.FILE_MP4; mVideoType = MediaRecorder.VideoEncoder.H264; mVideoType = MediaProperties.VCODEC_H264BP; // Do we have predefined values for this variable? mVideoProfile = 0; // Can video and audio duration be different? Loading media/java/android/media/videoeditor/VideoEditorFactory.java +16 −6 Original line number Diff line number Diff line Loading @@ -66,11 +66,11 @@ public class VideoEditorFactory { } } Class<?> cls = Class.forName(className); Class<?> partypes[] = new Class[1]; final Class<?> cls = Class.forName(className); final Class<?> partypes[] = new Class[1]; partypes[0] = String.class; Constructor<?> ct = cls.getConstructor(partypes); Object arglist[] = new Object[1]; final Constructor<?> ct = cls.getConstructor(partypes); final Object arglist[] = new Object[1]; arglist[0] = projectPath; return (VideoEditor)ct.newInstance(arglist); Loading @@ -84,6 +84,7 @@ public class VideoEditorFactory { * @param projectPath The path where all VideoEditor internal files * are stored. When a project is deleted the application is * responsible for deleting the path and its contents. * @param className The implementation class name * @param generatePreview if set to true the * {@link MediaEditor#generatePreview()} will be called internally to * generate any needed transitions. Loading @@ -96,8 +97,17 @@ public class VideoEditorFactory { * @throws IllegalStateException if a previous VideoEditor instance has not * been released */ public static VideoEditor load(String projectPath, boolean generatePreview) throws IOException { final VideoEditorTestImpl videoEditor = new VideoEditorTestImpl(projectPath); public static VideoEditor load(String projectPath, String className, boolean generatePreview) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException { final Class<?> cls = Class.forName(className); final Class<?> partypes[] = new Class[1]; partypes[0] = String.class; final Constructor<?> ct = cls.getConstructor(partypes); final Object arglist[] = new Object[1]; arglist[0] = projectPath; final VideoEditor videoEditor = (VideoEditor)ct.newInstance(arglist); if (generatePreview) { videoEditor.generatePreview(); } Loading media/java/android/media/videoeditor/VideoEditorTestImpl.java +55 −1 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String TAG_OVERLAY_USER_ATTRIBUTES = "overlay_user_attributes"; private static final String TAG_EFFECTS = "effects"; private static final String TAG_EFFECT = "effect"; private static final String TAG_AUDIO_TRACKS = "audio_tracks"; private static final String TAG_AUDIO_TRACK = "audio_track"; private static final String ATTR_ID = "id"; private static final String ATTR_FILENAME = "filename"; Loading @@ -65,7 +67,8 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String ATTR_ASPECT_RATIO = "aspect_ratio"; private static final String ATTR_TYPE = "type"; private static final String ATTR_DURATION = "duration"; private static final String ATTR_BEGIN_TIME = "start_time"; private static final String ATTR_START_TIME = "start_time"; private static final String ATTR_BEGIN_TIME = "begin_time"; private static final String ATTR_END_TIME = "end_time"; private static final String ATTR_VOLUME = "volume"; private static final String ATTR_BEHAVIOR = "behavior"; Loading @@ -85,6 +88,7 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String ATTR_END_RECT_T = "end_t"; private static final String ATTR_END_RECT_R = "end_r"; private static final String ATTR_END_RECT_B = "end_b"; private static final String ATTR_LOOP = "loop"; // Instance variables private long mDurationMs; Loading Loading @@ -700,6 +704,25 @@ public class VideoEditorTestImpl implements VideoEditor { } serializer.endTag("", TAG_TRANSITIONS); serializer.startTag("", TAG_AUDIO_TRACKS); for (AudioTrack at : mAudioTracks) { serializer.startTag("", TAG_AUDIO_TRACK); serializer.attribute("", ATTR_ID, at.getId()); serializer.attribute("", ATTR_FILENAME, at.getFilename()); serializer.attribute("", ATTR_START_TIME, Long.toString(at.getStartTime())); serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(at.getBoundaryBeginTime())); serializer.attribute("", ATTR_END_TIME, Long.toString(at.getBoundaryEndTime())); serializer.attribute("", ATTR_VOLUME, Integer.toString(at.getVolume())); serializer.attribute("", ATTR_LOOP, Boolean.toString(at.isLooping())); if (at.getAudioWaveformFilename() != null) { serializer.attribute("", ATTR_AUDIO_WAVEFORM_FILENAME, at.getAudioWaveformFilename()); } serializer.endTag("", TAG_AUDIO_TRACK); } serializer.endTag("", TAG_AUDIO_TRACKS); serializer.endTag("", TAG_PROJECT); serializer.endDocument(); Loading Loading @@ -792,6 +815,11 @@ public class VideoEditorTestImpl implements VideoEditor { currentMediaItem.addEffect(effect); } } } else if (TAG_AUDIO_TRACK.equals(name)) { final AudioTrack audioTrack = parseAudioTrack(parser); if (audioTrack != null) { addAudioTrack(audioTrack); } } break; } Loading Loading @@ -959,6 +987,32 @@ public class VideoEditorTestImpl implements VideoEditor { return effect; } /** * Parse the audio track * * @param parser The parser * * @return The audio track */ private AudioTrack parseAudioTrack(XmlPullParser parser) { final String audioTrackId = parser.getAttributeValue("", ATTR_ID); final String filename = parser.getAttributeValue("", ATTR_FILENAME); final long startTimeMs = Long.parseLong(parser.getAttributeValue("", ATTR_START_TIME)); final long beginMs = Long.parseLong(parser.getAttributeValue("", ATTR_BEGIN_TIME)); final long endMs = Long.parseLong(parser.getAttributeValue("", ATTR_END_TIME)); final int volume = Integer.parseInt(parser.getAttributeValue("", ATTR_VOLUME)); final boolean loop = Boolean.parseBoolean(parser.getAttributeValue("", ATTR_LOOP)); final String waveformFilename = parser.getAttributeValue("", ATTR_AUDIO_WAVEFORM_FILENAME); try { final AudioTrack audioTrack = new AudioTrack(audioTrackId, filename, startTimeMs, beginMs, endMs, loop, volume, waveformFilename); return audioTrack; } catch (IOException ex) { return null; } } public void cancelExport(String filename) { } Loading Loading
media/java/android/media/videoeditor/AudioTrack.java +45 −1 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ public class AudioTrack { /** * Constructor * @param audioTrackId The AudioTrack id * @param audioTrackId The audio track id * @param filename The absolute file name * * @throws IOException if file is not found Loading Loading @@ -226,6 +226,50 @@ public class AudioTrack { mAudioWaveformFilename = null; } /** * Constructor * * @param audioTrackId The audio track id * @param filename The audio filename * @param startTimeMs the start time in milliseconds (relative to the * timeline) * @param beginMs start time in the audio track in milliseconds (relative to * the beginning of the audio track) * @param endMs end time in the audio track in milliseconds (relative to the * beginning of the audio track) * @param loop true to loop the audio track * @param volume The volume in percentage * @param audioWaveformFilename The name of the waveform file * * @throws IOException if file is not found */ AudioTrack(String audioTrackId, String filename, long startTimeMs, long beginMs, long endMs, boolean loop, int volume, String audioWaveformFilename) throws IOException { mUniqueId = audioTrackId; mFilename = filename; mStartTimeMs = startTimeMs; // TODO: This value represents to the duration of the audio file mDurationMs = 300000; // TODO: This value needs to be read from the audio track of the source // file mAudioChannels = 2; mAudioType = MediaProperties.ACODEC_AAC_LC; mAudioBitrate = 128000; mAudioSamplingFrequency = 44100; mTimelineDurationMs = endMs - beginMs; mVolumePercent = volume; mBeginBoundaryTimeMs = beginMs; mEndBoundaryTimeMs = endMs; mLoop = loop; mAudioWaveformFilename = audioWaveformFilename; } /** * @return The id of the audio track */ Loading
media/java/android/media/videoeditor/MediaVideoItem.java +1 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.List; import android.graphics.Bitmap; import android.media.MediaRecorder; import android.util.Log; import android.view.SurfaceHolder; Loading Loading @@ -228,7 +227,7 @@ public class MediaVideoItem extends MediaItem { mHeight = 720; mAspectRatio = MediaProperties.ASPECT_RATIO_3_2; mFileType = MediaProperties.FILE_MP4; mVideoType = MediaRecorder.VideoEncoder.H264; mVideoType = MediaProperties.VCODEC_H264BP; // Do we have predefined values for this variable? mVideoProfile = 0; // Can video and audio duration be different? Loading
media/java/android/media/videoeditor/VideoEditorFactory.java +16 −6 Original line number Diff line number Diff line Loading @@ -66,11 +66,11 @@ public class VideoEditorFactory { } } Class<?> cls = Class.forName(className); Class<?> partypes[] = new Class[1]; final Class<?> cls = Class.forName(className); final Class<?> partypes[] = new Class[1]; partypes[0] = String.class; Constructor<?> ct = cls.getConstructor(partypes); Object arglist[] = new Object[1]; final Constructor<?> ct = cls.getConstructor(partypes); final Object arglist[] = new Object[1]; arglist[0] = projectPath; return (VideoEditor)ct.newInstance(arglist); Loading @@ -84,6 +84,7 @@ public class VideoEditorFactory { * @param projectPath The path where all VideoEditor internal files * are stored. When a project is deleted the application is * responsible for deleting the path and its contents. * @param className The implementation class name * @param generatePreview if set to true the * {@link MediaEditor#generatePreview()} will be called internally to * generate any needed transitions. Loading @@ -96,8 +97,17 @@ public class VideoEditorFactory { * @throws IllegalStateException if a previous VideoEditor instance has not * been released */ public static VideoEditor load(String projectPath, boolean generatePreview) throws IOException { final VideoEditorTestImpl videoEditor = new VideoEditorTestImpl(projectPath); public static VideoEditor load(String projectPath, String className, boolean generatePreview) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException { final Class<?> cls = Class.forName(className); final Class<?> partypes[] = new Class[1]; partypes[0] = String.class; final Constructor<?> ct = cls.getConstructor(partypes); final Object arglist[] = new Object[1]; arglist[0] = projectPath; final VideoEditor videoEditor = (VideoEditor)ct.newInstance(arglist); if (generatePreview) { videoEditor.generatePreview(); } Loading
media/java/android/media/videoeditor/VideoEditorTestImpl.java +55 −1 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String TAG_OVERLAY_USER_ATTRIBUTES = "overlay_user_attributes"; private static final String TAG_EFFECTS = "effects"; private static final String TAG_EFFECT = "effect"; private static final String TAG_AUDIO_TRACKS = "audio_tracks"; private static final String TAG_AUDIO_TRACK = "audio_track"; private static final String ATTR_ID = "id"; private static final String ATTR_FILENAME = "filename"; Loading @@ -65,7 +67,8 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String ATTR_ASPECT_RATIO = "aspect_ratio"; private static final String ATTR_TYPE = "type"; private static final String ATTR_DURATION = "duration"; private static final String ATTR_BEGIN_TIME = "start_time"; private static final String ATTR_START_TIME = "start_time"; private static final String ATTR_BEGIN_TIME = "begin_time"; private static final String ATTR_END_TIME = "end_time"; private static final String ATTR_VOLUME = "volume"; private static final String ATTR_BEHAVIOR = "behavior"; Loading @@ -85,6 +88,7 @@ public class VideoEditorTestImpl implements VideoEditor { private static final String ATTR_END_RECT_T = "end_t"; private static final String ATTR_END_RECT_R = "end_r"; private static final String ATTR_END_RECT_B = "end_b"; private static final String ATTR_LOOP = "loop"; // Instance variables private long mDurationMs; Loading Loading @@ -700,6 +704,25 @@ public class VideoEditorTestImpl implements VideoEditor { } serializer.endTag("", TAG_TRANSITIONS); serializer.startTag("", TAG_AUDIO_TRACKS); for (AudioTrack at : mAudioTracks) { serializer.startTag("", TAG_AUDIO_TRACK); serializer.attribute("", ATTR_ID, at.getId()); serializer.attribute("", ATTR_FILENAME, at.getFilename()); serializer.attribute("", ATTR_START_TIME, Long.toString(at.getStartTime())); serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(at.getBoundaryBeginTime())); serializer.attribute("", ATTR_END_TIME, Long.toString(at.getBoundaryEndTime())); serializer.attribute("", ATTR_VOLUME, Integer.toString(at.getVolume())); serializer.attribute("", ATTR_LOOP, Boolean.toString(at.isLooping())); if (at.getAudioWaveformFilename() != null) { serializer.attribute("", ATTR_AUDIO_WAVEFORM_FILENAME, at.getAudioWaveformFilename()); } serializer.endTag("", TAG_AUDIO_TRACK); } serializer.endTag("", TAG_AUDIO_TRACKS); serializer.endTag("", TAG_PROJECT); serializer.endDocument(); Loading Loading @@ -792,6 +815,11 @@ public class VideoEditorTestImpl implements VideoEditor { currentMediaItem.addEffect(effect); } } } else if (TAG_AUDIO_TRACK.equals(name)) { final AudioTrack audioTrack = parseAudioTrack(parser); if (audioTrack != null) { addAudioTrack(audioTrack); } } break; } Loading Loading @@ -959,6 +987,32 @@ public class VideoEditorTestImpl implements VideoEditor { return effect; } /** * Parse the audio track * * @param parser The parser * * @return The audio track */ private AudioTrack parseAudioTrack(XmlPullParser parser) { final String audioTrackId = parser.getAttributeValue("", ATTR_ID); final String filename = parser.getAttributeValue("", ATTR_FILENAME); final long startTimeMs = Long.parseLong(parser.getAttributeValue("", ATTR_START_TIME)); final long beginMs = Long.parseLong(parser.getAttributeValue("", ATTR_BEGIN_TIME)); final long endMs = Long.parseLong(parser.getAttributeValue("", ATTR_END_TIME)); final int volume = Integer.parseInt(parser.getAttributeValue("", ATTR_VOLUME)); final boolean loop = Boolean.parseBoolean(parser.getAttributeValue("", ATTR_LOOP)); final String waveformFilename = parser.getAttributeValue("", ATTR_AUDIO_WAVEFORM_FILENAME); try { final AudioTrack audioTrack = new AudioTrack(audioTrackId, filename, startTimeMs, beginMs, endMs, loop, volume, waveformFilename); return audioTrack; } catch (IOException ex) { return null; } } public void cancelExport(String filename) { } Loading