code
stringlengths
73
34.1k
label
stringclasses
1 value
public void bind(boolean isLocal, boolean rtcpMux) throws IOException, IllegalStateException { this.rtpChannel.bind(isLocal, rtcpMux); if(!rtcpMux) { this.rtcpChannel.bind(isLocal, this.rtpChannel.getLocalPort() + 1); } this.rtcpMux = rtcpMux; if(logger.isDebugEnabled()) { logger.debug(this.mediaType...
java
public void connectRtp(SocketAddress address) { this.rtpChannel.setRemotePeer(address); if(logger.isDebugEnabled()) { logger.debug(this.mediaType + " RTP channel " + this.ssrc + " connected to remote peer " + address.toString()); } }
java
public void bindRtcp(boolean isLocal, int port) throws IOException, IllegalStateException { if(this.ice) { throw new IllegalStateException("Cannot bind when ICE is enabled"); } this.rtcpChannel.bind(isLocal, port); this.rtcpMux = (port == this.rtpChannel.getLocalPort()); }
java
public void connectRtcp(SocketAddress remoteAddress) { this.rtcpChannel.setRemotePeer(remoteAddress); if(logger.isDebugEnabled()) { logger.debug(this.mediaType + " RTCP channel " + this.ssrc + " has connected to remote peer " + remoteAddress.toString()); } }
java
protected RTPFormats buildRTPMap(RTPFormats profile) { RTPFormats list = new RTPFormats(); Formats fmts = new Formats(); if (this.rtpChannel.getOutputDsp() != null) { Codec[] currCodecs = this.rtpChannel.getOutputDsp().getCodecs(); for (int i = 0; i < currCodecs.length; i++) { if (currCodecs[i].getSu...
java
public void negotiateFormats(MediaDescriptionField media) { // Clean currently offered formats this.offeredFormats.clean(); // Map payload types to RTP Format for (String payloadType : media.getPayloadTypes()) { RTPFormat format; try { int payloadTypeInt = Integer.parseInt(payload...
java
public void enableICE(String externalAddress, boolean rtcpMux) { if (!this.ice) { this.ice = true; this.rtcpMux = rtcpMux; this.iceAuthenticator.generateIceCredentials(); // Enable ICE on RTP channels this.rtpChannel.enableIce(this.iceAuth...
java
public void disableICE() { if (this.ice) { this.ice = false; this.iceAuthenticator.reset(); // Disable ICE on RTP channels this.rtpChannel.disableIce(); if(!rtcpMux) { this.rtcpChannel.disableIce(); } ...
java
public void disableDTLS() { if (this.dtls) { this.rtpChannel.disableSRTP(); if (!this.rtcpMux) { this.rtcpChannel.disableSRTCP(); } this.dtls = false; if (logger.isDebugEnabled()) { logger.debug(this.mediaType + " chann...
java
public static long calculateLastSrTimestamp(long ntp1, long ntp2) { byte[] high = uIntLongToByteWord(ntp1); byte[] low = uIntLongToByteWord(ntp2); low[3] = low[1]; low[2] = low[0]; low[1] = high[3]; low[0] = high[2]; return bytesToUIntLong(low, 0); }
java
private static byte[] uIntLongToByteWord(long j) { int i = (int) j; byte[] byteWord = new byte[4]; byteWord[0] = (byte) ((i >>> 24) & 0x000000FF); byteWord[1] = (byte) ((i >> 16) & 0x000000FF); byteWord[2] = (byte) ((i >> 8) & 0x000000FF); byteWord[3] = (byte) (i & 0x00FF); return byteWord; }
java
public void commit() throws IOException { // assures we perform the close operation only once. if (open.compareAndSet(true, false)) { // flush & close fout.force(true); fout.close(); // if the current file exists, and append is true, then append samples a...
java
protected void release() { stack.getLocalTransactions().remove(Integer.valueOf(localTID)); stack.getRemoteTxToLocalTxMap().remove(Integer.valueOf(remoteTID)); cancelTHISTTimerTask(); cancelLongtranTimer(); cancelReTransmissionTimer(); if(originalPacket!=null) stack.releasePacket(originalPacket); ...
java
private void send(JainMgcpCommandEvent event) { sent = true; String host = ""; int port = 0; switch (event.getObjectIdentifier()) { case Constants.CMD_NOTIFY: Notify notifyCommand = (Notify) event; NotifiedEntity notifiedEntity = notifyCommand.getNotifiedEntity(); if (notifiedEntity == null) { ...
java
private void send(JainMgcpResponseEvent event) { cancelLongtranTimer(); // to send response we already should know the address and port // number from which the original request was received if (remoteAddress == null) { throw new IllegalArgumentException("Unknown orinator address"); } // restore the o...
java
public void receiveResponse(byte[] data,SplitDetails[] msg,Integer txID,ReturnCode returnCode) { cancelReTransmissionTimer(); cancelLongtranTimer(); JainMgcpResponseEvent event = null; try { event = decodeResponse(data,msg,txID,returnCode); } catch (Exception e) { logger.error("Could not dec...
java
private void fireEvent(RecorderEventImpl event) { eventSender.event = event; scheduler.submit(eventSender, PriorityQueueScheduler.INPUT_QUEUE); }
java
public void accept(Task task) { if((activeIndex+1)%2==0) { if(!task.isInQueue0()) { taskList[0].offer(task); task.storedInQueue0(); } } else { if(!task.isInQueue1()) { taskList[1].offer(task); task.storedInQueue1(); } } ...
java
public boolean reverseTransformPacket(RawPacket pkt) { boolean decrypt = false; int tagLength = policy.getAuthTagLength(); int indexEflag = pkt.getSRTCPIndex(tagLength); if ((indexEflag & 0x80000000) == 0x80000000) { decrypt = true; } int index = in...
java
private void computeIv(byte label) { for (int i = 0; i < 14; i++) { ivStore[i] = masterSalt[i]; } ivStore[7] ^= label; ivStore[14] = ivStore[15] = 0; }
java
public void deriveSrtcpKeys() { // compute the session encryption key byte label = 3; computeIv(label); KeyParameter encryptionKey = new KeyParameter(masterKey); cipher.init(true, encryptionKey); Arrays.fill(masterKey, (byte)0); cipherCtr.getCipherStrea...
java
public static TransportAddress applyXor(TransportAddress address, byte[] transactionID) { byte[] addressBytes = address.getAddressBytes(); char port = (char) address.getPort(); char portModifier = (char) ((transactionID[0] << 8 & 0x0000FF00) | (transactionID[1] & 0x000000FF)); port ^= portModifier; for (...
java
public TransportAddress getAddress(byte[] transactionID) { byte[] xorMask = new byte[16]; System.arraycopy(StunMessage.MAGIC_COOKIE, 0, xorMask, 0, 4); System.arraycopy(transactionID, 0, xorMask, 4, 12); return applyXor(xorMask); }
java
public void setAddress(TransportAddress address, byte[] transactionID) { byte[] xorMask = new byte[16]; System.arraycopy(StunMessage.MAGIC_COOKIE, 0, xorMask, 0, 4); System.arraycopy(transactionID, 0, xorMask, 4, 12); TransportAddress xorAddress = applyXor(address, xorMask); super.setAddress(xorAddress); ...
java
public void setErrorClass(byte errorClass) throws IllegalArgumentException { if (errorClass < 0 || errorClass > 99) { throw new IllegalArgumentException( errorClass + "Only error classes between 0 and 99 are valid. Current class: " + errorClass); } this.errorClass = errorClass; }
java
public static String getDefaultReasonPhrase(char errorCode) { switch (errorCode) { case BAD_REQUEST: return "(Bad Request): The request was malformed. The client should not " + "retry the request without modification from the previous attempt."; case UNAUTHORIZED: return "(Unauthorized): The Binding R...
java
@Override public void write(RtpPacket packet, RTPFormat format) { // checking format if (format == null) { if (logger.isTraceEnabled()) { logger.trace("No format specified. Packet dropped!"); } return; } boolean locked = false; ...
java
public Frame read(long timestamp) { Frame frame = null; boolean locked = false; try { locked = this.lock.tryLock() || this.lock.tryLock(5, TimeUnit.MILLISECONDS); if (locked) { frame = safeRead(); } else { this.ready.set(false);...
java
public void reset() { boolean locked = false; try { locked = lock.tryLock() || lock.tryLock(5, TimeUnit.MILLISECONDS); if (locked) { while (queue.size() > 0) { queue.remove(0).recycle(); } } } catch (Interrup...
java
public void addFieldParser(char type, SdpParser<? extends SdpField> parser) { synchronized (this.fieldParsers) { this.fieldParsers.put(type, parser); } }
java
public void addAttributeParser(String type, SdpParser<? extends AttributeField> parser) { synchronized (this.attributeParsers) { this.attributeParsers.put(type, parser); } }
java
private Transition find(String name) { for (Transition t : transitions) { if (t.getName().matches(name)) { return t; } } return null; }
java
public void joinRtpSession() { if (!this.joined.get()) { // Schedule first RTCP packet long t = this.statistics.rtcpInterval(this.initial.get()); this.tn = this.statistics.getCurrentTime() + t; scheduleRtcp(this.tn, RtcpPacketType.RTCP_REPORT); // Sta...
java
private void scheduleRtcp(long timestamp, RtcpPacketType packetType) { // Create the task and schedule it long interval = resolveInterval(timestamp); this.scheduledTask = new TxTask(packetType); try { this.reportTaskFuture = this.scheduler.schedule(this.scheduledTask, interv...
java
private void rescheduleRtcp(TxTask task, long timestamp) { // Cancel current execution of the task this.reportTaskFuture.cancel(true); // Re-schedule task execution long interval = resolveInterval(timestamp); try { this.reportTaskFuture = this.scheduler.sched...
java
private void closeChannel() { if (this.channel != null) { if (this.channel.isConnected()) { try { this.channel.disconnect(); } catch (IOException e) { logger.warn(e.getMessage(), e); } } ...
java
private boolean decode_WSP() { boolean decoded = false; if (index < totalChars && (chars[index] == 0x20 || chars[index] == 0x09)) { index++; decoded = true; } return decoded; }
java
public double[] perform(double[] buffer, int len) { int size = (int)((double)F/f * len); double signal[] = new double[size]; double dx = 1./(double)f; double dX = 1./(double)F; signal[0] = buffer[0]; double k = 0; for (int i = 1; i < size - 1; i++) { ...
java
public void strain(byte[] data, int pos, int len) { this.chars = data; this.pos = pos; this.len = len; this.linePointer = 0; }
java
public void duplicate(Text destination) { System.arraycopy(chars, pos, destination.chars, destination.pos, len); destination.len = len; }
java
public int divide(char separator, Text[] parts) { int pointer = pos; int limit = pos + len; int mark = pointer; int count = 0; while (pointer < limit) { if (chars[pointer] == separator) { parts[count].strain(chars, mark, pointer - mark); ...
java
public void trim() { try { //cut white spaces from the head while (len>0 && chars[pos] == ' ') { pos++; len--; } //cut from the end while (len>0 && (chars[pos + len - 1] == ' ' || chars[pos + len - 1] == '\n' || chars[pos + len - 1] == '\r')) { len--; }...
java
public Text nextLine() { if (linePointer == 0) { linePointer = pos; } else { linePointer++; } int mark = linePointer; int limit = pos + len; while (linePointer < limit && chars[linePointer] != '\n') { linePointer++; } ...
java
private boolean compareChars(byte[] chars, int pos) { for (int i = 0; i < len; i++) { if (differentChars((char) this.chars[i + this.pos], (char) chars[i + pos])) return false; } return true; }
java
public boolean startsWith(Text pattern) { if (pattern == null) { return false; } return this.subSequence(0, pattern.len).equals(pattern); }
java
private boolean differentChars(char c1, char c2) { if (65 <= c1 && c1 < 97) { c1 +=32; } if (65 <= c2 && c2 < 97) { c2 +=32; } return c1 != c2; }
java
public int toInteger() throws NumberFormatException { int res = 0; byte currChar; int i=1; currChar=chars[pos]; boolean isMinus=false; if(currChar==minus_byte) isMinus=true; else if(currChar>=zero_byte && currChar<=nine_byte) res+=currChar-...
java
public void copyRemainder(Text other) { other.chars = this.chars; other.pos = this.linePointer + 1; other.len = this.len - this.linePointer - 1; }
java
public boolean contains(char c) { for (int k = pos; k < len; k++) { if (chars[k] == c) return true; } return false; }
java
public void attach(RequestIdentifier reqID, JainMgcpListener listener) { this.requestListeners.put(reqID.toString().trim(), listener); }
java
public void deattach(JainMgcpListener listener) { int identifier = -1; //search identifier of the specified listener Set<Integer> IDs = txListeners.keySet(); for (Integer id : IDs) { if (txListeners.get(id) == listener) { identifier = id; ...
java
public boolean isSenderTimeout() { long t = rtcpReceiverInterval(false); long minTime = getCurrentTime() - (2 * t); if (this.rtpSentOn < minTime) { removeSender(this.ssrc); } return this.weSent; }
java
public void strain(Text line) throws ParseException { try { Iterator<Text> it = line.split('=').iterator(); it.next(); Text token = it.next(); it = token.split(' ').iterator(); name = it.next(); name.trim(); sessionID = it.ne...
java
private void setupAudioChannelInbound(MediaDescriptionField remoteAudio) throws IOException { // Negotiate audio codecs this.audioChannel.negotiateFormats(remoteAudio); if (!this.audioChannel.containsNegotiatedFormats()) { throw new IOException("Audio codecs were not supported"); ...
java
private void setupAudioChannelOutbound(MediaDescriptionField remoteAudio) throws IOException { // Negotiate audio codecs this.audioChannel.negotiateFormats(remoteAudio); if (!this.audioChannel.containsNegotiatedFormats()) { throw new IOException("Audio codecs were not supported"); ...
java
public boolean removeHandler(PacketHandler handler) { synchronized (this.handlers) { boolean removed = this.handlers.remove(handler); if (removed) { this.count.decrementAndGet(); } return removed; } }
java
public PacketHandler getHandler(byte[] packet) { synchronized (this.handlers) { // Search for the first handler capable of processing the packet for (PacketHandler protocolHandler : this.handlers) { if (protocolHandler.canHandle(packet)) { return proto...
java
public void close() { stopped = true; try { if (logger.isDebugEnabled()) { logger.debug("Closing socket"); } // selector.close(); socket.close(); if (this.channel != null) { this.channel.close(); } for(int i=0;i<decodingThreads.length;i++) { decodingThreads[i].shutdown(); } ...
java
public boolean reverseTransformPacket(RawPacket pkt) { int seqNo = pkt.getSequenceNumber(); if (!seqNumSet) { seqNumSet = true; seqNum = seqNo; } // Guess the SRTP index (48 bit), see rFC 3711, 3.3.1 // Stores the guessed roc in this.guessedROC long guessedIndex = guessIndex(seqNo); // Replay c...
java
private void authenticatePacketHMCSHA1(RawPacket pkt, int rocIn) { ByteBuffer buf = pkt.getBuffer(); buf.rewind(); int len = buf.remaining(); buf.get(tempBuffer, 0, len); mac.update(tempBuffer, 0, len); rbStore[0] = (byte) (rocIn >> 24); rbStore[1] = (byte) (rocIn >> 16); rbStore[2] = (byte) (rocIn >> 8...
java
private void computeIv(long label, long index) { long key_id; if (keyDerivationRate == 0) { key_id = label << 48; } else { key_id = ((label << 48) | (index / keyDerivationRate)); } for (int i = 0; i < 7; i++) { ivStore[i] = masterSalt[i]; } for (int i = 7; i < 14; i++) { ivStore[i] = (byte) (...
java
@Override public Dsp newProcessor() throws InstantiationException, ClassNotFoundException, IllegalAccessException { int numClasses = this.classes.size(); Codec[] codecs = new Codec[numClasses]; for(int i = 0; i < numClasses; i++) { String fqn = this.classes.get(i); Cl...
java
private Node<E> extract() { Node<E> current = head; head = head.next; current.item = head.item; head.item = null; return current; }
java
private void estimateJitter(RtpPacket packet) { long transit = rtpClock.getLocalRtpTime() - packet.getTimestamp(); long d = transit - this.currentTransit; this.currentTransit = transit; if(d < 0) { d = -d; } this.jitter += d - ((this.jitter + 8) >> 4); }
java
public static AudioFormat createAudioFormat(EncodingName name) { //check name and create specific if (name.equals(DTMF)) { return new DTMFFormat(); } //default format return new AudioFormat(name); }
java
public static ChangeRequestAttribute createChangeRequestAttribute( boolean changeIP, boolean changePort) { ChangeRequestAttribute attribute = new ChangeRequestAttribute(); attribute.setAddressChanging(changeIP); attribute.setPortChanging(changePort); return attribute; }
java
public static ChangedAddressAttribute createChangedAddressAttribute( TransportAddress address) { ChangedAddressAttribute attribute = new ChangedAddressAttribute(); attribute.setAddress(address); return attribute; }
java
public static ErrorCodeAttribute createErrorCodeAttribute(byte errorClass, byte errorNumber, String reasonPhrase) throws StunException { ErrorCodeAttribute attribute = new ErrorCodeAttribute(); attribute.setErrorClass(errorClass); attribute.setErrorNumber(errorNumber); attribute.setReasonPhrase(reasonPhras...
java
public static ErrorCodeAttribute createErrorCodeAttribute(char errorCode, String reasonPhrase) throws IllegalArgumentException { ErrorCodeAttribute attribute = new ErrorCodeAttribute(); attribute.setErrorCode(errorCode); attribute.setReasonPhrase(reasonPhrase == null ? ErrorCodeAttribute .getDefaultReason...
java
public static MappedAddressAttribute createMappedAddressAttribute( TransportAddress address) { MappedAddressAttribute attribute = new MappedAddressAttribute(); attribute.setAddress(address); return attribute; }
java
public static ReflectedFromAttribute createReflectedFromAttribute( TransportAddress address) { ReflectedFromAttribute attribute = new ReflectedFromAttribute(); attribute.setAddress(address); return attribute; }
java
public static ResponseAddressAttribute createResponseAddressAttribute( TransportAddress address) { ResponseAddressAttribute attribute = new ResponseAddressAttribute(); attribute.setAddress(address); return attribute; }
java
public static SourceAddressAttribute createSourceAddressAttribute( TransportAddress address) { SourceAddressAttribute attribute = new SourceAddressAttribute(); attribute.setAddress(address); return attribute; }
java
public static XorRelayedAddressAttribute createXorRelayedAddressAttribute( TransportAddress address, byte[] tranID) { XorRelayedAddressAttribute attribute = new XorRelayedAddressAttribute(); // TODO shouldn't we be XORing the address before setting it? attribute.setAddress(address, tranID); return attribute...
java
public static XorPeerAddressAttribute createXorPeerAddressAttribute( TransportAddress address, byte[] tranID) { XorPeerAddressAttribute attribute = new XorPeerAddressAttribute(); // TODO shouldn't we be XORing the address before setting it? attribute.setAddress(address, tranID); return attribute; }
java
public static UsernameAttribute createUsernameAttribute(byte username[]) { UsernameAttribute attribute = new UsernameAttribute(); attribute.setUsername(username); return attribute; }
java
public static ChannelNumberAttribute createChannelNumberAttribute( char channelNumber) { ChannelNumberAttribute attribute = new ChannelNumberAttribute(); attribute.setChannelNumber(channelNumber); return attribute; }
java
public static RealmAttribute createRealmAttribute(byte realm[]) { RealmAttribute attribute = new RealmAttribute(); attribute.setRealm(realm); return attribute; }
java
public static NonceAttribute createNonceAttribute(byte nonce[]) { NonceAttribute attribute = new NonceAttribute(); attribute.setNonce(nonce); return attribute; }
java
public static SoftwareAttribute createSoftwareAttribute(byte software[]) { SoftwareAttribute attribute = new SoftwareAttribute(); attribute.setSoftware(software); return attribute; }
java
public static EvenPortAttribute createEvenPortAttribute(boolean rFlag) { EvenPortAttribute attribute = new EvenPortAttribute(); attribute.setRFlag(rFlag); return attribute; }
java
public static LifetimeAttribute createLifetimeAttribute(int lifetime) { LifetimeAttribute attribute = new LifetimeAttribute(); attribute.setLifetime(lifetime); return attribute; }
java
public static RequestedTransportAttribute createRequestedTransportAttribute( byte protocol) { RequestedTransportAttribute attribute = new RequestedTransportAttribute(); attribute.setRequestedTransport(protocol); return attribute; }
java
public static ReservationTokenAttribute createReservationTokenAttribute( byte token[]) { ReservationTokenAttribute attribute = new ReservationTokenAttribute(); attribute.setReservationToken(token); return attribute; }
java
public static ControlledAttribute createIceControlledAttribute( long tieBreaker) { ControlledAttribute attribute = new ControlledAttribute(); attribute.setTieBreaker(tieBreaker); return attribute; }
java
public static PriorityAttribute createPriorityAttribute(long priority) throws IllegalArgumentException { PriorityAttribute attribute = new PriorityAttribute(); attribute.setPriority(priority); return attribute; }
java
public static ControllingAttribute createIceControllingAttribute( long tieBreaker) { ControllingAttribute attribute = new ControllingAttribute(); attribute.setTieBreaker(tieBreaker); return attribute; }
java
public static DestinationAddressAttribute createDestinationAddressAttribute( TransportAddress address) { DestinationAddressAttribute attribute = new DestinationAddressAttribute(); attribute.setAddress(address); return attribute; }
java
public void bind(boolean isLocal, int port) throws IOException { try { // Open this channel with UDP Manager on first available address this.selectionKey = udpManager.open(this); this.dataChannel = (DatagramChannel) this.selectionKey.channel(); } catch (IOException e) { throw new SocketException(e.getMe...
java
public void parse(byte[] data) throws ParseException { Text text = new Text(); text.strain(data, 0, data.length); init(text); }
java
public Set<Integer> getConnections(String endpointId) { return Collections.unmodifiableSet(this.entries.get(endpointId)); }
java
public boolean addConnection(String endpointId, int connectionId) { boolean added = this.entries.put(endpointId, connectionId); if (added && log.isDebugEnabled()) { int left = this.entries.get(endpointId).size(); log.debug("Call " + getCallIdHex() + " registered connection " + In...
java
public boolean removeConnection(String endpointId, int connectionId) { boolean removed = this.entries.remove(endpointId, connectionId); if (removed && log.isDebugEnabled()) { int left = this.entries.get(endpointId).size(); log.debug("Call " + getCallIdHex() + " unregistered conne...
java
public Set<Integer> removeConnections(String endpointId) { Set<Integer> removed = this.entries.removeAll(endpointId); if (!removed.isEmpty() && log.isDebugEnabled()) { log.debug("Call " + getCallIdHex() + " unregistered connections " + Arrays.toString(convertToHex(removed)) + " from endpoint...
java
private MgcpConnection createRemoteConnection(int callId, ConnectionMode mode, MgcpEndpoint endpoint, CrcxContext context) throws MgcpConnectionException { // Create connection MgcpConnection connection = endpoint.createConnection(callId, false); // TODO set call agent String localDescri...
java
private MgcpConnection createLocalConnection(int callId, MgcpEndpoint endpoint) throws MgcpConnectionException { MgcpConnection connection = endpoint.createConnection(callId, true); connection.open(null); return connection; }
java
public RTPFormats negotiateAudio(SessionDescription sdp, RTPFormats formats) { this.audio.clean(); MediaDescriptorField descriptor = sdp.getAudioDescriptor(); descriptor.getFormats().intersection(formats, this.audio); return this.audio; }
java
public RTPFormats negotiateVideo(SessionDescription sdp, RTPFormats formats) { this.video.clean(); MediaDescriptorField descriptor = sdp.getVideoDescriptor(); descriptor.getFormats().intersection(formats, this.video); return this.video; }
java
public RTPFormats negotiateApplication(SessionDescription sdp, RTPFormats formats) { this.application.clean(); MediaDescriptorField descriptor = sdp.getApplicationDescriptor(); descriptor.getFormats().intersection(formats, this.application); return this.application; }
java
private static RtcpSenderReport buildSenderReport(RtpStatistics statistics, boolean padding) { /* * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...
java