Core Media

Horus-iOS·2022년 5월 31일
0

https://developer.apple.com/documentation/coremedia

Represent time-based audio-visual assets with essential data types.

필수적인 데이터 타입을 사용해 시간 기반 오디오 시각적 자산을 나타냅니다.

Overview

코어 미디어 프레임워크는 애플 플랫폼에서 찾을 수 있는 AVFoundation 및 다른 고수준 미디어 프레임워크에 의해 사용되는 미디어 파이프라인을 정의합니다. 미디어 샘플 처리 및 미디어 데이터의 큐를 효율적으로 관리하려면 코어 미디어의 저수준 데이터 타입 및 인터페이스를 사용하시기 바랍니다.

CMSampleBuffer

An object that models a buffer of media data.

미디어 데이터의 버퍼를 모델링하는 객체입니다.

버퍼가 무엇인지부터.

이 글이 버퍼를 조금이라도 이해하기에 도움이 되었다. '미디어 데이터의 버퍼'를 보고 '데이터의 버퍼', '데이터 버퍼'를 떠올릴 수 있어서 'data buffer'로 구글링한 결과 아래 링크를 볼 수 있었다.

https://ko.wikipedia.org/wiki/버퍼_(컴퓨터_과학)

컴퓨팅에서, 버퍼(buffer, 문화어: 완충기억기)는 데이터를 한 곳에서 다른 한 곳으로 전송하는 동안 일시적으로 그 데이터를 보관하는 메모리의 영역이다. 버퍼링(buffering)이란 버퍼를 활용하는 방식 또는 버퍼를 채우는 동작을 말한다. 다른 말로 '큐(Queue)'라고도 표현한다.

출처: 위키백과

번역 링크.

https://velog.io/@horus222128/CMSampleBuffer

CMFormatDescription

A media format descriptor that describes the samples in a sample buffer.

샘플 버퍼에 있는 샘플을 설명하는 미디어 포맷 설명자입니다.

당장 와닿기로는 인풋이라면 인풋으로 들어오는 샘플 버퍼의 샘플이 어떤 것인지 파악할 수 있도록 설명해주는 객체가 아닐까 싶다.

https://developer.apple.com/documentation/avfoundation/additional_data_capture/avcamfilter_applying_filters_to_a_capture_stream

위 링크 샘플 코드 중 아래와 같은 코드가 보인다.

let inputMediaSubType = CMFormatDescriptionGetMediaSubType(inputFormatDescription)

메소드의 인자로 (inputFormatDescription: CMFormatDescription)라고 구현되어 있고, 이 인자를 통해서 인풋 미디어의 서브타입을 선언했다. 선언 이후 코드를 보면 이 인풋 미디어 서브타입이 kCVPixelFormatType_32BGRA와 같지 않다면 assertionFailure를 내보내도록 하고 있다. CMFormatDescription을 통해서 미디어 서브타입을 가져오는 것 같다.

실제로 공식 문서의 아래에 메소드가 포함되어 있으며, 해당 메소드는 아래의 형태이다.

func CMFormatDescriptionGetMediaSubType(_ desc: CMFormatDescription) -> FourCharCode

설명 역시 서브타입을 가져온다고 되어 있고, 서브타입을 나타내는 코드가 반환된다. 이 외에도 타입 자체를 가져오는 메소드도 보인다.

샘플 코드에서 이어지는 코드 중 아래와 같은 코드도 있다.

let inputDimensions = CMVideoFormatDescriptionGetDimensions(inputFormatDescription)

CMVideoFormatDescriptionGetDimensions는 아래처럼 설명한다.

func CMVideoFormatDescriptionGetDimensions(_ videoDesc: CMVideoFormatDescription) -> CMVideoDimensions

CMVideoDimensions를 반환하도록 되어 있다.

https://velog.io/@horus222128/CMFormatDescription

CMVideoFormatDescriptionCreateForImageBuffer(allocator:imageBuffer:formatDescriptionOut:)

Creates a format description for a video media stream by using an image buffer.

이미지 버퍼를 사용해서 비디오 미디어 스트림에 대한 포맷 설명을 생성합니다.

https://velog.io/@horus222128/CMVideoFormatDescriptionCreateForImageBufferallocatorimageBufferformatDescriptionOut

CMSampleBufferCreateForImageBuffer(allocator:imageBuffer:dataReady:makeDataReadyCallback:refcon:formatDescription:sampleTiming:sampleBufferOut:)

Creates a sample buffer with an image buffer and a callback to make the data ready for use.

이미지 버퍼와 사용을 위한 데이터 준비 콜백을 사용해서 샘플 버퍼를 생성합니다.

알아야 하는 개념이 많은 것 같다. 다른 객체를 이해하고 있는 가정 하에 문서가 서술되는 것 같다.

https://velog.io/@horus222128/CMSampleBufferCreateForImageBufferallocatorimageBufferdataReadymakeDataReadyCallbackrefconformatDescriptionsampleTimingsampleBufferOut

CMTime

A structure that represents time.

시간을 나타내는 구조체입니다.

CMTime.negativeInfinity와 같은 값을 사용하는 모습을 보고 찾아봤다. 시간을 수치로 나타낼 수 있고, 수치로 나타낼 수 없는 시간 역시 나타낼 수 있다고 한다. 음의 방향으로 무한인 것 역시 나타낼 수 있는데, 구조체 내부에 정의되어 있는 것 같다.

https://velog.io/@horus222128/CMTime

0개의 댓글