In several cases a node must be configured before it can be used. In our MP3 player example, the MP3ReadNode needs the name of a file that should be read. Even though the clic-application offers a command line arguments for such a scenario, other nodes, like a node to encode video streams, can require some quality parameters which can not be set in this way. In this case you must call a node specific method, offered by an interface. Each method that can be called from an NMM-interface can be called from graph description as well. For this purpose you have to write the corresponding C++ method with all arguments prefaced by the character '$'. Furthermore you have to specify the state in which the method must be executed. For example the MP3ReadNode offers the method setFilename in one of its interfaces to set a MP3 file which must be called in the state INITIALIZED. Furthermore you want to change the queue of the MPEGAudioDecodeNode for incoming buffers that can be done using the method setDownstreamMaxSize which must be called in the state CONSTRUCTED. Note: All configuration parameters must be written after the node configuration parameters which are prefaced by the character '#' and before the connection parameters introduces by the character '@'. The following example shows how to call these two methods from a graph description.
% This graph description describes a simple MP3 player and shows how to
% call interface methods from a graph description. So it is not required
% to set the input file using the option -i of clic.
MP3ReadNode $ setFilename("/home/bob/audio/song.mp3") INITIALIZED !
MPEGAudioDecodeNode $ setDownstreamMaxSize(1, "default") CONSTRUCTED !
PlaybackNode
|
Be careful using this feature! The given arguments are read as strings and converted to the expected type. So it can cause curious errors if you set invalid arguments due to the lack of type safety! Furthermore, you must specify all arguments! Default arguments like in C++ are currently not supported.
At least you can also specify the transport protocol that is used to control the node. The parameter setEventStrategy prefaced by the character '$' is used to specify the transport strategy that is used to forward interface method calls to its node. If this parameter is not set, the default transport strategy proposed by the NMM middleware is used, which is a LocalStrategy for nodes in the address space of the application and TCPStrategy for nodes running on a different host or address space. The following example shows how to use this parameter.
MP3ReadNode $ setEventStrategy("TCPStrategy") !
MPEGAudioDecodeNode !
PlaybackNode
|