1 |
/*************************************************************************** |
---|
2 |
Copyright (C) 2005 by Pieter Palmers * |
---|
3 |
* |
---|
4 |
This program is free software; you can redistribute it and/or modify * |
---|
5 |
it under the terms of the GNU General Public License as published by * |
---|
6 |
the Free Software Foundation; either version 2 of the License, or * |
---|
7 |
(at your option) any later version. * |
---|
8 |
* |
---|
9 |
This program is distributed in the hope that it will be useful, * |
---|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
12 |
GNU General Public License for more details. * |
---|
13 |
* |
---|
14 |
You should have received a copy of the GNU General Public License * |
---|
15 |
along with this program; if not, write to the * |
---|
16 |
Free Software Foundation, Inc., * |
---|
17 |
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
18 |
***************************************************************************/ |
---|
19 |
|
---|
20 |
#ifdef HAVE_CONFIG_H |
---|
21 |
#include <config.h> |
---|
22 |
#endif |
---|
23 |
|
---|
24 |
#include <stdio.h> |
---|
25 |
#include <stdlib.h> |
---|
26 |
#include <string.h> |
---|
27 |
|
---|
28 |
#include <signal.h> |
---|
29 |
#include "debugmodule/debugmodule.h" |
---|
30 |
|
---|
31 |
#include "IsoHandler.h" |
---|
32 |
#include "IsoStream.h" |
---|
33 |
#include "StreamProcessorManager.h" |
---|
34 |
#include "AmdtpStreamProcessor.h" |
---|
35 |
#include "IsoHandlerManager.h" |
---|
36 |
#include "StreamRunner.h" |
---|
37 |
#include "FreebobPosixThread.h" |
---|
38 |
|
---|
39 |
using namespace FreebobStreaming; |
---|
40 |
|
---|
41 |
int run; |
---|
42 |
|
---|
43 |
static void sighandler (int sig) |
---|
44 |
{ |
---|
45 |
run = 0; |
---|
46 |
} |
---|
47 |
|
---|
48 |
int main(int argc, char *argv[]) |
---|
49 |
{ |
---|
50 |
|
---|
51 |
int retval=0; |
---|
52 |
int i=0; |
---|
53 |
run=1; |
---|
54 |
|
---|
55 |
signal (SIGINT, sighandler); |
---|
56 |
signal (SIGPIPE, sighandler); |
---|
57 |
|
---|
58 |
printf("Freebob streaming test application\n"); |
---|
59 |
printf(" ISO handler tests\n"); |
---|
60 |
|
---|
61 |
// the first thing we need is a ISO handler manager |
---|
62 |
IsoHandlerManager *isomanager = new IsoHandlerManager(); |
---|
63 |
if(!isomanager) { |
---|
64 |
printf("Could not create IsoHandlerManager\n"); |
---|
65 |
return -1; |
---|
66 |
} |
---|
67 |
|
---|
68 |
isomanager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
69 |
printf("----------------------\n"); |
---|
70 |
|
---|
71 |
// also create a processor manager to manage the actual stream |
---|
72 |
// processors |
---|
73 |
StreamProcessorManager *procMan = new StreamProcessorManager(512,3); |
---|
74 |
if(!procMan) { |
---|
75 |
printf("Could not create StreamProcessorManager\n"); |
---|
76 |
return -1; |
---|
77 |
} |
---|
78 |
procMan->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
79 |
|
---|
80 |
// now we can allocate the stream processors themselves |
---|
81 |
|
---|
82 |
// StreamProcessor *spt = new AmdtpTransmitStreamProcessor(3,2,44100,10); |
---|
83 |
// if(!spt) { |
---|
84 |
// printf("Could not create transmit AmdtpTransmitStreamProcessor\n"); |
---|
85 |
// return -1; |
---|
86 |
// } |
---|
87 |
// spt->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
88 |
|
---|
89 |
// AmdtpReceiveStreamProcessor *spr = new AmdtpReceiveStreamProcessor(0,2,44100,7); |
---|
90 |
ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100); |
---|
91 |
if(!spr) { |
---|
92 |
printf("Could not create receive AmdtpStreamProcessor\n"); |
---|
93 |
return -1; |
---|
94 |
} |
---|
95 |
spr->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
96 |
|
---|
97 |
// if (isomanager->registerStream(spt)) { |
---|
98 |
// printf("Could not register transmit stream processor with the ISO manager\n"); |
---|
99 |
// return -1; |
---|
100 |
// } |
---|
101 |
// printf("----------------------\n"); |
---|
102 |
|
---|
103 |
|
---|
104 |
// now we have an xmit stream, |
---|
105 |
// register it with the manager that assigns an iso handler |
---|
106 |
|
---|
107 |
if (isomanager->registerStream(spr)) { |
---|
108 |
printf("Could not register receive stream processor with the ISO manager\n"); |
---|
109 |
return -1; |
---|
110 |
} |
---|
111 |
printf("----------------------\n"); |
---|
112 |
|
---|
113 |
|
---|
114 |
// printf("----------------------\n"); |
---|
115 |
// if (procMan->registerProcessor(spt)) { |
---|
116 |
// printf("Could not register transmit stream processor with the Processor manager\n"); |
---|
117 |
// return -1; |
---|
118 |
// } |
---|
119 |
// printf("----------------------\n"); |
---|
120 |
|
---|
121 |
// also register it with the processor manager, so that it is aware of |
---|
122 |
// buffer sizes etc... |
---|
123 |
if (procMan->registerProcessor(spr)) { |
---|
124 |
printf("Could not register receive stream processor with the Processor manager\n"); |
---|
125 |
return -1; |
---|
126 |
} |
---|
127 |
printf("----------------------\n"); |
---|
128 |
|
---|
129 |
// now create the runner that does the actual streaming |
---|
130 |
StreamRunner *runner = new StreamRunner(isomanager,procMan); |
---|
131 |
if(!runner) { |
---|
132 |
printf("Could not create StreamRunner\n"); |
---|
133 |
return -1; |
---|
134 |
} |
---|
135 |
|
---|
136 |
FreebobPosixThread *thread=new FreebobPosixThread(runner); |
---|
137 |
|
---|
138 |
// start the runner |
---|
139 |
thread->Start(); |
---|
140 |
printf("----------------------\n"); |
---|
141 |
|
---|
142 |
if(isomanager->startHandlers()) { |
---|
143 |
printf("Could not start handlers\n"); |
---|
144 |
return -1; |
---|
145 |
} |
---|
146 |
printf("----------------------\n"); |
---|
147 |
|
---|
148 |
while(run) { |
---|
149 |
printf("\n"); |
---|
150 |
printf("============================================\n"); |
---|
151 |
isomanager->dumpInfo(); |
---|
152 |
printf("--------------------------------------------\n"); |
---|
153 |
procMan->dumpInfo(); |
---|
154 |
printf("============================================\n"); |
---|
155 |
printf("\n"); |
---|
156 |
|
---|
157 |
sleep(1); |
---|
158 |
} |
---|
159 |
|
---|
160 |
thread->Stop(); |
---|
161 |
|
---|
162 |
isomanager->stopHandlers(); |
---|
163 |
|
---|
164 |
// isomanager->unregisterStream(spt); |
---|
165 |
isomanager->unregisterStream(spr); |
---|
166 |
|
---|
167 |
// procMan->unregisterProcessor(spt); |
---|
168 |
procMan->unregisterProcessor(spr); |
---|
169 |
|
---|
170 |
delete thread; |
---|
171 |
delete runner; |
---|
172 |
delete procMan; |
---|
173 |
delete isomanager; |
---|
174 |
|
---|
175 |
// delete spt; |
---|
176 |
delete spr; |
---|
177 |
|
---|
178 |
printf("Bye...\n"); |
---|
179 |
|
---|
180 |
|
---|
181 |
return EXIT_SUCCESS; |
---|
182 |
} |
---|