My problem is that Asterisk seems to be answering the phone just a bit too late after the "Hello?" for the AMD functionality to work right, i.e. the AMD comes in on the silence and the person has to say hello again for it to know there's a person there.
We've tested it using IAX via a softphone and see more or less the same delay upon answering so we're assuming it's the Asterisk configuration.
I have more or less a vanilla Asterisk install. We are initiating outbound calls via SIP through a local provider. I'm using the "Manager" portion of the Java Asterisk API to tell Asterisk to make the call and then the Java Agi API to deal with it.
The SIP portion of the config looks like this (sip.conf):
[my-sip-trunk]
disallow=all
allow=ulaw
allow=alaw
allow=gsm
host=<ip to our provider>
type=peer
canreinvite=no
nat=never
The data I send via the Manager to Asterisk looks something like this:
Channel: SIP/<phonenumberhere>#my-sip-trunk
Context: MyContext
Extension: 100
Priority: 1
Caller ID: <caller's caller ID>
In my extensions.conf I have the appropriate info and-- solely for the purpose of this demonstration-- only a couple of commands:
[MyContext]
exten => 100,1,Answer()
exten => 100,n,Background(beep)
What happens is I pick up the phone, have time to say, "Hello?" and have the beep occur shortly after I finish speaking. The beep tells me when the AMD would have started listning-- but since it's past when I started speaking it will only hear silence.
Does anyone have any ideas where/how I've misconfigured Asterisk to have this delay?
SIP call progress analysis is notoriously fickle (it basically doesn't work).
What I've had to do in the past is use a SIP proxy that analyzes the audio in-band, and then passes the result back to Asterisk.
Check out Sangoma Call Analyzer.
Related
I have installed touchOSC on my phone and I would like to control the score editor Musescore (that accept OSC messages).
Problem: touchOSC send messages always together with a double value while a lot of controls I'd like to use in Musescore has a method signature with no arguments at all (e.g. /actions/play to start playback of the score).
So, the only way I'm figuring out right now is to write a sort of listener (python? java?) listening to touchOSC, changing the message (typically, cutting the double value) and sending the modified message to the right port for Musescore.
I have some Java skills but I wouldn't know how to manage OSC message.
I have also downloaded a python library named simpleOSC but I have 0 skills in python.
Could someone help?
Thank you very much
https://pypi.python.org/pypi/SimpleOSC
I'd recommend to use PureData for this: https://puredata.info/
It's free, open-source, cross-platform and is equipped to do what you want: Receive OSC messages and filter/modify/forward them, all in a visual, flow-based programming way.
Here's the "TouchOSC | OSC with PureData" tutorial, which has some basic example PD patchers as well to get you started:
https://hexler.net/docs/touchosc-getting-started-osc
Kind of a followup to this question, I have been able to:
Find the device for with which I am working, disconnect it from the kernel, and claim the (single) interface. . . and that's about as far as I can get.
When I try to write to the device (which is a custom wireless transceiver, not my own design), I get (when using LibUsb.bulkTransfer with the endpoint 0x00):
LibUsb.bulkTransfer(handle, (byte)0x00, bb, transfered, 5000);
an Input/Output error, and (when using LibUsb.bulkTransfer with the endpoint 0x81):
LibUsb.bulkTransfer(handle, (byte)0x81, bb, transfered, 5000);
a TimeOut error.
I'm pretty sure I have absolutely NO idea what I'm doing here (which doesn't help my position), and this is way deeper than I am accustomed to going as far as communicating with devices on a lower level (the most I've done is interop with .Net).
I've seen the lsusb command and executed it and gotten... a lot of stuff, and I can recognize some of it, but most of it I'm kind of lost with and was hoping for someone to hold my hand, or point me to a sort of... USB for Dummies guide that might help me figure out what I need to do.
The end result (ideally) will be a Java package that allows cross-platform communication with the device without any sort of tinkering on behalf of the end-user (and by cross-platform I mean, windows, linux and mac, which is why I'm using the java4usb java library).
Where I am right now is, using the output from the lsusb command, I'm hoping to be able to send commands from the transceiver to the external device with which it communicates. (basically it sends commands to a device connected to an LED that can turn the LED on and off, and make it flash, and it also can receive commands from that device and respond accordingly to them, but baby steps).
The lsusb output you can find here (it's quite verbose, and I didn't want to flood the question with more than necessary). Any help or direction would be tremendously appreciated.
EDIT: A bit more research reveals (from the lsusb output) that the 0x81 endpoint is an interrupt type. Putting 2 and 2 together lead me to the conclusion that I wanted neither a bulk transfer nor a control transfer but an interrupt transfer:
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval
LibUsb.interruptTransfer(handle, (byte)0x81, bb, transfered, 1000);
Unfortunately I'm still getting a Timeout error.
EDIT: Some more information is needed:
It has been suggested for Synchronous control (which is fine for half of what I need to do) that I should use the usb4java.LibUsb controlTransfer method, which is fine but there are several parameters that need to be filled, and I do not know what it is with that they need to be filled:
public static int controlTransfer(DeviceHandle handle, //I know this.
byte bmRequestType, //<--- What goes here?
byte bRequest, //<--- What goes here?
short wValue, //<--- What goes here?
short wIndex, //<--- What goes here?
ByteBuffer data, //<--- What goes here?
long timeout) //<--- What goes here?
Any and all direction to the answer to what I need to populate these fields with would be a great help and greatly appreciated.
I'm working with Java and JSP. I have to create something like a promotion which has start date and end date. Within the start date and end date, it will show a form that is corresponding to the promotion; otherwise, it will be just show a normal page. I have done the validation based on the time they open the page. I can manipulate the time in Unit Testing by making the current time to any time I want.
However, the problem is when I want to pass this to client to test. They want to see how it's like on the promotion day? Does the promotion really show on a particular time? Does it really close afterwards? One possible way is to secretly pass current date as HTTP param when trying to access the page. Doing so, client can check how the system behaves on a particular day but it's very dangerous indeed. Anyone who knows this will be able to access the promotion anytime they want. I don't know what the best way to handle this.
What's your suggestion?
It sounds like a bad idea basing ANY of your JSP (server-side) code on time being sent from a client. It would be much better to handle this entirely server side and have some way of configuring the time via which you and your client can do testing.
1) if the client is really concerned (or your application is complex) - it may be that the ONLY way to do such a test reasonably is to change the server time as suggested by Nathan Hoad's comment. Every other test comes with confidence since it relies on something other than the time ticking over and "triggering" the promotion to start or end. Also keep in mind the activities that occur during the promotion - do they use the system time to make decisions or store the date/time in a database etc?
2) if #1 isn't a real issue I would have your code that checks the time (for the trigger of the promotion) to call a custom function in your code (eg. getCustomTime()). That method will by default return the system time, but also checks to see if an offset has been configured and use that to offset the actual time. The offset can be dynamically configured.
Good luck.
Firstly, you shouldn't be putting this functionality onto a live production server, so the "very dangerous" exposure shouldn't happen.
I'd try a "belt and braces" approach:
Set up a demo server that only has read-only access so can't do any damage
Tell the client the secret parameter to use
Have the "client promotion demo" feature switchable on/off from an admin console
(If you're really nervous) limit access to only the client's IP
The client can access the demo box and check everything works perfectly. When they are happy, you deploy to production, but with the "demo mode" disabled, so only the "time-sensitive" way of accessing the promotion will work.
You don't have to tweak the time on your server to demo this to the client. Just have a promotion that is expired in the system, one that is currently active and another that is in the future on three different items, and show the customer the effects.
Either that, or create a promotion during your presentation that takes effect one minute in the future, lasts for 2-3 minutes and then expires, then talk through it and click around and show them the effects.
I want to write a program that will be able to call into my company's bi-weekly conference calls, and record the call, so it can then be made into a podcast.
I am thinking of using Gizmo's SIP interface (and the fact that it allows you to make toll-free calls for free), but I am having trouble finding any example code (preferably in Java) that will be able to make an audio call, and get hold of the audio stream.
I have seen plenty of SIP programming tutorials that deal with establishing a session, and then they seem to just do some hand waving, and say "here is where you can establish the audio connection" without actually doing it.
I am experienced in Java, so I would prefer to use it, but other language suggestions are welcome as well.
I have never written a VOIP application, so I'm not really sure where to start. Can anyone suggest a good library or other resource that would help me get started?
Thanks!
Look for a VOIP softphone writtin in Java, then modify it to save the final audio stream instead of sending it to be played.
Side note: In many states you would be violating the law unless you do one of several things, varying by state: Notify the participants they're being recorded, insert BEEPs every N seconds, both, etc. Probably you only have to comply with the laws of the state you're calling from. Even worse, you may need to allow the users to decline recording (requires you to be there before recording starts). If you control the conference server, you may be able to get it to play a canned announcement that the call is being recorded.
You could do this with Twilio with almost no programming whatsoever. It will cost you 3ยข per minute, so if your company's weekly call is 45 minutes long, you're looking at $1.35 per week, about as close to free as possible. Here are the steps:
Sign up for Twilio and make note of your Account ID and token
Create a publicly accessible file on your web server that does nothing but output the following XML (see the documentation for explanation of the record parameters):
<Response>
<Record timeout="30" finishOnKey="#" />
</ Response>
When it's time to start the recording, perform a POST to this URL (documented here) with your browser or set up an automated process or script to do it for you:
POST http://api.twilio.com/2008-08-01/Accounts/ACCOUNT SID HERE/Calls
HTTP/1.1
Called=CONFERENCE NUMBER HERE
&Url=WEB PAGE HERE
&Method=GET
&SendDigits=PIN CODE HERE
If you want to get really creative, you can actually write code to handle the result of the recording verb and email the link to the MP3 or WAV file that Twilio hosts for you. But, if this is a one off, you can skip it because you can access all your recordings in the control panel for your account anyway.
try peers with mediaDebug option true in peers.xml. This option records all outgoing and incoming media streams in a media/ folder with a date pattern for file name. Nevertheless this file will probably not be usable as is. It contains raw uncompressed lienar PCM samples. You can use Audacity, sox or ffmpeg to convert it to whatever you want.
https://voip.dev.java.net/
They have some sample code there.
I have a simple ajax game between 2 users with java backend (tomcat, spring). I need some good way of notifying one user that his opponent made a turn. Now all communication is done through database and waiting for opponent to finish his turn looks like this:
while(!timeout && !opponentIsDone) {
//...get the game record from db and check if opponent made turn
Thread.sleep(100);
}
Can I somehow get rid of this loop with sleep() and get instantly notified without a delay (but with timeout)? I can probably make some global static var and communicate through it, but I still will need similar loop only maybe timeout will be smaller.
I can't just call some method once the turn is done because it is all need to go to the browser through ajax and I can't push data there, only pull. So I need to have process that waits for the opponent.
I am looking for some light and simple solution.
Thanks.
You may want to look into Tomcat's advanced IO (Comet) support.
http://tomcat.apache.org/tomcat-6.0-doc/aio.html
I think you're looking for the Distributed Events (aka Subscriber/Publisher) pattern, and I believe Dojo Framework has implemented it:
http://ajaxpatterns.org/Distributed_Events
There are many ways to push notifications to a web client. Gmail's IM client is an excellent example of this sort of thing. This is often accomplished by holding an open HTTP connection in some manner, and this family of techniques is referred to as COMET. Wikipedia has an article on it, and there are blogs dedicated to the subject ( http://cometdaily.com/ ).
Even if you didn't use this technique, there are still many improvements you can make to the algorithm you identified in your question. One way would be to use a wait/notify sort of pattern or a subscriber/publisher approach. Another would be to return a "waiting for other player to make a turn" page immediately, and have that page automatically refresh every few seconds until the other player has taken his turn.
I think the solution you're looking for is COMET-style notification, though.
If you had a global static var of some sort, you could use a java.util.concurrent.BlockingQueue<T>
BlockingQueue<Turn> handoff = new ArrayBlockingQueue<Turn>(1);
// opponent thread
handoff.offer(myTurn);
// other thread can use
Turn otherTurn = handoff.poll( 90, TimeUnit.SECONDS );
if ( otherTurn == null )
// then no turn made
You can easily make the people wait for each other by using SynchronousQueue instead of ArrayBlockingQueue.
and of course it doesn't need to be global static -- it could be anything accessible to both users.
flex/flash has a real-time chatroom system (using remote-object programming).
you have to install BlazeDS (free) http://opensource.adobe.com/blazeds/, it comes with sample application. This is called AMF technology. I think Spring does support this AMF in one way or another.
http://www.adobe.com/devnet/livecycle/articles/blazeds_spring.html
http://blog.springsource.com/2008/12/17/using-spring-blazeds-integration-m1/
It's good for Flash based website. However, if you don't want to use flash, i think u can hide it or make it small enough, just to use it as a communication channel on your page.
Perhaps you have to find a way to notify your webpage/javascript after flash receive data from server.
Yeah, I know this method is a bit hacky, and it's not a clean way of doing thing :) just to provide an alternative for you.
DWR (Direct Web Remoting) is a package that allows you to make Java methods on the server directly available to Javascript (by creating a proxy). It has a feature called "Reverse Ajax" that is an easy way to handle push scenarios.
Perhaps consider Jetty Continuations if you aren't locked into Tomcat?
http://bill.burkecentral.com/2008/11/12/buggybroken-tomcat-6-comet-nio-apis/ has some discussion about Tomcat NIO