Mercurial > hg > nodescore
comparison oscpack/examples/OscDump.cpp @ 76:0ae87af84e2f
added oscgroups
author | Rob Canning <rob@foo.net> |
---|---|
date | Sun, 13 Jul 2014 10:07:41 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:3a2845e3156e | 76:0ae87af84e2f |
---|---|
1 /* | |
2 oscpack -- Open Sound Control (OSC) packet manipulation library | |
3 http://www.rossbencina.com/code/oscpack | |
4 | |
5 Copyright (c) 2004-2013 Ross Bencina <rossb@audiomulch.com> | |
6 | |
7 Permission is hereby granted, free of charge, to any person obtaining | |
8 a copy of this software and associated documentation files | |
9 (the "Software"), to deal in the Software without restriction, | |
10 including without limitation the rights to use, copy, modify, merge, | |
11 publish, distribute, sublicense, and/or sell copies of the Software, | |
12 and to permit persons to whom the Software is furnished to do so, | |
13 subject to the following conditions: | |
14 | |
15 The above copyright notice and this permission notice shall be | |
16 included in all copies or substantial portions of the Software. | |
17 | |
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
21 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR | |
22 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
23 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
25 */ | |
26 | |
27 /* | |
28 The text above constitutes the entire oscpack license; however, | |
29 the oscpack developer(s) also make the following non-binding requests: | |
30 | |
31 Any person wishing to distribute modifications to the Software is | |
32 requested to send the modifications to the original developer so that | |
33 they can be incorporated into the canonical version. It is also | |
34 requested that these non-binding requests be included whenever the | |
35 above license is reproduced. | |
36 */ | |
37 | |
38 /* | |
39 OscDump prints incoming OSC packets. Unlike the Berkeley dumposc program | |
40 OscDump uses a different printing format which indicates the type of each | |
41 message argument. | |
42 */ | |
43 | |
44 | |
45 #include <iostream> | |
46 #include <cstring> | |
47 #include <cstdlib> | |
48 | |
49 #if defined(__BORLANDC__) // workaround for BCB4 release build intrinsics bug | |
50 namespace std { | |
51 using ::__strcmp__; // avoid error: E2316 '__strcmp__' is not a member of 'std'. | |
52 } | |
53 #endif | |
54 | |
55 #include "osc/OscReceivedElements.h" | |
56 #include "osc/OscPrintReceivedElements.h" | |
57 | |
58 #include "ip/UdpSocket.h" | |
59 #include "ip/PacketListener.h" | |
60 | |
61 | |
62 class OscDumpPacketListener : public PacketListener{ | |
63 public: | |
64 virtual void ProcessPacket( const char *data, int size, | |
65 const IpEndpointName& remoteEndpoint ) | |
66 { | |
67 (void) remoteEndpoint; // suppress unused parameter warning | |
68 | |
69 std::cout << osc::ReceivedPacket( data, size ); | |
70 } | |
71 }; | |
72 | |
73 int main(int argc, char* argv[]) | |
74 { | |
75 if( argc >= 2 && std::strcmp( argv[1], "-h" ) == 0 ){ | |
76 std::cout << "usage: OscDump [port]\n"; | |
77 return 0; | |
78 } | |
79 | |
80 int port = 7000; | |
81 | |
82 if( argc >= 2 ) | |
83 port = std::atoi( argv[1] ); | |
84 | |
85 OscDumpPacketListener listener; | |
86 UdpListeningReceiveSocket s( | |
87 IpEndpointName( IpEndpointName::ANY_ADDRESS, port ), | |
88 &listener ); | |
89 | |
90 std::cout << "listening for input on port " << port << "...\n"; | |
91 std::cout << "press ctrl-c to end\n"; | |
92 | |
93 s.RunUntilSigInt(); | |
94 | |
95 std::cout << "finishing.\n"; | |
96 | |
97 return 0; | |
98 } | |
99 | |
100 |