Net::S...::Call(3pm)
๐ NAME ๐
Net::S...::Call โ bestie, this is the call context for Net::SIP::Simple. That's it, that's the whole vibe. Manual name is Net::S...::Call(3pm) from the User Contributed Perl Documentation, and yes she's iconic for it. ๐
โจ SYNOPSIS โจ
my $call = $simple->invite(...);
$call->reinvite(... );
$call->bye();
look at her go ๐ฆ
๐ธ DESCRIPTION ๐ธ
okay so this package is the one holding the call context for Net::SIP::Simple. it manages the whole situation โ like (re-)invites on an already existing context, etc. it's giving backstage manager energy, fr fr. ๐
๐ CONSTRUCTOR ๐
new ( CONTROL, CTX, \%ARGS )
makes you a fresh lil Net::SIP::Simple::Call object so you can control a call. usually you don't call this yourself โ invite in Net::SIP::Simple does it for you. ๐ซถ
CONTROLโ theNet::SIP::Simpleobject that's running the calls, aka the one in charge here.CTXโ this one's flexible, bestie. it's either an already-existingNet::SIP::Endpoint::Context, or the SIP address of the peer you're gonna contact in this call, or a hash that can be used to create the context. if the context isn't complete, the missing info gets pulled from$callwhen it's called as"$call-"new>. โจ%ARGSโ these describe how the call should behave, and they get saved into the object as the connection parameter. the options below all live in that connection parameter and can be passed in%ARGS:legโ tells you which leg to use for the call. the default is just the first leg in the dispatcher. no cap.sdp_on_ackโ if you pass this and it's TRUE, it will not send the SDP body on the INVITE request, it sends it on the ACK instead. mostly used for testing how proxies behave between the two parties. lowkey a little sneaky. ๐init_mediaโ a callback that initializes the media for the connection. see methodrtpinNet::SIP::Simpleand alsoNet::SIP::Simple::RTP.
the callback gets called with the call $self and the connection parameter as its arguments (as a hash reference).
rtp_paramโ data for the codec used in the media set up byinit_media, plus for initializing the default SDP data. it's an array reference[pt,size,interval,name]whereptis the payload type,sizeis the size of the payload, andintervalis the interval at which the RTP packets get sent.nameis optional โ if you give it,rtpmapandptimeentries get added to the SDP so the name gets associated with that payload type.
the default is for PCMU/8000: [0,160,160/8000]. an alternative could be, for example, [97,50,0.03,'iLBC/8000'] for iLBC. ๐
sdpโ aNet::SIP::SDPobject, or the argument for constructing one. if you don't give it, it'll create an SDP body with one RTP audio connection โ unless it already got first SDP data from the peer, in which case it just matches them. slay, adaptive. ๐sdp_peerโ holds theNet::SIP::SDPbody sent by the peer. usually it's not set in the constructor, but you can get at it from callbacks.media_lsocksโ contains a\@listof sockets, one for each media-line in the SDP. every item in this list is either a single socket (when the port range is 1) or a\@listof sockets.
โ ๏ธ if sdp is provided, this parameter has to be provided too. like, the package will not allocate the sockets described in the SDP packet. so bring your own, bestie.
media_ssocksโ the sockets used for sending RTP data. if you don't give this, the socket for sending RTP is the same one used for receiving RTP โ unlessasymetric_rtpis specified.asymetric_rtpโ by default it sends the RTP data from the same port where it listens for data. if this option is TRUE it allocates a different port for receiving data. mostly used for testing how proxies behave between the two parties. ๐งdtmf_methodsโ if a DTMF callback is specified, this is treated as the list of supported DTMF methods for receiving DTMF. if you don't give it, it defaults to'rfc2833,audio'.recv_byeโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when the peer initiated the close of the connection using BYE or CANCEL.
the argument for the callback will be a hash reference containing the connection parameter.
send_byeโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when the local side initiated the close of the connection using BYE or CANCEL.
the argument for the callback will be a hash reference containing the connection parameter merged with the parameter from the bye method.
clear_sdpโ if TRUE, the keysmedia_lsocks,media_ssocks,sdpandsdp_peerget cleared on each new (re)INVITE request. so it'll allocate brand new sockets for RTP instead of reusing the existing ones. fresh start energy โจcb_finalโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received the final answer on locally created INVITE requests (like, when it established the call by sending the ACK).
the callback gets invoked with ( STATUS, SELF, %INFO ) where STATUS is either 'OK' or 'FAIL' ('OK' if the final response meant success, else 'FINAL'), and %INFO contains more info โ like ( packet => packet ) for the packet containing the final answer, or ( code => response_code ) in case of failures caused by an unsuccessful response.
cb_preliminaryโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received a preliminary response on a locally created INVITE.
the callback gets invoked with ( SELF, CODE, RESPONSE ) where CODE is the response code and RESPONSE is the Net::SIP::Response packet.
cb_establishedโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received the final answer on locally created INVITE requests.
the callback gets invoked with ( 'OK', SELF ). periodt. ๐
cb_inviteโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received an INVITE request.
the callback gets invoked with ( SELF, REQUEST ) where REQUEST is the Net::SIP::Request packet for the INVITE. if it returns a Net::SIP::Packet, that gets used as the response โ otherwise a default response with code 200 gets created. easy. ๐
cb_dtmfโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received a DTMF event.
the callback gets invoked with ( EVENT, DURATION ) where EVENT is the event ([0-9A-D*#]) and DURATION is the duration in ms.
receiving DTMF needs to be supported by the active RTP handler set withinit_media. all builtin handlers fromNet::SIP::Simple::RTPare supported. but if no RTP handler is set up, or if the RTP handler doesn't support DTMF sending, no DTMF will be received โ and there's no warning at all. ๐ญ silent treatment fr fr.
cb_notifyโ a callback usable byinvoke_callbackinNet::SIP::Util. it gets invoked when it received a NOTIFY request.
the callback gets invoked with ( SELF, REQUEST ) where REQUEST is the Net::SIP::Request packet for the NOTIFY.
sip_headerโ a reference to a hash with extra SIP headers for the INVITE requests. ๐ธcall_on_holdโ this option makes the next SDP have0.0.0.0as its address, which puts this side of the call on hold (it will not receive data). it's a one-shot option, bestie โ so it needs to be set withset_paramor withinreinviteeach time the call should be put on hold. no set-and-forget here. ๐...โ more parameters can be specified and they're accessible from the callbacks. for instance,media_send_recvinNet::SIP::Simple::RTPuses a parametercb_rtp_done. go look over there, iykyk. ๐
๐ METHODS ๐
okay bestie, here's where the actual doing happens. every method, every arg, no skipping, we go ๐
๐งน cleanup
this one gets called to clean up the call. why does that even matter? because callbacks and stuff can create cyclic references, and those bad boys need to be broken or they'll haunt your memory forever ๐ญ. it calls rtp_cleanup too, obviously.
how does it work? it invokes all the callbacks that are stored as \@list in $self->{call_cleanup}. cute, right?
it gets called automatically at a clean end of a call โ like on BYE or CANCEL, whether you issued it locally or your peer sent it over ๐ซถ. but if the end is not clean and you wanna destroy the call all messy and unhinged, you gotta call this method manually. no cap.
๐งผ rtp_cleanup
cleanup of the current RTP connection โจ. works by invoking all the callbacks stored as \@list in $self->{rtp_cleanup} โ and btw those callbacks get inserted by Net::SIP::Simple::RTP and friends. iykyk.
๐ get_peer
returns the peer of the call. that's it, that's the method. for the full lore see peer in Net::SIP::Endpoint::Context.
๐จ reinvite ( %ARGS )
creates an INVITE request which either kicks off the initial SDP session or updates an existing SDP session (aka a reinvite, hence the name bestie). %ARGS gets merged with the connection parameter โ see the constructor description for that whole situation.
bonus tip from the source: also using resp40x as an auth parameter here would make sense if you want to have full control over the authorization process. main character energy fr.
it sets up a callback for the connection, which will invoke cb_final once the final response for the INVITE was received, and init_media if that response was successful ๐ฅ.
if no cb_final callback was given, it will wait in the event loop until a final response was received. only in this case will it also use the param ring_time, which specifies the time it'll wait for that final response. and if no final response came in within that time? it sends a CANCEL request for this call to close it ๐ซ. in that case, a callback specified with cb_noanswer will be called after the CANCEL was delivered (or delivery failed).
returns the connection context as a Net::SIP::Endpoint::Context object.
also, for the record: this method is called within invite in Net::SIP::Simple after creating the new Net::SIP::Simple::Call object, to create the first SDP session. changes to the SDP session will be done by calling this method on the Net::SIP::Simple::Call object $self ๐.
โ cancel ( %ARGS )
closes a pending call by sending a CANCEL request. returns true if the call was pending and could be canceled, false if not, simple as that ๐ธ.
if %ARGS contains cb_final, it'll be used as a callback and invoked once it gets the response for the CANCEL โ and that response might be a response packet or a timeout, so prepare yourself ๐ญ. the rest of %ARGS gets merged with the connection parameter and handed to the cb_final callback as an argument (as a hash reference).
๐ bye ( %ARGS )
closes a call by sending a BYE request. if %ARGS contains cb_final, it'll be used as a callback and invoked once it gets the response for the BYE โ again, that could be a response packet or a timeout ๐. the rest of %ARGS gets merged with the connection parameter and given as an argument to the cb_final callback (as a hash reference). same energy as cancel, different request. slay.
๐ฎ request ( METHOD, BODY, %ARGS )
will create a request with METHOD and BODY, then wait for completion โณ. if %ARGS contains cb_final, it'll be used as a callback and invoked once it gets the response for the request (or a timeout). the rest of %ARGS will be used to create the request โ mostly for the request header, see Net::SIP::Endpoint::new_request for the details bestie.
๐ข dtmf ( EVENTS, %ARGS )
sends DTMF (dial tones ๐
) events to the peer according to RFC2833 โ like, as RTP events, iconic.
EVENTS is a string with the characters 0-9,A-D,*,#. those will be sent as DTMF. any other characters in the string lead to a pause in sending DTMF. for example, "123--#" will send "1", "2,", "3", then add to pauses, and then send "#" ๐.
in %ARGS you can specify a duration in ms (default 100ms) and a callback cb_final, which is invoked with first argument 'OK' when all events are sent. if no cb_final callback is given, the method will only return when all events are sent.
you can also overwrite the automatic detection of the DTMF method using methods in %ARGS. default is 'rfc2833,audio'. with 'rfc2833' only, one enforces the use of RTP events โ and if the peer does not support it, it will croak ๐. setting it to 'audio' will not fail from the client side, but the peer might not look for DTMF inband data if it expects RTP events. messy, we know.
โ ๏ธ sending DTMF needs to be supported by the active RTP handler set withinit_media. all builtin handlers fromNet::SIP::Simple::RTPare supported. but if no RTP handler is set up, or if the RTP handler does not support DTMF sending, no DTMF will be received โ without any warning. like, silence. nothing. ๐
๐ฅ receive ( ENDPOINT, CTX, ERROR, CODE, PACKET, LEG, FROM )
this one gets called from the dispatcher on incoming packets ๐ฌ. here's the whole cast:
ENDPOINTโ theNet::SIP::Endpointobject which manages theNet::SIP::Endpoint::ContextCTXcalling context for the current call.ERRORโ an errno describing the error (and0|undefif there's no error).CODEโ the numerical code from the packet, if a response packet was received.PACKETโ the incoming packet.LEGโ theNet::SIP::Legwhere it came in.FROMโ the"ip:port"of the sender.
for more details see the documentation to set_callback in Net::SIP::Endpoint::Context ๐
and what does it do with all that? if the incoming packet is a BYE or CANCEL request, it will close the call and invoke the recv_bye callback.
if it's INVITE or ACK, it will make sure that the RTP sockets are set up ๐งฆ. and if it's receiving an ACK to the current call, it will invoke the cb_established callback and also the init_media callback, which cares about setting up the RTP connections (e.g. produce and accept RTP traffic). it's giving setup era โจ.
๐๏ธ set_param ( %ARGS )
changes params like init_media, sdp_on_ack on the current call. see the constructor for what those are. this is super useful if the call consists of multiple invites with different features โ vibe shift mid-call, we love to see it.
๐ get_param ( @KEYS )
returns values for the parameter @KEYS, the pendant to set_param ๐ซถ. if there's only one key, it'll return the value as a scalar; on multiple keys it returns an array with all the values. depending on how many keys you asked for, bestie.
and that's the whole page ๐โจ you now officially know Net::SIP::Simple::Call better than most people know themselves. go forth and handle those calls, icon ๐๐
this little manual page is from perl v5.40.1, dated 2025-12-07 โ shoutout to the perl crew for keeping the docs alive, mwah ๐
๐ฆ where this page comes from
- ubuntu resolute: libnet-sip-perl 0.840-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sip-perl 0.840-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms