AVCaptureSession旋转| 定位同时传输video

我正在开发videostream应用程序,在这个应用程序中,我需要捕获前置摄像头的video帧并进行编码然后转移到另一端,典型的stream程就是这样

AVCaptureSession – > AVCaptureDeviceInput – > AVCaptureVideoDataOutput – >捕获帧 – >编码帧 – >发送帧到另一端,

它工作正常,我已经设置了kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange作为帧格式。

也预览图层被用来显示预览,

问题出现在设备方向得到改变,如果设备从纵向移动到风景,然后在另一端帧旋转90,我期待,因为方向在预览层支持,所以我会自动接收旋转的缓冲区在捕获callback,但是看起来像,预览层只显示捕获的缓冲区的预览和UI缓冲区的缓冲区,而在另一端,我会得到咆哮的缓冲区,

所以我想知道,是否有任何configuration,使其发生变化,或者我需要旋转/变换缓冲区的Capture缓冲区中的callback。

感谢您查看,基本上解决scheme是,应该设置连接的方向,我正在玩预览图层,所以它影响预览图层而不是方向。

这里是代码片段

-(void) orientationChanged { // get the new orientation from device AVCaptureVideoOrientation newOrientation = [self videoOrientationFromDeviceOrientation]; // set the orientation of preview layer :( which will be displayed in the device ) [previewLayer.connection setVideoOrientation:newOrientation]; // set the orientation of the connection: which will take care of capture [pCaptureConnection setVideoOrientation:newOrientation]; }