在iOS上通过WiFi和蓝牙进行视频流传输

4
这个问题比较宽泛,因为我是iOS、视频流和蓝牙方面的新手(这将是一个有趣的项目)。
基本上,我希望能够通过WiFi或蓝牙从一个iOS设备流式传输低分辨率视频到另一个iOS设备,具体取决于哪个设备可用。Bonjour用于初始服务发现。(虽然知道通过蓝牙流式传输视频不是最理想的,但这是该项目的要求之一)
所以问题是,有哪些视频流框架/库可以用来最大化共享在WiFi和蓝牙上流式传输视频的代码量?
3个回答

5
以下是测试使用Multipeer Conectivity进行视频流的说明:

您需要Cocoapods,如果尚未安装,请前往http://cocoapods.org/#install

  1. https://github.com/pj4533/AVCaptureMultipeerVideoDataOutput克隆发射器。
  2. 在终端中导航到AVCaptureMultipeerVideoDataOutput/Sample目录并执行pod install
  3. https://github.com/pj4533/SGSMultipeerVideoMixer克隆接收器。
  4. 在物理设备上运行发射器,您将在屏幕上看到后置摄像头。
  5. 在模拟器或物理设备上运行一个或多个接收器,发射器的图像应出现在接收器中。

注意:Multipeer Connectivity需要iOS 7,两台设备都应启用WiFi或蓝牙,我已在WiFi上成功测试过,蓝牙可能太慢。


3

我建议使用MultipeerConnectivity框架。以下是MCSessionDelegate提供的几个委托方法:

MCSessionDelegate <NSObject>


// Received a byte stream from remote peer

- (void)session:(MCSession *)session didReceiveStream:(NSInputStream *)stream withName:(NSString *)streamName fromPeer:(MCPeerID *)peerID;


// Start receiving a resource from remote peer

- (void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID withProgress:(NSProgress *)progress;


// Finished receiving a resource from remote peer and saved the content in a temporary location - the app is responsible for moving the file to a permanent location within its sandbox

- (void)session:(MCSession *)session didFinishReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID atURL:(NSURL *)localURL withError:(NSError *)error;`

尝试阅读 http://nshipster.com/multipeer-connectivity/

1
我编写了相关代码,以下是我制作的视频,演示了我的应用程序将视频从一台设备流式传输到另一台设备:

<iframe width="560" height="315" src="https://www.youtube.com/embed/mWyZ1z55chw?rel=0" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>

屏幕录制器(iOS 11.2)会偶尔导致接收端卡顿(同时录制视频和我的应用程序正在显示它)。无论如何,它使用设备之间的任何连接(无线,蓝牙,烟信号等),让我知道,我会帮你开始。无法看到视频?https://youtu.be/mWyZ1z55chw

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接