Package org.zoolu.net

Examples of org.zoolu.net.UdpPacket


   {
      if (udp_socket==null || input_stream==null) return;
      //else
     
      byte[] buffer=new byte[frame_size];
      UdpPacket udp_packet=new UdpPacket(buffer,0);
      long time=0;
      long start_time=System.currentTimeMillis();
      long byte_rate=frame_rate*frame_size;
     
      running=true;
           
      if (DEBUG) println("Reading blocks of "+(buffer.length)+" bytes");

      try
      while (running)
         {
            //if (DEBUG) System.out.print("o");
            int num=input_stream.read(buffer,12,buffer.length);
          //if (DEBUG) System.out.print("*");
            if (num>0)
            {  udp_packet.setLength(num);
               udp_socket.send(udp_packet);
               // update rtp timestamp (in milliseconds)
               time+=(num*1000)/byte_rate;
               // wait fo next departure
               if (do_sync)
View Full Code Here


         return;
      }
      //else

      byte[] buffer=new byte[BUFFER_SIZE];
      UdpPacket udp_packet=new UdpPacket(buffer,0);

      if (DEBUG) println("Reading blocks of max "+buffer.length+" bytes");

      //byte[] aux=new byte[BUFFER_SIZE];

      running=true;
      try
      udp_socket.setSoTimeout(SO_TIMEOUT);
         while (running)
         {  try
            // read a block of data from the rtp socket
               udp_socket.receive(udp_packet);
               //if (DEBUG) System.out.print(".");
              
               // write this block to the output_stream (only if still running..)
               if (running) output_stream.write(udp_packet.getData(), udp_packet.getOffset(), udp_packet.getLength());
            }
            catch (java.io.InterruptedIOException e) { }
         }
      }
      catch (Exception e) {  running=false; e.printStackTrace()}
View Full Code Here

TOP

Related Classes of org.zoolu.net.UdpPacket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.