Video streaming 实时摄像机流媒体

Video streaming 实时摄像机流媒体,video-streaming,wifi,gamekit,live-streaming,nsstream,Video Streaming,Wifi,Gamekit,Live Streaming,Nsstream,我正试图开发一个应用程序来做实时流视频和音频监控服务 从iPhone、iPad或iPod捕获相机,并在其他设备(如iPhone、iPad或iPod)上实时显示 同时,我希望允许两个(或更多)设备之间同时进行音频通信和数据传输 据我所知,Bonjour、GameKit和NSStream允许通过wifi或蓝牙在设备之间传输数据 到目前为止,我一直使用AVCaptureSession(来自AVFoundation)从相机捕获并发送每一帧 使用GKSession(从GameKit)连接到其他设备(蓝牙或

我正试图开发一个应用程序来做实时流视频和音频监控服务

从iPhone、iPad或iPod捕获相机,并在其他设备(如iPhone、iPad或iPod)上实时显示

同时,我希望允许两个(或更多)设备之间同时进行音频通信和数据传输

据我所知,Bonjour、GameKit和NSStream允许通过wifi或蓝牙在设备之间传输数据

到目前为止,我一直使用AVCaptureSession(来自AVFoundation)从相机捕获并发送每一帧 使用GKSession(从GameKit)连接到其他设备(蓝牙或wifi)

我发现的问题是GameKit没有提供我需要的结果

如果我想以一种温和的性能(15帧/秒)传输相机,发送方的图像质量非常糟糕,而接收方的图像质量更差

如果我想通过相机以正常或高质量传输,我在接收器端只有0.2 fps(每5秒只有1张图像)

我想以最好的图像质量和尽可能多的fps实时流式传输相机,以获得平滑和详细的实时相机流式传输, 同时具有音频通信和数据传输功能

我想知道实现这一点的最佳方法是什么:我是否需要注册到服务器,或者我是否需要其他类型的软件或应用程序

总结一下,我希望在应用程序(任何iPhone、iPad或iPod)中使用的功能:

发送或接收具有最佳质量和性能的摄像头(面部检测将作为我们的主要功能)

发送和接收具有最佳音频质量的麦克风

发送或接收其他类型的数据(例如NSStrings、布尔、NSArrays、C数组、循环)

实现这些功能的最佳方式是什么?我需要使用哪些工具来实现这些功能

事先非常感谢


佩德罗·蒙特维德

您能否成功实现这一目标?
Here is the main process to send frames from the camera capturing:

    - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:   (CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
    {       
        // Get a CMSampleBuffer's Core Video image buffer for the media data
        CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

        // Lock the base address of the pixel buffer
        CVPixelBufferLockBaseAddress(imageBuffer, 0);

        // Get the number of bytes per row for the pixel buffer
        void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer);

        // Get the number of bytes per row for the pixel buffer
        size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);

        // Get the pixel buffer width and height
        size_t width = CVPixelBufferGetWidth(imageBuffer);
        size_t height = CVPixelBufferGetHeight(imageBuffer);

        // Create a device-dependent RGB color space
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

        // Create a bitmap graphics context with the sample buffer data
        CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);

        // Create a Quartz image from the pixel data in the bitmap graphics context
        CGImageRef quartzImage = CGBitmapContextCreateImage(context);

        // Unlock the pixel buffer
        CVPixelBufferUnlockBaseAddress(imageBuffer,0);

        // Free up the context and color space
        CGContextRelease(context);
        CGColorSpaceRelease(colorSpace);

        // Create an image object from the Quartz image
        UIImage *image = [UIImage imageWithCGImage:quartzImage];

        NSData *data = UIImageJPEGRepresentation(image, 0.0);

        // Release the Quartz image
        CGImageRelease(quartzImage);

        // Send image data to peers, using GKSession from GameKit
        [self.gkSession sendDataToAllPeers:data withDataMode:GKSendDataReliable error:nil];

        CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
    }

And here is the other end (where i display the received frames in a UIImageView):

    - (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context
    {
        // Receive image data from peers
        self.imageView.image = [UIImage imageWithData:data];
    }