]> git.vomp.tv Git - vompclient.git/blob - draintarget.h
e3a8f2b195050f4076c814686a2ee91705653998
[vompclient.git] / draintarget.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef DRAINTARGET_H
22 #define DRAINTARGET_H
23
24 #include "defines.h"
25 #include <list>
26
27 #define MPTYPE_VIDEO_MPEG2 0x00
28 #define MPTYPE_MPEG_AUDIO 0x01
29 #define MPTYPE_AC3 0x02
30 #define MPTYPE_AC3_PRE13 0x03 //old vdr recording compatmode
31 #define MPTYPE_MPEG_AUDIO_LAYER3 0x04 //for media mp3 playback
32 #define MPTYPE_TELETEXT 0x05 //for EBU VBI teletext
33 #define MPTYPE_VIDEO_H264 0x06
34 #define MPTYPE_AAC_LATM 0x07
35
36
37
38 struct MediaPacket
39 {
40   ULONG pos_buffer; //position in stream buffer
41   ULONG length; //length of the packet
42   // The fields below are not needed by the MVP
43   UCHAR type;
44   ULLONG pts;
45   ULLONG dts;
46   bool synched;
47   int index;
48 #ifndef VOMP_PLATTFORM_MVP
49   long long presentation_time;/* native time of plattform, in 100 ns units(Windows)*/
50   bool disconti;
51 #endif
52 };
53
54 using namespace std;
55 typedef list<MediaPacket> MediaPacketList;
56
57
58
59 class DrainTarget
60 {
61   public:
62     DrainTarget() {
63
64     }
65     virtual ~DrainTarget(){
66
67     }
68
69     virtual long long SetStartOffset(long long curreftime, bool *rsync)=0;
70     virtual void ResetTimeOffsets()=0;
71
72     virtual bool DrainTargetReady() {return false;}; //if the draintarget is blocking in paused state, this tells that it is ready to rumble
73     virtual bool DrainTargetBufferFull() { return false;};
74
75     virtual bool dtsTimefix(){return false;} //determines if the draintargets needs a mixure of pts and dts or not
76
77 // The following two functions are used by the Stream
78 // to deliver media packets to the front end (DrainTarget).
79 //
80 // First, the Stream calls PrepareMediaSample, which gives the front end
81 // read-only access to the Stream's MediaPacketList. PrepareMediaSample should
82 // examine the list to determine how much it wishes to consume, and
83 // should copy any data it requires from the MediaPacket objects into
84 // local storage.
85 // This function call takes place under a mutex lock to ensure integrity
86 // of the list structure. It should be fast and must not contain any
87 // cancellation points, such as I/O calls for logging.
88 //
89 // Second, the Stream releases the mutex and calls DeliverMediaSample.
90 // This function delivers data from the Stream buffer to the presentation
91 // device and returns information to the Stream regarding how many MediaPackets
92 // were consumed. Any data copied from the MediaPackets objects during
93 // PrepareMediaSample is guaranteed by the Stream still to be valid
94 // during the following DeliverMediaSample call.
95
96     // samplepos is equal to the number of bytes from the first MediaPacket
97     // in the list that have already been consumed in a previous call.
98     virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos)=0;
99
100     // The Stream guarantees that the value of *samplepos passed to
101     // DeliverMediaSample will be equal to the value of samplepos passed to
102     // PrepareMediaSample in the previous call.
103     // This function should consume data from the buffer according to the
104     // decisions made in PrepareMediaSample. Its return value and *samplepos
105     // tell the Stream how much data it consumed.
106     // If DeliverMediaSample returns X, the Stream will remove packets 0 to X-1
107     // (inclusive) from the list before the next call.
108     // DeliverMediaSample must also set *samplepos equal to the number of bytes
109     // processed from packet X (usually zero).
110         // It is allowed, that the draintarget modifies the part of the buffer, which belongs 
111         // to the mediapackets it is processing.
112     virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos)=0;
113     // The drain target might advice the feeder about free buffers with threadSignal
114
115
116 };
117
118 #endif