/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2002 by Gary Czvitkovicz * * 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. * ****************************************************************************/ /* * Minimal printf and snprintf formatting functions * * These support %c %s %d and %x * Field width and zero-padding flag only */ #include #include #include #include #include "format.h" /* ALSA library requires a more advanced snprintf, so let's not override it in simulator for Linux. Note that Cygwin requires our snprintf or it produces garbled output after a while. */ struct for_snprintf { unsigned char *ptr; /* where to store it */ size_t bytes; /* amount already stored */ size_t max; /* max amount to store */ }; static int sprfunc(void *ptr, unsigned char letter) { struct for_snprintf *pr = (struct for_snprintf *)ptr; if(pr->bytes < pr->max) { *pr->ptr = letter; pr->ptr++; pr->bytes++; return true; } return false; /* filled buffer */ } int snprintf(char *buf, size_t size, const char *fmt, ...) { va_list ap; struct for_snprintf pr; pr.ptr = (unsigned char *)buf; pr.bytes = 0; pr.max = size; va_start(ap, fmt); format(sprfunc, &pr, fmt, ap); va_end(ap); /* make sure it ends with a trailing zero */ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0'; return pr.bytes; } int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) { struct for_snprintf pr; pr.ptr = (unsigned char *)buf; pr.bytes = 0; pr.max = size; format(sprfunc, &pr, fmt, ap); /* make sure it ends with a trailing zero */ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0'; return pr.bytes; } 69'>root/apps/plugins/mpegplayer/parser.h
blob: ba2181e98bead8e376683b3bf808bee6eeb9e760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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);