1 7 8 package org.openlaszlo.iv.flash.api.sound; 9 10 import java.io.PrintStream ; 11 import org.openlaszlo.iv.flash.parser.*; 12 import org.openlaszlo.iv.flash.util.*; 13 import org.openlaszlo.iv.flash.api.*; 14 15 public class SoundStreamHead extends FlashObject 16 { 17 public int reserved; public int playbackRate; public boolean isPlayback16bit; public boolean isPlaybackStereo; 22 public int streamCompression; public int streamRate; public boolean isStream16bit; public boolean isStreamStereo; 27 public int streamSampleCount; 29 private int tagCode = -1; 31 32 public int getTag() 33 { 34 if( tagCode != -1 ) return tagCode; 35 if ( streamCompression == Sound.COMPRESS_ADPCM 36 && streamRate == Sound.RATE_5_5 37 && isStream16bit == true ) 38 { 39 return Tag.SOUNDSTREAMHEAD; 40 } 41 else 42 { 43 return Tag.SOUNDSTREAMHEAD2; 44 } 45 } 46 47 public static SoundStreamHead parse( Parser p ) 48 { 49 SoundStreamHead o = new SoundStreamHead(); 50 51 o.tagCode = p.getTagCode(); 52 p.initBits(); 53 54 o.reserved = p.getBits(4); 56 57 o.playbackRate = p.getBits( 2 ); 58 o.isPlayback16bit = p.getBool(); 59 o.isPlaybackStereo = p.getBool(); 60 61 o.streamCompression = p.getBits( 4 ); 62 63 o.streamRate = p.getBits( 2 ); 64 o.isStream16bit = p.getBool(); 65 o.isStreamStereo = p.getBool(); 66 67 o.streamSampleCount = p.getUWord(); 68 69 return o; 70 } 71 72 public void write( FlashOutput fob ) 73 { 74 fob.writeTag( getTag(), 4 ); 75 76 fob.initBits(); 78 fob.writeBits(reserved, 4); 80 81 fob.writeBits( playbackRate, 2 ); 82 fob.writeBool( isPlayback16bit ); 83 fob.writeBool( isPlaybackStereo ); 84 85 fob.flushBits(); 87 fob.writeBits( streamCompression, 4 ); 88 fob.writeBits( streamRate, 2 ); 89 fob.writeBool( isStream16bit ); 90 fob.writeBool( isStreamStereo ); 91 92 fob.flushBits(); 94 fob.writeWord( streamSampleCount ); 95 } 96 97 public boolean isConstant() 98 { 99 return true; 100 } 101 102 protected FlashItem copyInto( FlashItem item, ScriptCopier copier ) 103 { 104 super.copyInto( item, copier ); 105 106 ( (SoundStreamHead) item ).tagCode = tagCode; 107 ( (SoundStreamHead) item ).playbackRate = playbackRate; 108 ( (SoundStreamHead) item ).isPlayback16bit = isPlayback16bit; 109 ( (SoundStreamHead) item ).isPlaybackStereo = isPlaybackStereo; 110 111 ( (SoundStreamHead) item ).streamCompression = streamCompression; 112 ( (SoundStreamHead) item ).streamRate = streamRate; 113 ( (SoundStreamHead) item ).isStream16bit = isStream16bit; 114 ( (SoundStreamHead) item ).isStreamStereo = isStreamStereo; 115 116 ( (SoundStreamHead) item ).streamSampleCount = streamSampleCount; 117 118 return item; 119 } 120 public FlashItem getCopy( ScriptCopier copier ) 121 { 122 return copyInto( new SoundStreamHead(), copier ); 123 } 124 125 public void printContent( PrintStream out, String indent ) 126 { 127 if ( getTag() == Tag.SOUNDSTREAMHEAD2 ) 128 { 129 out.println( indent + "SoundStreamHead2" ); 130 } 131 else 132 { 133 out.println( indent + "SoundStreamHead" ); 134 } 135 136 out.println( indent + " Playback Rate: " + Sound.rates[ playbackRate ] ); 137 out.println( indent + " Playback 16 Bit: " + isPlayback16bit ); 138 out.println( indent + " Playback Stereo: " + isPlaybackStereo ); 139 140 out.println( indent + " Stream Compression: " + Sound.compressions [ streamCompression ] ); 141 out.println( indent + " Stream Rate: " + Sound.rates[ streamRate ] ); 142 out.println( indent + " Stream 16 Bit: " + isStream16bit ); 143 out.println( indent + " Stream Stereo: " + isStreamStereo ); 144 145 out.println( indent + " Stream Sample Count: " + streamSampleCount ); 146 } 147 } 148 | Popular Tags |