obs-studio/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm
Fabian Mastenbroek 5edabfe7c1
mac-virtualcam: Remove unused CMSampleBuffer utility functions
This change removes the unused CMSampleBuffer utility functions that
were still left from the previous implementation. Since we construct the
CMSampleBuffer directly from an IOSurface, we do not need any custom
construction logic anymore, since that is now performed by the OBS
plugin.
2022-06-10 13:37:03 +02:00

28 lines
1 KiB
Text

//
// CMSampleBufferUtils.m
// dal-plugin
//
// Created by John Boiles on 5/8/20.
//
#import "CMSampleBufferUtils.h"
CMSampleTimingInfo CMSampleTimingInfoForTimestamp(uint64_t timestampNanos,
uint32_t fpsNumerator,
uint32_t fpsDenominator)
{
// The timing here is quite important. For frames to be delivered correctly and successfully be recorded by apps
// like QuickTime Player, we need to be accurate in both our timestamps _and_ have a sensible scale. Using large
// timestamps and scales like mach_absolute_time() and NSEC_PER_SEC will work for display, but will error out
// when trying to record.
//
// 600 is a common default in Apple's docs https://developer.apple.com/documentation/avfoundation/avmutablemovie/1390622-timescale
CMTimeScale scale = 600;
CMSampleTimingInfo timing;
timing.duration =
CMTimeMake(fpsDenominator * scale, fpsNumerator * scale);
timing.presentationTimeStamp = CMTimeMake(
(timestampNanos / (double)NSEC_PER_SEC) * scale, scale);
timing.decodeTimeStamp = kCMTimeInvalid;
return timing;
}