7 #ifndef __PVSAMPLETRANSMITTERCONFIG_H__
8 #define __PVSAMPLETRANSMITTERCONFIG_H__
10 #include <PvSampleUtils.h>
12 #include <PvNetworkAdapter.h>
18 #define DEFAULT_NUMBER_OF_BUFFERS ( 48 )
19 #define DEFAULT_SOURCE_ADDRESS ( "" )
20 #define DEFAULT_DESTINATION_ADDRESS ( "239.192.1.1" )
21 #define DEFAULT_DESTINATION_PORT ( 1042 )
22 #define DEFAULT_SOURCE_PORT ( 0 )
23 #define DEFAULT_BUFFER_COUNT ( 4 )
24 #define DEFAULT_PACKET_SIZE ( 1440 )
25 #define DEFAULT_FPS ( 30 )
26 #define DEFAULT_SILENT ( false )
29 #ifndef PV_GENERATING_DOXYGEN_DOC
33 class PvSampleTransmitterConfig
37 PvSampleTransmitterConfig()
42 ~PvSampleTransmitterConfig()
46 const char *GetSourceAddress()
const {
return mSourceAddress.c_str(); }
47 uint16_t GetSourcePort()
const {
return mSourcePort; }
48 const char *GetDestinationAddress()
const {
return mDestinationAddress.c_str(); }
49 uint16_t GetDestinationPort()
const {
return mDestinationPort; }
50 float GetFPS()
const {
return mFPS; }
51 bool GetSilent()
const {
return mSilent; }
52 uint32_t GetPacketSize()
const {
return mPacketSize; }
53 uint32_t GetBufferCount()
const {
return mBufferCount; }
55 virtual void ParseCommandLine(
int aCount,
const char **aArgs )
57 if ( ParseOptionFlag( aCount, aArgs,
"--help" ) )
63 ParseOption<float>( aCount, aArgs,
"--fps", mFPS );
64 ParseOption<uint32_t>( aCount, aArgs,
"--packetsize", mPacketSize );
65 ParseOption<string>( aCount, aArgs,
"--destinationaddress", mDestinationAddress );
66 ParseOption<uint16_t>( aCount, aArgs,
"--destinationport", mDestinationPort );
67 ParseOption<string>( aCount, aArgs,
"--sourceaddress", mSourceAddress );
68 ParseOption<uint16_t>( aCount, aArgs,
"--sourceport", mSourcePort );
69 ParseOption<uint32_t>( aCount, aArgs,
"--buffercount", mBufferCount );
70 ParseOptionFlag( aCount, aArgs,
"--silent", &mSilent );
71 if ( mDestinationPort == 0 )
73 cout <<
"Please enter a destination port." << endl;
74 cin >> mDestinationPort;
78 virtual void PrintHelp()
80 cout <<
"Optional command line arguments:" << endl << endl;
82 cout <<
"--help " << endl <<
"Print this help message." << endl << endl;
84 cout <<
"--packetsize=<maximimum size of streaming packets>" << endl;
85 cout <<
"Default: 1440 For best results, set \"Jumbo Frames\" property on your NIC and increase this value accordingly." << endl << endl;
87 cout <<
"--destinationaddress=<destination address in the form 123.456.789.101>" << endl;
88 cout <<
"Default: " << DEFAULT_DESTINATION_ADDRESS << endl << endl;
90 cout <<
"--destinationport=<destination port>" << endl;
91 cout <<
"Default: " << DEFAULT_DESTINATION_PORT << endl << endl;
93 cout <<
"--sourceaddress=<source address in the form 123.456.789.101>" << endl;
94 cout <<
"Default: first valid address encountered while enumerating interfaces" << endl << endl;
96 cout <<
"--sourceport=<source port>" << endl;
97 cout <<
"Default: " << DEFAULT_SOURCE_PORT <<
" - a port is automatically assigned when the socket is opened" << endl << endl;
99 cout <<
"--buffercount=<number of transmit buffers to use>" << endl;
100 cout <<
"Default: " << DEFAULT_BUFFER_COUNT <<
" - increase this number when sending smaller images at high frame rates." << endl << endl;
102 cout <<
"--silent" << endl;
103 cout <<
"Don't wait for a key press." << endl;
104 cout <<
"By default, the system waits for a key press before it begins transmitting. " << endl << endl;
106 cout <<
"--fps=<frame per second>" << endl;
107 cout <<
"Default: " << DEFAULT_FPS << endl << endl;
123 if ( lNetworkAdapter == NULL )
129 for ( uint32_t j = 0; j < lIPCount; j++ )
132 if ( strcmp(
"0.0.0.0", lIP.
GetAscii() ) != 0 )
141 cout <<
"No valid interfaces found." << endl;
146 mDestinationAddress = DEFAULT_DESTINATION_ADDRESS;
147 mDestinationPort = DEFAULT_DESTINATION_PORT;
148 mSourcePort = DEFAULT_SOURCE_PORT;
149 mPacketSize = DEFAULT_PACKET_SIZE;
150 mBufferCount = DEFAULT_BUFFER_COUNT;
152 mSilent = DEFAULT_SILENT;
155 string mSourceAddress;
156 uint16_t mSourcePort;
158 string mDestinationAddress;
159 uint16_t mDestinationPort;
164 uint32_t mPacketSize;
165 uint32_t mBufferCount;
170 #endif // PV_GENERATING_DOXYGEN_DOC