input_internal.h 8.16 KB
Newer Older
Laurent Aimar's avatar
Laurent Aimar committed
1
/*****************************************************************************
Clément Stenac's avatar
Clément Stenac committed
2
 * input_internal.h: Internal input structures
Laurent Aimar's avatar
Laurent Aimar committed
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
4
 * Copyright (C) 1998-2006 VLC authors and VideoLAN
Antoine Cellerier's avatar
Antoine Cellerier committed
5
 * $Id$
Laurent Aimar's avatar
Laurent Aimar committed
6 7 8
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
9 10 11
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
Laurent Aimar's avatar
Laurent Aimar committed
12 13 14 15
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
16 17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
Laurent Aimar's avatar
Laurent Aimar committed
18
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
19 20 21
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Laurent Aimar's avatar
Laurent Aimar committed
22 23
 *****************************************************************************/

24 25
#ifndef LIBVLC_INPUT_INTERNAL_H
#define LIBVLC_INPUT_INTERNAL_H 1
Laurent Aimar's avatar
Laurent Aimar committed
26

27 28
#include <stddef.h>

Clément Stenac's avatar
Clément Stenac committed
29 30 31
#include <vlc_access.h>
#include <vlc_demux.h>
#include <vlc_input.h>
32
#include <vlc_viewpoint.h>
33
#include <libvlc.h>
34
#include "input_interface.h"
35
#include "misc/interrupt.h"
Clément Stenac's avatar
Clément Stenac committed
36 37 38 39

/*****************************************************************************
 *  Private input fields
 *****************************************************************************/
40 41 42

#define INPUT_CONTROL_FIFO_SIZE    100

Clément Stenac's avatar
Clément Stenac committed
43 44 45
/* input_source_t: gathers all information per input source */
typedef struct
{
46
    struct vlc_common_members obj;
47

48
    demux_t  *p_demux; /**< Demux object (most downstream) */
Clément Stenac's avatar
Clément Stenac committed
49 50

    /* Title infos for that input */
Antoine Cellerier's avatar
Antoine Cellerier committed
51
    bool         b_title_demux; /* Titles/Seekpoints provided by demux */
Clément Stenac's avatar
Clément Stenac committed
52 53 54 55 56 57 58 59 60 61 62 63
    int          i_title;
    input_title_t **title;

    int i_title_offset;
    int i_seekpoint_offset;

    int i_title_start;
    int i_title_end;
    int i_seekpoint_start;
    int i_seekpoint_end;

    /* Properties */
64 65 66
    bool b_can_pause;
    bool b_can_pace_control;
    bool b_can_rate_control;
67
    bool b_can_stream_record;
68
    bool b_rescale_ts;
69
    double f_fps;
70

71 72 73
    /* */
    int64_t i_pts_delay;

Antoine Cellerier's avatar
Antoine Cellerier committed
74
    bool       b_eof;   /* eof of demuxer */
Clément Stenac's avatar
Clément Stenac committed
75 76 77

} input_source_t;

Laurent Aimar's avatar
Laurent Aimar committed
78 79 80 81 82 83
typedef struct
{
    int         i_type;
    vlc_value_t val;
} input_control_t;

