2012-03-19 4 views
0

음악을 재생할 플레이어를 작성하고 싶습니다. AudioQueueProperty을 설정하는 이유이 대기열 속성 (iOS 오디오 대기열)의 의미는 무엇입니까?

AudioFileGetPropertyInfo(audioFile, 
         kAudioFilePropertyMagicCookieData, &size, nil); 

if (size > 0) { 
    cookie = malloc(sizeof(char) * size); 
    AudioFileGetProperty(audioFile, 
         kAudioFilePropertyMagicCookieData, &size, cookie); 
    AudioQueueSetProperty(aduioQueue, 
          kAudioQueueProperty_MagicCookie, cookie, size); 
    free(cookie); 
} 

내가 아는하지 않으며, kAudioQueueProperty_MagicCookie에 대한 수단은 무엇인가 : 나는 코드를 아래와 같이 참조? 설명서에서 도움말을 찾을 수 없습니다. 누가 문제를 해결할 방향을 제시 할 수 있습니까?

답변

1

"마법 쿠키"는 파일 시작 부분에 고유 한 바이트 시퀀스로 구성되어 파일 형식을 나타내는 파일 유형 서명입니다. 오디오 큐 프레임 워크는이 정보를 사용하여 파일 이름 확장명을 사용하거나 신뢰하는 대신 파일 스트림에서 오디오 정보를 디코딩하거나 추출하는 방법을 결정합니다. 게시 한 코드가 파일에서이 바이트 세트를 읽고이를 쿠키로 오디오 대기열에 전달합니다. (예를 들어 PCM 샘플로 대신 해석하는 것은 실수입니다.)

+0

감사합니다. kAudioQueueProperty_MagicCookie에 대한 문서를 찾을 수 있습니다. "재생하거나 녹음하는 오디오 포맷에 마법의 쿠키가 필요한 경우, 버퍼를 대기열에 넣기 전에이 속성의 값을 설정해야합니다."... 내 앱에서 위의 코드를 지우면 사운드는 다음과 같습니다. 승인. 제 질문은 오디오 대기열에서 파일 형식을 예측할 수 있다는 것입니다. – Henry

1

사실 마술 쿠키는 단순히 서명 이상의 것입니다.이 쿠키는 인코더에 대한 정보를 담고 있으며, 가장 유용한 항목은 "최대 비트 전송률"과 "평균 비트 전송률"입니다. 특히 AudioFileMPEG4Type과 같은 압축 형식에 적합합니다. 이 특정 유형의 경우 마술 쿠키는 MPEG-4 데이터 파일의 "esds"상자와 동일합니다. 당신은에서 정확한 비트 설정을 찾을 수 있습니다

http://xhelmboyx.tripod.com/formats/mp4-layout.txt


8 + 바이트 적이있는합니다. 2 ES 설명자 상자 긴 오프셋 부호 = + 긴 ASCII 텍스트 문자열 'ESDS' - ISO/IEC 14496-10 AVC 표준으로 인코딩 된 경우 다음 선택적으로 사용 = 긴 오프셋 부호 + 긴 ASCII 텍스트 문자열 'm4ds'

