1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * AV parser inteface declarations
12 * Copyright (c) 2007 Michael Sevakis
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
28 STREAM_FMT_UNKNOWN
= -1,
29 STREAM_FMT_MPEG_TS
, /* MPEG transport stream */
30 STREAM_FMT_MPEG_PS
, /* MPEG program stream */
31 STREAM_FMT_MPV
, /* MPEG Video only (1 or 2) */
32 STREAM_FMT_MPA
, /* MPEG Audio only */
35 /* Structure used by a thread that handles a single demuxed data stream and
36 * receives commands from the stream manager */
37 enum stream_parse_states
40 SSTATE_SYNC
, /* synchronizing by trying to find a start code */
41 SSTATE_PARSE
, /* parsing the stream looking for packets */
42 SSTATE_END
, /* at the end of data */
45 enum stream_parse_mode
47 STREAM_PM_STREAMING
= 0, /* Next packet when streaming */
48 STREAM_PM_RANDOM_ACCESS
, /* Random-access parsing */
51 enum stream_parser_flags
53 STREAMF_CAN_SEEK
= 0x1, /* Seeking possible for this stream */
58 /* Common generic parser data */
59 enum stream_formats format
; /* Stream format */
60 uint32_t start_pts
; /* The movie start time as represented by
61 the first audio PTS tag in the
62 stream converted to half minutes */
63 uint32_t end_pts
; /* The movie end time as represented by
64 the maximum audio PTS tag in the
65 stream converted to half minutes */
66 uint32_t duration
; /* Duration in PTS units */
67 unsigned flags
; /* Various attributes set at init */
68 struct vo_ext dims
; /* Movie dimensions in pixels */
69 uint32_t last_seek_time
;
70 int (*next_data
)(struct stream
*str
, enum stream_parse_mode type
);
71 union /* A place for reusable no-cache parameters */
73 struct str_sync_data sd
;
77 extern struct stream_parser str_parser
;
80 uint8_t * mpeg_parser_scan_start_code(struct stream_scan
*sk
, uint32_t code
);
81 unsigned mpeg_parser_scan_pes(struct stream_scan
*sk
);
82 uint32_t mpeg_parser_scan_scr(struct stream_scan
*sk
);
83 uint32_t mpeg_parser_scan_pts(struct stream_scan
*sk
, unsigned id
);
84 off_t
mpeg_stream_stream_seek_PTS(uint32_t time
, int id
);
87 bool parser_init(void);
88 void str_initialize(struct stream
*str
, off_t pos
);
89 intptr_t parser_send_video_msg(long id
, intptr_t data
);
90 bool parser_get_video_size(struct vo_ext
*sz
);
91 int parser_init_stream(void);
92 void parser_close_stream(void);
93 static inline bool parser_can_seek(void)
94 { return str_parser
.flags
& STREAMF_CAN_SEEK
; }
95 uint32_t parser_seek_time(uint32_t time
);
96 void parser_prepare_streaming(void);
97 void str_end_of_stream(struct stream
*str
);
99 static inline int parser_get_next_data(struct stream
*str
,
100 enum stream_parse_mode type
)
101 { return str_parser
.next_data(str
, type
); }
103 #endif /* PARSER_H */