Clément Stenac's avatar
Clément Stenac committed
84
/** Private input fields */
85
typedef struct input_thread_private_t
Clément Stenac's avatar
Clément Stenac committed
86
{
87 88
    struct input_thread_t input;

Clément Stenac's avatar
Clément Stenac committed
89
    /* Global properties */
90
    bool        b_preparsing;
Antoine Cellerier's avatar
Antoine Cellerier committed
91 92
    bool        b_can_pause;
    bool        b_can_rate_control;
93
    bool        b_can_pace_control;
Clément Stenac's avatar
Clément Stenac committed
94

95
    /* Current state */
96 97 98
    int         i_state;
    bool        is_running;
    bool        is_stopped;
99
    bool        b_recording;
100
    int         i_rate;
101

Laurent Aimar's avatar
Laurent Aimar committed
102
    /* Playtime configuration and state */
Clément Stenac's avatar
Clément Stenac committed
103 104
    int64_t     i_start;    /* :start-time,0 by default */
    int64_t     i_stop;     /* :stop-time, 0 if none */
Laurent Aimar's avatar
Laurent Aimar committed
105
    int64_t     i_time;     /* Current time */
106
    bool        b_fast_seek;/* :input-fast-seek */
Clément Stenac's avatar
Clément Stenac committed
107

108 109 110 111 112
    /* Output */
    bool            b_out_pace_control; /* XXX Move it ot es_sout ? */
    sout_instance_t *p_sout;            /* Idem ? */
    es_out_t        *p_es_out;
    es_out_t        *p_es_out_display;
113
    vlc_viewpoint_t viewpoint;
114
    bool            viewpoint_changed;
115
    vlc_renderer_item_t *p_renderer;
116

117 118 119 120
    /* Title infos FIXME multi-input (not easy) ? */
    int          i_title;
    const input_title_t **title;

Clément Stenac's avatar
Clément Stenac committed
121 122 123 124
    int i_title_offset;
    int i_seekpoint_offset;

    /* User bookmarks FIXME won't be easy with multiples input */
125
    seekpoint_t bookmark;
Clément Stenac's avatar
Clément Stenac committed
126
    int         i_bookmark;
127
    seekpoint_t **pp_bookmark;
Clément Stenac's avatar
Clément Stenac committed
128

129 130 131
    /* Input attachment */
    int i_attachment;
    input_attachment_t **attachment;
132
    const demux_t **attachment_demux;
133

Clément Stenac's avatar
Clément Stenac committed
134
    /* Main input properties */
135

136 137
    /* Input item */
    input_item_t   *p_item;
138

139
    /* Main source */
140
    input_source_t *master;
141
    /* Slave sources (subs, and others) */
Clément Stenac's avatar
Clément Stenac committed
142 143 144
    int            i_slave;
    input_source_t **slave;

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
145
    /* Resources */
146
    input_resource_t *p_resource;
147
    input_resource_t *p_resource_private;
148

Clément Stenac's avatar
Clément Stenac committed
149 150 151 152 153 154 155
    /* Stats counters */
    struct {
        counter_t *p_read_packets;
        counter_t *p_read_bytes;
        counter_t *p_input_bitrate;
        counter_t *p_demux_read;
        counter_t *p_demux_bitrate;
156 157
        counter_t *p_demux_corrupted;
        counter_t *p_demux_discontinuity;
Clément Stenac's avatar
Clément Stenac committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
        counter_t *p_decoded_audio;
        counter_t *p_decoded_video;
        counter_t *p_decoded_sub;
        counter_t *p_sout_sent_packets;
        counter_t *p_sout_sent_bytes;
        counter_t *p_sout_send_bitrate;
        counter_t *p_played_abuffers;
        counter_t *p_lost_abuffers;
        counter_t *p_displayed_pictures;
        counter_t *p_lost_pictures;
        vlc_mutex_t counters_lock;
    } counters;

    /* Buffer of pending actions */
    vlc_mutex_t lock_control;
173
    vlc_cond_t  wait_control;
Clément Stenac's avatar
Clément Stenac committed
174
    int i_control;
Laurent Aimar's avatar
Laurent Aimar committed
175 176
    input_control_t control[INPUT_CONTROL_FIFO_SIZE];

177
    vlc_thread_t thread;
178
    vlc_interrupt_t interrupt;
179 180 181 182
} input_thread_private_t;

static inline input_thread_private_t *input_priv(input_thread_t *input)
{
183
    return container_of(input, input_thread_private_t, input);
184
}
Clément Stenac's avatar
Clément Stenac committed
185 186 187 188

/***************************************************************************
 * Internal control helpers
 ***************************************************************************/
Laurent Aimar's avatar
Laurent Aimar committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
enum input_control_e
{
    INPUT_CONTROL_SET_STATE,

    INPUT_CONTROL_SET_RATE,

    INPUT_CONTROL_SET_POSITION,

    INPUT_CONTROL_SET_TIME,

    INPUT_CONTROL_SET_PROGRAM,

    INPUT_CONTROL_SET_TITLE,
    INPUT_CONTROL_SET_TITLE_NEXT,
    INPUT_CONTROL_SET_TITLE_PREV,

    INPUT_CONTROL_SET_SEEKPOINT,
    INPUT_CONTROL_SET_SEEKPOINT_NEXT,
    INPUT_CONTROL_SET_SEEKPOINT_PREV,

    INPUT_CONTROL_SET_BOOKMARK,

211 212 213 214 215
    INPUT_CONTROL_NAV_ACTIVATE, // NOTE: INPUT_CONTROL_NAV_* values must be
    INPUT_CONTROL_NAV_UP,       // contiguous and in the same order as
    INPUT_CONTROL_NAV_DOWN,     // INPUT_NAV_* and DEMUX_NAV_*.
    INPUT_CONTROL_NAV_LEFT,
    INPUT_CONTROL_NAV_RIGHT,
216
    INPUT_CONTROL_NAV_POPUP,
217
    INPUT_CONTROL_NAV_MENU,
218

Laurent Aimar's avatar
Laurent Aimar committed
219
    INPUT_CONTROL_SET_ES,
220
    INPUT_CONTROL_RESTART_ES,
221

222
    INPUT_CONTROL_SET_VIEWPOINT,    // new absolute viewpoint
223
    INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video)
224 225
    INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current

226 227
    INPUT_CONTROL_SET_AUDIO_DELAY,
    INPUT_CONTROL_SET_SPU_DELAY,
228 229

    INPUT_CONTROL_ADD_SLAVE,
230 231

    INPUT_CONTROL_SET_RECORD_STATE,
232 233

    INPUT_CONTROL_SET_FRAME_NEXT,
234 235

    INPUT_CONTROL_SET_RENDERER,
Laurent Aimar's avatar
Laurent Aimar committed
236 237 238
};

/* Internal helpers */
Laurent Aimar's avatar
Laurent Aimar committed
239 240 241 242

/* XXX for string value you have to allocate it before calling
 * input_ControlPush
 */
Laurent Aimar's avatar
Laurent Aimar committed
243
void input_ControlPush( input_thread_t *, int i_type, vlc_value_t * );
Laurent Aimar's avatar
Laurent Aimar committed
244

245 246
bool input_Stopped( input_thread_t * );

247 248 249
/* Bound pts_delay */
#define INPUT_PTS_DELAY_MAX INT64_C(60000000)

Clément Stenac's avatar
Clément Stenac committed
250 251 252
/**********************************************************************
 * Item metadata
 **********************************************************************/
253
/* input_ExtractAttachmentAndCacheArt:
254 255
 *  Be careful: p_item lock will be taken! */
void input_ExtractAttachmentAndCacheArt( input_thread_t *, const char *name );
256

Clément Stenac's avatar
Clément Stenac committed
257 258 259 260
/***************************************************************************
 * Internal prototypes
 ***************************************************************************/

Laurent Aimar's avatar
Laurent Aimar committed
261 262
/* var.c */
void input_ControlVarInit ( input_thread_t * );
263
void input_ControlVarStop( input_thread_t * );
Laurent Aimar's avatar
Laurent Aimar committed
264 265 266 267 268 269
void input_ControlVarNavigation( input_thread_t * );
void input_ControlVarTitle( input_thread_t *, int i_title );

void input_ConfigVarInit ( input_thread_t * );

/* Subtitles */
270
int subtitles_Detect( input_thread_t *, char *, const char *, input_item_slave_t ***, int * );
271 272
int subtitles_Filter( const char *);

273
/* input.c */
274 275
void input_SplitMRL( const char **, const char **, const char **,
                     const char **, char * );
276

277 278 279 280
/* meta.c */
void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
                                          const vlc_meta_t *p_meta );

281 282 283
/* item.c */
void input_item_node_PostAndDelete( input_item_node_t *p_node );

284
#endif