root/branches/libfreebob-2.0/tests/streaming/test-isohandling.cpp

Revision 205, 4.1 kB (checked in by pieterpalmers, 18 years ago)

- test files

Line 
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 "StreamProcessor.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         IsoStream *xms = new IsoStream(IsoStream::EST_Transmit,2,2);
62         if(!xms) {
63                 printf("Could not create transmit IsoStream\n");
64                 return -1;
65         }
66         xms->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
67
68         IsoStream *rcs = new IsoStream(IsoStream::EST_Receive,0,2);
69         if(!rcs) {
70                 printf("Could not create receive IsoStream\n");
71                 return -1;
72         }
73         rcs->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
74
75         IsoStream *rcs2 = new IsoStream(IsoStream::EST_Receive,1,2);
76         if(!rcs2) {
77                 printf("Could not create receive IsoStream\n");
78                 return -1;
79         }
80         rcs2->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
81
82         // now we have an xmit stream, attached to an xmit handler
83         // register it with the manager
84
85         IsoHandlerManager *isomanager = new IsoHandlerManager();
86         if(!isomanager) {
87                 printf("Could not create IsoHandlerManager\n");
88                 return -1;
89         }
90
91         isomanager->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
92        
93         if (isomanager->registerStream(xms)) {
94                 printf("Could not register transmit handler with the manager\n");
95                 return -1;
96         }
97         if (isomanager->registerStream(rcs)) {
98                 printf("Could not register receive handler with the manager\n");
99                 return -1;
100         }
101         if (isomanager->registerStream(rcs2)) {
102                 printf("Could not register receive handler 2 with the manager\n");
103                 return -1;
104         }
105         // also create a processor as a dummy for the stream runner
106        
107         StreamProcessorManager *procMan = new StreamProcessorManager(512);
108         if(!procMan) {
109                 printf("Could not create StreamProcessor\n");
110                 return -1;
111         }
112
113         // now create the runner that does the actual streaming
114         StreamRunner *runner = new StreamRunner(isomanager,procMan);
115         if(!runner) {
116                 printf("Could not create StreamRunner\n");
117                 return -1;
118         }
119
120         FreebobPosixThread *thread=new FreebobPosixThread(runner);
121
122         // start the runner
123         thread->Start();
124
125         if(isomanager->startHandlers()) {
126                 printf("Could not start handlers\n");
127                 return -1;
128         }
129
130         while(run) {
131                 isomanager->dumpInfo();
132                 sleep(1);
133         }
134
135         thread->Stop();
136
137         isomanager->stopHandlers();
138
139         isomanager->unregisterStream(xms);
140         isomanager->unregisterStream(rcs);
141         isomanager->unregisterStream(rcs2);
142
143         delete thread;
144         delete runner;
145         delete procMan;
146         delete isomanager;
147
148         delete rcs2;
149         delete rcs;
150         delete xms;
151
152         printf("Bye...\n");
153
154
155   return EXIT_SUCCESS;
156 }
Note: See TracBrowser for help on using the browser.