kAudioFilePropertyMagicCookieData에서 오는
   -> 4 bytes version/flags = 8-bit hex version + 24-bit hex flags 
        (current = 0) 

       -> 1 byte ES descriptor type tag = 8-bit hex value 0x03 
       -> 3 bytes extended descriptor type tag string = 3 * 8-bit hex value 
        - types are Start = 0x80 ; End = 0xFE 
        - NOTE: the extended start tags may be left out 
       -> 1 byte descriptor type length = 8-bit unsigned length 

        -> 2 bytes ES ID = 16-bit unsigned value 
        -> 1 byte stream priority = 8-bit unsigned value 
        - Defaults to 16 and ranges from 0 through to 31 

        -> 1 byte decoder config descriptor type tag = 8-bit hex value 0x04 
        -> 3 bytes extended descriptor type tag string = 3 * 8-bit hex value 
         - types are Start = 0x80 ; End = 0xFE 
         - NOTE: the extended start tags may be left out 
        -> 1 byte descriptor type length = 8-bit unsigned length 

         -> 1 byte object type ID = 8-bit unsigned value 
         - type IDs are system v1 = 1 ; system v2 = 2 
         - type IDs are MPEG-4 video = 32 ; MPEG-4 AVC SPS = 33 
         - type IDs are MPEG-4 AVC PPS = 34 ; MPEG-4 audio = 64 
         - type IDs are MPEG-2 simple video = 96 
         - type IDs are MPEG-2 main video = 97 
         - type IDs are MPEG-2 SNR video = 98 
         - type IDs are MPEG-2 spatial video = 99 
         - type IDs are MPEG-2 high video = 100 
         - type IDs are MPEG-2 4:2:2 video = 101 
         - type IDs are MPEG-4 ADTS main = 102 
         - type IDs are MPEG-4 ADTS Low Complexity = 103 
         - type IDs are MPEG-4 ADTS Scalable Sampling Rate = 104 
         - type IDs are MPEG-2 ADTS = 105 ; MPEG-1 video = 106 
         - type IDs are MPEG-1 ADTS = 107 ; JPEG video = 108 
         - type IDs are private audio = 192 ; private video = 208 
         - type IDs are 16-bit PCM LE audio = 224 ; vorbis audio = 225 
         - type IDs are dolby v3 (AC3) audio = 226 ; alaw audio = 227 
         - type IDs are mulaw audio = 228 ; G723 ADPCM audio = 229 
         - type IDs are 16-bit PCM Big Endian audio = 230 
         - type IDs are Y'CbCr 4:2:0 (YV12) video = 240 ; H264 video = 241 
         - type IDs are H263 video = 242 ; H261 video = 243 
         -> 6 bits stream type = 3/4 byte hex value 
         - type IDs are object descript. = 1 ; clock ref. = 2 
         - type IDs are scene descript. = 4 ; visual = 4 
         - type IDs are audio = 5 ; MPEG-7 = 6 ; IPMP = 7 
         - type IDs are OCI = 8 ; MPEG Java = 9 
         - type IDs are user private = 32 
         -> 1 bit upstream flag = 1/8 byte hex value 
         -> 1 bit reserved flag = 1/8 byte hex value set to 1 
         -> 3 bytes buffer size = 24-bit unsigned value 
         -> 4 bytes maximum bit rate = 32-bit unsigned value 
         -> 4 bytes average bit rate = 32-bit unsigned value 

         -> 1 byte decoder specific descriptor type tag 
          = 8-bit hex value 0x05 
         -> 3 bytes extended descriptor type tag string 
          = 3 * 8-bit hex value 
          - types are Start = 0x80 ; End = 0xFE 
          - NOTE: the extended start tags may be left out 
         -> 1 byte descriptor type length 
          = 8-bit unsigned length 

          -> ES header start codes = hex dump 

        -> 1 byte SL config descriptor type tag = 8-bit hex value 0x06 
        -> 3 bytes extended descriptor type tag string = 3 * 8-bit hex value 
         - types are Start = 0x80 ; End = 0xFE 
         - NOTE: the extended start tags may be left out 
        -> 1 byte descriptor type length = 8-bit unsigned length 

         -> 1 byte SL value = 8-bit hex value set to 0x02 

"

매직 쿠키 (단지지도에 설명 된 처음 4 바이트를 무시하고 나머지는 쿠키를 마법 (magick) 정확히 일치 될 것입니다).

샘플 마법 쿠키를 ES 설명자에서 시작 좋아 할거야. 이 -> 0XFA00 (또는 64000)에서 22 오프셋 평균 비트 전송률 -

03 80 80 80 22 00 00 00 04 80 80 80 14 40 15 00 18 00 00 00 FA 00 00 00 FA 00 05 80 80 80 02 12 08 06 80 80 80 01 02 

최대 비트 레이트는 18 오프셋> 0XFA00 (또는 64,000)

을 애플 설명서에 따라, 마법 쿠키 비록 읽기/쓰기이지만 파일을 만들거나 변환하기 전에 비트 전송률을 변경할 가능성이 없습니다.

누군가를 돕는 희망.