| 7 |
| } |
| 8 |
| 9 | #import "ExtractCVPixelBuffer.h" |
| 10 |
| 11 | namespace tgcalls { |
| 12 |
| 13 | static enum AVPixelFormat getDarwinPreferredPixelFormat(__unused AVCodecContext *ctx, __unused const enum AVPixelFormat *pix_fmts) { |
| 14 | return AV_PIX_FMT_VIDEOTOOLBOX; |
| 15 | } |
| 16 |
| 17 | void setupDarwinVideoDecoding(AVCodecContext *codecContext) { |
| 18 | return; |
| 19 |
| 20 | #if TARGET_IPHONE_SIMULATOR |
| 21 | #else |
| 22 | if (!codecContext) { |
| 23 | return; |
| 24 | } |
| 25 | av_hwdevice_ctx_create(&codecContext->hw_device_ctx, AV_HWDEVICE_TYPE_VIDEOTOOLBOX, nullptr, nullptr, 0); |
| 26 | codecContext->get_format = getDarwinPreferredPixelFormat; |
| 27 | #endif |
| 28 | } |
| 29 |
| 30 | webrtc::scoped_refptr<webrtc::VideoFrameBuffer> createDarwinPlatformFrameFromData(AVFrame const *frame) { |
| 31 | if (!frame) { |
| 32 | return nullptr; |
| 33 | } |
| 34 | if (frame->format == AV_PIX_FMT_VIDEOTOOLBOX && frame->data[3]) { |
| 35 | return extractCVPixelBuffer((void *)frame->data[3]); |
| 36 | } else { |
| 37 | return nullptr; |
| 38 | } |
| 39 | } |
| 40 |
| 41 | } |
| 42 |