| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.metadata.mov.atoms; |
| 22 |
|
| 23 |
import com.drew.lang.SequentialReader; |
| 24 |
import com.drew.lang.annotations.NotNull; |
| 25 |
import com.drew.metadata.mov.media.QuickTimeSubtitleDirectory; |
| 26 |
|
| 27 |
import java.io.IOException; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class SubtitleSampleDescriptionAtom extends SampleDescriptionAtom<SubtitleSampleDescriptionAtom.SubtitleSampleDescription> |
| 35 |
{ |
| 36 |
public SubtitleSampleDescriptionAtom(SequentialReader reader, Atom atom) throws IOException |
| 37 |
{ |
| 38 |
super(reader, atom); |
| 39 |
} |
| 40 |
|
| 41 |
@NotNull |
| 42 |
@Override |
| 43 |
SubtitleSampleDescription getSampleDescription(SequentialReader reader) throws IOException |
| 44 |
{ |
| 45 |
return new SubtitleSampleDescription(reader); |
| 46 |
} |
| 47 |
|
| 48 |
static class SubtitleSampleDescription extends SampleDescription |
| 49 |
{ |
| 50 |
int displayFlags; |
| 51 |
long defaultTextBox; |
| 52 |
int fontIdentifier; |
| 53 |
int fontFace; |
| 54 |
int fontSize; |
| 55 |
int[] foregroundColor; |
| 56 |
|
| 57 |
public SubtitleSampleDescription(SequentialReader reader) throws IOException |
| 58 |
{ |
| 59 |
super(reader); |
| 60 |
|
| 61 |
displayFlags = reader.getInt32(); |
| 62 |
reader.skip(1); |
| 63 |
reader.skip(1); |
| 64 |
reader.skip(4); |
| 65 |
defaultTextBox = reader.getInt64(); |
| 66 |
reader.skip(4); |
| 67 |
fontIdentifier = reader.getInt16(); |
| 68 |
fontFace = reader.getInt8(); |
| 69 |
fontSize = reader.getInt8(); |
| 70 |
foregroundColor = new int[]{reader.getUInt16(), reader.getUInt16(), reader.getUInt16()}; |
| 71 |
|
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
public void addMetadata(QuickTimeSubtitleDirectory directory) |
| 76 |
{ |
| 77 |
if (sampleDescriptions.size() == 0) { |
| 78 |
return; |
| 79 |
} |
| 80 |
|
| 81 |
SubtitleSampleDescription description = sampleDescriptions.get(0); |
| 82 |
|
| 83 |
directory.setBoolean(QuickTimeSubtitleDirectory.TAG_VERTICAL_PLACEMENT, (description.displayFlags & 0x20000000) == 0x20000000); |
| 84 |
directory.setBoolean(QuickTimeSubtitleDirectory.TAG_SOME_SAMPLES_FORCED, (description.displayFlags & 0x40000000) == 0x40000000); |
| 85 |
directory.setBoolean(QuickTimeSubtitleDirectory.TAG_ALL_SAMPLES_FORCED, (description.displayFlags & 0xC0000000) == 0xC0000000); |
| 86 |
|
| 87 |
directory.setLong(QuickTimeSubtitleDirectory.TAG_DEFAULT_TEXT_BOX, description.defaultTextBox); |
| 88 |
directory.setInt(QuickTimeSubtitleDirectory.TAG_FONT_IDENTIFIER, description.fontIdentifier); |
| 89 |
switch (description.fontFace) { |
| 90 |
case (1): |
| 91 |
directory.setString(QuickTimeSubtitleDirectory.TAG_FONT_FACE, "Bold"); |
| 92 |
break; |
| 93 |
case (2): |
| 94 |
directory.setString(QuickTimeSubtitleDirectory.TAG_FONT_FACE, "Italic"); |
| 95 |
break; |
| 96 |
case (4): |
| 97 |
directory.setString(QuickTimeSubtitleDirectory.TAG_FONT_FACE, "Underline"); |
| 98 |
break; |
| 99 |
} |
| 100 |
directory.setInt(QuickTimeSubtitleDirectory.TAG_FONT_SIZE, description.fontSize); |
| 101 |
directory.setIntArray(QuickTimeSubtitleDirectory.TAG_FOREGROUND_COLOR, description.foregroundColor); |
| 102 |
} |
| 103 |
} |