How to play audio sample buffers from AVCaptureAudioDataOutput

后端 未结 1 1924
不思量自难忘°
不思量自难忘° 2021-01-06 21:00

The main goal of the app Im trying to make is a peer-to-peer video streaming. (Sort of like FaceTime using bluetooth/WiFi).

Using AVFoundation, I was able to capture

相关标签:
1条回答
  • 2021-01-06 21:29

    To show video you can use (here is : getting of ARGB picture and converting to Qt (nokia qt) QImage you can replace by other image)

    place it to delegate class

     - (void)captureOutput:(AVCaptureOutput *)captureOutput
        didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
               fromConnection:(AVCaptureConnection *)connection
    

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    
    CVPixelBufferLockBaseAddress(imageBuffer,0);
    
    SVideoSample sample;
    
    sample.pImage      = (char *)CVPixelBufferGetBaseAddress(imageBuffer);
    sample.bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
    sample.width       = CVPixelBufferGetWidth(imageBuffer);
    sample.height      = CVPixelBufferGetHeight(imageBuffer);
    
    QImage img((unsigned char *)sample.pImage, sample.width, sample.height, sample.bytesPerRow, QImage::Format_ARGB32);
    
    self->m_receiver->eventReceived(img);
    
    CVPixelBufferUnlockBaseAddress(imageBuffer,0);
    [pool drain];
    
    0 讨论(0)
提交回复
热议问题