summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/parser.h')
-rw-r--r--apps/plugins/mpegplayer/parser.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/parser.h b/apps/plugins/mpegplayer/parser.h
new file mode 100644
index 0000000000..892a8a14d2
--- /dev/null
+++ b/apps/plugins/mpegplayer/parser.h
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * AV parser inteface declarations
11 *
12 * Copyright (c) 2007 Michael Sevakis
13 *
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef PARSER_H
22#define PARSER_H
23
24enum stream_formats
25{
26 STREAM_FMT_UNKNOWN = -1,
27 STREAM_FMT_MPEG_TS, /* MPEG transport stream */
28 STREAM_FMT_MPEG_PS, /* MPEG program stream */
29 STREAM_FMT_MPV, /* MPEG Video only (1 or 2) */
30 STREAM_FMT_MPA, /* MPEG Audio only */
31};
32
33/* Structure used by a thread that handles a single demuxed data stream and
34 * receives commands from the stream manager */
35enum stream_parse_states
36{
37 /* Stream is... */
38 SSTATE_SYNC, /* synchronizing by trying to find a start code */
39 SSTATE_PARSE, /* parsing the stream looking for packets */
40 SSTATE_END, /* at the end of data */
41};
42
43enum stream_parse_mode
44{
45 STREAM_PM_STREAMING = 0, /* Next packet when streaming */
46 STREAM_PM_RANDOM_ACCESS, /* Random-access parsing */
47};
48
49enum stream_parser_flags
50{
51 STREAMF_CAN_SEEK = 0x1, /* Seeking possible for this stream */
52};
53
54struct stream_parser
55{
56 /* Common generic parser data */
57 enum stream_formats format; /* Stream format */
58 uint32_t start_pts; /* The movie start time as represented by
59 the first audio PTS tag in the
60 stream converted to half minutes */
61 uint32_t end_pts; /* The movie end time as represented by
62 the maximum audio PTS tag in the
63 stream converted to half minutes */
64 uint32_t duration; /* Duration in PTS units */
65 unsigned flags; /* Various attributes set at init */
66 struct vo_ext dims; /* Movie dimensions in pixels */
67 uint32_t last_seek_time;
68 int (*next_data)(struct stream *str, enum stream_parse_mode type);
69 union /* A place for reusable no-cache parameters */
70 {
71 struct str_sync_data sd;
72 } parms;
73};
74
75extern struct stream_parser str_parser;
76
77/* MPEG parsing */
78uint8_t * mpeg_parser_scan_start_code(struct stream_scan *sk, uint32_t code);
79unsigned mpeg_parser_scan_pes(struct stream_scan *sk);
80uint32_t mpeg_parser_scan_scr(struct stream_scan *sk);
81uint32_t mpeg_parser_scan_pts(struct stream_scan *sk, unsigned id);
82off_t mpeg_stream_stream_seek_PTS(uint32_t time, int id);
83
84/* General parsing */
85bool parser_init(void);
86void str_initialize(struct stream *str, off_t pos);
87intptr_t parser_send_video_msg(long id, intptr_t data);
88bool parser_get_video_size(struct vo_ext *sz);
89int parser_init_stream(void);
90void parser_close_stream(void);
91static inline bool parser_can_seek(void)
92 { return str_parser.flags & STREAMF_CAN_SEEK; }
93uint32_t parser_seek_time(uint32_t time);
94void parser_prepare_streaming(void);
95void str_end_of_stream(struct stream *str);
96
97static inline int parser_get_next_data(struct stream *str,
98 enum stream_parse_mode type)
99 { return str_parser.next_data(str, type); }
100
101#endif /* PARSER_H */