Effect.java revision fdacc8be92cd36f712cfdb0fcf9b0e847f8eeb58
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.media.videoeditor; 18 19/** 20 * This is the super class for all effects. An effect can only be applied to a 21 * single media item. If one wants to apply the same effect to multiple media 22 * items, multiple @{MediaItem.addEffect(Effect)} call must be invoked on each 23 * of the MediaItem objects. 24 * {@hide} 25 */ 26public abstract class Effect { 27 // Instance variables 28 private final String mUniqueId; 29 protected long mDurationMs; 30 // The start time of the effect relative to the media item timeline 31 protected long mStartTimeMs; 32 33 /** 34 * Default constructor 35 */ 36 @SuppressWarnings("unused") 37 private Effect() { 38 mUniqueId = null; 39 mStartTimeMs = 0; 40 mDurationMs = 0; 41 } 42 43 /** 44 * Constructor 45 * 46 * @param effectId The effect id 47 * @param startTimeMs The start time relative to the media item to which it 48 * is applied 49 * @param durationMs The effect duration in milliseconds 50 */ 51 public Effect(String effectId, long startTimeMs, long durationMs) { 52 mUniqueId = effectId; 53 mStartTimeMs = startTimeMs; 54 mDurationMs = durationMs; 55 } 56 57 /** 58 * @return The id of the effect 59 */ 60 public String getId() { 61 return mUniqueId; 62 } 63 64 /** 65 * Set the duration of the effect. If a preview or export is in progress, 66 * then this change is effective for next preview or export session. s 67 * 68 * @param durationMs of the effect in milliseconds 69 */ 70 public void setDuration(long durationMs) { 71 mDurationMs = durationMs; 72 } 73 74 /** 75 * Get the duration of the effect 76 * 77 * @return The duration of the effect in milliseconds 78 */ 79 public long getDuration() { 80 return mDurationMs; 81 } 82 83 /** 84 * Set start time of the effect. If a preview or export is in progress, then 85 * this change is effective for next preview or export session. 86 * 87 * @param startTimeMs The start time of the effect relative to the begining 88 * of the media item in milliseconds 89 */ 90 public void setStartTime(long startTimeMs) { 91 mStartTimeMs = startTimeMs; 92 } 93 94 /** 95 * @return The start time in milliseconds 96 */ 97 public long getStartTime() { 98 return mStartTimeMs; 99 } 100 101 /* 102 * {@inheritDoc} 103 */ 104 @Override 105 public boolean equals(Object object) { 106 if (!(object instanceof Effect)) { 107 return false; 108 } 109 return mUniqueId.equals(((Effect)object).mUniqueId); 110 } 111 112 /* 113 * {@inheritDoc} 114 */ 115 @Override 116 public int hashCode() { 117 return mUniqueId.hashCode(); 118 } 119} 120