root/branches/libfreebob-2.0/src/libstreaming/IsoStream.h

Revision 204, 3.2 kB (checked in by pieterpalmers, 18 years ago)

- ISO streaming infrastructure starts to look good
- client side infrastructure unexistant

Line 
1 /* $Id$ */
2
3 /*
4  *   FreeBob Streaming API
5  *   FreeBob = Firewire (pro-)audio for linux
6  *
7  *   http://freebob.sf.net
8  *
9  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>
10  *
11  *   This program is free software {} you can redistribute it and/or modify
12  *   it under the terms of the GNU General Public License as published by
13  *   the Free Software Foundation {} either version 2 of the License, or
14  *   (at your option) any later version.
15  *
16  *   This program is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY {} without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with this program {} if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  *
26  *
27  */
28 #ifndef __FREEBOB_ISOSTREAM__
29 #define __FREEBOB_ISOSTREAM__
30
31 #include <libraw1394/raw1394.h>
32 #include "../debugmodule/debugmodule.h"
33
34 namespace FreebobStreaming
35 {
36
37 class PacketBuffer;
38
39 /*!
40 \brief The Base Class for ISO streams
41 */
42
43 class IsoStream
44 {
45
46     public:
47
48                 enum EStreamType {
49                         EST_Receive,
50                         EST_Transmit
51                 };
52
53         IsoStream(enum EStreamType type, int channel) : m_type(type), m_channel(channel), m_port(0)
54         {};
55         IsoStream(enum EStreamType type, int channel, int port) : m_type(type), m_channel(channel), m_port(port)
56         {};
57         virtual ~IsoStream()
58         {};
59
60                 virtual void setVerboseLevel(int l) { setDebugLevel( l ); };
61
62                 int getChannel() {return m_channel;};
63                 int getPort() {return m_port;};
64
65                 enum EStreamType getType() { return m_type;};
66
67                 virtual int initialize() {return 0;};
68
69                 virtual int
70                         putPacket(unsigned char *data, unsigned int length,
71                               unsigned char channel, unsigned char tag, unsigned char sy,
72                                   unsigned int cycle, unsigned int dropped);
73                 virtual int
74                         getPacket(unsigned char *data, unsigned int *length,
75                               unsigned char *tag, unsigned char *sy,
76                               int cycle, unsigned int dropped, unsigned int max_length);
77        
78         protected:
79                 enum EStreamType m_type;
80                 int m_channel;
81                 int m_port;
82
83                 DECLARE_DEBUG_MODULE;
84
85 };
86
87 class IsoStreamBuffered : public IsoStream
88 {
89
90     public:
91
92         IsoStreamBuffered(int headersize,int buffersize, int max_packetsize, enum EStreamType type, int channel)
93                    : IsoStream(type,channel), m_headersize(headersize), m_buffersize(buffersize), m_max_packetsize(max_packetsize), buffer(0)
94         {};
95         virtual ~IsoStreamBuffered();
96
97                 void setVerboseLevel(int l);
98
99                 int initialize();
100
101                 int
102                         putPacket(unsigned char *data, unsigned int length,
103                               unsigned char channel, unsigned char tag, unsigned char sy,
104                                   unsigned int cycle, unsigned int dropped);
105                 int
106                         getPacket(unsigned char *data, unsigned int *length,
107                               unsigned char *tag, unsigned char *sy,
108                               int cycle, unsigned int dropped, unsigned int max_length);
109                 int getBufferFillPackets();
110                 int getBufferFillPayload();
111
112         protected:
113                 int m_headersize;
114                 int m_buffersize;
115                 int m_max_packetsize;
116
117                 PacketBuffer *buffer;
118
119                 DECLARE_DEBUG_MODULE;
120
121 };
122
123 }
124
125 #endif /* __FREEBOB_ISOSTREAM__ */
126
127
128
Note: See TracBrowser for help on using the browser.