1

I have got an issue regarding video capture orientation. first of all its about voip app which uses pjsip which can transmit video. the video is being captured using AVCapture frame. so the issue arises while device orientation changes then i have to set the avcapture orientation as well. for example:

capConnection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;

it works fine but i have repeat image part. enter image description here

so the question is how to get rid of this repeated image part. i have tried this solution but it keeps crashing on vImageRotate90_ARGB8888 any idea how resolve this issue?

in order to try this yourself out, you can get PJSIP version 2.3 video with sample project compile and run it against a test SIP server.

edit: the preview layer is rotated and scaled fine. the particular issue happens on receiving RTP (video) stream when that device rotates and sends images with repeated edges. for instance, if iPadA(horizontal) starts video call with iPadB(horizontal) the image is fine and not repeated edges. but if the iPadA rotates to vertical then iPadB gets this repeated edge images. notice on rotation the capture connection orientation is set to current device orientation. note the the preview layer has AVLayerVideoGravityResize but that does not affect the outgoing video stream.

Community
  • 1
  • 1
Hashmat Khalil
  • 1,826
  • 1
  • 25
  • 49
  • Hello @Hashmat Khalil, i think problem is due to `self.previewLayer` bound setting. have you set bound properly once it rotate? – Jatin Patel - JP Apr 03 '15 at 09:01
  • may this [link]http://stackoverflow.com/questions/21258372/avcapturevideopreviewlayer-landscape-orientation help you. – Jatin Patel - JP Apr 03 '15 at 09:21
  • thats actually not the my own preview layer. the preview layer for my own camera looks good. it need a tweak and its fine. but the RTP stream from from other iphone's camera sends this kind of repeated image part. so the question is how to properly rotate and crop and then send it over RTP. – Hashmat Khalil Apr 07 '15 at 07:57

1 Answers1

0

The two key pieces are setting the autoresizingMask in viewDidLoad and adjusting your captureVideoPreviewLayer.frame to self.view.layer.bounds; in willAnimateRotationToInterfaceOrientation.

- (void)viewDidLoad
{
   [super viewDidLoad];

   self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

      //
      // react to device orientation notifications
      //
      [[NSNotificationCenter defaultCenter] addObserver : self
                                               selector : @selector(deviceOrientationDidChange:)
                                                   name : UIDeviceOrientationDidChangeNotification
                                                 object : nil];

      [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];


}


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

   captureVideoPreviewLayer.frame = self.view.layer.bounds;

   [[captureVideoPreviewLayer connection] setVideoOrientation:toInterfaceOrientation];
}



- (void)deviceOrientationDidChange: (NSNotification*)notification
{
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;

    switch (orientation)
    {
        case UIDeviceOrientationPortrait:
        case UIDeviceOrientationPortraitUpsideDown:
        case UIDeviceOrientationLandscapeLeft:
        case UIDeviceOrientationLandscapeRight:
            currentDeviceOrientation = orientation;
            break;

            // unsupported?
        case UIDeviceOrientationFaceUp:
        case UIDeviceOrientationFaceDown:
        default:
            break;
    }
}
Markus Schumann
  • 7,636
  • 1
  • 21
  • 27
  • I have added more details to my original question please check that. but in short the preview layer is fine. the issue arises for streaming video to other device. – Hashmat Khalil Apr 07 '15 at 08:14