测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2014年12月 |
由 PJ Gray 维护。
通过多用户连接发送一路视频流。
使用 SGSMultipeerVideoMixer 查看示例。
将多用户连接相关内容抽象在 AVCaptureVideoDataOutput 子类内部,因此使用正常的 AV 管道设置起来很容易
// Create the AVCaptureSession
self.captureSession = [[AVCaptureSession alloc] init];
// Setup the preview view
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.captureSession];
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
captureVideoPreviewLayer.frame = CGRectMake(0,0, 320, 320);
[self.previewView.layer addSublayer:captureVideoPreviewLayer];
// Create video device input
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:nil];
[self.captureSession addInput:videoDeviceInput];
// Create output
AVCaptureMultipeerVideoDataOutput *multipeerVideoOutput = [[AVCaptureMultipeerVideoDataOutput alloc] initWithDisplayName:[[UIDevice currentDevice] name]];
[self.captureSession addOutput:multipeerVideoOutput];
[self.captureSession startRunning];
就这样!查看 AVCaptureMultipeerVideoDataOutput 类以了解其发送数据的详细信息。(发送的数据最终是一个相当低质量的 JPEG)。
使用 cocoapods,因此只需将其添加到您的 Podfile 中
pod "AVCaptureMultipeerVideoDataOutput"
查看示例项目以获取实现示例。要运行示例
pod install
然后打开 'MultipeerVideoOutputSample.xcworkspace'
PJ Gray
AVCaptureMultipeerVideoDataOutput 可在 MIT 许可证下获得。有关更多信息,请参阅 LICENSE 文件。