Loading media/java/android/media/videoeditor/AudioTrack.java +17 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ public class AudioTrack { // The audio waveform filename private String mAudioWaveformFilename; // The audio waveform data private WaveformData mWaveformData; /** * An object of this type cannot be instantiated by using the default Loading Loading @@ -103,6 +105,7 @@ public class AudioTrack { // The audio waveform file is generated later mAudioWaveformFilename = null; mWaveformData = null; } /** Loading Loading @@ -161,6 +164,11 @@ public class AudioTrack { mDuckedTrackVolume = duckedTrackVolume; mAudioWaveformFilename = audioWaveformFilename; if (audioWaveformFilename != null) { mWaveformData = new WaveformData(audioWaveformFilename); } else { mWaveformData = null; } } /** Loading Loading @@ -416,6 +424,7 @@ public class AudioTrack { throws IOException { // TODO: Set mAudioWaveformFilename at the end once the extract is // complete mWaveformData = new WaveformData(mAudioWaveformFilename); } /** Loading @@ -431,10 +440,17 @@ public class AudioTrack { * * @return the name of the file, null if the file does not exist */ public String getAudioWaveformFilename() { String getAudioWaveformFilename() { return mAudioWaveformFilename; } /** * @return The waveform data */ public WaveformData getWaveformData() { return mWaveformData; } /* * {@inheritDoc} */ Loading media/java/android/media/videoeditor/MediaVideoItem.java +16 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class MediaVideoItem extends MediaItem { private int mVolumePercentage; private boolean mMuted; private String mAudioWaveformFilename; // The audio waveform data private WaveformData mWaveformData; /** * An object of this type cannot be instantiated with a default constructor Loading Loading @@ -115,6 +117,11 @@ public class MediaVideoItem extends MediaItem { mVolumePercentage = volumePercent; mMuted = muted; mAudioWaveformFilename = audioWaveformFilename; if (audioWaveformFilename != null) { mWaveformData = new WaveformData(audioWaveformFilename); } else { mWaveformData = null; } } /** Loading Loading @@ -286,6 +293,7 @@ public class MediaVideoItem extends MediaItem { public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener) throws IOException { // TODO: Set mAudioWaveformFilename at the end once the export is complete mWaveformData = new WaveformData(mAudioWaveformFilename); } /** Loading @@ -299,10 +307,17 @@ public class MediaVideoItem extends MediaItem { * @return the name of the file, null if the file has not been computed or * if there is no Audio track in the mediaItem */ public String getAudioWaveformFilename() { String getAudioWaveformFilename() { return mAudioWaveformFilename; } /** * @return The waveform data */ public WaveformData getWaveformData() { return mWaveformData; } /** * Set volume of the Audio track of this mediaItem * Loading media/java/android/media/videoeditor/WaveformData.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * 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; /** * Class which describes the waveform data of an audio track. The gain values * represent the average gain for an audio frame. For audio codecs which do * not operate on a per frame bases (eg. ALAW, ULAW) a reasonable audio frame * duration will be assumed (eg. 50ms). * {@hide} */ public class WaveformData { // Instance variables final int mFrameDurationMs; final int mFramesCount; final short[] mGains; /** * This constructor shall not be used */ @SuppressWarnings("unused") private WaveformData() { mFrameDurationMs = 0; mFramesCount = 0; mGains = null; } /** * Constructor * * @param audioWaveformFilename The name of the audio waveform file */ WaveformData(String audioWaveformFilename) { // TODO: Read these values from the file mFrameDurationMs = 20; mFramesCount = 300000 / mFrameDurationMs; mGains = new short[mFramesCount]; for (int i = 0; i < mFramesCount; i++) { mGains[i] = (short)((i * 5) % 256); } } /** * @return The duration of a frame in milliseconds */ public int getFrameDuration() { return mFrameDurationMs; } /** * @return The number of frames within the waveform data */ public int getFramesCount() { return mFramesCount; } /** * @return The array of frame gains. The size of the array is the frames * count. The values of the frame gains range from 0 to 256. */ public short[] getFrameGains() { return mGains; } } Loading
media/java/android/media/videoeditor/AudioTrack.java +17 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ public class AudioTrack { // The audio waveform filename private String mAudioWaveformFilename; // The audio waveform data private WaveformData mWaveformData; /** * An object of this type cannot be instantiated by using the default Loading Loading @@ -103,6 +105,7 @@ public class AudioTrack { // The audio waveform file is generated later mAudioWaveformFilename = null; mWaveformData = null; } /** Loading Loading @@ -161,6 +164,11 @@ public class AudioTrack { mDuckedTrackVolume = duckedTrackVolume; mAudioWaveformFilename = audioWaveformFilename; if (audioWaveformFilename != null) { mWaveformData = new WaveformData(audioWaveformFilename); } else { mWaveformData = null; } } /** Loading Loading @@ -416,6 +424,7 @@ public class AudioTrack { throws IOException { // TODO: Set mAudioWaveformFilename at the end once the extract is // complete mWaveformData = new WaveformData(mAudioWaveformFilename); } /** Loading @@ -431,10 +440,17 @@ public class AudioTrack { * * @return the name of the file, null if the file does not exist */ public String getAudioWaveformFilename() { String getAudioWaveformFilename() { return mAudioWaveformFilename; } /** * @return The waveform data */ public WaveformData getWaveformData() { return mWaveformData; } /* * {@inheritDoc} */ Loading
media/java/android/media/videoeditor/MediaVideoItem.java +16 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class MediaVideoItem extends MediaItem { private int mVolumePercentage; private boolean mMuted; private String mAudioWaveformFilename; // The audio waveform data private WaveformData mWaveformData; /** * An object of this type cannot be instantiated with a default constructor Loading Loading @@ -115,6 +117,11 @@ public class MediaVideoItem extends MediaItem { mVolumePercentage = volumePercent; mMuted = muted; mAudioWaveformFilename = audioWaveformFilename; if (audioWaveformFilename != null) { mWaveformData = new WaveformData(audioWaveformFilename); } else { mWaveformData = null; } } /** Loading Loading @@ -286,6 +293,7 @@ public class MediaVideoItem extends MediaItem { public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener) throws IOException { // TODO: Set mAudioWaveformFilename at the end once the export is complete mWaveformData = new WaveformData(mAudioWaveformFilename); } /** Loading @@ -299,10 +307,17 @@ public class MediaVideoItem extends MediaItem { * @return the name of the file, null if the file has not been computed or * if there is no Audio track in the mediaItem */ public String getAudioWaveformFilename() { String getAudioWaveformFilename() { return mAudioWaveformFilename; } /** * @return The waveform data */ public WaveformData getWaveformData() { return mWaveformData; } /** * Set volume of the Audio track of this mediaItem * Loading
media/java/android/media/videoeditor/WaveformData.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * 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; /** * Class which describes the waveform data of an audio track. The gain values * represent the average gain for an audio frame. For audio codecs which do * not operate on a per frame bases (eg. ALAW, ULAW) a reasonable audio frame * duration will be assumed (eg. 50ms). * {@hide} */ public class WaveformData { // Instance variables final int mFrameDurationMs; final int mFramesCount; final short[] mGains; /** * This constructor shall not be used */ @SuppressWarnings("unused") private WaveformData() { mFrameDurationMs = 0; mFramesCount = 0; mGains = null; } /** * Constructor * * @param audioWaveformFilename The name of the audio waveform file */ WaveformData(String audioWaveformFilename) { // TODO: Read these values from the file mFrameDurationMs = 20; mFramesCount = 300000 / mFrameDurationMs; mGains = new short[mFramesCount]; for (int i = 0; i < mFramesCount; i++) { mGains[i] = (short)((i * 5) % 256); } } /** * @return The duration of a frame in milliseconds */ public int getFrameDuration() { return mFrameDurationMs; } /** * @return The number of frames within the waveform data */ public int getFramesCount() { return mFramesCount; } /** * @return The array of frame gains. The size of the array is the frames * count. The values of the frame gains range from 0 to 256. */ public short[] getFrameGains() { return mGains; } }