
org.jitsi.impl.neomedia.RTPConnectorTCPOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libjitsi Show documentation
Show all versions of libjitsi Show documentation
libjitsi is an advanced Java media library for secure real-time audio/video
communication
The newest version!
/*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.impl.neomedia;
import java.io.*;
import java.net.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.packetlogging.*;
/**
* RTPConnectorOutputStream implementation for TCP protocol.
*
* @author Sebastien Vincent
*/
public class RTPConnectorTCPOutputStream
extends RTPConnectorOutputStream
{
/**
* TCP socket used to send packet data
*/
private final Socket socket;
/**
* Initializes a new RTPConnectorTCPOutputStream.
*
* @param socket a Socket
*/
public RTPConnectorTCPOutputStream(Socket socket)
{
this.socket = socket;
}
/**
* Sends a specific RawPacket through this
* OutputDataStream to a specific InetSocketAddress.
*
* @param packet the RawPacket to send through this
* OutputDataStream to the specified target
* @param target the InetSocketAddress to which the specified
* packet is to be sent through this OutputDataStream
* @throws IOException if anything goes wrong while sending the specified
* packet through this OutputDataStream to the specified
* target
*/
@Override
protected void sendToTarget(RawPacket packet, InetSocketAddress target)
throws IOException
{
socket.getOutputStream().write(
packet.getBuffer(),
packet.getOffset(),
packet.getLength());
}
/**
* Log the packet.
*
* @param packet packet to log
*/
@Override
protected void doLogPacket(RawPacket packet, InetSocketAddress target)
{
PacketLoggingService pktLogging = getPacketLoggingService();
if (pktLogging != null)
{
pktLogging.logPacket(
PacketLoggingService.ProtocolName.RTP,
socket.getLocalAddress().getAddress(),
socket.getLocalPort(),
target.getAddress().getAddress(),
target.getPort(),
PacketLoggingService.TransportName.TCP,
true,
packet.getBuffer(),
packet.getOffset(),
packet.getLength());
}
}
/**
* Returns whether or not this RTPConnectorOutputStream has a valid
* socket.
*
* @return trueif this RTPConnectorOutputStream has a valid
* socket, and false otherwise.
*/
@Override
protected boolean isSocketValid()
{
return (socket != null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy