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