001/*******************************************************************************
002 * Copyright (c) 2024, 2026, Olivier Ayache.  All rights reserved.
003 *
004 * This file is part of AVPKit.
005 *
006 * AVPKit is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Lesser General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * AVPKit is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with AVPKit.  If not, see <http://www.gnu.org/licenses/>.
018 *******************************************************************************/
019
020package com.avpkit.mediatool.event;
021
022import java.util.concurrent.TimeUnit;
023
024import com.avpkit.mediatool.IMediaListener;
025import com.avpkit.core.IMediaData;
026
027/**
028 * An {@link IEvent} that contains raw, decoded, media data.
029 * 
030 * @author aclarke
031 *
032 */
033public interface IRawMediaEvent extends IStreamEvent
034{
035
036  /**
037   * The {@link IMediaData} for this object.
038   * May be null if {@link #getJavaData()}
039   * is not null.
040   * <p>
041   * The returned {@link IMediaData} will only be valid for
042   * the duration of the {@link IMediaListener} method call
043   * it was dispatched on and 
044   * implementations must not access it after
045   * that call returns.  If you need to keep a copy of this data
046   * either copy the data into your own object, or
047   * use {@link IMediaData#copyReference()} to create a reference
048   * that will outlive your call.
049   * </p>
050   * 
051   * @return the media data, or null if unavailable
052   */
053  public abstract IMediaData getMediaData();
054
055  /**
056   * The Java object registered with this event.  If null,
057   * you must use {@link #getMediaData()}.  Not all
058   * {@link IRawMediaEvent} support the ability to attach
059   * java data.
060   * @return the object, or null if not available
061   */
062  public abstract Object getJavaData();
063
064  /**
065   * The time stamp of this media, in {@link TimeUnit#MICROSECONDS}.
066   * @return the timeStamp, or null if none.
067   */
068  public abstract Long getTimeStamp();
069
070  /**
071   * Get the time stamp of this media in the specified units.
072   * @param unit the time unit
073   * @return the time stamp, or null if none
074   * @throws IllegalArgumentException if unit is null
075   */
076  public abstract Long getTimeStamp(TimeUnit unit);
077
078  /**
079   * The time unit of {@link #getTimeStamp()}.
080   * @return the timeUnit
081   */
082  public abstract TimeUnit getTimeUnit();
083
084}