summaryrefslogtreecommitdiff
path: root/dxr3pesframe.h
blob: 054760473596224a1f0663f33ab45f94840dadcf (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * dxr3pesframe.h
 *
 * Copyright (C) 2002-2004 Kai Möller
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */

#ifndef _DXR3PESFRAME_H_
#define _DXR3PESFRAME_H_

#include <assert.h>
#include "dxr3audio.h"
#include "uncopyable.h"

// ==================================
enum eVideoFrameType
{
    I_FRAME,
    P_FRAME,
    B_FRAME,
    UNKNOWN_FRAME
};

// ==================================
// pes - packetized elementary stream
class cDxr3PesFrame : private Uncopyable {
public:

    // ==================================
    enum ePesDataType
    {
	PES_AUDIO_DATA,
	PES_VIDEO_DATA,
	PES_PRIVATE_DATA,
	PES_UNKNOWN_DATA
    };

public:
    cDxr3PesFrame() :
	m_pesDataType(PES_UNKNOWN_DATA),
	m_pesStart(0),
	m_payload(0),
	m_payloadLength(0),
	m_pts(0),
	m_videoFrameType(UNKNOWN_FRAME),
	m_aspectRatio(m_staticAspectRatio),
	m_horizontalSize(0),
	m_verticalSize(0) {}

    virtual ~cDxr3PesFrame() {}

    bool parse(const uint8_t *pes, uint32_t length);

    ePesDataType GetPesDataType() const
    {
        return m_pesDataType;
    }

    const uint8_t* GetPesStart() const
    {
        return m_pesStart;
    }

    const uint8_t* GetPayload() const
    {
        return m_payload;
    }

    uint32_t GetPayloadLength() const
    {
        return m_payloadLength;
    }

    uint32_t GetPts() const
    {
        return m_pts;
    }

    eVideoFrameType GetFrameType() const
    {
        assert(m_pesDataType == PES_VIDEO_DATA);
        return m_videoFrameType;
    }

    uint32_t GetAspectRatio() const
    {
        assert(m_pesDataType == PES_VIDEO_DATA);
        return m_aspectRatio;
    }

    uint32_t GetHorizontalSize() const
    {
        assert(m_pesDataType == PES_VIDEO_DATA);
        return m_horizontalSize;
    }

    uint32_t GetVerticalSize() const
    {
        assert(m_pesDataType == PES_VIDEO_DATA);
        return m_verticalSize;
    }

    // needed for audio
    uint32_t decodedSize;
    int16_t *decoded;
    SampleContext ctx;

private:
    ePesDataType m_pesDataType;
    const uint8_t* m_pesStart;
    const uint8_t* m_payload;
    uint32_t m_payloadLength;
    uint32_t m_pts;

    eVideoFrameType m_videoFrameType;
    uint32_t m_aspectRatio;
    uint32_t m_horizontalSize;
    uint32_t m_verticalSize;

    static uint32_t m_staticAspectRatio;

    static const uint32_t MAX_PES_HEADER_SIZE;
};

#endif /*_DXR3PESFRAME_H_*/

// Local variables:
// mode: c++
// c-file-style: "stroustrup"
// c-file-offsets: ((inline-open . 0))
// c-basic-offset: 4
// indent-tabs-mode: nil
// End: