/*
 * Copyright (c) 2008-2011, Oracle and/or its affiliates. All rights reserved.
 */

package javafx.scene.media;

import com.sun.javafx.beans.annotations.NoBuilder;

/**
 * A class representing a track contained in a media resource.
 * A media resource may have multiple parallel tracks, such as a video
 * track with several audio tracks in different languages. The types of tracks
 * supported by the system may be inferred from the existing subclasses of this
 * class. Not all media resources will contain a track of each supported type,
 * and the time span of a given track need not be commensurate with the time
 * span of the containing media.
 *
 * @see AudioTrack
 * @see VideoTrack
 */
@NoBuilder
public abstract class Track {
    /**
     * The name of the track or <code>null</code> if the track is unnamed.
     */
    private String name;

    /**
     * Retrieves the name of the track.
     * @return the track name or <code>null</code>.
     */
    public final String getName() {
        return name;
    }

    // Internal track reference
    private com.sun.media.jfxmedia.track.Track mediaTrack;
    com.sun.media.jfxmedia.track.Track getMediaTrack() {
        return mediaTrack;
    }

    /**
     * Creates a new {@link Track} from a {@link com.sun.media.jfxmedia.track.Track}.
     * 
     * @param nativeTrack the implementation layer track.
     * @throws NullPointerException if <code>nativeTrack</code> is <code>null</code>.
     */
    Track(com.sun.media.jfxmedia.track.Track nativeTrack) {
        mediaTrack = nativeTrack;
        name = nativeTrack.getName();
    }
}
