Skip to content

Instantly share code, notes, and snippets.

View aibo-cora's full-sized avatar

Yura aibo-cora

  • Stamford, CT
View GitHub Profile
@aibo-cora
aibo-cora / PlanarConverter.swift
Last active July 17, 2021 23:38
Convert triplanar 420YpCbCr8PlanarFullRange image buffer to ARGB8888.
import Foundation
import TwilioVideo
import Accelerate
/// This object provides easy color sampling of the `imageBuffer` property of an VideoFrame.
///
/// - Warning: This class is NOT thread safe. The `rawRGBBuffer` property is shared between instances
/// and will cause a lot of headaches if 2 instances try to simultaneously access it.
/// If you need multi-threading, make the shared buffer an instance property instead.
/// Just remember to release it when you're done with it.
@objc public class PlanarConverter : NSObject {
@aibo-cora
aibo-cora / Converter.swift
Created July 17, 2021 19:15
Class to convert AVAudioPCMBuffer to CMSampleBuffer.
import Foundation
import AVFoundation
import CoreMedia
class Converter {
static func configureSampleBuffer(pcmBuffer: AVAudioPCMBuffer) -> CMSampleBuffer? {
let audioBufferList = pcmBuffer.mutableAudioBufferList
let asbd = pcmBuffer.format.streamDescription
var sampleBuffer: CMSampleBuffer? = nil