1
votes

I am working on an application that captures a live video stream from front camera and sends it to the remote end (using RTP). Essentially the data flow is: AVCaptureSession -> AVCaptureVideoDataOutput -> callback -> RTP -> Display at remote end

When I use landscape mode the image on the remote end is upside down. In portrait mode it is rotated to the left.

How can I rotate the pixel buffer in the following callback so the image at remote end has the right orientation? Appreciate any pointers.

void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection
1
I'm facing exactly the same problem, you haven't found a solution have you? - thomketler

1 Answers

0
votes

Well up till now, I was able to get half of a solution:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration
{

    switch (toInterfaceOrientation)
    {
        case UIInterfaceOrientationLandscapeRight:
            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(0)];
            break;
        case UIInterfaceOrientationLandscapeLeft:
            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(M_PI)];
            break;
//        case UIInterfaceOrientationPortrait:
//            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(M_PI / 2)];
//            break;
//        case UIInterfaceOrientationPortraitUpsideDown:
//            [[[self imageView] layer] setAffineTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
//            break;
    }
}

I overwrote the willAnimitateRotation function, but this only works for the Landscape-Orientations properly (I designed the ViewController in Landscape-Mode).