lib: deprecate the old track API
[vlc.git] / include / vlc / libvlc_media_track.h
blobf8afc01c808e7a7297a868c50da98678db9c1a60
1 /*****************************************************************************
2 * libvlc_media_track.h: libvlc external API
3 *****************************************************************************
4 * Copyright (C) 1998-2020 VLC authors and VideoLAN
6 * Authors: Clément Stenac <zorglub@videolan.org>
7 * Jean-Paul Saman <jpsaman@videolan.org>
8 * Pierre d'Herbemont <pdherbemont@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_LIBVLC_MEDIA_TRACK_H
26 #define VLC_LIBVLC_MEDIA_TRACK_H 1
28 # ifdef __cplusplus
29 extern "C" {
30 # else
31 # include <stdbool.h>
32 # endif
34 /** \defgroup libvlc_media_track LibVLC media track
35 * \ingroup libvlc
36 * @ref libvlc_media_track_t is an abstract representation of a media track.
37 * @{
38 * \file
39 * LibVLC media track
42 typedef enum libvlc_track_type_t
44 libvlc_track_unknown = -1,
45 libvlc_track_audio = 0,
46 libvlc_track_video = 1,
47 libvlc_track_text = 2
48 } libvlc_track_type_t;
50 typedef struct libvlc_audio_track_t
52 unsigned i_channels;
53 unsigned i_rate;
54 } libvlc_audio_track_t;
56 typedef enum libvlc_video_orient_t
58 libvlc_video_orient_top_left, /**< Normal. Top line represents top, left column left. */
59 libvlc_video_orient_top_right, /**< Flipped horizontally */
60 libvlc_video_orient_bottom_left, /**< Flipped vertically */
61 libvlc_video_orient_bottom_right, /**< Rotated 180 degrees */
62 libvlc_video_orient_left_top, /**< Transposed */
63 libvlc_video_orient_left_bottom, /**< Rotated 90 degrees clockwise (or 270 anti-clockwise) */
64 libvlc_video_orient_right_top, /**< Rotated 90 degrees anti-clockwise */
65 libvlc_video_orient_right_bottom /**< Anti-transposed */
66 } libvlc_video_orient_t;
68 typedef enum libvlc_video_projection_t
70 libvlc_video_projection_rectangular,
71 libvlc_video_projection_equirectangular, /**< 360 spherical */
73 libvlc_video_projection_cubemap_layout_standard = 0x100,
74 } libvlc_video_projection_t;
76 /**
77 * Viewpoint
79 * \warning allocate using libvlc_video_new_viewpoint()
81 typedef struct libvlc_video_viewpoint_t
83 float f_yaw; /**< view point yaw in degrees ]-180;180] */
84 float f_pitch; /**< view point pitch in degrees ]-90;90] */
85 float f_roll; /**< view point roll in degrees ]-180;180] */
86 float f_field_of_view; /**< field of view in degrees ]0;180[ (default 80.)*/
87 } libvlc_video_viewpoint_t;
89 typedef enum libvlc_video_multiview_t
91 libvlc_video_multiview_2d, /**< No stereoscopy: 2D picture. */
92 libvlc_video_multiview_stereo_sbs, /**< Side-by-side */
93 libvlc_video_multiview_stereo_tb, /**< Top-bottom */
94 libvlc_video_multiview_stereo_row, /**< Row sequential */
95 libvlc_video_multiview_stereo_col, /**< Column sequential */
96 libvlc_video_multiview_stereo_frame, /**< Frame sequential */
97 libvlc_video_multiview_stereo_checkerboard, /**< Checkerboard pattern */
98 } libvlc_video_multiview_t;
100 typedef struct libvlc_video_track_t
102 unsigned i_height;
103 unsigned i_width;
104 unsigned i_sar_num;
105 unsigned i_sar_den;
106 unsigned i_frame_rate_num;
107 unsigned i_frame_rate_den;
109 libvlc_video_orient_t i_orientation;
110 libvlc_video_projection_t i_projection;
111 libvlc_video_viewpoint_t pose; /**< Initial view point */
112 libvlc_video_multiview_t i_multiview;
113 } libvlc_video_track_t;
115 typedef struct libvlc_subtitle_track_t
117 char *psz_encoding;
118 } libvlc_subtitle_track_t;
120 typedef struct libvlc_media_track_t
122 /* Codec fourcc */
123 uint32_t i_codec;
124 uint32_t i_original_fourcc;
125 int i_id; /* DEPRECATED: use psz_id */
126 libvlc_track_type_t i_type;
128 /* Codec specific */
129 int i_profile;
130 int i_level;
132 union {
133 libvlc_audio_track_t *audio;
134 libvlc_video_track_t *video;
135 libvlc_subtitle_track_t *subtitle;
138 unsigned int i_bitrate;
139 char *psz_language;
140 char *psz_description;
142 /** String identifier of track, can be used to save the track preference
143 * from an other LibVLC run, only valid when the track is fetch from a
144 * media_player */
145 const char *psz_id;
146 /** A string identifier is stable when it is certified to be the same
147 * across different playback instances for the same track, only valid when
148 * the track is fetch from a media_player */
149 bool id_stable;
150 /** Name of the track, only valid when the track is fetch from a
151 * media_player */
152 char *psz_name;
153 /** true if the track is selected, only valid when the track is fetch from
154 * a media_player */
155 bool selected;
157 } libvlc_media_track_t;
160 * Opaque struct containing a list of tracks
162 typedef struct libvlc_media_tracklist_t libvlc_media_tracklist_t;
165 * Get the number of tracks in a tracklist
167 * \version LibVLC 4.0.0 and later.
169 * \param list valid tracklist
171 * \return number of tracks, or 0 if the list is empty
173 LIBVLC_API size_t
174 libvlc_media_tracklist_count( const libvlc_media_tracklist_t *list );
177 * Get a track at a specific index
179 * \warning The behaviour is undefined if the index is not valid.
181 * \version LibVLC 4.0.0 and later.
183 * \param list valid tracklist
184 * \param index valid index in the range [0; count[
186 * \return a valid track (can't be NULL if libvlc_media_tracklist_count()
187 * returned a valid count)
189 LIBVLC_API libvlc_media_track_t *
190 libvlc_media_tracklist_at( libvlc_media_tracklist_t *list, size_t index );
193 * Release a tracklist
195 * \version LibVLC 4.0.0 and later.
197 * \see libvlc_media_get_tracklist
198 * \see libvlc_media_player_get_tracklist
200 * \param list valid tracklist
202 LIBVLC_API void
203 libvlc_media_tracklist_delete( libvlc_media_tracklist_t *list );
207 * Hold a single track reference
209 * \version LibVLC 4.0.0 and later.
211 * This function can be used to hold a track from a tracklist. In that case,
212 * the track can outlive its tracklist.
214 * \param track valid track
215 * \return the same track, need to be released with libvlc_media_track_release()
217 LIBVLC_API libvlc_media_track_t *
218 libvlc_media_track_hold( libvlc_media_track_t * );
221 * Release a single track
223 * \version LibVLC 4.0.0 and later.
225 * \warning Tracks from a tracklist are released alongside the list with
226 * libvlc_media_tracklist_delete().
228 * \note You only need to release tracks previously held with
229 * libvlc_media_track_hold() or returned by
230 * libvlc_media_player_get_selected_track() and
231 * libvlc_media_player_get_track_from_id()
233 * \param track valid track
235 LIBVLC_API void
236 libvlc_media_track_release( libvlc_media_track_t *track );
237 /** @}*/
239 # ifdef __cplusplus
241 # endif
243 #endif /* VLC_LIBVLC_MEDIA_TRACK_H */