├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.m2e.core.prefs ├── COPYRIGHT.txt ├── LICENSE.txt ├── README.md ├── mjsip-examples ├── .classpath ├── .gitignore ├── .mjsip-ua.template ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── mjsip │ │ └── examples │ │ ├── AnsweringMachine.java │ │ ├── AudioApp.java │ │ ├── DummyUAS.java │ │ ├── Echo.java │ │ ├── ExampleMediaConfig.java │ │ ├── ExampleMediaOptions.java │ │ ├── ExampleStreamerFactory.java │ │ ├── Jukebox.java │ │ ├── MA.java │ │ ├── MessageAgentCli.java │ │ ├── MiniJukebox.java │ │ └── UserAgentCli.java │ └── test │ ├── fixtures │ └── tone-ulaw-8000khz.wav │ └── java │ └── org │ └── mjsip │ └── examples │ └── TestAudioApp.java ├── mjsip-net ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── org.eclipse.wst.validation.prefs ├── pom.xml └── src │ ├── main │ └── java │ │ ├── module-info.java │ │ └── org │ │ ├── mjsip │ │ └── net │ │ │ ├── UdpConnectedSocket.java │ │ │ ├── UdpConnection.java │ │ │ ├── UdpConnectionListener.java │ │ │ ├── UdpMultiRelay.java │ │ │ ├── UdpMultiRelayListener.java │ │ │ ├── UdpRelay.java │ │ │ ├── UdpRelayListener.java │ │ │ └── UdpTool.java │ │ └── zoolu │ │ └── net │ │ ├── AddressType.java │ │ ├── IpAddress.java │ │ ├── SocketAddress.java │ │ ├── TcpConnection.java │ │ ├── TcpConnectionListener.java │ │ ├── TcpServer.java │ │ ├── TcpServerListener.java │ │ ├── TcpSocket.java │ │ ├── TlsContext.java │ │ ├── TlsKeyTool.java │ │ ├── TlsServer.java │ │ ├── TlsServerFactory.java │ │ ├── TlsSocket.java │ │ ├── TlsSocketFactory.java │ │ ├── UdpPacket.java │ │ ├── UdpProvider.java │ │ ├── UdpProviderListener.java │ │ └── UdpSocket.java │ └── test │ └── java │ └── test │ └── org │ └── zoolu │ └── net │ └── TestIpAddress.java ├── mjsip-phone ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── mjsip │ └── phone │ └── gui │ ├── ImagePanel.java │ ├── PopupFrame.java │ ├── StringList.java │ └── UserAgentGui.java ├── mjsip-server ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── bin │ └── Registrar (localhost).launch ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── mjsip │ └── server │ ├── AuthenticationServer.java │ ├── AuthenticationServerImpl.java │ ├── AuthenticationService.java │ ├── AuthenticationServiceImpl.java │ ├── CallLogger.java │ ├── CallLoggerImpl.java │ ├── DomainProxyingRule.java │ ├── LocationService.java │ ├── LocationServiceImpl.java │ ├── PrefixProxyingRule.java │ ├── Proxy.java │ ├── ProxyInviteTransactionClient.java │ ├── ProxyingRule.java │ ├── Redirect.java │ ├── Registrar.java │ ├── Repository.java │ ├── ServerEngine.java │ ├── ServerProfile.java │ ├── StatefulProxy.java │ ├── StatefulProxyState.java │ └── sbc │ ├── AddressResolver.java │ ├── AddressResolverKeepAlive.java │ ├── CircularEnumeration.java │ ├── ExtendedSipProvider.java │ ├── InputRegulatedUdpProvider.java │ ├── InterceptingUdpRelay.java │ ├── Masquerade.java │ ├── MediaGw.java │ ├── OutputRegulatedUdpSocket.java │ ├── SessionBorderController.java │ ├── SessionBorderControllerProfile.java │ ├── SipMangler.java │ ├── SymmetricRegulatedUdpRelay.java │ ├── SymmetricUdpRelay.java │ └── SymmetricUdpRelayListener.java ├── mjsip-sip ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.jdt.ui.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── org.eclipse.wst.validation.prefs ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── module-info.java │ │ └── org │ │ │ └── mjsip │ │ │ ├── media │ │ │ ├── AudioStreamer.java │ │ │ ├── FlowSpec.java │ │ │ ├── LoopbackMediaStreamer.java │ │ │ ├── MediaDesc.java │ │ │ ├── MediaSpec.java │ │ │ ├── MediaStreamer.java │ │ │ ├── NativeMediaStreamer.java │ │ │ ├── RtpControlledReceiver.java │ │ │ ├── RtpControlledSender.java │ │ │ ├── RtpStreamReceiver.java │ │ │ ├── RtpStreamReceiverListener.java │ │ │ ├── RtpStreamReceiverListenerAdapter.java │ │ │ ├── RtpStreamSender.java │ │ │ ├── RtpStreamSenderListener.java │ │ │ ├── StreamerOptions.java │ │ │ ├── rx │ │ │ │ ├── AudioFileReceiver.java │ │ │ │ ├── AudioReceiver.java │ │ │ │ ├── AudioRxHandle.java │ │ │ │ ├── JavaxAudioOutput.java │ │ │ │ ├── RtpAudioRxHandler.java │ │ │ │ └── RtpReceiverOptions.java │ │ │ └── tx │ │ │ │ ├── AudioFileTransmitter.java │ │ │ │ ├── AudioTXHandle.java │ │ │ │ ├── AudioTransmitter.java │ │ │ │ ├── JavaxAudioInput.java │ │ │ │ ├── RtpAudioTxHandle.java │ │ │ │ ├── RtpSenderOptions.java │ │ │ │ └── ToneTransmitter.java │ │ │ ├── pool │ │ │ ├── PortConfig.java │ │ │ ├── PortOptions.java │ │ │ └── PortPool.java │ │ │ ├── rtp │ │ │ ├── AmrRtpPayloadFormat.java │ │ │ ├── BufferUtil.java │ │ │ ├── NtpTimeStamp.java │ │ │ ├── RrRtcpPacket.java │ │ │ ├── RtcpCompoundPacket.java │ │ │ ├── RtcpPacket.java │ │ │ ├── RtcpProvider.java │ │ │ ├── RtcpProviderListener.java │ │ │ ├── RtcpSocket.java │ │ │ ├── RtpContext.java │ │ │ ├── RtpControl.java │ │ │ ├── RtpPacket.java │ │ │ ├── RtpPayloadFormat.java │ │ │ ├── RtpProvider.java │ │ │ ├── RtpProviderListener.java │ │ │ ├── RtpReceiver.java │ │ │ ├── RtpReceiverListener.java │ │ │ ├── RtpSender.java │ │ │ ├── RtpSocket.java │ │ │ ├── SdesRtcpPacket.java │ │ │ └── SrRtcpPacket.java │ │ │ ├── sdp │ │ │ ├── AttributeField.java │ │ │ ├── MediaDescriptor.java │ │ │ ├── OfferAnswerModel.java │ │ │ ├── SdesOfferAnswerModel.java │ │ │ ├── SdpField.java │ │ │ ├── SdpMessage.java │ │ │ ├── SdpParser.java │ │ │ ├── TimeDescription.java │ │ │ └── field │ │ │ │ ├── ConnectionField.java │ │ │ │ ├── CryptoAttributeField.java │ │ │ │ ├── KeyField.java │ │ │ │ ├── KeyParam.java │ │ │ │ ├── MediaField.java │ │ │ │ ├── OriginField.java │ │ │ │ ├── SessionNameField.java │ │ │ │ ├── SrtpKeyParam.java │ │ │ │ └── TimeField.java │ │ │ └── sip │ │ │ ├── address │ │ │ ├── GenericURI.java │ │ │ ├── GenericURIImpl.java │ │ │ ├── NameAddress.java │ │ │ ├── SipNameAddress.java │ │ │ ├── SipURI.java │ │ │ ├── SipURIParser.java │ │ │ ├── TelURI.java │ │ │ └── UnexpectedUriSchemeException.java │ │ │ ├── authentication │ │ │ └── DigestAuthentication.java │ │ │ ├── call │ │ │ ├── Call.java │ │ │ ├── CallListener.java │ │ │ ├── CallListenerAdapter.java │ │ │ ├── CallState.java │ │ │ ├── CancelServer.java │ │ │ ├── DTMFInfo.java │ │ │ ├── ExtendedCall.java │ │ │ ├── ExtendedCallListener.java │ │ │ ├── NotImplementedServer.java │ │ │ ├── OptionsServer.java │ │ │ └── SipUser.java │ │ │ ├── config │ │ │ ├── IpAddressHandler.java │ │ │ ├── MediaDescHandler.java │ │ │ ├── NameAddressHandler.java │ │ │ ├── SipURIHandler.java │ │ │ └── SocketAddressHandler.java │ │ │ ├── dialog │ │ │ ├── Dialog.java │ │ │ ├── DialogInfo.java │ │ │ ├── DialogStatus.java │ │ │ ├── ExtendedInviteDialog.java │ │ │ ├── ExtendedInviteDialogListener.java │ │ │ ├── InviteDialog.java │ │ │ └── InviteDialogListener.java │ │ │ ├── header │ │ │ ├── AcceptEncodingHeader.java │ │ │ ├── AcceptHeader.java │ │ │ ├── AcceptLanguageHeader.java │ │ │ ├── AlertInfoHeader.java │ │ │ ├── AllowEventsHeader.java │ │ │ ├── AllowHeader.java │ │ │ ├── Analyzer.java │ │ │ ├── AuthenticationHeader.java │ │ │ ├── AuthenticationInfoHeader.java │ │ │ ├── AuthorizationHeader.java │ │ │ ├── CSeqHeader.java │ │ │ ├── CallIdHeader.java │ │ │ ├── ContactHeader.java │ │ │ ├── ContentDispositionHeader.java │ │ │ ├── ContentLengthHeader.java │ │ │ ├── ContentTypeHeader.java │ │ │ ├── CoreSipHeaders.java │ │ │ ├── DateHeader.java │ │ │ ├── EndPointHeader.java │ │ │ ├── EventHeader.java │ │ │ ├── ExpiresHeader.java │ │ │ ├── FromHeader.java │ │ │ ├── GenericHeader.java │ │ │ ├── Header.java │ │ │ ├── HeaderWithParams.java │ │ │ ├── InfoPackageHeader.java │ │ │ ├── LegacyHeader.java │ │ │ ├── ListHeader.java │ │ │ ├── MaxForwardsHeader.java │ │ │ ├── MinSEHeader.java │ │ │ ├── MultipleHeader.java │ │ │ ├── NameAddressHeader.java │ │ │ ├── OptionTagsHeader.java │ │ │ ├── ParametricHeader.java │ │ │ ├── ProxyAuthenticateHeader.java │ │ │ ├── ProxyAuthorizationHeader.java │ │ │ ├── ProxyRequireHeader.java │ │ │ ├── RAckHeader.java │ │ │ ├── RSeqHeader.java │ │ │ ├── ReasonHeader.java │ │ │ ├── RecordRouteHeader.java │ │ │ ├── RecvInfoHeader.java │ │ │ ├── ReferToHeader.java │ │ │ ├── ReferredByHeader.java │ │ │ ├── ReplacesHeader.java │ │ │ ├── RequestLine.java │ │ │ ├── RequireHeader.java │ │ │ ├── RouteHeader.java │ │ │ ├── ServerHeader.java │ │ │ ├── ServiceRouteHeader.java │ │ │ ├── SessionExpiresHeader.java │ │ │ ├── SipDateHeader.java │ │ │ ├── SipHeaders.java │ │ │ ├── StatusLine.java │ │ │ ├── SubjectHeader.java │ │ │ ├── SubscriptionStateHeader.java │ │ │ ├── SupportedHeader.java │ │ │ ├── ToHeader.java │ │ │ ├── TokenParametricHeader.java │ │ │ ├── UnsupportedHeader.java │ │ │ ├── UserAgentHeader.java │ │ │ ├── ViaHeader.java │ │ │ └── WwwAuthenticateHeader.java │ │ │ ├── message │ │ │ ├── BasicSipMessage.java │ │ │ ├── BasicSipMessageFactory.java │ │ │ ├── MalformedSipMessageException.java │ │ │ ├── SipMessage.java │ │ │ ├── SipMessageBuffer.java │ │ │ ├── SipMessageFactory.java │ │ │ ├── SipMethods.java │ │ │ └── SipResponses.java │ │ │ ├── provider │ │ │ ├── ConnectedSipProvider.java │ │ │ ├── ConnectionId.java │ │ │ ├── CopyOnWriteListeners.java │ │ │ ├── MessageProblem.java │ │ │ ├── SipConfig.java │ │ │ ├── SipId.java │ │ │ ├── SipKeepAlive.java │ │ │ ├── SipOptions.java │ │ │ ├── SipParser.java │ │ │ ├── SipProvider.java │ │ │ ├── SipProviderExceptionListener.java │ │ │ ├── SipProviderListener.java │ │ │ ├── SipStack.java │ │ │ ├── SipTransport.java │ │ │ ├── SipTransportCO.java │ │ │ ├── SipTransportConnection.java │ │ │ ├── SipTransportConnectionListener.java │ │ │ ├── SipTransportListener.java │ │ │ ├── TcpTransport.java │ │ │ ├── TcpTransportConnection.java │ │ │ ├── TlsTransport.java │ │ │ ├── TlsTransportConnection.java │ │ │ ├── UdpKeepAlive.java │ │ │ └── UdpTransport.java │ │ │ └── transaction │ │ │ ├── AckTransactionClient.java │ │ │ ├── AckTransactionServer.java │ │ │ ├── AckTransactionServerListener.java │ │ │ ├── CancelTransactionServer.java │ │ │ ├── InviteTransactionClient.java │ │ │ ├── InviteTransactionServer.java │ │ │ ├── InviteTransactionServerListener.java │ │ │ ├── ReliableProvisionalResponder.java │ │ │ ├── ReliableProvisionalResponderListener.java │ │ │ ├── Transaction.java │ │ │ ├── TransactionClient.java │ │ │ ├── TransactionClientListener.java │ │ │ ├── TransactionServer.java │ │ │ └── TransactionServerListener.java │ └── resources │ │ └── tinylog.properties │ └── test │ └── java │ ├── org │ └── mjsip │ │ └── sip │ │ ├── address │ │ └── TestSipURI.java │ │ └── authentication │ │ └── TestDigestAuthentication.java │ └── test │ └── org │ ├── mjsip │ ├── sdp │ │ └── field │ │ │ ├── TestConnectionField.java │ │ │ └── TestOriginField.java │ └── sip │ │ └── header │ │ └── TestViaHeader.java │ └── zoolu │ └── sound │ └── TestSimpleAudioSystem.java ├── mjsip-sound ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── org.eclipse.wst.validation.prefs ├── pom.xml └── src │ ├── main │ └── java │ │ ├── module-info.java │ │ └── org │ │ ├── mjsip │ │ └── sound │ │ │ ├── AuFileHeader.java │ │ │ ├── AudioFile.java │ │ │ ├── Codec.java │ │ │ ├── ToneGenerator.java │ │ │ ├── ToneInputStream.java │ │ │ ├── WavFileReader.java │ │ │ └── WavHeader.java │ │ └── zoolu │ │ └── sound │ │ ├── AudioOutputStream.java │ │ ├── BufferedAudioInputStream.java │ │ ├── CodecType.java │ │ ├── ConvertedAudioOutputStream.java │ │ ├── ConverterAudioSystem.java │ │ ├── SimpleAudioSystem.java │ │ ├── SourceLineAudioOutputStream.java │ │ └── codec │ │ ├── AMR.java │ │ ├── G711.java │ │ ├── G726.java │ │ ├── G726_24.java │ │ ├── G726_32.java │ │ ├── G726_40.java │ │ ├── amr │ │ ├── AmrEncoding.java │ │ ├── AmrFormatConversionProvider.java │ │ ├── AmrToPcmAudioInputStream.java │ │ ├── AmrToPcmEncoder.java │ │ ├── PcmToAmrAudioInputStream.java │ │ └── PcmToAmrEncoder.java │ │ ├── g711 │ │ ├── G711Encoding.java │ │ ├── G711FormatConversionProvider.java │ │ ├── G711ToPcmAudioInputStream.java │ │ ├── G711ToPcmEncoder.java │ │ ├── PcmToG711AudioInputStream.java │ │ └── PcmToG711Encoder.java │ │ ├── g726 │ │ ├── G726Encoding.java │ │ ├── G726FormatConversionProvider.java │ │ ├── G726ToPcmAudioInputStream.java │ │ └── PcmToG726AudioInputStream.java │ │ └── gsm │ │ ├── GsmToPcmEncoder.java │ │ └── PcmToGsmEncoder.java │ └── test │ └── java │ └── test │ └── org │ └── mjsip │ └── sound │ └── TestWavFileReader.java ├── mjsip-ua ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── org.eclipse.wst.validation.prefs ├── bin │ └── Start UserAgent.launch ├── buddy.lst.template ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── module-info.java │ │ └── org │ │ │ └── mjsip │ │ │ └── ua │ │ │ ├── ClientOptions.java │ │ │ ├── MediaAgent.java │ │ │ ├── MediaConfig.java │ │ │ ├── MediaOptions.java │ │ │ ├── MessageAgent.java │ │ │ ├── MessageAgentListener.java │ │ │ ├── MultipleUAS.java │ │ │ ├── RegisteringMultipleUAS.java │ │ │ ├── RegisteringUserAgent.java │ │ │ ├── ServiceConfig.java │ │ │ ├── ServiceOptions.java │ │ │ ├── StaticOptions.java │ │ │ ├── UAConfig.java │ │ │ ├── UAOptions.java │ │ │ ├── UIConfig.java │ │ │ ├── UserAgent.java │ │ │ ├── UserAgentListener.java │ │ │ ├── UserAgentListenerAdapter.java │ │ │ ├── UserAgentListenerChain.java │ │ │ ├── UserOptions.java │ │ │ ├── clip │ │ │ ├── AudioClipPlayer.java │ │ │ ├── AudioClipPlayerListener.java │ │ │ └── ClipPlayer.java │ │ │ ├── registration │ │ │ ├── AuthOptions.java │ │ │ ├── RegistrationClient.java │ │ │ ├── RegistrationClientListener.java │ │ │ ├── RegistrationLogger.java │ │ │ └── RegistrationOptions.java │ │ │ ├── sound │ │ │ ├── AlawSilenceTrimmer.java │ │ │ ├── IntRingBuffer.java │ │ │ ├── SilenceListener.java │ │ │ ├── SilenceListenerAdapter.java │ │ │ └── WavFileSplitter.java │ │ │ └── streamer │ │ │ ├── DefaultStreamerFactory.java │ │ │ ├── DispatchingStreamerFactory.java │ │ │ ├── LoopbackStreamerFactory.java │ │ │ ├── NativeStreamerFactory.java │ │ │ ├── NoStreamerFactory.java │ │ │ └── StreamerFactory.java │ └── resources │ │ └── media │ │ └── org │ │ └── mjsip │ │ └── ua │ │ ├── call.gif │ │ ├── hangup.gif │ │ ├── off.wav │ │ ├── on.wav │ │ ├── progress.wav │ │ └── ring.wav │ └── test │ ├── fixtures │ └── test-alaw.wav │ └── java │ └── org │ └── mjsip │ ├── ua │ └── sound │ │ ├── TestAlawSilenceTrimmer.java │ │ ├── TestIntRingBuffer.java │ │ └── TestWavFileSplitter.java │ └── up │ └── TestPortPool.java ├── mjsip-util ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── org.eclipse.wst.validation.prefs ├── pom.xml └── src │ └── main │ └── java │ ├── module-info.java │ └── org │ ├── mjsip │ ├── config │ │ ├── FileHandler.java │ │ ├── MetaConfig.java │ │ ├── OptionParser.java │ │ └── YesNoHandler.java │ └── time │ │ ├── ConfiguredScheduler.java │ │ ├── Scheduler.java │ │ └── SchedulerConfig.java │ └── zoolu │ └── util │ ├── Archive.java │ ├── Base64.java │ ├── BitString.java │ ├── BitStringBuffer.java │ ├── BufferedInputEncoder.java │ ├── ByteAddrUtils.java │ ├── ByteUtils.java │ ├── ConfigFile.java │ ├── Configurable.java │ ├── Configure.java │ ├── ContinuousPipe.java │ ├── DateFormat.java │ ├── Encoder.java │ ├── ExceptionPrinter.java │ ├── Flags.java │ ├── Identifier.java │ ├── MD5.java │ ├── MessageDigest.java │ ├── MultiTable.java │ ├── PacketLogger.java │ ├── Pair.java │ ├── Parser.java │ ├── Pipe.java │ ├── PipeInputStream.java │ ├── PipeOutputStream.java │ ├── Random.java │ ├── SimpleDigest.java │ ├── SortedVector.java │ ├── State.java │ ├── SystemUtils.java │ └── VectorUtils.java ├── mjsip.cfg.txt └── pom.xml /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /classes/ 3 | /lib/*.jar 4 | /target/ 5 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | MjSip - http://www.mjsip.org 2 | 3 | Copyright (C) 2012 by Luca Veltri - University of Parma - Italy. 4 | __________________________________________________ 5 | 6 | 7 | MjSip is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | MjSip is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with MjSip; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | PLEASE READ CAREFULLY THE LICENSE DOCUMENT RECEIVED ALONG WITH THIS LIBRARY. -------------------------------------------------------------------------------- /mjsip-examples/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /mjsip-examples/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.mjsip-ua 3 | /received.wav 4 | -------------------------------------------------------------------------------- /mjsip-examples/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-examples 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /mjsip-examples/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /mjsip-examples/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=disabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /mjsip-examples/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-examples 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-ua 17 | 18 | 19 | 20 | org.tinylog 21 | slf4j-tinylog 22 | 2.6.1 23 | runtime 24 | 25 | 26 | 27 | org.tinylog 28 | tinylog-impl 29 | 2.6.1 30 | runtime 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mjsip-examples/src/main/java/org/mjsip/examples/ExampleMediaOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.examples; 5 | 6 | import org.mjsip.ua.MediaOptions; 7 | 8 | /** 9 | * {@link MediaOptions} for test situations. 10 | */ 11 | public interface ExampleMediaOptions extends MediaOptions { 12 | 13 | /** Audio file to be recorded */ 14 | String getRecvFile(); 15 | 16 | /** Audio file to be streamed */ 17 | String getSendFile(); 18 | 19 | /** Whether looping the received media streams back to the sender. */ 20 | boolean isLoopback(); 21 | 22 | /** Whether playing a test tone in send only mode */ 23 | boolean isSendTone(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /mjsip-examples/src/test/fixtures/tone-ulaw-8000khz.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-examples/src/test/fixtures/tone-ulaw-8000khz.wav -------------------------------------------------------------------------------- /mjsip-examples/src/test/java/org/mjsip/examples/TestAudioApp.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.examples; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertTrue; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | /** 11 | * Test case for {@link AudioApp}. 12 | */ 13 | class TestAudioApp { 14 | 15 | @Test 16 | void testSendReceive() throws IOException { 17 | File rx = File.createTempFile("rx-audio", ".wav"); 18 | 19 | AudioApp.main(new String[] { 20 | "-r" , "5000", 21 | "-s", "localhost:5000", 22 | "-i", new File("./src/test/fixtures/tone-ulaw-8000khz.wav").getAbsolutePath(), 23 | "-o", rx.getAbsolutePath(), 24 | "--stopWhenTransmitted" 25 | }); 26 | 27 | assertTrue(rx.length() > 10000); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mjsip-net/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /mjsip-net/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /mjsip-net/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-net 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 4 | org.eclipse.jdt.core.compiler.compliance=11 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=11 12 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-net/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mjsip-net/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-net 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-util 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * The myjSip utilities. 7 | */ 8 | module org.mjsip.net { 9 | 10 | requires org.mjsip.util; 11 | 12 | requires args4j; 13 | requires org.slf4j; 14 | 15 | requires java.desktop; 16 | 17 | exports org.mjsip.net; 18 | exports org.zoolu.net; 19 | } -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/mjsip/net/UdpConnectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.net; 25 | 26 | 27 | 28 | import org.zoolu.net.UdpPacket; 29 | 30 | 31 | 32 | /** Listener for UdpConnection events. 33 | */ 34 | public interface UdpConnectionListener { 35 | 36 | /** When a new packet is received through the UdpConnection. */ 37 | public void onReceivedPacket(UdpConnection udp_conn, UdpPacket packet); 38 | 39 | /** When UdpConnection terminates. */ 40 | public void onConnectionTerminated(UdpConnection udp_conn, Exception error); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/mjsip/net/UdpMultiRelayListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.net; 2 | 3 | 4 | 5 | import org.zoolu.net.SocketAddress; 6 | 7 | 8 | 9 | /** Listener for MultiUdpRelay events. 10 | */ 11 | public interface UdpMultiRelayListener { 12 | 13 | /** When the remote source address changes. */ 14 | public void onUdpMultiRelaySourceAddressChanged(UdpMultiRelay mrelay, SocketAddress src_soaddr); 15 | 16 | /** When UdpRelay stops relaying UDP datagrams. */ 17 | public void onUdpMultiRelayTerminated(UdpMultiRelay mrelay); 18 | } 19 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/mjsip/net/UdpRelayListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.net; 2 | 3 | 4 | /** Listener for UdpRelay. 5 | */ 6 | public interface UdpRelayListener { 7 | 8 | /** When the remote source address changes. */ 9 | public void onUdpRelaySourceChanged(UdpRelay udp_relay, String remote_src_addr, int remote_src_port); 10 | 11 | /** When UdpRelay stops relaying UDP datagrams. */ 12 | public void onUdpRelayTerminated(UdpRelay udp_relay); 13 | } 14 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/zoolu/net/AddressType.java: -------------------------------------------------------------------------------- 1 | package org.zoolu.net; 2 | 3 | /** 4 | * Choice of addresses. 5 | */ 6 | public enum AddressType { 7 | /** 8 | * Select either an IPv4 or IPv6 address depending on the context. 9 | */ 10 | DEFAULT, 11 | 12 | /** 13 | * Use an IPv4 address. 14 | */ 15 | IP4, 16 | 17 | /** 18 | * Use an IPv6 address. 19 | */ 20 | IP6; 21 | 22 | public static AddressType fromString(String type) { 23 | switch (type.toUpperCase()) { 24 | case "IP4": return IP4; 25 | case "IP6": return IP6; 26 | } 27 | return DEFAULT; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/zoolu/net/TcpConnectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.net; 25 | 26 | 27 | 28 | /** Listener for TcpConnection events. 29 | */ 30 | public interface TcpConnectionListener { 31 | 32 | /** When new data is received through the TcpConnection. */ 33 | public void onReceivedData(TcpConnection tcp_conn, byte[] data, int len); 34 | 35 | /** When TcpConnection terminates. */ 36 | public void onConnectionTerminated(TcpConnection tcp_conn, Exception error); 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/zoolu/net/TcpServerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.net; 25 | 26 | 27 | 28 | 29 | /** Listener for TcpServer events. 30 | */ 31 | public interface TcpServerListener { 32 | 33 | /** When a new incoming connection is established. */ 34 | public void onIncomingConnection(TcpServer tcp_server, TcpSocket socket); 35 | 36 | /** When TcpServer terminates. */ 37 | public void onServerTerminated(TcpServer tcp_server, Exception error); 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/zoolu/net/TlsServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.net; 25 | 26 | 27 | 28 | import javax.net.ssl.SSLServerSocket; 29 | 30 | 31 | 32 | /** TlsServer implements a TLS server wainting for incoming connection. 33 | */ 34 | public class TlsServer extends TcpServer { 35 | 36 | 37 | /** Costructs a new TlsServer */ 38 | TlsServer(SSLServerSocket ssl_server, TcpServerListener listener) throws java.io.IOException { 39 | super(ssl_server,listener); 40 | } 41 | 42 | /** Costructs a new TlsServer */ 43 | /*public TlsServer(int port, TcpServerListener listener) throws java.io.IOException { 44 | super(port,null,listener); 45 | }*/ 46 | 47 | /** Costructs a new TlsServer */ 48 | /*public TlsServer(int port, IpAddress bind_ipaddr, TcpServerListener listener) throws java.io.IOException { 49 | super(port,bind_ipaddr,0,listener); 50 | }*/ 51 | 52 | /** Costructs a new TlsServer */ 53 | /*public TlsServer(int port, IpAddress bind_ipaddr, long alive_time, TcpServerListener listener) throws java.io.IOException { 54 | super(port,bind_ipaddr,alive_time,listener); 55 | }*/ 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mjsip-net/src/main/java/org/zoolu/net/UdpProviderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.net; 25 | 26 | 27 | 28 | 29 | /** Listener for UdpProvider events. 30 | */ 31 | public interface UdpProviderListener { 32 | 33 | /** When a new UDP datagram is received. */ 34 | public void onReceivedPacket(UdpProvider udp, UdpPacket packet); 35 | 36 | /** When UdpProvider terminates. */ 37 | public void onServiceTerminated(UdpProvider udp, Exception error); 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-net/src/test/java/test/org/zoolu/net/TestIpAddress.java: -------------------------------------------------------------------------------- 1 | package test.org.zoolu.net; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import java.net.InetAddress; 6 | import java.net.UnknownHostException; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.zoolu.net.AddressType; 10 | import org.zoolu.net.IpAddress; 11 | 12 | /** 13 | * Test case for {@link IpAddress}. 14 | */ 15 | class TestIpAddress { 16 | 17 | @Test 18 | void testAutoConfig() throws UnknownHostException { 19 | InetAddress ipv4 = IpAddress.getLocalHostAddress(AddressType.IP4); 20 | InetAddress ipv6 = IpAddress.getLocalHostAddress(AddressType.IP6); 21 | 22 | assertNotNull(ipv4); 23 | assertNotNull(ipv6); 24 | 25 | System.out.println("Found IPv4 address: " + ipv4.getHostAddress()); 26 | System.out.println("Found IPv6 address: " + ipv6.getHostAddress()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mjsip-phone/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /mjsip-phone/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /mjsip-phone/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-phone 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /mjsip-phone/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /mjsip-phone/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=disabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /mjsip-phone/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-phone/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-phone 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-ua 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mjsip-phone/src/main/java/org/mjsip/phone/gui/ImagePanel.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.phone.gui; 2 | 3 | 4 | 5 | import java.awt.Color; 6 | import java.awt.Graphics; 7 | import java.awt.Image; 8 | import java.awt.Panel; 9 | 10 | 11 | 12 | /** A Panel with a backgroung image 13 | */ 14 | class ImagePanel extends Panel { 15 | 16 | Image image=null; 17 | 18 | public ImagePanel(Image image) { 19 | this.image=image; 20 | try { 21 | jbInit(); 22 | } 23 | catch(Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | 28 | private void jbInit() throws Exception { 29 | this.setBackground(Color.black); 30 | } 31 | 32 | @Override 33 | public void paint(Graphics g) { 34 | if (image!=null) { 35 | int width=this.getSize().width; 36 | int height=this.getSize().height; 37 | double ratio=(double)width/height; 38 | 39 | if (image!=null && image.getWidth(null)>0) { 40 | // resized image 41 | Image aux=image.getScaledInstance(width,height,Image.SCALE_FAST); 42 | // wait for image loading.. 43 | int attempts=4; 44 | while( (attempts--)>0 && aux.getWidth(null)<0) try { Thread.sleep(80); } catch (Exception e) {} 45 | 46 | /* 47 | double x=width/2; 48 | double y=height/2; 49 | int dx=aux.getWidth(null)/2; 50 | int dy=aux.getHeight(null)/2; 51 | g.drawImage(aux,(int)(x-dx),(int)(y-dy),null); 52 | */ 53 | g.drawImage(aux,0,0,null); 54 | } 55 | } 56 | else { 57 | g.setColor(Color.red); 58 | g.fillRect(0,0,this.getSize().width,this.getSize().height); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mjsip-server/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /mjsip-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /users.db 3 | -------------------------------------------------------------------------------- /mjsip-server/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-server 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /mjsip-server/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /mjsip-server/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-server/bin/Registrar (localhost).launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mjsip-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-server 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-sip 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/AuthenticationServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.server; 23 | 24 | 25 | import org.mjsip.sip.header.AuthenticationInfoHeader; 26 | import org.mjsip.sip.message.SipMessage; 27 | 28 | 29 | /** AuthenticationServer is the interface used by a SIP server to authenticate SIP requests. 30 | */ 31 | public interface AuthenticationServer { 32 | 33 | /** Authenticates a SIP request. 34 | * @param msg is the SIP request to be authenticated 35 | * @return it returns the error Message in case of authentication failure, 36 | * or null in case of authentication success. */ 37 | public SipMessage authenticateRequest(SipMessage msg); 38 | 39 | /** Authenticates a proxying SIP request. 40 | * @param msg is the SIP request to be authenticated 41 | * @return it returns the error Message in case of authentication failure, 42 | * or null in case of authentication success. */ 43 | public SipMessage authenticateProxyRequest(SipMessage msg); 44 | 45 | /** Gets AuthenticationInfoHeader. */ 46 | public AuthenticationInfoHeader getAuthenticationInfoHeader(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/CallLogger.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.server; 2 | 3 | 4 | 5 | import org.mjsip.sip.message.SipMessage; 6 | 7 | 8 | 9 | /** CallLogger keeps a complete trace of processed calls. 10 | */ 11 | public interface CallLogger { 12 | 13 | /** Updates log with the present message. */ 14 | public void update(SipMessage msg); 15 | } 16 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/ProxyingRule.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.server; 2 | 3 | 4 | import org.mjsip.sip.address.GenericURI; 5 | import org.mjsip.sip.address.SipURI; 6 | 7 | 8 | /** ProxyingRule allows the matching of a SipURI with a proper next-hop SipURI. 9 | */ 10 | public interface ProxyingRule { 11 | 12 | /** Gets the proper next-hop SipURI for the selected URI. 13 | * It returns the SipURI used to reach the selected URI. 14 | * @param uri the selected destination URI 15 | * @return the proper next-hop SipURI for the selected URI 16 | * if the proxying rule matches the URI, otherwise it returns null. */ 17 | public SipURI getNexthop(GenericURI uri); 18 | 19 | /** Gets the String value. */ 20 | @Override 21 | public String toString(); 22 | } 23 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/sbc/CircularEnumeration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.server.sbc; 23 | 24 | 25 | import java.util.Vector; 26 | 27 | 28 | /** CircularEnumeration collects a set of Objects that can be accessed in a sequencial 29 | * and cyclic manner. 30 | *

31 | * A CircularEnumeration is created from a Vector of Objects. It implements only one 32 | * the nextElement() method. 33 | */ 34 | public class CircularEnumeration { 35 | 36 | Vector v; 37 | int i; 38 | 39 | public CircularEnumeration(Vector vector) { 40 | v=vector; 41 | i=0; 42 | } 43 | 44 | public E nextElement() { 45 | if (v==null || v.isEmpty()) return null; 46 | if (i==v.size()) i=0; 47 | return v.elementAt(i++); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/sbc/Masquerade.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.server.sbc; 23 | 24 | 25 | import org.zoolu.net.SocketAddress; 26 | 27 | 28 | /** Masquerade maintains soaddr mapping for a single flow. 29 | */ 30 | public class Masquerade { 31 | 32 | /** Peer SocketAddress */ 33 | private SocketAddress peer_soaddr; 34 | /** Masq SocketAddress */ 35 | private SocketAddress masq_soaddr; 36 | 37 | /** Creates a new Masquerade */ 38 | public Masquerade(SocketAddress peer_soaddr, SocketAddress masq_soaddr) { 39 | this.peer_soaddr=peer_soaddr; 40 | this.masq_soaddr=masq_soaddr; 41 | } 42 | 43 | /** Gets remote peer's address */ 44 | public SocketAddress getPeerSoaddr() { 45 | return peer_soaddr; 46 | } 47 | 48 | /** Gets masquerating address */ 49 | public SocketAddress getMasqSoaddr() { 50 | return masq_soaddr; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /mjsip-server/src/main/java/org/mjsip/server/sbc/SymmetricUdpRelayListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.server.sbc; 2 | 3 | 4 | import org.zoolu.net.SocketAddress; 5 | 6 | 7 | /** Listener for SymmetricUdpRelay events. 8 | */ 9 | public interface SymmetricUdpRelayListener { 10 | 11 | /** When left peer address changes. */ 12 | public void onSymmetricUdpRelayLeftPeerChanged(SymmetricUdpRelay symm_relay, SocketAddress soaddr); 13 | 14 | /** When right peer address changes. */ 15 | public void onSymmetricUdpRelayRightPeerChanged(SymmetricUdpRelay symm_relay,SocketAddress soaddr); 16 | 17 | /** When it stops relaying UDP datagrams (both directions). */ 18 | public void onSymmetricUdpRelayTerminated(SymmetricUdpRelay symm_relay); 19 | } 20 | -------------------------------------------------------------------------------- /mjsip-sip/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mjsip-sip/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /mjsip-sip/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-sip 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /mjsip-sip/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /mjsip-sip/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-sip/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /mjsip-sip/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-sip/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mjsip-sip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-sip 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-net 17 | 18 | 19 | 20 | org.mjsip 21 | mjsip-sound 22 | 23 | 24 | 25 | org.mjsip 26 | mjsip-util 27 | 28 | 29 | 30 | args4j 31 | args4j 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * The myjSip utilities. 7 | */ 8 | module org.mjsip.sip { 9 | 10 | requires transitive org.mjsip.sound; 11 | requires transitive org.mjsip.util; 12 | requires transitive org.mjsip.net; 13 | requires args4j; 14 | requires org.slf4j; 15 | requires java.desktop; 16 | 17 | opens org.mjsip.sip.provider to args4j; 18 | opens org.mjsip.pool to args4j; 19 | 20 | exports org.mjsip.media; 21 | exports org.mjsip.media.rx; 22 | exports org.mjsip.media.tx; 23 | exports org.mjsip.pool; 24 | exports org.mjsip.rtp; 25 | exports org.mjsip.sdp; 26 | exports org.mjsip.sdp.field; 27 | exports org.mjsip.sip.address; 28 | exports org.mjsip.sip.authentication; 29 | exports org.mjsip.sip.call; 30 | exports org.mjsip.sip.config; 31 | exports org.mjsip.sip.dialog; 32 | exports org.mjsip.sip.header; 33 | exports org.mjsip.sip.message; 34 | exports org.mjsip.sip.provider; 35 | exports org.mjsip.sip.transaction; 36 | } -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/LoopbackMediaStreamer.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.media; 2 | 3 | 4 | 5 | import org.mjsip.net.UdpRelay; 6 | import org.slf4j.LoggerFactory; 7 | 8 | 9 | 10 | /** System that sends back the incoming stream. 11 | */ 12 | public class LoopbackMediaStreamer implements MediaStreamer { 13 | 14 | private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(LoopbackMediaStreamer.class); 15 | 16 | /** UdpRelay */ 17 | UdpRelay udp_relay=null; 18 | 19 | 20 | /** Creates a new media streamer. */ 21 | public LoopbackMediaStreamer(FlowSpec flow_spec) { 22 | try { 23 | udp_relay=new UdpRelay(flow_spec.getLocalPort(),flow_spec.getRemoteAddress(),flow_spec.getRemotePort(),null); 24 | LOG.trace("relay {} started", udp_relay.toString()); 25 | } 26 | catch (Exception e) { 27 | LOG.info("Exception.", e); 28 | } 29 | } 30 | 31 | 32 | /** Starts media streams. */ 33 | @Override 34 | public boolean start() { 35 | // do nothing, already started.. 36 | return true; 37 | } 38 | 39 | 40 | /** Stops media streams. */ 41 | @Override 42 | public boolean halt() { 43 | if (udp_relay!=null) { 44 | udp_relay.halt(); 45 | udp_relay=null; 46 | LOG.trace("relay halted"); 47 | } 48 | return true; 49 | } 50 | 51 | 52 | // *************************** Callbacks *************************** 53 | 54 | /** From UdpRelayListener. When the remote source address changes. */ 55 | public void onUdpRelaySourceChanged(UdpRelay udp_relay, String remote_src_addr, int remote_src_port) { 56 | LOG.info("UDP relay: remote address changed: {}:{}", remote_src_addr, remote_src_port); 57 | } 58 | 59 | /** From UdpRelayListener. When UdpRelay stops relaying UDP datagrams. */ 60 | public void onUdpRelayTerminated(UdpRelay udp_relay) { 61 | LOG.info("UDP relay: terminated."); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/MediaStreamer.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.media; 2 | 3 | 4 | 5 | 6 | /** Interface for classes that start a media streamer (e.g. for audio or video fullduplex streaming). */ 7 | public interface MediaStreamer { 8 | 9 | /** Starts media streams. */ 10 | public boolean start(); 11 | 12 | /** Stops media streams. */ 13 | public boolean halt(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/RtpControlledSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.media; 23 | 24 | 25 | 26 | 27 | /** RTP controlled sender. 28 | */ 29 | public interface RtpControlledSender { 30 | 31 | /** Gets SSRC. 32 | * @return the synchronization source (SSRC) identifier */ 33 | public long getSSRC(); 34 | 35 | /** Gets current RTP timestamp. 36 | * @return the same time as the NTP timestamp, but in the same units and with the same random offset as the RTP timestamps in data packets */ 37 | public long getRtpTimestamp(); 38 | 39 | /** Gets packet count. 40 | * @return the total number of RTP data packets transmitted by the sender since starting transmission up until now */ 41 | public long getPacketCounter(); 42 | 43 | /** Gets octect count. 44 | * @return the total number of payload octets (i.e., not including header or padding) transmitted in RTP data packets by the sender since starting transmission up until now */ 45 | public long getOctectCounter(); 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/RtpStreamReceiverListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.media; 2 | 3 | 4 | 5 | import org.zoolu.net.SocketAddress; 6 | 7 | 8 | 9 | /** Listens for RtpStreamReceiver events. 10 | */ 11 | public interface RtpStreamReceiverListener { 12 | 13 | /** When the remote socket address (source) is changed. */ 14 | public void onRemoteSoAddressChanged(RtpStreamReceiver rr, SocketAddress remote_soaddr); 15 | 16 | /** When the stream receiver terminated. */ 17 | public void onRtpStreamReceiverTerminated(RtpStreamReceiver rr, Exception error); 18 | 19 | /** 20 | * Creates a listener concatenation that first calls this listener and then the given other 21 | * listener. 22 | */ 23 | default RtpStreamReceiverListener andThen(RtpStreamReceiverListener other) { 24 | if (other == null) { 25 | return this; 26 | } 27 | 28 | RtpStreamReceiverListener self = this; 29 | return new RtpStreamReceiverListener() { 30 | @Override 31 | public void onRemoteSoAddressChanged(RtpStreamReceiver rr, SocketAddress remote_soaddr) { 32 | try { 33 | self.onRemoteSoAddressChanged(rr, remote_soaddr); 34 | } finally { 35 | other.onRemoteSoAddressChanged(rr, remote_soaddr); 36 | } 37 | } 38 | 39 | @Override 40 | public void onRtpStreamReceiverTerminated(RtpStreamReceiver rr, Exception error) { 41 | try { 42 | self.onRtpStreamReceiverTerminated(rr, error); 43 | } finally { 44 | other.onRtpStreamReceiverTerminated(rr, error); 45 | } 46 | } 47 | }; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/RtpStreamReceiverListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media; 5 | 6 | import org.zoolu.net.SocketAddress; 7 | 8 | /** 9 | * {@link RtpStreamReceiverListener} that implements all callback as no-op. 10 | */ 11 | public interface RtpStreamReceiverListenerAdapter extends RtpStreamReceiverListener { 12 | 13 | @Override 14 | default void onRemoteSoAddressChanged(RtpStreamReceiver rr, SocketAddress remote_soaddr) { 15 | // Ignore. 16 | } 17 | 18 | @Override 19 | default void onRtpStreamReceiverTerminated(RtpStreamReceiver rr, Exception error) { 20 | // Ignore. 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/RtpStreamSenderListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.media; 2 | 3 | /** Listens for RtpStreamSender events. 4 | */ 5 | public interface RtpStreamSenderListener { 6 | 7 | /** When the stream sender terminated. */ 8 | public void onRtpStreamSenderTerminated(RtpStreamSender rs, Exception error); 9 | 10 | /** 11 | * Creates a listener concatenation that first calls this listener and then calls the given 12 | * other listener. 13 | */ 14 | default RtpStreamSenderListener andThen(RtpStreamSenderListener other) { 15 | if (other == null) { 16 | return this; 17 | } 18 | RtpStreamSenderListener self = this; 19 | return new RtpStreamSenderListener() { 20 | @Override 21 | public void onRtpStreamSenderTerminated(RtpStreamSender rs, Exception error) { 22 | try { 23 | self.onRtpStreamSenderTerminated(rs, error); 24 | } finally { 25 | other.onRtpStreamSenderTerminated(rs, error); 26 | } 27 | } 28 | }; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/rx/AudioReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.rx; 5 | 6 | import java.io.IOException; 7 | 8 | import javax.sound.sampled.AudioFormat; 9 | import javax.sound.sampled.UnsupportedAudioFileException; 10 | 11 | import org.mjsip.media.RtpStreamReceiver; 12 | import org.mjsip.media.RtpStreamReceiverListener; 13 | import org.mjsip.rtp.RtpPayloadFormat; 14 | import org.zoolu.net.UdpSocket; 15 | import org.zoolu.sound.CodecType; 16 | import org.zoolu.util.Encoder; 17 | 18 | /** 19 | * Algorithm creating a {@link RtpStreamReceiver}. 20 | */ 21 | public interface AudioReceiver { 22 | 23 | /** 24 | * Creates a {@link RtpStreamReceiver}. 25 | * 26 | * @param options 27 | * @param socket 28 | * TODO 29 | * @param audio_format 30 | * @param codec 31 | * @param payload_type 32 | * TODO 33 | * @param payloadFormat 34 | * TODO 35 | * @param sample_rate 36 | * @param channels 37 | * TODO 38 | * @param additional_decoder 39 | */ 40 | AudioRxHandle createReceiver(RtpReceiverOptions options, UdpSocket socket, AudioFormat audio_format, 41 | CodecType codec, 42 | int payload_type, RtpPayloadFormat payloadFormat, int sample_rate, int channels, Encoder additional_decoder, RtpStreamReceiverListener listener) 43 | throws IOException, UnsupportedAudioFileException; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/rx/AudioRxHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.rx; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | /** 9 | * TODO 10 | * 11 | * @author Bernhard Haumacher 12 | */ 13 | public interface AudioRxHandle { 14 | 15 | /** 16 | * TODO 17 | * 18 | */ 19 | void start(Executor executor); 20 | 21 | /** 22 | * TODO 23 | * 24 | */ 25 | void halt(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/rx/RtpAudioRxHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.rx; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.RtpStreamReceiver; 9 | 10 | /** 11 | * {@link AudioRxHandle} default implementation. 12 | */ 13 | public class RtpAudioRxHandler implements AudioRxHandle { 14 | 15 | private final RtpStreamReceiver _rtpReceiver; 16 | 17 | /** 18 | * Creates a {@link RtpAudioRxHandler}. 19 | */ 20 | public RtpAudioRxHandler(RtpStreamReceiver rtpReceiver) { 21 | _rtpReceiver = rtpReceiver; 22 | } 23 | 24 | @Override 25 | public void start(Executor executor) { 26 | executor.execute(_rtpReceiver); 27 | } 28 | 29 | @Override 30 | public void halt() { 31 | _rtpReceiver.halt(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/rx/RtpReceiverOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.rx; 5 | 6 | import org.mjsip.media.RtpStreamReceiver; 7 | 8 | /** 9 | * Options for {@link RtpStreamReceiver}. 10 | */ 11 | public interface RtpReceiverOptions { 12 | 13 | /** Whether out-of-sequence and duplicated packets are discarded. */ 14 | boolean sequenceCheck(); 15 | 16 | /** Whether filling silence intervals with (silence-equivalent) void data. */ 17 | boolean silencePadding(); 18 | 19 | /** 20 | * The packet random early drop (RED) value. The number of packets that separates two drops. A 21 | * value of 0 means no drop. If greater than 0, it is the inverse of the packet drop rate. 22 | */ 23 | int randomEarlyDrop(); 24 | 25 | /** 26 | * In ssrc-check mode packets with a SSRC that differs from the one in the first received packet 27 | * are discarded. 28 | */ 29 | boolean ssrcCheck(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/tx/AudioTXHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.tx; 5 | 6 | import java.net.UnknownHostException; 7 | import java.util.concurrent.Executor; 8 | 9 | import org.mjsip.media.RtpStreamSender; 10 | import org.mjsip.rtp.RtpControl; 11 | import org.mjsip.rtp.RtpPayloadFormat; 12 | import org.zoolu.net.SocketAddress; 13 | 14 | /** 15 | * Handle for controlling an audio transmission. 16 | * 17 | * @see AudioTransmitter#createSender(RtpSenderOptions, org.zoolu.net.UdpSocket, 18 | * javax.sound.sampled.AudioFormat, org.zoolu.sound.CodecType, int, RtpPayloadFormat, int, 19 | * int, org.zoolu.util.Encoder, long, int, String, int, org.mjsip.media.RtpStreamSenderListener, RtpControl) 20 | */ 21 | public interface AudioTXHandle { 22 | 23 | /** 24 | * Starts the transmission. 25 | */ 26 | void start(Executor executor); 27 | 28 | /** 29 | * Stops the transmission. 30 | */ 31 | void halt(); 32 | 33 | /** 34 | * Switches the remote socket address. 35 | * 36 | * @see RtpStreamSender#setRemoteSoAddress(SocketAddress) 37 | */ 38 | void setRemoteSoAddress(SocketAddress remote_soaddr) throws UnknownHostException; 39 | 40 | /** 41 | * Waits until the current transmission has completed. 42 | */ 43 | void join() throws InterruptedException; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/tx/AudioTransmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.tx; 5 | 6 | import java.io.IOException; 7 | 8 | import javax.sound.sampled.AudioFormat; 9 | 10 | import org.mjsip.media.RtpStreamSenderListener; 11 | import org.mjsip.rtp.RtpControl; 12 | import org.mjsip.rtp.RtpPayloadFormat; 13 | import org.zoolu.net.UdpSocket; 14 | import org.zoolu.sound.CodecType; 15 | import org.zoolu.util.Encoder; 16 | 17 | /** 18 | * An audio transmitter encapsulating the source of the audio data. 19 | */ 20 | public interface AudioTransmitter { 21 | 22 | /** 23 | * Creates a transmission handle. 24 | * @param payloadFormat TODO 25 | * @param rtpControl TODO 26 | * @see AudioTXHandle#start() 27 | * @see AudioTXHandle#halt() 28 | */ 29 | AudioTXHandle createSender(RtpSenderOptions options, UdpSocket udp_socket, AudioFormat audio_format, 30 | CodecType codec, int payload_type, RtpPayloadFormat payloadFormat, 31 | int sample_rate, int channels, Encoder additional_encoder, long packet_time, 32 | int packet_size, String remote_addr, int remote_port, RtpStreamSenderListener listener, RtpControl rtpControl) throws IOException; 33 | } 34 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/tx/RtpAudioTxHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.tx; 5 | 6 | import java.net.UnknownHostException; 7 | import java.util.concurrent.Executor; 8 | 9 | import org.mjsip.media.RtpStreamSender; 10 | import org.zoolu.net.SocketAddress; 11 | 12 | /** 13 | * {@link AudioTXHandle} implementation. 14 | */ 15 | public class RtpAudioTxHandle implements AudioTXHandle { 16 | 17 | private RtpStreamSender _rtpSender; 18 | 19 | /** 20 | * Creates a {@link RtpAudioTxHandle}. 21 | */ 22 | public RtpAudioTxHandle(RtpStreamSender rtpSender) { 23 | _rtpSender = rtpSender; 24 | } 25 | 26 | /** 27 | * The underlying sender. 28 | */ 29 | public RtpStreamSender getRtpSender() { 30 | return _rtpSender; 31 | } 32 | 33 | @Override 34 | public void start(Executor executor) { 35 | executor.execute(_rtpSender); 36 | } 37 | 38 | @Override 39 | public void halt() { 40 | _rtpSender.halt(); 41 | } 42 | 43 | @Override 44 | public void join() throws InterruptedException { 45 | _rtpSender.join(); 46 | } 47 | 48 | @Override 49 | public void setRemoteSoAddress(SocketAddress remote_soaddr) throws UnknownHostException { 50 | getRtpSender().setRemoteSoAddress(remote_soaddr); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/media/tx/RtpSenderOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.media.tx; 5 | 6 | import org.mjsip.media.RtpStreamSender; 7 | 8 | /** 9 | * Options for the {@link RtpStreamSender}. 10 | */ 11 | public interface RtpSenderOptions { 12 | 13 | /** 14 | * The synchronization adjustment time (in milliseconds). 15 | * 16 | *

17 | * It accelerates (< 0) or reduces (> 0) the sending rate with respect to the nominal 18 | * value. 19 | * 20 | * @return The difference between the actual inter-packet sending time with respect to the 21 | * nominal value (in milliseconds). 22 | */ 23 | long syncAdjust(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/pool/PortConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.pool; 5 | 6 | import org.kohsuke.args4j.Option; 7 | 8 | /** 9 | * Configuration options for specifying a port range to serve RTP streams. 10 | */ 11 | public class PortConfig implements PortOptions { 12 | 13 | @Option(name = "--media-port", usage = "The first port used for RTP media streams.") 14 | private int _mediaPort = 50000; 15 | 16 | @Option(name = "--port-count", usage = "The number of ports used for RTP media streaming.") 17 | private int _portCount = 100; 18 | 19 | @Override 20 | public int getMediaPort() { 21 | return _mediaPort; 22 | } 23 | 24 | /** @see #getMediaPort() */ 25 | public void setMediaPort(int mediaPort) { 26 | _mediaPort = mediaPort; 27 | } 28 | 29 | @Override 30 | public int getPortCount() { 31 | return _portCount; 32 | } 33 | 34 | /** @see #getPortCount() */ 35 | public void setPortCount(int portCount) { 36 | _portCount = portCount; 37 | } 38 | 39 | /** 40 | * Creates a {@link PortPool} with this configuration. 41 | */ 42 | public PortPool createPool() { 43 | return new PortPool(getMediaPort(), getPortCount()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/pool/PortOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.pool; 5 | 6 | /** 7 | * Options for the {@link PortPool}. 8 | */ 9 | public interface PortOptions { 10 | 11 | /** 12 | * The first port to use for media streaming. 13 | * 14 | * @see #getPortCount() 15 | */ 16 | int getMediaPort(); 17 | 18 | /** 19 | * The number of ports starting with {@link #getMediaPort()} to use for media streaming. 20 | * 21 | *

22 | * Each call handled in parallel requires as many ports as media streams are transmitted in that 23 | * call. This setting indirectly limits the number of parallel calls a system can handle. 24 | *

25 | * 26 | * @see #getMediaPort() 27 | */ 28 | int getPortCount(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/rtp/BufferUtil.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.rtp; 2 | 3 | /** 4 | * Utilities for accessing byte buffers. 5 | */ 6 | public class BufferUtil { 7 | 8 | /** Gets long value. */ 9 | public static long getLong(byte[] data, int start, int stop) { 10 | long result = 0; 11 | for (int n = start; n < stop; n++) { 12 | result <<= 8; 13 | result |= data[n] & 0xFF; 14 | } 15 | return result; 16 | } 17 | 18 | /** Sets long value. */ 19 | public static void setLong(long value, byte[] data, int start, int stop) { 20 | for (int n = stop - 1; n >= start; n--) { 21 | data[n] = (byte) (value & 0xFF); 22 | value >>>= 8; 23 | } 24 | } 25 | 26 | /** Gets Int value. */ 27 | public static int getInt(byte[] data, int start, int stop) { 28 | int result = 0; 29 | for (int n = start; n < stop; n++) { 30 | result <<= 8; 31 | result |= data[n] & 0xFF; 32 | } 33 | return result; 34 | } 35 | 36 | /** Sets Int value. */ 37 | public static void setInt(int value, byte[] data, int start, int stop) { 38 | for (int n = stop - 1; n >= start; n--) { 39 | data[n] = (byte) (value & 0xFF); 40 | value >>>= 8; 41 | } 42 | } 43 | 44 | /** Gets bit value. */ 45 | public static boolean getBit(byte b, int bit) { 46 | return ((b >>> bit) & 0x01) == 1; 47 | } 48 | 49 | /** Sets bit value. */ 50 | public static void setBit(boolean value, byte[] data, int offset, int bit) { 51 | byte b = data[offset]; 52 | if (value) { 53 | b |= (1 << bit); 54 | } else { 55 | b &= 0xFF ^ (1 << bit); 56 | } 57 | data[offset] = b; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/rtp/RtcpProviderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.rtp; 23 | 24 | 25 | 26 | 27 | /** Listener for RtcpProvider events. 28 | */ 29 | public interface RtcpProviderListener { 30 | 31 | /** When a new RTCP packet is received. */ 32 | public void onReceivedPacket(RtcpProvider rtcp, RtcpPacket rtcp_packet); 33 | 34 | /** When RtcpProvider terminates. */ 35 | public void onServiceTerminated(RtcpProvider rtcp, Exception error); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/rtp/RtpProviderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.rtp; 23 | 24 | 25 | 26 | 27 | /** Listener for RtpProvider events. 28 | */ 29 | public interface RtpProviderListener { 30 | 31 | /** When a new RTP packet is received. */ 32 | public void onReceivedPacket(RtpProvider rtp, RtpPacket rtp_packet); 33 | 34 | /** When RtpProvider terminates. */ 35 | public void onServiceTerminated(RtpProvider rtp, Exception error); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/rtp/RtpReceiverListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * This source code is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This source code is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this source code; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author(s): 19 | * Luca Veltri (luca.veltri@unipr.it) 20 | */ 21 | 22 | package org.mjsip.rtp; 23 | 24 | 25 | 26 | 27 | /** Listener for RtpReceiver events. 28 | */ 29 | public interface RtpReceiverListener { 30 | 31 | /** When a new RTP packet is received. */ 32 | public void onReceivedPacket(RtpReceiver rtp_receiver, RtpPacket rtp_packet); 33 | 34 | /** When RtpReceiver terminates. */ 35 | public void onServiceTerminated(RtpReceiver rtp_receiver, Exception error); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sdp/field/SessionNameField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sdp.field; 25 | 26 | 27 | 28 | import org.mjsip.sdp.SdpField; 29 | 30 | 31 | 32 | /** SDP session name field. 33 | *

34 | *

35 |   *    session-name-field = "s=" text CRLF
36 |   * 
37 | */ 38 | public class SessionNameField extends SdpField { 39 | 40 | /** Creates a new SessionNameField. 41 | * @param session_name session name */ 42 | public SessionNameField(String session_name) { 43 | super('s',session_name); 44 | } 45 | 46 | /** Creates a new SessionNameField with value '-'. */ 47 | public SessionNameField() { 48 | super('s',"-"); 49 | } 50 | 51 | /** Creates a new SessionNameField. 52 | * @param sf the session name filed */ 53 | public SessionNameField(SdpField sf) { 54 | super(sf); 55 | } 56 | 57 | /** Gets the session name. 58 | * @return the session name */ 59 | public String getSession() { 60 | return value; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/address/UnexpectedUriSchemeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.address; 25 | 26 | 27 | 28 | 29 | /** Unexpected URI's scheme exception. 30 | *

31 | * When a URI is processed with an invalid or unsupported URI'scheme. 32 | */ 33 | public class UnexpectedUriSchemeException extends RuntimeException { 34 | 35 | 36 | /** Creates a new UnexpectedUriSchemeException. */ 37 | public UnexpectedUriSchemeException() { 38 | super("Unexpected URI's scheme."); 39 | } 40 | 41 | 42 | /** Creates a new UnexpectedUriSchemeException. */ 43 | public UnexpectedUriSchemeException(String scheme) { 44 | super("Unexpected URI's scheme '"+scheme+"'."); 45 | } 46 | 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/config/IpAddressHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | import org.zoolu.net.IpAddress; 13 | 14 | /** 15 | * {@link OptionHandler} for {@link IpAddress} instances. 16 | */ 17 | public class IpAddressHandler extends OptionHandler { 18 | 19 | /** 20 | * Creates a {@link IpAddressHandler}. 21 | */ 22 | public IpAddressHandler(CmdLineParser parser, OptionDef option, Setter setter) { 23 | super(parser, option, setter); 24 | } 25 | 26 | @Override 27 | public int parseArguments(Parameters params) throws CmdLineException { 28 | String value = params.getParameter(0); 29 | setter.addValue(new IpAddress(value)); 30 | return 1; 31 | } 32 | 33 | @Override 34 | public String getDefaultMetaVariable() { 35 | return ""; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/config/MediaDescHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | import org.mjsip.media.MediaDesc; 13 | 14 | /** 15 | * {@link OptionHandler} for {@link MediaDesc} instances. 16 | */ 17 | public class MediaDescHandler extends OptionHandler { 18 | 19 | /** 20 | * Creates a {@link MediaDescHandler}. 21 | */ 22 | public MediaDescHandler(CmdLineParser parser, OptionDef option, Setter setter) { 23 | super(parser, option, setter); 24 | } 25 | 26 | @Override 27 | public int parseArguments(Parameters params) throws CmdLineException { 28 | String value = params.getParameter(0); 29 | setter.addValue(MediaDesc.parseMediaDesc(value)); 30 | return 1; 31 | } 32 | 33 | @Override 34 | public String getDefaultMetaVariable() { 35 | return ""; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/config/NameAddressHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | import org.mjsip.sip.address.NameAddress; 13 | 14 | /** 15 | * {@link OptionHandler} for {@link NameAddress} values. 16 | */ 17 | public class NameAddressHandler extends OptionHandler { 18 | 19 | /** 20 | * Creates a {@link NameAddressHandler}. 21 | */ 22 | public NameAddressHandler(CmdLineParser parser, OptionDef option, Setter setter) { 23 | super(parser, option, setter); 24 | } 25 | 26 | @Override 27 | public int parseArguments(Parameters params) throws CmdLineException { 28 | setter.addValue(NameAddress.parse(params.getParameter(0))); 29 | return 1; 30 | } 31 | 32 | @Override 33 | public String getDefaultMetaVariable() { 34 | return ""; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/config/SipURIHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | import org.mjsip.sip.address.SipURI; 13 | 14 | /** 15 | * {@link OptionHandler} for {@link SipURI}s. 16 | */ 17 | public class SipURIHandler extends OptionHandler { 18 | 19 | /** 20 | * Creates a {@link IpAddressHandler}. 21 | */ 22 | public SipURIHandler(CmdLineParser parser, OptionDef option, Setter setter) { 23 | super(parser, option, setter); 24 | } 25 | 26 | @Override 27 | public int parseArguments(Parameters params) throws CmdLineException { 28 | String value = params.getParameter(0); 29 | setter.addValue(SipURI.parseSipURI(value)); 30 | return 1; 31 | } 32 | 33 | @Override 34 | public String getDefaultMetaVariable() { 35 | return "[:]"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/config/SocketAddressHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | import org.zoolu.net.SocketAddress; 13 | 14 | /** 15 | * {@link OptionHandler} for {@link SocketAddress} instances. 16 | */ 17 | public class SocketAddressHandler extends OptionHandler { 18 | 19 | /** 20 | * Creates a {@link SocketAddressHandler}. 21 | */ 22 | public SocketAddressHandler(CmdLineParser parser, OptionDef option, Setter setter) { 23 | super(parser, option, setter); 24 | } 25 | 26 | @Override 27 | public int parseArguments(Parameters params) throws CmdLineException { 28 | String value = params.getParameter(0); 29 | setter.addValue(new SocketAddress(value)); 30 | return 1; 31 | } 32 | 33 | @Override 34 | public String getDefaultMetaVariable() { 35 | return ""; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/AcceptEncodingHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Accept-Encoding */ 30 | public class AcceptEncodingHeader extends ParametricHeader { 31 | 32 | public AcceptEncodingHeader(String hvalue) { 33 | super(SipHeaders.Accept_Encoding,hvalue); 34 | } 35 | 36 | public AcceptEncodingHeader(Header hd) { 37 | super(hd); 38 | } 39 | 40 | /** Gets the accept-encoding */ 41 | public String getAcceptEncoding() { 42 | return value; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/AcceptHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Accept */ 30 | public class AcceptHeader extends ParametricHeader { 31 | 32 | public AcceptHeader() { 33 | super(SipHeaders.Accept,"application/sdp"); 34 | } 35 | 36 | public AcceptHeader(String hvalue) { 37 | super(SipHeaders.Accept,hvalue); 38 | } 39 | 40 | public AcceptHeader(Header hd) { 41 | super(hd); 42 | } 43 | 44 | /** Gets the accept-range */ 45 | public String getAcceptRange() { 46 | return value; 47 | } 48 | 49 | /** Sets the accept-range */ 50 | public void setAcceptRange(String range) { 51 | value=range; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/AcceptLanguageHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Accept-Language */ 30 | public class AcceptLanguageHeader extends ParametricHeader { 31 | 32 | public AcceptLanguageHeader(String hvalue) { 33 | super(SipHeaders.Accept_Language,hvalue); 34 | } 35 | 36 | public AcceptLanguageHeader(Header hd) { 37 | super(hd); 38 | } 39 | 40 | /** Gets the accept-language */ 41 | public String getAcceptLanguage() { 42 | return value; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/AlertInfoHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Allert-Info */ 30 | public class AlertInfoHeader extends ParametricHeader { 31 | 32 | public AlertInfoHeader(String absolute_uri) { 33 | super(SipHeaders.Alert_Info,null); 34 | setAbsoluteURI(absolute_uri); 35 | } 36 | 37 | public AlertInfoHeader(Header hd) { 38 | super(hd); 39 | } 40 | 41 | /** Gets the absoluteURI */ 42 | public String getAbsoluteURI() { 43 | int begin=value.indexOf("<"); 44 | int end=value.indexOf(">"); 45 | if (begin<0) begin=0; else begin++; 46 | if (end<0) end=value.length(); 47 | return value.substring(begin,end); 48 | } 49 | 50 | /** Sets the absoluteURI */ 51 | public void setAbsoluteURI(String absolute_uri) { 52 | absolute_uri=absolute_uri.trim(); 53 | if (absolute_uri.indexOf("<")<0) absolute_uri="<"+absolute_uri; 54 | if (absolute_uri.indexOf(">")<0) absolute_uri=absolute_uri+">"; 55 | value=absolute_uri; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/AllowEventsHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import java.util.Vector; 28 | 29 | 30 | /** SIP Header Allow-Events */ 31 | public class AllowEventsHeader extends ListHeader { 32 | 33 | public AllowEventsHeader(String hvalue) { 34 | super(SipHeaders.Allow_Events,hvalue); 35 | } 36 | 37 | public AllowEventsHeader(Header hd) { 38 | super(hd); 39 | } 40 | 41 | /** Gets list of events (as Vector of Strings). */ 42 | public Vector getEvents() { 43 | return super.getElements(); 44 | } 45 | 46 | /** Sets the list of events. */ 47 | public void setEvents(Vector events) { 48 | super.setElements(events); 49 | } 50 | 51 | /** Adds a new event to the event list. */ 52 | public void addEvent(String event) { 53 | super.addElement(event); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ContentLengthHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import org.mjsip.sip.provider.SipParser; 28 | 29 | 30 | /** SIP Header Content-Length */ 31 | public class ContentLengthHeader extends LegacyHeader { 32 | 33 | //public ContentLengthHeader() 34 | //{ super(SipHeaders.Content_Length); 35 | //} 36 | 37 | public ContentLengthHeader(int len) { 38 | super(SipHeaders.Content_Length,String.valueOf(len)); 39 | } 40 | 41 | public ContentLengthHeader(Header hd) { 42 | super(hd); 43 | } 44 | 45 | /** Gets content-length of ContentLengthHeader */ 46 | public int getContentLength() { 47 | return (new SipParser(value)).getInt(); 48 | } 49 | 50 | /** Set content-length of ContentLengthHeader */ 51 | public void setContentLength(int cLength) { 52 | value=String.valueOf(cLength); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ContentTypeHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Content-Type */ 30 | public class ContentTypeHeader extends TokenParametricHeader { 31 | 32 | //public ContentTypeHeader() 33 | //{ super(SipHeaders.Content_Type); 34 | //} 35 | 36 | public ContentTypeHeader(String hvalue) { 37 | super(SipHeaders.Content_Type,hvalue); 38 | } 39 | 40 | public ContentTypeHeader(Header hd) { 41 | super(hd); 42 | } 43 | 44 | /** Gets content-length of ContentLengthHeader */ 45 | public String getContentType() { 46 | return getToken(); 47 | } 48 | 49 | /** Sets content-length of ContentLengthHeader */ 50 | public void setContentType(String cType) { 51 | value=cType; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/DateHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import java.util.Date; 28 | 29 | 30 | /** SIP Header Date */ 31 | public class DateHeader extends SipDateHeader { 32 | 33 | //public DateHeader() 34 | //{ super(SipHeaders.Date); 35 | //} 36 | 37 | public DateHeader(String hvalue) { 38 | super(SipHeaders.Date,hvalue); 39 | } 40 | 41 | public DateHeader(Date date) { 42 | super(SipHeaders.Date,date); 43 | } 44 | 45 | public DateHeader(Header hd) { 46 | super(hd); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/GenericHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.header; 5 | 6 | /** 7 | * A header with a plain string value. 8 | */ 9 | public class GenericHeader extends Header { 10 | 11 | /** The header string, without terminating CRLF */ 12 | private String _value; 13 | 14 | /** 15 | * Creates a {@link GenericHeader}. 16 | */ 17 | public GenericHeader(String name, String value) { 18 | super(name); 19 | this._value = value; 20 | } 21 | 22 | /** 23 | * Creates a {@link GenericHeader}. 24 | */ 25 | public GenericHeader(LegacyHeader hd) { 26 | this(hd.getName(), hd.getValue()); 27 | } 28 | 29 | @Override 30 | public String getValue() { 31 | return _value; 32 | } 33 | 34 | /** Sets value of Header */ 35 | public void setValue(String hvalue) { 36 | _value = hvalue; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/InfoPackageHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP header field Info-Package, defined by RFC 6086. 30 | */ 31 | public class InfoPackageHeader extends TokenParametricHeader { 32 | 33 | 34 | /** Creates a InfoPackageHeader with value hvalue. */ 35 | public InfoPackageHeader(String hvalue) { 36 | super(SipHeaders.Info_Package,hvalue); 37 | } 38 | 39 | /** Creates a new InfoPackageHeader equal to InfoPackageHeader hd. */ 40 | public InfoPackageHeader(Header hd) { 41 | super(hd); 42 | } 43 | 44 | /** Gets the package. */ 45 | public String getPackage() { 46 | return getToken(); 47 | } 48 | 49 | /** Whether package equals to the given package value. */ 50 | public boolean packageEqualsTo(String package_value) { 51 | return tokenEqualsTo(package_value); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/LegacyHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | package org.mjsip.sip.header; 24 | 25 | /** Header is the base Class for all SIP Headers 26 | */ 27 | public class LegacyHeader extends Header { 28 | 29 | /** The header string, without terminating CRLF */ 30 | protected String value; 31 | 32 | /** Creates a void Header. */ 33 | protected LegacyHeader() { 34 | super((String) null); 35 | value=null; 36 | } 37 | 38 | /** Creates a new Header. */ 39 | public LegacyHeader(String hname, String hvalue) { 40 | super(hname); 41 | value=hvalue; 42 | } 43 | 44 | /** Creates a new Header. */ 45 | public LegacyHeader(Header hd) { 46 | super(hd.getName()); 47 | value=hd.getValue(); 48 | } 49 | 50 | /** Creates and returns a copy of the Header */ 51 | @Override 52 | public Object clone() { 53 | return new LegacyHeader(getName(),getValue()); 54 | } 55 | 56 | /** Gets value of Header */ 57 | @Override 58 | public String getValue() { 59 | return value; 60 | } 61 | 62 | /** Sets value of Header */ 63 | public void setValue(String hvalue) { 64 | value=hvalue; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ProxyAuthenticateHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | import java.util.Vector; 27 | 28 | /** SIP Proxy-Authenticate header */ 29 | public class ProxyAuthenticateHeader extends WwwAuthenticateHeader { 30 | 31 | /** Creates a new ProxyAuthenticateHeader */ 32 | public ProxyAuthenticateHeader(String hvalue) { 33 | super(SipHeaders.Proxy_Authenticate, hvalue); 34 | } 35 | 36 | /** Creates a new ProxyAuthenticateHeader */ 37 | public ProxyAuthenticateHeader(Header hd) { 38 | super(hd); 39 | } 40 | 41 | /** Creates a new ProxyAuthenticateHeader 42 | * specifing the auth_scheme and the vector of authentication parameters. 43 | *

auth_param is a vector of String of the form parm_name "=" parm_value */ 44 | public ProxyAuthenticateHeader(String auth_scheme, Vector auth_params) { 45 | super(SipHeaders.Proxy_Authenticate, auth_scheme, auth_params); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ProxyAuthorizationHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import java.util.Vector; 29 | 30 | 31 | 32 | /** SIP Proxy-Authorization header */ 33 | public class ProxyAuthorizationHeader extends AuthorizationHeader { 34 | 35 | /** Creates a new ProxyAuthorizationHeader */ 36 | public ProxyAuthorizationHeader(String hvalue) { 37 | super(SipHeaders.Proxy_Authorization, hvalue); 38 | } 39 | 40 | /** Creates a new ProxyAuthorizationHeader */ 41 | public ProxyAuthorizationHeader(Header hd) { 42 | super(hd); 43 | } 44 | 45 | /** Creates a new ProxyAuthorizationHeader 46 | * specifing the auth_scheme and the vector of authentication parameters. 47 | *

auth_param is a vector of String of the form parm_name "=" parm_value */ 48 | public ProxyAuthorizationHeader(String auth_scheme, Vector auth_params) { 49 | super(SipHeaders.Proxy_Authorization, auth_scheme, auth_params); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/RecordRouteHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import org.mjsip.sip.address.NameAddress; 28 | 29 | 30 | /** SIP Header Record-Route */ 31 | public class RecordRouteHeader extends NameAddressHeader { 32 | 33 | //public RecordRouteHeader() 34 | //{ super(SipHeaders.Record_Route); 35 | //} 36 | 37 | public RecordRouteHeader(NameAddress nameaddr) { 38 | super(SipHeaders.Record_Route,nameaddr); 39 | } 40 | 41 | public RecordRouteHeader(Header hd) { 42 | super(hd); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ReferToHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import org.mjsip.sip.address.NameAddress; 29 | import org.mjsip.sip.address.SipURI; 30 | 31 | 32 | 33 | /** SIP ReferTo header (RFC 3515). 34 | *

Refer-To is a request header field (request-header). 35 | * It appears in REFER requests. It provides a URI to reference. */ 36 | public class ReferToHeader extends NameAddressHeader { 37 | 38 | 39 | public ReferToHeader(NameAddress nameaddr) { 40 | super(SipHeaders.Refer_To,nameaddr); 41 | } 42 | 43 | public ReferToHeader(SipURI uri) { 44 | super(SipHeaders.Refer_To,uri); 45 | } 46 | 47 | public ReferToHeader(Header hd) { 48 | super(hd); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ReferredByHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import org.mjsip.sip.address.NameAddress; 29 | import org.mjsip.sip.address.SipURI; 30 | 31 | 32 | 33 | /** SIP Referred-By header (draft-ietf-sip-referredby). 34 | *

Referred-By is a request header field (request-header). 35 | * It appears in REFER requests. It provides the URI of the referrer. */ 36 | public class ReferredByHeader extends NameAddressHeader { 37 | 38 | 39 | /** Costructs a new ReferredByHeader. */ 40 | public ReferredByHeader(NameAddress nameaddr) { 41 | super(SipHeaders.Referred_By,nameaddr); 42 | } 43 | 44 | /** Costructs a new ReferredByHeader. */ 45 | public ReferredByHeader(SipURI uri) { 46 | super(SipHeaders.Referred_By,uri); 47 | } 48 | 49 | /** Costructs a new ReferredByHeader. */ 50 | public ReferredByHeader(Header hd) { 51 | super(hd); 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/RequireHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import java.util.Vector; 29 | 30 | 31 | 32 | /** SIP Header Require. 33 | */ 34 | public class RequireHeader extends OptionTagsHeader { 35 | 36 | 37 | /** Creates a new RequireHeader. 38 | * @param option_tags Vector (of String) of option-tags. */ 39 | public RequireHeader(Vector option_tags) { 40 | super(SipHeaders.Require,option_tags); 41 | } 42 | 43 | /** Creates a new RequireHeader. 44 | * @param option_tags array of option-tags. */ 45 | public RequireHeader(String[] option_tags) { 46 | super(SipHeaders.Require,option_tags); 47 | } 48 | 49 | /** Creates a new RequireHeader. 50 | * @param option_tag a single option-tag or a comma-separated list of option-tags. */ 51 | public RequireHeader(String option_tag) { 52 | super(SipHeaders.Require,option_tag); 53 | } 54 | 55 | 56 | /** Creates a new RequireHeader. */ 57 | public RequireHeader(Header hd) { 58 | super(hd); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/RouteHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import org.mjsip.sip.address.NameAddress; 28 | 29 | 30 | /** SIP Header Route */ 31 | public class RouteHeader extends NameAddressHeader { 32 | 33 | //public RouteHeader() 34 | //{ super(SipHeaders.Route); 35 | //} 36 | 37 | public RouteHeader(NameAddress nameaddr) { 38 | super(SipHeaders.Route,nameaddr); 39 | } 40 | 41 | public RouteHeader(Header hd) { 42 | super(hd); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ServerHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** Server header that carries information about the UAS */ 30 | public class ServerHeader extends LegacyHeader { 31 | 32 | public ServerHeader(String info) { 33 | super(SipHeaders.Server,info); 34 | } 35 | 36 | public ServerHeader(Header hd) { 37 | super(hd); 38 | } 39 | 40 | /** Gets UAS information */ 41 | public String getInfo() { 42 | return value; 43 | } 44 | 45 | /** Sets the UAS information */ 46 | public void setInfo(String info) { 47 | value=info; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/ServiceRouteHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | import org.mjsip.sip.address.NameAddress; 28 | 29 | 30 | /** SIP Service-Route header field. */ 31 | public class ServiceRouteHeader extends NameAddressHeader { 32 | 33 | public ServiceRouteHeader(NameAddress nameaddr) { 34 | super(SipHeaders.ServiceRoute,nameaddr); 35 | } 36 | 37 | public ServiceRouteHeader(LegacyHeader hd) { 38 | super(hd); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/SubjectHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** SIP Header Subject. 30 | */ 31 | public class SubjectHeader extends LegacyHeader { 32 | 33 | /** Creates a SubjectHeader */ 34 | //public SubjectHeader() 35 | //{ super(SipHeaders.Subject); 36 | //} 37 | 38 | /** Creates a SubjectHeader with value hvalue */ 39 | public SubjectHeader(String hvalue) { 40 | super(SipHeaders.Subject,hvalue); 41 | } 42 | 43 | /** Creates a new SubjectHeader equal to SubjectHeader hd */ 44 | public SubjectHeader(Header hd) { 45 | super(hd); 46 | } 47 | 48 | /** Gets the subject */ 49 | public String getSubject() { 50 | return value; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/SupportedHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import java.util.Vector; 29 | 30 | 31 | 32 | /** SIP Header Supported. 33 | */ 34 | public class SupportedHeader extends OptionTagsHeader { 35 | 36 | 37 | /** Creates a new SupportedHeader. 38 | * @param option_tags Vector (of String) of option-tags. */ 39 | public SupportedHeader(Vector option_tags) { 40 | super(SipHeaders.Supported,option_tags); 41 | } 42 | 43 | /** Creates a new SupportedHeader. 44 | * @param option_tags array of option-tags. */ 45 | public SupportedHeader(String[] option_tags) { 46 | super(SipHeaders.Supported,option_tags); 47 | } 48 | 49 | /** Creates a new SupportedHeader. 50 | * @param option_tag a single option-tag or a comma-separated list of option-tags. */ 51 | public SupportedHeader(String option_tag) { 52 | super(SipHeaders.Supported,option_tag); 53 | } 54 | 55 | 56 | /** Creates a new SupportedHeader. */ 57 | public SupportedHeader(Header hd) { 58 | super(hd); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/TokenParametricHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import org.mjsip.sip.provider.SipParser; 29 | 30 | 31 | 32 | /** Abstract TokenParametricHeader is the base class for all SIP Header fields that contains a token, 33 | * optionally followed by parameters */ 34 | public abstract class TokenParametricHeader extends ParametricHeader { 35 | 36 | 37 | /** Creates a new TokenParametricHeader. */ 38 | protected TokenParametricHeader(String hname, String hvalue) { 39 | super(hname,hvalue); 40 | } 41 | 42 | /** Creates a new TokenParametricHeader. */ 43 | protected TokenParametricHeader(Header hd) { 44 | super(hd); 45 | } 46 | 47 | /** Gets token value. */ 48 | protected String getToken() { 49 | int index=indexOfFirstSemi(); 50 | String str=(index<0)? value : value.substring(0,index); 51 | return (new SipParser(str)).getString(); 52 | } 53 | 54 | /** Whether token equals the given value. */ 55 | protected boolean tokenEqualsTo(String token_value) { 56 | return getToken().equals(token_value); 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/UnsupportedHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | import java.util.Vector; 29 | 30 | 31 | 32 | /** SIP Header Unsupported. 33 | */ 34 | public class UnsupportedHeader extends OptionTagsHeader { 35 | 36 | 37 | /** Creates a new UnsupportedHeader. 38 | * @param option_tags Vector (of String) of option-tags. */ 39 | public UnsupportedHeader(Vector option_tags) { 40 | super(SipHeaders.Unsupported,option_tags); 41 | } 42 | 43 | /** Creates a new UnsupportedHeader. 44 | * @param option_tags array of option-tags. */ 45 | public UnsupportedHeader(String[] option_tags) { 46 | super(SipHeaders.Unsupported,option_tags); 47 | } 48 | 49 | /** Creates a new UnsupportedHeader. 50 | * @param option_tag a single option-tag or a comma-separated list of option-tags. */ 51 | public UnsupportedHeader(String option_tag) { 52 | super(SipHeaders.Unsupported,option_tag); 53 | } 54 | 55 | 56 | /** Creates a new UnsupportedHeader. */ 57 | public UnsupportedHeader(Header hd) { 58 | super(hd); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/header/UserAgentHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.header; 25 | 26 | 27 | 28 | 29 | /** User-Agent header that carries information about the UAC */ 30 | public class UserAgentHeader extends LegacyHeader { 31 | 32 | public UserAgentHeader(String info) { 33 | super(SipHeaders.User_Agent,info); 34 | } 35 | 36 | public UserAgentHeader(Header hd) { 37 | super(hd); 38 | } 39 | 40 | /** Gets UAC information */ 41 | public String getInfo() { 42 | return value; 43 | } 44 | 45 | /** Sets the UAC information */ 46 | public void setInfo(String info) { 47 | value=info; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/message/MalformedSipMessageException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.message; 25 | 26 | 27 | 28 | import java.io.IOException; 29 | 30 | 31 | 32 | /** Malformed SIP message exception. 33 | */ 34 | public class MalformedSipMessageException extends IOException { 35 | 36 | 37 | /** Creates a new MalformedSipMessageException. */ 38 | public MalformedSipMessageException() { 39 | super(); 40 | } 41 | 42 | /** Creates a new MalformedSipMessageException. 43 | * @param error the error message */ 44 | public MalformedSipMessageException(String error) { 45 | super(error); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/CopyOnWriteListeners.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.provider; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Listener lists with copy on write semantics. 11 | * 12 | * @author Bernhard Haumacher 13 | */ 14 | public abstract class CopyOnWriteListeners { 15 | 16 | private boolean _iterating; 17 | 18 | private List _list = new ArrayList<>(); 19 | 20 | /** 21 | * Adds the given element. 22 | */ 23 | public boolean add(L listener) { 24 | if (_list.contains(listener)) { 25 | return false; 26 | } 27 | return copyWhileIterating().add(listener); 28 | } 29 | 30 | private List copyWhileIterating() { 31 | if (_iterating) { 32 | _list = new ArrayList<>(_list); 33 | } 34 | return _list; 35 | } 36 | 37 | /** 38 | * Removes the given element. 39 | */ 40 | public boolean remove(L listener) { 41 | if (!_list.contains(listener)) { 42 | return false; 43 | } 44 | return copyWhileIterating().remove(listener); 45 | } 46 | 47 | /** 48 | * Clears this list. 49 | */ 50 | public void clear() { 51 | copyWhileIterating().clear(); 52 | } 53 | 54 | /** 55 | * Delivers the message to all listeners. 56 | */ 57 | public void notify(M msg) { 58 | boolean before = _iterating; 59 | try { 60 | _iterating = true; 61 | for (L listener : _list) { 62 | handle(listener, msg); 63 | } 64 | } finally { 65 | if (_iterating) { 66 | _iterating = before; 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * Callback actually delivering the message to the given listener. 73 | */ 74 | protected abstract void handle(L listener, M msg); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/MessageProblem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.provider; 5 | 6 | import org.mjsip.sip.message.SipMessage; 7 | 8 | /** 9 | * Description of a problem that occurred while processing a {@link SipMessage}. 10 | */ 11 | public class MessageProblem extends SipMessage { 12 | 13 | private final SipMessage _msg; 14 | 15 | private final Exception _exception; 16 | 17 | /** 18 | * Creates a {@link MessageProblem}. 19 | */ 20 | public MessageProblem(SipMessage msg, Exception exception) { 21 | _msg = msg; 22 | _exception = exception; 23 | } 24 | 25 | /** 26 | * The {@link SipMessage} that caused the problem. 27 | */ 28 | public SipMessage getMsg() { 29 | return _msg; 30 | } 31 | 32 | /** 33 | * The {@link Exception} that occurred. 34 | */ 35 | public Exception getException() { 36 | return _exception; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/SipProviderExceptionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.provider; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** A SipProviderExceptionListener listens for SipProvider onMessageException(SipMessage,Exception) events. 33 | */ 34 | public interface SipProviderExceptionListener { 35 | 36 | public void onMessageException(SipMessage msg, Exception e); 37 | } 38 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/SipProviderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.provider; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** A SipProviderListener listens for SipProvider onReceivedMessage(SipProvider,SipMessage) events. 33 | */ 34 | public interface SipProviderListener { 35 | 36 | /** When a new SipMessage is received by the SipProvider. */ 37 | public void onReceivedMessage(SipProvider sip_provider, SipMessage message); 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/SipTransportConnectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.provider; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** Listener for SipTransportConnection events. 33 | */ 34 | public interface SipTransportConnectionListener { 35 | 36 | /** When a new SIP message is received. */ 37 | public void onReceivedMessage(SipTransportConnection conn, SipMessage msg); 38 | 39 | /** When SipTransportConnection terminates. */ 40 | public void onConnectionTerminated(SipTransportConnection conn, Exception error); 41 | } 42 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/provider/SipTransportListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.provider; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | import org.zoolu.net.SocketAddress; 30 | 31 | 32 | 33 | /** Listener for SipTransport events. 34 | */ 35 | public interface SipTransportListener { 36 | 37 | /** When a new SIP message is received. */ 38 | public void onReceivedMessage(SipTransport transport, SipMessage msg); 39 | 40 | /** When a new incoming transport connection is established. It is called only for CO transport portocols. */ 41 | public void onIncomingTransportConnection(SipTransport transport, SocketAddress remote_soaddr); 42 | 43 | /** When a transport connection terminates. It is called only for CO transport portocols. */ 44 | public void onTransportConnectionTerminated(SipTransport transport, SocketAddress remote_soaddr, Exception error); 45 | 46 | /** When SipTransport terminates. */ 47 | public void onTransportTerminated(SipTransport transport, Exception error); 48 | } 49 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/transaction/AckTransactionServerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.transaction; 25 | 26 | 27 | 28 | 29 | /** An AckTransactionServerListener listens for AckTransactionServer events. 30 | */ 31 | public interface AckTransactionServerListener { 32 | 33 | /** When the AckTransactionServer receives the ACK and goes into the "Terminated" state. */ 34 | //public void onTransAck(AckTransactionServer ts, SipMessage ack); 35 | 36 | /** When the AckTransactionServer goes into the "Terminated" state, caused by transaction . */ 37 | public void onTransAckTimeout(AckTransactionServer ts); 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/transaction/InviteTransactionServerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.transaction; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** A TransactionServerListener listens for InviteTransactionServer events. 33 | * It extends TransactionServerListener by adding the onTransFailureAck(InviteTransactionServer,SipMessage) method. 34 | */ 35 | public interface InviteTransactionServerListener extends TransactionServerListener { 36 | 37 | /** When an InviteTransactionServer goes into the "Confirmed" state receining an ACK for NON-2xx response */ 38 | public void onTransFailureAck(InviteTransactionServer ts, SipMessage ack); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/transaction/ReliableProvisionalResponderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.transaction; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** A ReliableProvisionalResponderListener listens for ReilableProvisionalResponder events. 33 | */ 34 | public interface ReliableProvisionalResponderListener { 35 | 36 | 37 | /** When a provisional response has been confirmed (PRACK). */ 38 | public void onReliableProvisionalResponseConfirmation(ReliableProvisionalResponder rr, SipMessage resp, SipMessage prack); 39 | 40 | 41 | /** When the retransmission timeout expired without receiving coinfirmation. */ 42 | public void onReliableProvisionalResponseTimeout(ReliableProvisionalResponder rr, SipMessage resp); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/java/org/mjsip/sip/transaction/TransactionServerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.mjsip.sip.transaction; 25 | 26 | 27 | 28 | import org.mjsip.sip.message.SipMessage; 29 | 30 | 31 | 32 | /** A TransactionServerListener listens for TransactionServer events. 33 | * It collects all TransactionServer callback functions. 34 | */ 35 | public interface TransactionServerListener { 36 | 37 | /** When the TransactionServer goes into the "Trying" state receiving a request */ 38 | public void onTransRequest(TransactionServer ts, SipMessage req); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /mjsip-sip/src/main/resources/tinylog.properties: -------------------------------------------------------------------------------- 1 | writer.buffered = false 2 | writer.level = debug 3 | writer.format = [{date}] {level}: [{class}]: {message} 4 | writer.stream = out 5 | 6 | level = info 7 | 8 | # To enable debug logging. 9 | #level@org.mjsip.media.AudioFile = debug 10 | #level@org.mjsip.sip.provider.SipProvider = debug 11 | #level@org.mjsip.sip.dialog.Dialog = debug 12 | #level@org.mjsip.sip.dialog.InviteDialog = debug 13 | #level@org.mjsip.sip.dialog.ExtendedInviteDialog = debug 14 | -------------------------------------------------------------------------------- /mjsip-sip/src/test/java/org/mjsip/sip/authentication/TestDigestAuthentication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.sip.authentication; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.mjsip.sip.header.AuthorizationHeader; 9 | 10 | /** 11 | * Test for {@link DigestAuthentication}. 12 | */ 13 | @SuppressWarnings("javadoc") 14 | class TestDigestAuthentication { 15 | 16 | @Test 17 | void testResponse() { 18 | AuthorizationHeader ah = new AuthorizationHeader( 19 | "Digest username=\"Mufasa\", " 20 | + "realm=\"testrealm@host.com\", " 21 | + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " 22 | + "uri=\"/dir/index.html\", " 23 | + "qop=auth, " 24 | + "nc=00000001, " 25 | + "cnonce=\"0a4f113b\", " 26 | + "response=\"6629fae49393a05397450978507c4ef1\", " 27 | + "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"\n"); 28 | DigestAuthentication a = new DigestAuthentication("GET", ah, null, "Circle Of Life"); 29 | 30 | Assertions.assertEquals("GET", a.method); 31 | Assertions.assertEquals("Circle Of Life", a.passwd); 32 | Assertions.assertEquals("testrealm@host.com", a.realm); 33 | Assertions.assertEquals("dcd98b7102dd2f0e8b11d0f600bfb0c093", a.nonce); 34 | Assertions.assertEquals("/dir/index.html", a.uri); 35 | Assertions.assertEquals("auth", a.qop); 36 | Assertions.assertEquals("00000001", a.nc); 37 | Assertions.assertEquals("0a4f113b", a.cnonce); 38 | Assertions.assertEquals("Mufasa", a.username); 39 | 40 | Assertions.assertEquals("6629fae49393a05397450978507c4ef1", a.getResponse()); 41 | Assertions.assertTrue(a.checkResponse()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mjsip-sip/src/test/java/test/org/mjsip/sdp/field/TestConnectionField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package test.org.mjsip.sdp.field; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.mjsip.sdp.field.ConnectionField; 9 | import org.zoolu.net.AddressType; 10 | 11 | /** 12 | * Test for {@link ConnectionField} 13 | */ 14 | class TestConnectionField { 15 | 16 | @Test 17 | void testParse() { 18 | ConnectionField field = new ConnectionField("IN IP6 2001:9e8:2050:becc:7eff:4dff:fe57:1a5a"); 19 | 20 | Assertions.assertEquals(AddressType.IP6, field.getAddressType()); 21 | Assertions.assertEquals("2001:9e8:2050:becc:7eff:4dff:fe57:1a5a", field.getAddress()); 22 | Assertions.assertEquals(0, field.getNum()); 23 | Assertions.assertEquals(0, field.getTTL()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mjsip-sip/src/test/java/test/org/mjsip/sdp/field/TestOriginField.java: -------------------------------------------------------------------------------- 1 | package test.org.mjsip.sdp.field; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import org.mjsip.sdp.field.OriginField; 6 | import org.zoolu.net.AddressType; 7 | 8 | /** 9 | * Test case for {@link OriginField}. 10 | */ 11 | public class TestOriginField { 12 | 13 | @Test 14 | void testParse() { 15 | OriginField field = new OriginField("user 6597542 6597543 IN IP6 fd00::9a9b:cbff:fe34:c1e9"); 16 | Assertions.assertEquals("fd00::9a9b:cbff:fe34:c1e9", field.getAddress()); 17 | Assertions.assertEquals(AddressType.IP6, field.getAddressType()); 18 | Assertions.assertEquals("6597542", field.getSessionId()); 19 | Assertions.assertEquals("6597543", field.getSessionVersion()); 20 | Assertions.assertEquals("user", field.getUserName()); 21 | Assertions.assertEquals('o', field.getType()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /mjsip-sound/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /mjsip-sound/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /mjsip-sound/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-sound 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 4 | org.eclipse.jdt.core.compiler.compliance=11 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=11 12 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-sound/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mjsip-sound/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-sound 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-util 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mjsip-sound/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * The myjSip utilities. 7 | */ 8 | module org.mjsip.sound { 9 | 10 | requires org.mjsip.util; 11 | 12 | requires args4j; 13 | requires org.slf4j; 14 | requires transitive java.desktop; 15 | 16 | exports org.mjsip.sound; 17 | exports org.zoolu.sound; 18 | exports org.zoolu.sound.codec; 19 | exports org.zoolu.sound.codec.amr; 20 | exports org.zoolu.sound.codec.g711; 21 | exports org.zoolu.sound.codec.g726; 22 | exports org.zoolu.sound.codec.gsm; 23 | } -------------------------------------------------------------------------------- /mjsip-sound/src/main/java/org/mjsip/sound/Codec.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.sound; 2 | 3 | import org.zoolu.util.Encoder; 4 | 5 | 6 | /** Couples a data encoder with a data decoder. 7 | */ 8 | public class Codec { 9 | 10 | /** Encoder */ 11 | Encoder encoder; 12 | 13 | /** Decoder */ 14 | Encoder decoder; 15 | 16 | 17 | /** Creates a new codec. 18 | * @param encoder the encoder 19 | * @param decoder the decoder */ 20 | public Codec(Encoder encoder, Encoder decoder) { 21 | this.encoder=encoder; 22 | this.decoder=decoder; 23 | } 24 | 25 | 26 | /** Gets encoder */ 27 | public Encoder getEncoder() { 28 | return encoder; 29 | } 30 | 31 | /** Gets decoder */ 32 | public Encoder getDecoder() { 33 | return decoder; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mjsip-sound/src/main/java/org/zoolu/sound/codec/amr/AmrToPcmEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * THE PUBLICATION, REDISTRIBUTION OR MODIFY, COMPLETE OR PARTIAL OF CONTENTS, 5 | * CAN BE MADE ONLY AFTER AUTHORIZATION BY THE AFOREMENTIONED COPYRIGHT HOLDER. 6 | * 7 | * Author(s): 8 | * Luca Veltri (luca.veltri@unipr.it) 9 | */ 10 | 11 | package org.zoolu.sound.codec.amr; 12 | 13 | 14 | 15 | import org.zoolu.sound.codec.AMR; 16 | import org.zoolu.util.Encoder; 17 | 18 | 19 | 20 | /** AMR-to-PCM Encoder. */ 21 | public class AmrToPcmEncoder implements Encoder { 22 | 23 | /** AMR codec */ 24 | AMR amr; 25 | 26 | 27 | /** Creates a new AmrToPcmEncoder */ 28 | public AmrToPcmEncoder() { 29 | amr=new AMR(); 30 | } 31 | 32 | 33 | /** Encodes the input chunk in_buff and returns the encoded chuck into out_buff. 34 | * @return the actual size of the output data */ 35 | @Override 36 | public int encode(byte[] in_buff, int in_offset, int in_len, byte[] out_buff, int out_offset) { 37 | //int mode=(in_buff[in_offset]>>3)&0xf; 38 | //int frame_size=AMR.frameSize(mode); 39 | //if (in_len!=frame_size) return 0; 40 | //try { 41 | if (in_offset!=0) { 42 | byte[] in_aux=new byte[in_len]; 43 | System.arraycopy(in_buff,in_offset,in_aux,0,in_len); 44 | in_buff=in_aux; 45 | } 46 | short[] out_aux=new short[160]; 47 | amr.decode(in_buff,out_aux); 48 | for (int i=0; i<160; i++) { 49 | short linear=out_aux[i]; 50 | // convert signed short to little-endian byte array 51 | out_buff[out_offset++]=(byte)(linear&0xFF); 52 | out_buff[out_offset++]=(byte)(linear>>8); 53 | } 54 | return 320; 55 | //} 56 | //catch (Exception e) {} 57 | //return 0; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /mjsip-sound/src/main/java/org/zoolu/sound/codec/g711/G711Encoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * THE PUBLICATION, REDISTRIBUTION OR MODIFY, COMPLETE OR PARTIAL OF CONTENTS, 5 | * CAN BE MADE ONLY AFTER AUTHORIZATION BY THE AFOREMENTIONED COPYRIGHT HOLDER. 6 | * 7 | * Author(s): 8 | * Luca Veltri (luca.veltri@unipr.it) 9 | */ 10 | 11 | package org.zoolu.sound.codec.g711; 12 | 13 | 14 | 15 | import javax.sound.sampled.AudioFormat; 16 | 17 | 18 | 19 | /** Encodings used by the G711 audio decoder. 20 | */ 21 | public class G711Encoding extends AudioFormat.Encoding { 22 | 23 | /** Specifies G.711 ULAW 64 Kbps encoding. */ 24 | public static final G711Encoding G711_ULAW=new G711Encoding("G711_ULAW"); 25 | 26 | /** Specifies G.711 ALAW 64 Kbps encoding. */ 27 | public static final G711Encoding G711_ALAW=new G711Encoding("G711_ALAW"); 28 | 29 | 30 | /** Constructs a new encoding. 31 | * @param name - Name of the G711 encoding. */ 32 | public G711Encoding(final String name) 33 | { super(name); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mjsip-sound/src/main/java/org/zoolu/sound/codec/g726/G726Encoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Luca Veltri - University of Parma - Italy 3 | * 4 | * THE PUBLICATION, REDISTRIBUTION OR MODIFY, COMPLETE OR PARTIAL OF CONTENTS, 5 | * CAN BE MADE ONLY AFTER AUTHORIZATION BY THE AFOREMENTIONED COPYRIGHT HOLDER. 6 | * 7 | * Author(s): 8 | * Luca Veltri (luca.veltri@unipr.it) 9 | */ 10 | 11 | package org.zoolu.sound.codec.g726; 12 | 13 | 14 | 15 | import javax.sound.sampled.AudioFormat; 16 | 17 | 18 | 19 | /** Encodings used by the G726 audio decoder. 20 | */ 21 | public class G726Encoding extends AudioFormat.Encoding { 22 | 23 | /** Specifies G.721 32 Kbps encoding. */ 24 | public static final G726Encoding G726_32=new G726Encoding("G726_32"); 25 | 26 | /** Specifies G.723 24 Kbps encoding. */ 27 | public static final G726Encoding G726_24=new G726Encoding("G726_24"); 28 | 29 | /** Specifies G.723 40 Kbps encoding. */ 30 | public static final G726Encoding G726_40=new G726Encoding("G726_40"); 31 | 32 | 33 | /** Constructs a new encoding. 34 | * @param name - Name of the G726 encoding. */ 35 | public G726Encoding(final String name) 36 | { super(name); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-ua/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mjsip-ua/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /announcement-8000hz-mono-a-law.wav 3 | -------------------------------------------------------------------------------- /mjsip-ua/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-ua 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /mjsip-ua/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /mjsip-ua/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-ua/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /mjsip-ua/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-ua/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mjsip-ua/bin/Start UserAgent.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /mjsip-ua/buddy.lst.template: -------------------------------------------------------------------------------- 1 | # Add phone numbers of your contacts here one in each line. 2 | -------------------------------------------------------------------------------- /mjsip-ua/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.mjsip 7 | mjsip-parent 8 | 2.0.6-SNAPSHOT 9 | 10 | 11 | mjsip-ua 12 | 13 | 14 | 15 | org.mjsip 16 | mjsip-sip 17 | 18 | 19 | 20 | args4j 21 | args4j 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * The myjSip utilities. 7 | */ 8 | module org.mjsip.ua { 9 | 10 | requires org.mjsip.sound; 11 | requires org.mjsip.util; 12 | requires transitive org.mjsip.sip; 13 | requires org.mjsip.net; 14 | requires args4j; 15 | requires org.slf4j; 16 | requires java.desktop; 17 | 18 | opens org.mjsip.ua to args4j; 19 | 20 | exports org.mjsip.ua; 21 | exports org.mjsip.ua.clip; 22 | exports org.mjsip.ua.registration; 23 | exports org.mjsip.ua.sound; 24 | exports org.mjsip.ua.streamer; 25 | } -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/ClientOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | /** 7 | * Options for controlling a {@link UserAgent}. 8 | * 9 | * @see UAOptions 10 | */ 11 | public interface ClientOptions extends StaticOptions, UserOptions { 12 | // Pure sum interface. 13 | } 14 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/MediaOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | import org.mjsip.media.MediaDesc; 7 | import org.zoolu.net.SocketAddress; 8 | 9 | /** 10 | * Tool-options for interactive media streaming. 11 | */ 12 | public interface MediaOptions { 13 | 14 | /** Whether using audio */ 15 | boolean isAudio(); 16 | 17 | /** 18 | * Whether using explicit external converter (i.e. direct access to an external conversion 19 | * provider) instead of that provided by javax.sound.sampled.spi. It applies only when javax 20 | * sound is used, that is when no other audio apps (such as jmf or rat) are used. 21 | */ 22 | boolean isJavaxSoundDirectConversion(); 23 | 24 | /** Whether using symmetric_rtp */ 25 | boolean isSymmetricRtp(); 26 | 27 | /** 28 | * Receiver random early drop (RED) rate. Actually it is the inverse of packet drop rate. It can 29 | * used to prevent long play back delay. A value less or equal to 0 means that no packet 30 | * dropping is explicitly performed at the RTP receiver. 31 | */ 32 | int getRandomEarlyDropRate(); 33 | 34 | /** Whether using RAT (Robust Audio Tool) as audio sender/receiver */ 35 | boolean isUseRat(); 36 | 37 | /** Media descriptions that are used in calls. */ 38 | MediaDesc[] getMediaDescs(); 39 | 40 | /** Fixed audio multicast socket address; if defined, it forces the use of this maddr+port for audio session */ 41 | SocketAddress getAudioMcastSoAddr(); 42 | 43 | /** RAT command-line executable */ 44 | String getBinRat(); 45 | 46 | /** Whether using video */ 47 | boolean isVideo(); 48 | 49 | /** Whether using VIC (Video Conferencing Tool) as video sender/receiver */ 50 | boolean isUseVic(); 51 | 52 | /** VIC command-line executable */ 53 | String getBinVic(); 54 | 55 | /** Fixed video multicast socket address; if defined, it forces the use of this maddr+port for video session */ 56 | SocketAddress getVideoMcastSoAddr(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/MessageAgentListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.ua; 2 | 3 | 4 | import org.mjsip.sip.address.NameAddress; 5 | 6 | 7 | /** Listener of MessageAgent */ 8 | public interface MessageAgentListener { 9 | 10 | /** When a new Message is received. */ 11 | public void onMaReceivedMessage(MessageAgent ma, NameAddress sender, NameAddress recipient, String subject, String content_type, String body); 12 | 13 | /** When a message delivery successes. */ 14 | public void onMaDeliverySuccess(MessageAgent ma, NameAddress recipient, String subject, String result); 15 | 16 | /** When a message delivery fails. */ 17 | public void onMaDeliveryFailure(MessageAgent ma, NameAddress recipient, String subject, String result); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/ServiceConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | import org.kohsuke.args4j.Option; 7 | 8 | /** 9 | * Options for SIP a command-line tool or user interface. 10 | */ 11 | public class ServiceConfig implements ServiceOptions { 12 | 13 | @Option(name = "--hangup-time", usage = "Hang up after the given number of seconds (0 means manual hangup).") 14 | private int _hangupTime=-1; 15 | 16 | @Override 17 | public int getHangupTime() { 18 | return _hangupTime; 19 | } 20 | 21 | /** 22 | * @see #getHangupTime() 23 | */ 24 | public void setHangupTime(int hangupTime) { 25 | _hangupTime = hangupTime; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/ServiceOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | /** 7 | * Options for services automatically answering calls. 8 | */ 9 | public interface ServiceOptions { 10 | 11 | /** Automatic hangup time (maximum call duartion) in seconds; time<=0 means no automatic hangup. */ 12 | int getHangupTime(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/UAOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | import org.mjsip.ua.registration.RegistrationOptions; 7 | 8 | /** 9 | * Options for setting up a {@link UserAgent} 10 | */ 11 | public interface UAOptions extends ClientOptions, RegistrationOptions { 12 | 13 | /** Whether registering with a registrar server */ 14 | boolean isRegister(); 15 | 16 | /** 17 | * Whether running the UAS (User Agent Server), or acting just as UAC (User Agent Client). In 18 | * the latter case only outgoing calls are supported. 19 | */ 20 | boolean isUaServer(); 21 | 22 | /** Whether running an Options Server, that automatically responds to OPTIONS requests. */ 23 | boolean isOptionsServer(); 24 | 25 | /** Whether running an Null Server, that automatically responds to not-implemented requests. */ 26 | boolean isNullServer(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/UserOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua; 5 | 6 | import org.mjsip.ua.registration.AuthOptions; 7 | 8 | /** 9 | * Account-specific aspect of {@link ClientOptions}. 10 | */ 11 | public interface UserOptions extends AuthOptions { 12 | 13 | /** 14 | * Fully qualified domain name (or address) of the proxy server. It is part of the user's AOR 15 | * registered to the registrar server and used as From URI. 16 | *

17 | * If proxy is not defined, the registrar value is used in its place. 18 | *

19 | *

20 | * If registrar is not defined, the proxy value is used in its place. 21 | *

22 | */ 23 | String getProxy(); 24 | 25 | /** 26 | * User's name. It is used to build the user's AOR registered to the registrar server and used 27 | * as From URI. 28 | * 29 | *

30 | * AoR - Address of Record: 31 | * An address-of-record (AOR) is a SIP or SIPs URI that points to a domain with a location service 32 | * that can map the URI to another URI where the user might be available. Typically, the location 33 | * service is populated through the SIP Registration process. An AOR is frequently thought of as 34 | * the public address of the user. 35 | *

36 | */ 37 | String getSipUser(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/clip/AudioClipPlayerListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.ua.clip; 2 | 3 | /** Listener for AudioClipPlayer. 4 | * It captures onAudioClipStop() events, fired when the sound stops. 5 | */ 6 | public interface AudioClipPlayerListener { 7 | 8 | /** When the sound stops. */ 9 | public void onAudioClipStopped(AudioClipPlayer player); 10 | 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/registration/AuthOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.registration; 5 | 6 | import org.mjsip.sip.address.NameAddress; 7 | import org.mjsip.ua.UserOptions; 8 | 9 | /** 10 | * User authentication common to {@link UserOptions} and {@link RegistrationOptions}. 11 | */ 12 | public interface AuthOptions { 13 | 14 | /** 15 | * Gets the user's AOR (Address Of Record) registered to the registrar server and used as From 16 | * URI. 17 | *

18 | * In case of proxy and user parameters have been defined it is formed as 19 | * "display_name" <sip:user@proxy>, otherwhise the local UA address 20 | * (obtained by the SipProvider) is used. 21 | * 22 | * @return the user's name address 23 | */ 24 | NameAddress getUserURI(); 25 | 26 | /** User's name used for server authentication. */ 27 | String getAuthUser(); 28 | 29 | /** User's passwd used for server authentication. */ 30 | String getAuthPasswd(); 31 | 32 | /** User's realm used for server authentication. */ 33 | String getAuthRealm(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/registration/RegistrationClientListener.java: -------------------------------------------------------------------------------- 1 | package org.mjsip.ua.registration; 2 | 3 | 4 | 5 | import org.mjsip.sip.address.NameAddress; 6 | 7 | 8 | 9 | /** Listener of RegistrationClient */ 10 | public interface RegistrationClientListener { 11 | 12 | /** When it has been successfully (un)registered. */ 13 | public void onRegistrationSuccess(RegistrationClient registration, NameAddress target, NameAddress contact, int expires, int renewTime, String result); 14 | 15 | /** When it failed on (un)registering. */ 16 | public void onRegistrationFailure(RegistrationClient registration, NameAddress target, NameAddress contact, String result); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/registration/RegistrationLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.registration; 5 | 6 | import org.mjsip.sip.address.NameAddress; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** 10 | * {@link RegistrationClientListener} logging registration status. 11 | */ 12 | public class RegistrationLogger implements RegistrationClientListener { 13 | 14 | private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(RegistrationLogger.class); 15 | 16 | /** When a UA has been successfully (un)registered. */ 17 | @Override 18 | public void onRegistrationSuccess(RegistrationClient rc, NameAddress target, NameAddress contact, int expires, int renewTime, String result) { 19 | LOG.info("Registration of '{}' {}, expires in {}s {}.", contact, result, expires, (renewTime > 0 ? ", renewing in " + renewTime + "s" : "")); 20 | } 21 | 22 | /** When a UA failed on (un)registering. */ 23 | @Override 24 | public void onRegistrationFailure(RegistrationClient rc, NameAddress target, NameAddress contact, String result) { 25 | LOG.info("Registration of '{}' failed: {}", contact, result); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/registration/RegistrationOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.registration; 5 | 6 | import org.mjsip.sip.address.SipURI; 7 | 8 | /** 9 | * Options for a {@link RegistrationClient}. 10 | */ 11 | public interface RegistrationOptions extends AuthOptions { 12 | 13 | /** 14 | * Additional routing information to reach the {@link #getRegistrar() registrar}. 15 | */ 16 | SipURI getRoute(); 17 | 18 | /** 19 | * Fully qualified domain name (or address) of the registrar server. It is used as recipient for 20 | * REGISTER requests. 21 | *

22 | * If registrar is not defined, the proxy value is used in its place. 23 | *

24 | *

25 | * If proxy is not defined, the registrar value is used in its place. 26 | *

27 | */ 28 | SipURI getRegistrar(); 29 | 30 | /** Expires time (in seconds). */ 31 | int getExpires(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/sound/SilenceListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.sound; 5 | 6 | /** 7 | * Listener that is informed about events in {@link AlawSilenceTrimmer}. 8 | */ 9 | public interface SilenceListener { 10 | 11 | void onSilenceStarted(long clock); 12 | 13 | void onSilenceEnded(long clock); 14 | 15 | /** 16 | * Creates a guard when the given listener is null. 17 | */ 18 | public static SilenceListener nonNull(SilenceListener listener) { 19 | if (listener == null) { 20 | return new SilenceListenerAdapter() { 21 | // No-op. 22 | }; 23 | } 24 | return listener; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/sound/SilenceListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.sound; 5 | 6 | import javax.sound.sampled.LineListener; 7 | 8 | /** 9 | * {@link LineListener} that implements all callbacks with a no-op. 10 | */ 11 | public interface SilenceListenerAdapter extends SilenceListener { 12 | 13 | @Override 14 | default void onSilenceStarted(long clock) { 15 | // Ignore. 16 | } 17 | 18 | @Override 19 | default void onSilenceEnded(long clock) { 20 | // Ignore. 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/DefaultStreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.AudioStreamer; 9 | import org.mjsip.media.FlowSpec; 10 | import org.mjsip.media.MediaStreamer; 11 | import org.mjsip.media.StreamerOptions; 12 | import org.mjsip.media.rx.AudioReceiver; 13 | import org.mjsip.media.tx.AudioTransmitter; 14 | 15 | /** 16 | * {@link StreamerFactory} creating an {@link AudioStreamer} based on {@link StreamerOptions}, 17 | * {@link AudioReceiver} and {@link AudioTransmitter}. 18 | */ 19 | public class DefaultStreamerFactory implements StreamerFactory { 20 | 21 | private final AudioReceiver _rx; 22 | private final AudioTransmitter _tx; 23 | private final StreamerOptions _options; 24 | 25 | /** 26 | * Creates a {@link DefaultStreamerFactory}. 27 | */ 28 | public DefaultStreamerFactory(StreamerOptions options, AudioReceiver rx, AudioTransmitter tx) { 29 | _options = options; 30 | _rx = rx; 31 | _tx = tx; 32 | } 33 | 34 | @Override 35 | public MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec) { 36 | return new AudioStreamer(executor, flow_spec, _tx, _rx, _options); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/DispatchingStreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.concurrent.Executor; 9 | 10 | import org.mjsip.media.FlowSpec; 11 | import org.mjsip.media.MediaStreamer; 12 | 13 | /** 14 | * {@link StreamerFactory} that dispatches based on the media type to other {@link StreamerFactory} 15 | * implementations. 16 | */ 17 | public class DispatchingStreamerFactory implements StreamerFactory { 18 | 19 | private final StreamerFactory _defaultStreamerFactory; 20 | private final Map _factoryByType = new HashMap<>(); 21 | 22 | /** 23 | * Creates a {@link DispatchingStreamerFactory} with no default {@link StreamerFactory}. 24 | */ 25 | public DispatchingStreamerFactory() { 26 | this(NoStreamerFactory.INSTANCE); 27 | } 28 | 29 | /** 30 | * Creates a {@link DispatchingStreamerFactory}. 31 | * 32 | * @param defaultStreamerFactory 33 | * The {@link StreamerFactory} to use, if no factory was added for a certain media type. 34 | */ 35 | public DispatchingStreamerFactory(StreamerFactory defaultStreamerFactory) { 36 | _defaultStreamerFactory = defaultStreamerFactory; 37 | } 38 | 39 | /** 40 | * Adds a new {@link StreamerFactory} for the given media type. 41 | * 42 | * @see FlowSpec#getMediaType() 43 | */ 44 | public DispatchingStreamerFactory addFactory(String mediaType, StreamerFactory factory) { 45 | _factoryByType.put(mediaType, factory); 46 | return this; 47 | } 48 | 49 | @Override 50 | public MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec) { 51 | StreamerFactory factory = _factoryByType.get(flow_spec.getMediaType()); 52 | if (factory == null) { 53 | return _defaultStreamerFactory.createMediaStreamer(executor, flow_spec); 54 | } 55 | 56 | return factory.createMediaStreamer(executor, flow_spec); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/LoopbackStreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.FlowSpec; 9 | import org.mjsip.media.LoopbackMediaStreamer; 10 | import org.mjsip.media.MediaStreamer; 11 | 12 | /** 13 | * {@link StreamerFactory} creating {@link LoopbackMediaStreamer}s. 14 | */ 15 | public final class LoopbackStreamerFactory implements StreamerFactory { 16 | @Override 17 | public MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec) { 18 | return new LoopbackMediaStreamer(flow_spec); 19 | } 20 | } -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/NativeStreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.FlowSpec; 9 | import org.mjsip.media.MediaStreamer; 10 | import org.mjsip.media.NativeMediaStreamer; 11 | import org.zoolu.net.SocketAddress; 12 | 13 | /** 14 | * {@link StreamerFactory} that creates streamers base on a native program for streaming. 15 | */ 16 | public class NativeStreamerFactory implements StreamerFactory { 17 | 18 | private final SocketAddress _mcastAddr; 19 | private final String _executable; 20 | 21 | /** 22 | * Creates a {@link NativeStreamerFactory}. 23 | */ 24 | public NativeStreamerFactory(SocketAddress mcastAddr, String executable) { 25 | _mcastAddr = mcastAddr; 26 | _executable = executable; 27 | } 28 | 29 | @Override 30 | public MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec) { 31 | String remote_addr=(_mcastAddr!=null)? _mcastAddr.getAddress().toString() : flow_spec.getRemoteAddress(); 32 | int remote_port=(_mcastAddr!=null)? _mcastAddr.getPort() : flow_spec.getRemotePort(); 33 | int local_port=(_mcastAddr!=null)? _mcastAddr.getPort() : flow_spec.getLocalPort(); 34 | String[] args=new String[]{(remote_addr+"/"+remote_port)}; 35 | return new NativeMediaStreamer(_executable, args, local_port, remote_port); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/NoStreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.FlowSpec; 9 | import org.mjsip.media.MediaStreamer; 10 | 11 | /** 12 | * {@link StreamerFactory} that creates no streamers at all. 13 | */ 14 | public class NoStreamerFactory implements StreamerFactory { 15 | 16 | /** 17 | * Singleton {@link NoStreamerFactory} instance. 18 | */ 19 | public static final NoStreamerFactory INSTANCE = new NoStreamerFactory(); 20 | 21 | private NoStreamerFactory() { 22 | // Singleton constructor. 23 | } 24 | 25 | @Override 26 | public MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec) { 27 | return null; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/java/org/mjsip/ua/streamer/StreamerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.streamer; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | import org.mjsip.media.FlowSpec; 9 | import org.mjsip.media.MediaStreamer; 10 | 11 | /** 12 | * Factory for {@link MediaStreamer}s. 13 | * 14 | * @see DispatchingStreamerFactory#addFactory(String, StreamerFactory) 15 | */ 16 | public interface StreamerFactory { 17 | 18 | /** 19 | * Creates a {@link MediaStreamer} for the given flow. 20 | * @param executor TODO 21 | */ 22 | MediaStreamer createMediaStreamer(Executor executor, FlowSpec flow_spec); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/call.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/call.gif -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/hangup.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/hangup.gif -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/off.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/off.wav -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/on.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/on.wav -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/progress.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/progress.wav -------------------------------------------------------------------------------- /mjsip-ua/src/main/resources/media/org/mjsip/ua/ring.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/main/resources/media/org/mjsip/ua/ring.wav -------------------------------------------------------------------------------- /mjsip-ua/src/test/fixtures/test-alaw.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haumacher/mjSIP/6a9dc0760011b71c69606fa432b451beaa1b146b/mjsip-ua/src/test/fixtures/test-alaw.wav -------------------------------------------------------------------------------- /mjsip-ua/src/test/java/org/mjsip/ua/sound/TestWavFileSplitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.ua.sound; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.nio.file.FileVisitResult; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | import java.nio.file.SimpleFileVisitor; 12 | import java.nio.file.attribute.BasicFileAttributes; 13 | 14 | import javax.sound.sampled.UnsupportedAudioFileException; 15 | 16 | import org.junit.jupiter.api.Assertions; 17 | import org.junit.jupiter.api.Test; 18 | 19 | /** 20 | * Test for {@link WavFileSplitter} 21 | */ 22 | class TestWavFileSplitter { 23 | 24 | /** 25 | * Tests splitting a real-world recording. 26 | */ 27 | @Test 28 | void testSplit() throws IOException, UnsupportedAudioFileException { 29 | File output = new File("./target/TestWavFileSplitter"); 30 | clear(output); 31 | output.mkdirs(); 32 | new WavFileSplitter(new File("./src/test/fixtures/test-alaw.wav")).setOutputDir(output).run(); 33 | 34 | Assertions.assertEquals(3, output.listFiles(f -> f.isFile()).length); 35 | } 36 | 37 | private void clear(File output) throws IOException { 38 | if (output.isDirectory()) { 39 | Files.walkFileTree(output.toPath(), new SimpleFileVisitor() { 40 | @Override 41 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { 42 | Files.delete(file); 43 | return super.visitFile(file, attrs); 44 | } 45 | 46 | @Override 47 | public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { 48 | Files.delete(dir); 49 | return super.postVisitDirectory(dir, exc); 50 | } 51 | }); 52 | } else { 53 | Files.deleteIfExists(output.toPath()); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mjsip-ua/src/test/java/org/mjsip/up/TestPortPool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.up; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.mjsip.pool.PortPool; 9 | import org.mjsip.pool.PortPool.Exhausted; 10 | 11 | /** 12 | * Test case for {@link PortPool} 13 | */ 14 | @SuppressWarnings("javadoc") 15 | class TestPortPool { 16 | 17 | @Test 18 | void testSingletonPool() { 19 | PortPool pool = new PortPool(10, 1); 20 | 21 | Assertions.assertTrue(pool.isAvailable()); 22 | Assertions.assertEquals(10, pool.allocate()); 23 | Assertions.assertFalse(pool.isAvailable()); 24 | Assertions.assertThrows(Exhausted.class, pool::allocate, "Allocating from an exhausted pool must fail."); 25 | pool.release(10); 26 | Assertions.assertTrue(pool.isAvailable()); 27 | } 28 | 29 | @Test 30 | void testPool() { 31 | PortPool pool = new PortPool(10, 3); 32 | 33 | Assertions.assertTrue(pool.isAvailable()); 34 | Assertions.assertEquals(10, pool.allocate()); 35 | Assertions.assertTrue(pool.isAvailable()); 36 | Assertions.assertEquals(11, pool.allocate()); 37 | Assertions.assertTrue(pool.isAvailable()); 38 | pool.release(10); 39 | Assertions.assertEquals(10, pool.allocate()); 40 | Assertions.assertTrue(pool.isAvailable()); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /mjsip-util/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /mjsip-util/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /mjsip-util/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mjsip-util 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 4 | org.eclipse.jdt.core.compiler.compliance=11 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=11 12 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mjsip-util/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mjsip-util/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.mjsip 6 | mjsip-parent 7 | 2.0.6-SNAPSHOT 8 | 9 | 10 | mjsip-util 11 | 12 | 13 | 14 | args4j 15 | args4j 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * The myjSip utilities. 7 | */ 8 | module org.mjsip.util { 9 | 10 | exports org.mjsip.config; 11 | exports org.mjsip.time; 12 | exports org.zoolu.util; 13 | 14 | opens org.mjsip.config to args4j; 15 | opens org.mjsip.time to args4j; 16 | 17 | requires args4j; 18 | requires org.slf4j; 19 | requires java.desktop; 20 | 21 | } -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/mjsip/config/FileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.config; 5 | 6 | import java.io.File; 7 | 8 | import org.kohsuke.args4j.CmdLineException; 9 | import org.kohsuke.args4j.CmdLineParser; 10 | import org.kohsuke.args4j.OptionDef; 11 | import org.kohsuke.args4j.spi.OptionHandler; 12 | import org.kohsuke.args4j.spi.Parameters; 13 | import org.kohsuke.args4j.spi.Setter; 14 | 15 | /** 16 | * {@link OptionHandler} accepting yes/no values for {@link Boolean} options. 17 | */ 18 | public class FileHandler extends OptionHandler { 19 | 20 | /** 21 | * Creates a {@link FileHandler}. 22 | */ 23 | public FileHandler(CmdLineParser parser, OptionDef option, Setter setter) { 24 | super(parser, option, setter); 25 | } 26 | 27 | @Override 28 | public int parseArguments(Parameters params) throws CmdLineException { 29 | String value = params.getParameter(0); 30 | setter.addValue(value.isBlank() ? null : new File(value)); 31 | return 1; 32 | } 33 | 34 | @Override 35 | public String getDefaultMetaVariable() { 36 | return ""; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/mjsip/config/MetaConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.config; 5 | 6 | import java.io.File; 7 | 8 | import org.kohsuke.args4j.Option; 9 | 10 | /** 11 | * Configuration with reference to configuration file. 12 | */ 13 | public class MetaConfig { 14 | 15 | @Option(name = "-h", aliases = "--help", usage = "Print this help message.", help = true) 16 | boolean help; 17 | 18 | /** 19 | * The configuration file to read. 20 | */ 21 | @Option(name = "-f", aliases = "--config-file", metaVar = "", usage = "File with configuration options, 'none' to prevent reading from the default location.") 22 | public String configFile; 23 | 24 | /** 25 | * The configuration file passed through the command line options. 26 | */ 27 | public File getConfigFile() { 28 | return configFile == null || configFile.isBlank() || "none".equals(configFile) ? null : new File(configFile); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/mjsip/config/YesNoHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.config; 5 | 6 | import org.kohsuke.args4j.CmdLineException; 7 | import org.kohsuke.args4j.CmdLineParser; 8 | import org.kohsuke.args4j.OptionDef; 9 | import org.kohsuke.args4j.spi.OptionHandler; 10 | import org.kohsuke.args4j.spi.Parameters; 11 | import org.kohsuke.args4j.spi.Setter; 12 | 13 | /** 14 | * {@link OptionHandler} accepting yes/no values for {@link Boolean} options. 15 | */ 16 | public class YesNoHandler extends OptionHandler { 17 | 18 | /** 19 | * Creates a {@link YesNoHandler}. 20 | */ 21 | public YesNoHandler(CmdLineParser parser, OptionDef option, Setter setter) { 22 | super(parser, option, setter); 23 | } 24 | 25 | @Override 26 | public int parseArguments(Parameters params) throws CmdLineException { 27 | String arg = params.getParameter(0).toLowerCase(); 28 | setter.addValue(parseBoolean(arg)); 29 | return 1; 30 | } 31 | 32 | private Boolean parseBoolean(String arg) throws CmdLineException { 33 | switch (arg) { 34 | case "true": return Boolean.TRUE; 35 | case "false": return Boolean.FALSE; 36 | case "yes": return Boolean.TRUE; 37 | case "no": return Boolean.FALSE; 38 | case "1": return Boolean.TRUE; 39 | case "0": return Boolean.FALSE; 40 | default: throw new CmdLineException(owner, "Invalid boolean value '" + arg + "' in option '" + option + "'.", null); 41 | } 42 | } 43 | 44 | @Override 45 | public String getDefaultMetaVariable() { 46 | return "yes/no"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/mjsip/time/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.time; 5 | 6 | import java.util.concurrent.Executor; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.ScheduledExecutorService; 9 | import java.util.concurrent.ScheduledFuture; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * Service for scheduling tasks. 14 | */ 15 | public interface Scheduler extends Executor { 16 | 17 | /** 18 | * The executor. 19 | */ 20 | default ExecutorService executor() { 21 | return scheduler(); 22 | } 23 | 24 | /** 25 | * The scheduler. 26 | */ 27 | ScheduledExecutorService scheduler(); 28 | 29 | @Override 30 | default void execute(Runnable command) { 31 | executor().execute(command); 32 | } 33 | 34 | /** 35 | * Schedules a new task. 36 | * 37 | * @param delay 38 | * the delay in milliseconds to wait before starting the given task 39 | * @param task 40 | * the task to be scheduled 41 | * 42 | * @return The {@link ScheduledFuture} to control the task. 43 | */ 44 | default ScheduledFuture schedule(long delay, Runnable task) { 45 | return scheduler().schedule(task, delay, TimeUnit.MILLISECONDS); 46 | } 47 | 48 | /** 49 | * Schedules the given repeated task with a given fixed delay. 50 | */ 51 | default ScheduledFuture schedulerWithFixedDelay(long delay, Runnable task) { 52 | return scheduler().scheduleWithFixedDelay(task, delay, delay, TimeUnit.MILLISECONDS); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/mjsip/time/SchedulerConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.mjsip.time; 5 | 6 | import org.kohsuke.args4j.Option; 7 | import org.mjsip.config.YesNoHandler; 8 | 9 | /** 10 | * Configuration options for the {@link Scheduler}. 11 | * 12 | * @author Bernhard Haumacher 13 | */ 14 | public class SchedulerConfig { 15 | 16 | @Option(name = "--thread-pool-size") 17 | private int _threadPoolSize = 5; 18 | 19 | @Option(name = "--use-daemon-treads", handler = YesNoHandler.class) 20 | private boolean _daemonThreads = true; 21 | 22 | /** 23 | * The core pool size of the scheduler's thread pool. 24 | */ 25 | public int getThreadPoolSize() { 26 | return _threadPoolSize; 27 | } 28 | 29 | /** 30 | * Whether the scheduler uses daemon threads. 31 | */ 32 | public boolean useDaemonThreads() { 33 | return _daemonThreads; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/ConfigFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Bernhard Haumacher et al. All Rights Reserved. 3 | */ 4 | package org.zoolu.util; 5 | 6 | import java.io.File; 7 | import java.util.Arrays; 8 | import java.util.Collection; 9 | import java.util.LinkedHashMap; 10 | import java.util.Map; 11 | import java.util.Map.Entry; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * A buffer of key value pairs. 16 | * 17 | * @author Bernhard Haumacher 18 | */ 19 | public class ConfigFile extends Configure { 20 | 21 | private final Map _options = new LinkedHashMap<>(); 22 | 23 | /** 24 | * Creates a {@link ConfigFile}. 25 | */ 26 | public ConfigFile(File file) { 27 | loadFile(file); 28 | } 29 | 30 | @Override 31 | public void setOption(String attribute, Parser par) { 32 | _options.put(attribute, par.getRemainingString().trim()); 33 | } 34 | 35 | /** 36 | * Sets an option. 37 | */ 38 | public void setOption(String key, String value) { 39 | _options.put(key, value); 40 | } 41 | 42 | /** 43 | * Transfers all buffered options to the given {@link Configure}. 44 | */ 45 | public void configure(Configure other) { 46 | for (Entry entry : _options.entrySet()) { 47 | other.setOption(entry.getKey(), new Parser(entry.getValue())); 48 | } 49 | } 50 | 51 | /** 52 | * Converts the parsed options to an arguments list. 53 | */ 54 | public Collection toArguments() { 55 | return _options.entrySet().stream().flatMap(e -> Arrays.asList("--" + e.getKey().replace('_', '-'), e.getValue()).stream()).collect(Collectors.toList()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/Configurable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.util; 25 | 26 | 27 | 28 | /** Configurable is the base interface for classes that can be configurated by a text file. 29 | */ 30 | public interface Configurable { 31 | 32 | /** Parses a single text line. */ 33 | public void parseLine(String line); 34 | } 35 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.util; 25 | 26 | 27 | 28 | /** Generic interface for an encoding algorithm. 29 | */ 30 | public interface Encoder { 31 | 32 | /** Encodes an input chunk of data. 33 | * @param in_buf buffer containing the input data 34 | * @param in_off offset within the input buffer 35 | * @param in_len length of the input data 36 | * @param out_buf buffer for the output data (where the encoded data is written) 37 | * @param out_off offset within the output buffer 38 | * @return the length of the output data */ 39 | public int encode(byte[] in_buf, int in_off, int in_len, byte[] out_buf, int out_off); 40 | } 41 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/ExceptionPrinter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.zoolu.util; 25 | 26 | 27 | import java.io.ByteArrayOutputStream; 28 | import java.io.PrintStream; 29 | 30 | 31 | /** Class ExceptionPrinter just contains method getStackTrace(Exception e) 32 | * for getting a String reporting the stack-trace and description of Exception e. 33 | */ 34 | public class ExceptionPrinter { 35 | 36 | /** Gets the stack-trace and description of Exception e. 37 | * @return It returns a String with the stack-trace and description of the Exception. */ 38 | public static String getStackTraceOf(Exception e) { 39 | //return e.toString(); 40 | ByteArrayOutputStream err=new ByteArrayOutputStream(); 41 | e.printStackTrace(new PrintStream(err)); 42 | return err.toString(); 43 | } 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/SystemUtils.java: -------------------------------------------------------------------------------- 1 | package org.zoolu.util; 2 | 3 | 4 | 5 | /** Class that collects various system-level methods and objects. 6 | */ 7 | public class SystemUtils { 8 | 9 | /** Causes the current thread to sleep for the specified number of milliseconds. 10 | * Differently from method {@link Thread#sleep(long)}, it never throws an {@link InterruptedException}. 11 | * @param millisecs the length of time to sleep in milliseconds */ 12 | public static void sleep(long millisecs) { 13 | try { Thread.sleep(millisecs); } catch (InterruptedException e) {} 14 | } 15 | 16 | 17 | /** Exits after a given time. 18 | *

Note that this method is not blocking. 19 | * @param millisecs the length of time before exiting, in milliseconds */ 20 | public static void exitAfter(final long millisecs) { 21 | new Thread() { 22 | @Override 23 | public void run() { 24 | SystemUtils.sleep(millisecs); 25 | System.exit(0); 26 | } 27 | }.start(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /mjsip-util/src/main/java/org/zoolu/util/VectorUtils.java: -------------------------------------------------------------------------------- 1 | package org.zoolu.util; 2 | 3 | 4 | import java.util.Vector; 5 | 6 | 7 | /** Collects some utilities for handling java vectors and arrays. 8 | * It has been added for compatibility with Java ME. 9 | */ 10 | public class VectorUtils { 11 | 12 | /** Converts an array into a vector. 13 | * @param array the array 14 | * @return a vector containing all elements of array */ 15 | public static Vector arrayToVector(T[] array) { 16 | Vector v = new Vector<>(); 17 | for (int i=0; i void addArray(Vector v, T[] a) { 25 | for (int i=0; i void addVector(Vector v, Vector a) { 32 | for (int i=0; i Vector copy(Vector v) { 49 | Vector v2 = new Vector<>(); 50 | for (int i=0; i