Modify the Ogg/Speex demuxer and the libspeex decoder so that they always treat
[FFMpeg-mirror/lagarith.git] / libavformat / seek.h
blob570c2bcedf5fd586c6d8f8b31799504cb1c01f08
1 /*
2 * Utility functions for seeking for use within FFmpeg format handlers.
4 * Copyright (c) 2009 Ivan Schreter
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVFORMAT_SEEK_H
24 #define AVFORMAT_SEEK_H
26 #include "avformat.h"
28 /// Opaque structure for parser state.
29 typedef struct AVParserState AVParserState;
31 /**
32 * Search for sync point of all active streams.
34 * This is not supposed to be called directly by a user application,
35 * but by demuxers.
37 * A sync point is a point in stream, so that decoding from this point,
38 * output of decoders of all streams synchronizes closest to given timestamp
39 * ts (but taking timestamp limits into account, i.e., no sooner than ts_min
40 * and no later than ts_max).
42 * @param stream_index stream index for time base reference of timestamps.
43 * @param pos approximate position where to start searching for key frames.
44 * @param min_ts minimum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
45 * @param ts target timestamp (or position, if AVSEEK_FLAG_BYTE set in flags).
46 * @param max_ts maximum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
47 * @param flags if AVSEEK_FLAG_ANY is set, seek to any frame, otherwise only
48 * to a keyframe. If AVSEEK_FLAG_BYTE is set, search by
49 * position, not by timestamp.
50 * @return < 0 if no such sync point could be found, otherwise stream position
51 * (stream is repositioned to this position).
53 int64_t ff_gen_syncpoint_search(AVFormatContext *s,
54 int stream_index,
55 int64_t pos,
56 int64_t min_ts,
57 int64_t ts,
58 int64_t max_ts,
59 int flags);
61 /**
62 * Store current parser state and file position.
64 * This function can be used by demuxers before destructive seeking algorithm
65 * to store parser state. After the seek, depending on outcome, original state
66 * can be restored or new state kept and original state freed.
68 * @note As a side effect, original parser state is reset, since structures
69 * are relinked to stored state instead of being deeply-copied (for
70 * performance reasons and to keep code simple).
72 * @param s context from which to save state.
73 * @return parser state object or NULL if memory could not be allocated.
75 AVParserState *ff_store_parser_state(AVFormatContext *s);
77 /**
78 * Restore previously saved parser state and file position.
80 * Saved state will be invalidated and freed by this call, since internal
81 * structures will be relinked back to stored state instead of being
82 * deeply-copied.
84 * @param s context to which to restore state (same as used for storing state).
85 * @param state state to restore.
87 void ff_restore_parser_state(AVFormatContext *s, AVParserState *state);
89 /**
90 * Free previously saved parser state.
92 * @param s context to which the state belongs (same as used for storing state).
93 * @param state state to free.
95 void ff_free_parser_state(AVFormatContext *s, AVParserState *state);
97 #endif /* AVFORMAT_SEEK_H */