title: Camera Orientation issue on OnPreviewCallback method
body: <p>Hello i am implementing the ipStreaming code from <a href="https://github.com/fyhertz/spydroid-ipcamera" rel="nofollow noreferrer">here</a>
  But issue is in 90 degree orientation [Working with portrait mode] video is flipped not in proper orientation. </p>
  
  <p><strong>Solution tried:-</strong> </p>
  
  <p>1.)<a href="https://gist.github.com/sbaar/0a85727d599fcbd5acd1#file-nv21converter-java" rel="nofollow noreferrer">nv21Converter</a></p>
  
  <p>Output is :- 
  <a href="https://i.stack.imgur.com/5pUb9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5pUb9.png" alt="enter image description here"></a></p>
  
  <p>2.) <a href="https://stackoverflow.com/questions/6853401/camera-pixels-rotated">SO_Solution</a></p>
  
  <p>output is:- </p>
  
  <pre><code>public static byte[] rotateNV21(final byte[] yuv,
                              final int width,
                              final int height,
                                  [![final int rotation)
  {
    if (rotation == 0) return yuv;
    if (rotation % 90 != 0 || rotation &lt; 0 || rotation &gt; 270) {
      throw new IllegalArgumentException("0 &lt;= rotation &lt; 360, rotation % 90 == 0");
    }
  
    final byte\[\]  output    = new byte\[yuv.length\];
    final int     frameSize = width * height;
    final boolean swap      = rotation % 180 != 0;
    final boolean xflip     = rotation % 270 != 0;
    final boolean yflip     = rotation &gt;= 180;
  
    for (int j = 0; j &lt; height; j++) {
      for (int i = 0; i &lt; width; i++) {
        final int yIn = j * width + i;
        final int uIn = frameSize + (j &gt;&gt; 1) * width + (i &amp; ~1);
        final int vIn = uIn       + 1;
  
        final int wOut     = swap  ? height              : width;
        final int hOut     = swap  ? width               : height;
        final int iSwapped = swap  ? j                   : i;
        final int jSwapped = swap  ? i                   : j;
        final int iOut     = xflip ? wOut - iSwapped - 1 : iSwapped;
        final int jOut     = yflip ? hOut - jSwapped - 1 : jSwapped;
  
        final int yOut = jOut * wOut + iOut;
        final int uOut = frameSize + (jOut &gt;&gt; 1) * wOut + (iOut &amp; ~1);
        final int vOut = uOut + 1;
  
        output\[yOut\] = (byte)(0xff &amp; yuv\[yIn\]);
        output\[uOut\] = (byte)(0xff &amp; yuv\[uIn\]);
        output\[vOut\] = (byte)(0xff &amp; yuv\[vIn\]);
      }
    }
    return output;
  }][4]][4]
  </code></pre>
  
  <p><strong>output is:-</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/1QgU6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1QgU6.png" alt="enter image description here"></a></p>