Red5 CustomVideoSource发送Black&白色视频

时间:2017-10-05 05:55:32

标签: ios video-streaming streaming red5 red5pro

我正在使用Red5 iOS代码及其CustomVideoSource类。通过服务器成功发布流,但它显示为Black&白色。不是实际的彩色流。 如果有人遇到过这个问题,请帮我找到解决方法。 请找到代码示例

  let contextImage = McamImage.shared.image
        let image: CGImage? = contextImage.cgImage
        let dataProvider: CGDataProvider? = image?.dataProvider
        let data: CFData? = dataProvider?.data


        if (data != nil) {

        let baseAddress = CFDataGetBytePtr(data!)
        //contextImage = nil

        /*
         * We own the copied CFData which will back the CVPixelBuffer, thus the data's lifetime is bound to the buffer.
         * We will use a CVPixelBufferReleaseBytesCallback callback in order to release the CFData when the buffer dies.
         */
        let unmanagedData = Unmanaged<CFData>.passRetained(data!)
        var pixelBuffer: CVPixelBuffer?
        var result = CVPixelBufferCreateWithBytes(nil,
                                                  (image?.width)!,
                                                  (image?.height)!,
                                                  kCVPixelFormatType_24RGB,
                                                  UnsafeMutableRawPointer( mutating: baseAddress!),
                                                  (image?.bytesPerRow)!,
                                                  { releaseContext, baseAddress in
                                                    let contextData = Unmanaged<CFData>.fromOpaque(releaseContext!)
                                                    contextData.release()
        },
                                                  unmanagedData.toOpaque(),
                                                  nil,
                                                  &pixelBuffer)

谢谢!

0 个答案:

没有答案