title: Send Android h264 capture over a rtp stream
body: <p>I'm writing a rtp video streamer for android that reads h264 coded data from an Android local socket and packetize it. The thing is that I did it but I keep getting black frames in the client side (Voip).</p>
  
  <p>The communication goes like this: Android -> Asterisk -> Jitsi (Osx) (and reverse)</p>
  
  <p>There are a few things that I haven't understood yet:</p>
  
  <p>1) Android's mediarecorder gives me a raw h264 stream, How can I know when a NAL starts / ends based on that stream? It doesn't have any 0x000001 pattern but it does have a 0x0000 (which I'm assuming is a separator) </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Adding more information. These are 2 (<a href="http://dl.dropbox.com/u/671680/1.png" rel="nofollow">first</a>, <a href="http://dl.dropbox.com/u/671680/2.png" rel="nofollow">second</a>) different reads of the input buffer (in order). If I got it right the first 4 bytes should be used to get the NALU length and the 5th one (index 4) is the NALU header.</p>
  
  <p>I'll copy here the byte's values for future usage:</p>
  
  <pre><code>1) 0 0 12 114 101 -72 4 25 -15 -1 -121 -53 .....
  
     length = (114&amp;0xFF) + (12&amp;0xFF)*256 + (0&amp;0xFF)
     length -&gt; 3186
  
     forbidden = 101 &amp; 0x80
     forbidden -&gt; 0
  
     nri = 101 &amp; 0x60
     nri -&gt; 96
  
     nal_unit_type = 101 &amp; 0x1F
     nal_unit_type -&gt; 5
  
  
  2) 0 0 1 -93 97 -32 32 103 -14 93 -1 .... 
  
     length = (-93&amp;0xFF) + (1&amp;0xFF)*256 + (0&amp;0xFF)
     length -&gt; 419
  
     forbidden = 97 &amp; 0x80
     forbidden -&gt; 0
  
     nri = 97 &amp; 0x60
     nri -&gt; 96
  
     nal_unit_type = 97 &amp; 0x1F
     nal_unit_type -&gt; 1
  </code></pre>
  
  <p>is this correct? </p>
  
  <p>2) How can I get the NALu timestamp and its length from that stream? </p>
  
  <p>3) For some reason the packets are being marked (Even when I unset the marker). (In case you check the pcap file) [<strong>FIXED:</strong> I wasn't using the same SSCR for every packet]</p>
  
  <p>Here's a <a href="http://dl.dropbox.com/u/671680/android_last.pcap" rel="nofollow">pcap</a> capture of the stream coming from asterisk (wich comes from Android). The Android device is an Asus Transform Prime with Android ICS.</p>
  
  <p>I'm sending the packetization-mode (<code>1</code>) and profile-level-id (<code>42801e</code>) in the sdp, I've also tried sending the sprops (sps: <code>Z0KAHpWgUHxA</code>, psp: <code>aM48gA==</code>) parameter but nothing changed.</p>
  
  <p>Cheers.</p>