Question: PLEASE WRITE THE IMPLEMENTED CODE Upackage ca . yorku.rtsp . client.net;import ca . yorku.rtsp . client.exception.RTSPException;import ca . yorku.rtsp . client.model.Frame;import ca . yorku.rtsp .

PLEASE WRITE THE IMPLEMENTED CODE
Upackage ca.yorku.rtsp.client.net;import ca.yorku.rtsp.client.exception.RTSPException;import ca.yorku.rtsp.client.model.Frame;import ca.yorku.rtsp.client.model.Session;import java.io.*;import java.net.*;import java.nio.ByteBuffer;import java.nio.ByteOrder;/*** This class represents a connection with an RTSP server. */public class RTSPConnection { private static final int BUFFER_LENGTH =0x10000; private final Session session; // TODO Add additional fields, if necessary /*** Establishes a new connection with an RTSP server. No message is * sent at this point, and no stream is set up.** @param session The Session object to be used for connectivity with the UI.* @param server The hostname or IP address of the server. * @param port The TCP port number where the server is listening to.* @throws RTSPException If the connection couldn't be accepted, * such as if the host name or port number * are invalid or there is no connectivity. */ public RTSPConnection(Session session, String server, int port) throws RTSPException { this.session = session; // TODO }/*** Sets up a new video stream with the server. This method is * responsible for sending the SETUP request, receiving the * response and retrieving the session identification to be used * in future messages. It is also responsible for establishing an * RTP datagram socket to be used for data transmission by the * server. The datagram socket should be created with a random * available UDP port number, and the port number used in that * connection has to be sent to the RTSP server for setup. This * datagram socket should also be defined to timeout after 2* seconds if no packet is received. ** @param videoName The name of the video to be setup. * @throws RTSPException If there was an error sending or * receiving the RTSP data, or if the RTP * socket could not be created, or if the * server did not return a successful * response. */ public synchronized void setup(String videoName) throws RTSPException {// TODO }/*** Starts (or resumes) the playback of a set up stream. This * method is responsible for sending the request, receiving the * response and, in case of a successful response, starting a * separate thread responsible for receiving RTP packets with * frames (achieved by calling start() on a new object of type * RTPReceivingThread).** @throws RTSPException If there was an error sending or * receiving the RTSP data, or if the server * did not return a successful response. */ public synchronized void play() throws RTSPException {// TODO } private class RTPReceivingThread extends Thread {/*** Continuously receives RTP packets until the thread is * cancelled or until an RTP packet is received with a * zero-length payload. Each packet received from the datagram * socket is assumed to be no larger than BUFFER_LENGTH * bytes. This data is then parsed into a Frame object (using * the parseRTPPacket() method) and the method * session.processReceivedFrame() is called with the resulting * packet. The receiving process should be configured to * timeout if no RTP packet is received after two seconds. If * a frame with zero-length payload is received, indicating * the end of the stream, the method session.videoEnded() is * called, and the thread is terminated. */ @Override public void run(){// TODO }}/*** Pauses the playback of a set up stream. This method is * responsible for sending the request, receiving the response * and, in case of a successful response, stopping the thread * responsible for receiving RTP packets with frames. ** @throws RTSPException If there was an error sending or * receiving the RTSP data, or if the server * did not return a successful response. */ public synchronized void pause() throws RTSPException {// TODO }/*** Terminates a set up stream. This method is responsible for * sending the request, receiving the response and, in case of a * successful response, closing the RTP socket. This method does * not close the RTSP connection, and a further SETUP in the same * connection should be accepted. Also, this method can be called * both for a paused and for a playing stream, so the thread * responsible for receiving RTP packets will also be cancelled, * if active. ** @throws RTSPException If there was an error sending or * receiving the RTSP data, or if the server * did not return a successful response. */ public synchronized void teardown() throws RTSPException {// TODO }/*** Closes the connection with the RTSP server. This method should * also close any open resource associated to this connection, * such as the RTP connection and thread, if it is still open. */ public synchronized void closeConnection(){// TODO }/*** Parses an RTP packet into a Frame object. This method is * intended to be a helper method in this class, but it is made * public to facilitate testing. ** @param packet the byte representation of a frame, corresponding to the RTP packet. * @return A Frame object. */ public static Frame parseRTPPacket(DatagramPacket packet){// TODO return null; }/*** Reads and parses an RTSP response from the socket's input. This * method is intended to be a helper method in this class, but it * is made public to facilitate testing. ** @return An RTSPResponse object if the response was read * completely, or null if the end of the stream was reached. * @throws IOException In case of an I/O error, such as loss of connectivity. * @throws RTSPException If the response doesn't match the expected format. */ public RTSPResponse readRTSPResponse() throws IOException, RTSPException {// TODO return null; // Replace with a proper RTSPResponse }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!