"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
ImageReader subclass:#RIFFReader
instanceVariableNames:'chunkSize streamTypes'
classVariableNames:'UnsupportedFormatErrorSignal'
poolDictionaries:''
category:'Graphics-Images-Support'
!
!RIFFReader class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
Abstract helper class to read RIFF files. See concrete subclasses for details.
This is in an experimental state and not yet finished.
The protocol may change.
"
! !
!RIFFReader class methodsFor:'class initialization'!
initialize
UnsupportedFormatErrorSignal isNil ifTrue:[
UnsupportedFormatErrorSignal := ErrorSignal newSignalMayProceed:true.
UnsupportedFormatErrorSignal nameClass:self message:#unsupportedFormatErrorSignal.
].
"
RIFFReader initialize
"
"Created: 4.4.1997 / 22:35:52 / cg"
"Modified: 5.4.1997 / 16:12:16 / cg"
! !
!RIFFReader class methodsFor:'testing'!
isRIFFFile:aFileName
"return true, if aFileName contains RIFF-encoded data"
|data1 inStream|
inStream := self streamReadingFile:aFileName.
inStream isNil ifTrue:[^ false].
inStream binary.
data1 := String new:4.
inStream nextBytes:4 into:data1.
inStream close.
^ (data1 = 'RIFF')
"
RIFFReader isRIFFFile:'bitmaps/magtape.xpm'
RIFFReader isRIFFFile:'/home2/pd_stuff/movies/avi/drlair.avi'
"
"Created: 4.4.1997 / 22:35:52 / cg"
"Modified: 5.4.1997 / 16:12:16 / cg"
! !
!RIFFReader methodsFor:'reading from stream'!
fromStream:aStream
"read RIFF chunks from aStream. Process chunks in getChunkXXX methods
(usually redefined in concrete reader classes."
inStream := aStream.
inStream binary.
[inStream atEnd] whileFalse:[
self getChunk
].
^ nil
"
RIFFReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
RIFFReader fromFile:'/home2/cg/AFsp-V2R0/test/audiofiles/jg00b1ss.wav'
"
"Modified: 17.4.1997 / 03:25:08 / cg"
!
getChunk
"get a single chunk"
|id s sel streamNr streamType|
'getChunk -> ' infoPrint.
id := ' '.
inStream nextBytes:4 into:id startingAt:1.
chunkSize := inStream nextLongMSB:false.
(id at:4) == Character space ifTrue:[
id := id copyTo:3
].
(id at:1) isDigit ifTrue:[
streamNr := Number readFrom:(id copyTo:2).
streamTypes notNil ifTrue:[
streamType := streamTypes at:(streamNr + 1).
s := 'getChunk_' , streamType , '_' , (id copyFrom:3).
] ifFalse:[
s := 'getChunk_' , id.
]
] ifFalse:[
s := 'getChunk_' , id.
].
sel := s asSymbolIfInterned.
(sel isNil or:[(self respondsTo:sel) not]) ifTrue:[
'[' infoPrint. s infoPrint. '] ' infoPrint.
sel := #'getChunk_Unknown'
].
self perform:sel.
'' infoPrintCR.
"Created: 5.4.1997 / 16:29:40 / cg"
"Modified: 17.4.1997 / 03:24:48 / cg"
!
getChunk_LIST
"process a LIST chunk"
'getChunk_LIST' infoPrint.
inStream skip:4.
"
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
RIFFReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
RIFFReader fromFile:'/home2/cg/AFsp-V2R0/test/audiofiles/jg00b1ss.wav'
"
"Created: 4.4.1997 / 23:18:33 / cg"
"Modified: 17.4.1997 / 03:22:15 / cg"
!
getChunk_RIFF
"process a RIFF chunk"
'getChunk_RIFF' infoPrint.
inStream skip:4.
"
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
"
"Created: 4.4.1997 / 23:18:08 / cg"
"Modified: 5.4.1997 / 16:12:16 / cg"
!
getChunk_Unknown
"ignore any other chunk"
'getChunk_Unknown -> ' infoPrint.
self skipChunk
"
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
"
"Created: 5.4.1997 / 00:03:43 / cg"
"Modified: 5.4.1997 / 16:12:16 / cg"
!
skipChunk
"skip a chunk"
|sz|
'skipChunk' infoPrint.
sz := chunkSize.
(sz bitTest:1) ifTrue:[
sz := sz + 1
].
inStream skip:sz.
"
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
"
"Created: 5.4.1997 / 14:13:43 / cg"
"Modified: 5.4.1997 / 16:12:16 / cg"
! !
!RIFFReader class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview2/RIFFReader.st,v 1.3 1997-04-17 01:32:11 cg Exp $'
! !
RIFFReader initialize!