root/branches/libfreebob-2.0/src/libstreaming/StreamProcessor.cpp

Revision 221, 5.0 kB (checked in by pieterpalmers, 18 years ago)

--

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
29 #include "StreamProcessor.h"
30 #include "StreamProcessorManager.h"
31 #include <assert.h>
32
33 namespace FreebobStreaming {
34
35 IMPL_DEBUG_MODULE( StreamProcessor, StreamProcessor, DEBUG_LEVEL_NORMAL );
36 IMPL_DEBUG_MODULE( ReceiveStreamProcessor, ReceiveStreamProcessor, DEBUG_LEVEL_NORMAL );
37 IMPL_DEBUG_MODULE( TransmitStreamProcessor, TransmitStreamProcessor, DEBUG_LEVEL_NORMAL );
38
39 StreamProcessor::StreamProcessor(enum IsoStream::EStreamType type, int channel, int port, int framerate)
40         : IsoStream(type, channel, port)
41         , m_manager(0)
42         , m_nb_buffers(0)
43         , m_period(0)
44         , m_xruns(0)
45         , m_framecounter(0)
46         , m_framerate(framerate)
47 {
48
49 }
50
51 StreamProcessor::~StreamProcessor() {
52
53 }
54
55 int StreamProcessor::putPacket(unsigned char *data, unsigned int length,
56                               unsigned char channel, unsigned char tag, unsigned char sy,
57                                   unsigned int cycle, unsigned int dropped) {
58
59         debugWarning("BUG: received packet in StreamProcessor base class!\n");
60
61         return -1;
62 }
63
64 int StreamProcessor::getPacket(unsigned char *data, unsigned int *length,
65                               unsigned char *tag, unsigned char *sy,
66                               int cycle, unsigned int dropped, unsigned int max_length) {
67        
68         debugWarning("BUG: packet requested from StreamProcessor base class!\n");
69
70         return -1;
71 }
72
73 void StreamProcessor::dumpInfo()
74 {
75
76         debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor information\n");
77         debugOutputShort( DEBUG_LEVEL_NORMAL, "  Iso stream info:\n");
78        
79         ((IsoStream*)this)->dumpInfo();
80         debugOutputShort( DEBUG_LEVEL_NORMAL, "  Frame counter  : %d\n", m_framecounter);
81         debugOutputShort( DEBUG_LEVEL_NORMAL, "  Xruns          : %d\n", m_xruns);
82        
83 };
84
85 int StreamProcessor::init()
86 {
87         debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n");
88         if(!m_manager) {
89                 debugFatal("Not attached to a manager!\n");
90                 return -1;
91         }
92
93         m_nb_buffers=m_manager->getNbBuffers();
94         debugOutputShort( DEBUG_LEVEL_VERBOSE, "Setting m_nb_buffers  : %d\n", m_nb_buffers);
95
96         m_period=m_manager->getPeriodSize();
97         debugOutputShort( DEBUG_LEVEL_VERBOSE, "Setting m_period      : %d\n", m_period);
98
99
100         return IsoStream::init();
101 }
102
103 void StreamProcessor::reset() {
104
105         debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n");
106
107         m_framecounter=0;
108
109         // loop over the ports to reset them
110         PortManager::reset();
111
112         // reset the iso stream
113         IsoStream::reset();
114
115 }
116
117 void StreamProcessor::prepare() {
118
119         debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");
120 // TODO: implement
121
122         // init the ports
123        
124
125         // loop over the ports to reset them
126         PortManager::prepare();
127
128         // reset the iso stream
129         IsoStream::prepare();
130
131 }
132
133 int StreamProcessor::transfer() {
134
135         debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Transferring period...\n");
136 // TODO: implement
137
138         return 0;
139 }
140
141 void StreamProcessor::setVerboseLevel(int l) {
142         setDebugLevel(l);
143         IsoStream::setVerboseLevel(l);
144         PortManager::setVerboseLevel(l);
145
146 }
147
148
149 ReceiveStreamProcessor::ReceiveStreamProcessor(int channel, int port, int framerate)
150         : StreamProcessor(IsoStream::EST_Receive, channel, port, framerate) {
151
152 }
153
154 ReceiveStreamProcessor::~ReceiveStreamProcessor() {
155
156 }
157
158 int ReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length,
159                               unsigned char channel, unsigned char tag, unsigned char sy,
160                                   unsigned int cycle, unsigned int dropped) {
161
162         debugOutput( DEBUG_LEVEL_VERY_VERBOSE,
163                      "received packet: length=%d, channel=%d, cycle=%d\n",
164                      length, channel, cycle );
165
166         return 0;
167 }
168
169 void ReceiveStreamProcessor::setVerboseLevel(int l) {
170         setDebugLevel(l);
171         StreamProcessor::setVerboseLevel(l);
172
173 }
174
175
176 TransmitStreamProcessor::TransmitStreamProcessor(int channel, int port, int framerate)
177         : StreamProcessor(IsoStream::EST_Transmit, channel, port, framerate) {
178
179 }
180
181 TransmitStreamProcessor::~TransmitStreamProcessor() {
182
183 }
184
185 int TransmitStreamProcessor::getPacket(unsigned char *data, unsigned int *length,
186                       unsigned char *tag, unsigned char *sy,
187                       int cycle, unsigned int dropped, unsigned int max_length) {
188         *length=0;
189         *tag = 1;
190         *sy = 0;
191
192         return 0;
193 }
194
195 void TransmitStreamProcessor::setVerboseLevel(int l) {
196         setDebugLevel(l);
197         StreamProcessor::setVerboseLevel(l);
198
199 }
200
201 }
Note: See TracBrowser for help on using the browser.