title: How to extract rtp packet timestamp on android
body: <p>I'm working on a project where I stream video over wifi-direct from one android device to another using rtp over udp. </p>
  
  <p>Essentially, the first android device hosts a rtsp server and listens for connections. Once the client android device connects to it (over wi-fi direct) and starts listening for packets, the first device begins to stream the video content.</p>
  
  <p>I'm aware that RTP packet headers have a 32-bit timestamp at bit offset 32 - 64. But I do not know how to access the contents of the packet and subsequently access just that segment of their header. </p>
  
  <p>Currently, I am using libvlc to play the streamed video on the device. But I would like to be able to measure the latency between the two devices. Either by extracting the timestamps from the packets on arrival or by some other way (maybe VLC can help?)</p>
  
  <p>Edit: I am going to try to learn from the code posted <a href="https://code.google.com/p/rcsjta/source/browse/" rel="nofollow">here</a>, but still await any replies.</p>
  
  <p>Edit2: So I'm trying to go simpler. I've instead made a client activity to connect to the remote host and read packets that way using android's DatagramSocket api. However, my server activity doesn't start serving even after the client activity says it is connected. Not sure what needs to be done to let the server know there is a client ready to be served. MediaPlayer and VLC apis both were able to start streaming video once they connected. What am I missing? Do I need to do more than DatagramSocket.connect(ipaddress, port)?</p>