]> git.vomp.tv Git - vompclient.git/blob - draintarget.h
Add -s option to select server
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #ifndef DRAINTARGET_H
22 #define DRAINTARGET_H
23
24 #include "defines.h"
25 #include <list>
26
27 #define MPTYPE_VIDEO 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
33 struct MediaPacket
34 {
35   ULONG pos_buffer; //position in stream buffer
36   ULONG length; //length of the packet
37   // The fields below are not needed by the MVP
38   UCHAR type;
39 #ifdef WIN32
40   ULLONG recording_byte_pos; //position in recording
41   ULLONG pts;
42   long long presentation_time;/* in 100 ns units*/
43   bool synched;
44   bool disconti;
45 #endif
46 };
47
48 using namespace std;
49 typedef list<MediaPacket> MediaPacketList;
50
51 class DrainTarget
52 {
53   public:
54     DrainTarget();
55     virtual ~DrainTarget();
56
57     virtual long long SetStartOffset(long long curreftime, bool *rsync)=0;
58     virtual void ResetTimeOffsets()=0;
59
60 // The following two functions are used by the Stream
61 // to deliver media packets to the front end (DrainTarget).
62 //
63 // First, the Stream calls PrepareMediaSample, which gives the front end
64 // read-only access to the Stream's MediaPacketList. PrepareMediaSample should
65 // examine the list to determine how much it wishes to consume, and
66 // should copy any data it requires from the MediaPacket objects into
67 // local storage.
68 // This function call takes place under a mutex lock to ensure integrity
69 // of the list structure. It should be fast and must not contain any
70 // cancellation points, such as I/O calls for logging.
71 //
72 // Second, the Stream releases the mutex and calls DeliverMediaSample.
73 // This function delivers data from the Stream buffer to the presentation
74 // device and returns information to the Stream regarding how many MediaPackets
75 // were consumed. Any data copied from the MediaPackets objects during
76 // PrepareMediaSample is guaranteed by the Stream still to be valid
77 // during the following DeliverMediaSample call.
78
79     // samplepos is equal to the number of bytes from the first MediaPacket
80     // in the list that have already been consumed in a previous call.
81     virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos)=0;
82
83     // The Stream guarantees that the value of *samplepos passed to
84     // DeliverMediaSample will be equal to the value of samplepos passed to
85     // PrepareMediaSample in the previous call.
86     // This function should consume data from the buffer according to the
87     // decisions made in PrepareMediaSample. Its return value and *samplepos
88     // tell the Stream how much data it consumed.
89     // If DeliverMediaSample returns X, the Stream will remove packets 0 to X-1
90     // (inclusive) from the list before the next call.
91     // DeliverMediaSample must also set *samplepos equal to the number of bytes
92     // processed from packet X (usually zero).
93     virtual UINT DeliverMediaSample(const UCHAR* buffer, UINT *samplepos)=0;
94 };
95
96 #endif