From 9d3d925295112a0080bc1d70fad170db9e1af2a9 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 13 Oct 2022 11:04:12 -0400 Subject: Revert "RFC: Get rid of mpegplayer plugin" This reverts commit d25d24812e8120c0eb133a412287ac030eb185c9. Change-Id: I1563223e343fb1e2eda72a45823b38350025ff93 --- apps/plugins/mpegplayer/parser.h | 103 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 apps/plugins/mpegplayer/parser.h (limited to 'apps/plugins/mpegplayer/parser.h') diff --git a/apps/plugins/mpegplayer/parser.h b/apps/plugins/mpegplayer/parser.h new file mode 100644 index 0000000000..ba2181e98b --- /dev/null +++ b/apps/plugins/mpegplayer/parser.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * AV parser inteface declarations + * + * Copyright (c) 2007 Michael Sevakis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef PARSER_H +#define PARSER_H + +enum stream_formats +{ + STREAM_FMT_UNKNOWN = -1, + STREAM_FMT_MPEG_TS, /* MPEG transport stream */ + STREAM_FMT_MPEG_PS, /* MPEG program stream */ + STREAM_FMT_MPV, /* MPEG Video only (1 or 2) */ + STREAM_FMT_MPA, /* MPEG Audio only */ +}; + +/* Structure used by a thread that handles a single demuxed data stream and + * receives commands from the stream manager */ +enum stream_parse_states +{ + /* Stream is... */ + SSTATE_SYNC, /* synchronizing by trying to find a start code */ + SSTATE_PARSE, /* parsing the stream looking for packets */ + SSTATE_END, /* at the end of data */ +}; + +enum stream_parse_mode +{ + STREAM_PM_STREAMING = 0, /* Next packet when streaming */ + STREAM_PM_RANDOM_ACCESS, /* Random-access parsing */ +}; + +enum stream_parser_flags +{ + STREAMF_CAN_SEEK = 0x1, /* Seeking possible for this stream */ +}; + +struct stream_parser +{ + /* Common generic parser data */ + enum stream_formats format; /* Stream format */ + uint32_t start_pts; /* The movie start time as represented by + the first audio PTS tag in the + stream converted to half minutes */ + uint32_t end_pts; /* The movie end time as represented by + the maximum audio PTS tag in the + stream converted to half minutes */ + uint32_t duration; /* Duration in PTS units */ + unsigned flags; /* Various attributes set at init */ + struct vo_ext dims; /* Movie dimensions in pixels */ + uint32_t last_seek_time; + int (*next_data)(struct stream *str, enum stream_parse_mode type); + union /* A place for reusable no-cache parameters */ + { + struct str_sync_data sd; + } parms; +}; + +extern struct stream_parser str_parser; + +/* MPEG parsing */ +uint8_t * mpeg_parser_scan_start_code(struct stream_scan *sk, uint32_t code); +unsigned mpeg_parser_scan_pes(struct stream_scan *sk); +uint32_t mpeg_parser_scan_scr(struct stream_scan *sk); +uint32_t mpeg_parser_scan_pts(struct stream_scan *sk, unsigned id); +off_t mpeg_stream_stream_seek_PTS(uint32_t time, int id); + +/* General parsing */ +bool parser_init(void); +void str_initialize(struct stream *str, off_t pos); +bool parser_prepare_image(uint32_t time); +bool parser_get_video_size(struct vo_ext *sz); +int parser_init_stream(void); +void parser_close_stream(void); +static inline bool parser_can_seek(void) + { return str_parser.flags & STREAMF_CAN_SEEK; } +uint32_t parser_seek_time(uint32_t time); +void parser_prepare_streaming(void); +void str_end_of_stream(struct stream *str); + +static inline int parser_get_next_data(struct stream *str, + enum stream_parse_mode type) + { return str_parser.next_data(str, type); } + +#endif /* PARSER_H */ -- cgit v1.2.3