Dbwave
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | This module works with [[wavefile]] and a database driver | + | This module works with [[wavefile]] module and a database driver, currently only [[MySQL]]. |
+ | |||
+ | The module is used to play or record wave sounds. The wave sounds are kept in binary database records. | ||
+ | |||
+ | ===Play a wave record=== | ||
From a routing module you can play a wave record like this: | From a routing module you can play a wave record like this: | ||
Line 12: | Line 16: | ||
^1$=fork;callto.1=dbwave/play//path/to/fallback/file/audiotoplay.slin;callto.1.callto_account=dbaccount;callto.1.callto_query=SELECT binary_field FROM table WHERE condition | ^1$=fork;callto.1=dbwave/play//path/to/fallback/file/audiotoplay.slin;callto.1.callto_account=dbaccount;callto.1.callto_query=SELECT binary_field FROM table WHERE condition | ||
;callto.1.fork.autoring=true;callto.2=error;stoperror=busy;autoanswer=yes | ;callto.1.fork.autoring=true;callto.2=error;stoperror=busy;autoanswer=yes | ||
+ | |||
+ | ===Record a wave file=== | ||
To record a wave you can use this: | To record a wave you can use this: | ||
Line 26: | Line 32: | ||
* '''${data}''' - holds the collected binary data | * '''${data}''' - holds the collected binary data | ||
* '''${length}''' - holds the length of the data in bytes | * '''${length}''' - holds the length of the data in bytes | ||
+ | |||
+ | ===Parameters=== | ||
The name of the parameters holding the database account and the query depends on the relevant parameter of the message. | The name of the parameters holding the database account and the query depends on the relevant parameter of the message. | ||
Line 34: | Line 42: | ||
This way you can specify different accounts and queries even if you attach or record multiple data channels in the same message. | This way you can specify different accounts and queries even if you attach or record multiple data channels in the same message. | ||
− | For [[ | + | For [[call.execute]] (when routing directly to the module) the relevant parameter is '''callto'''. |
=== Example=== | === Example=== | ||
Line 42: | Line 50: | ||
%%>message:<id>:<time>:chan.attach::consumer=dbwave/record/arbitrary.alaw:notify=myid42:single=true:consumer_account=dbaccount:consumer_query=INSERT INTO table(len,data) | %%>message:<id>:<time>:chan.attach::consumer=dbwave/record/arbitrary.alaw:notify=myid42:single=true:consumer_account=dbaccount:consumer_query=INSERT INTO table(len,data) | ||
VALUES('${length}','${data}') | VALUES('${length}','${data}') | ||
+ | |||
+ | '''See also''' | ||
+ | |||
+ | * [[Modules]] | ||
+ | |||
+ | [[Category:Wave]] [[Category:Database]] |
Latest revision as of 12:10, 4 November 2013
This module works with wavefile module and a database driver, currently only MySQL.
The module is used to play or record wave sounds. The wave sounds are kept in binary database records.
Contents |
[edit] Play a wave record
From a routing module you can play a wave record like this:
^1$=dbwave/play//path/to/fallback/file/audiotoplay.slin;callto_account=dbaccount;callto_query=SELECT binary_field FROM table WHERE condition Or new syntax since Yate 3.3.3 To play a sound file and hangup the call ^1$=fork;callto.1=dbwave/play//path/to/fallback/file/audiotoplay.slin;callto.1.callto_account=dbaccount;callto.1.callto_query=SELECT binary_field FROM table WHERE condition ;callto.1.fork.autoring=true;callto.2=error;stoperror=busy;autoanswer=yes
[edit] Record a wave file
To record a wave you can use this:
^1$=dbwave/record//path/to/file/audiorecorded.slin;callto_account=dbaccount;callto_query=INSERT INTO table(binary_field) VALUES('$($){data}')
In the example above the construction $($){data} is specific to regexroute. The raw string required is ${data}
The matching call.execute, chan.attach and chan.record messages are modified just before being received by wavefile.
For playback (parameters source, override or replace) the query is executed and the result (must be exactly 1 row, 1 column, binary) is passed to the wavefile module as a DataBlock.
For recording (parameters consumer, call or peer) a memory stream is created that executes the query after all data is collected. The query can contain two variable parameters:
- ${data} - holds the collected binary data
- ${length} - holds the length of the data in bytes
[edit] Parameters
The name of the parameters holding the database account and the query depends on the relevant parameter of the message.
- param - holds the desired attach or record (example: override)
- param_account - holds the database account used (example: override_account)
- param_query - holds the query to execute (example: override_query)
This way you can specify different accounts and queries even if you attach or record multiple data channels in the same message.
For call.execute (when routing directly to the module) the relevant parameter is callto.
[edit] Example
To record wave data from an external module do this:
%%>message:<id>:<time>:chan.attach::consumer=dbwave/record/arbitrary.alaw:notify=myid42:single=true:consumer_account=dbaccount:consumer_query=INSERT INTO table(len,data) VALUES('${length}','${data}')
See also