| 1 | // |
|---|
| 2 | // SubImport.h |
|---|
| 3 | // SSARender2 |
|---|
| 4 | // |
|---|
| 5 | // Created by Alexander Strange on 7/24/07. |
|---|
| 6 | // Copyright 2007 __MyCompanyName__. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | |
|---|
| 9 | #ifndef __SUBIMPORT_H__ |
|---|
| 10 | #define __SUBIMPORT_H__ |
|---|
| 11 | |
|---|
| 12 | #include <QuickTime/QuickTime.h> |
|---|
| 13 | #ifndef __OBJC__ |
|---|
| 14 | #include "SubATSUIRenderer.h" |
|---|
| 15 | #endif |
|---|
| 16 | |
|---|
| 17 | #ifndef __OBJC_GC__ |
|---|
| 18 | #ifndef __strong |
|---|
| 19 | #define __strong |
|---|
| 20 | #endif |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | #ifdef __cplusplus |
|---|
| 24 | extern "C" |
|---|
| 25 | { |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | short GetFilenameLanguage(CFStringRef filename); |
|---|
| 29 | ComponentResult LoadExternalSubtitles(const FSRef *theFile, Movie theMovie); |
|---|
| 30 | ComponentResult LoadExternalSubtitlesFromFileDataRef(Handle dataRef, OSType dataRefType, Movie theMovie); |
|---|
| 31 | Track CreatePlaintextSubTrack(Movie theMovie, ImageDescriptionHandle imgDesc, TimeScale timescale, Handle dataRef, OSType dataRefType, FourCharCode subType, Handle imageExtension, Rect movieBox); |
|---|
| 32 | |
|---|
| 33 | #ifdef __OBJC__ |
|---|
| 34 | #import <Cocoa/Cocoa.h> |
|---|
| 35 | #import "SubContext.h" |
|---|
| 36 | #import "SubATSUIRenderer.h" |
|---|
| 37 | |
|---|
| 38 | @interface SubLine : NSObject |
|---|
| 39 | { |
|---|
| 40 | @public |
|---|
| 41 | NSString *line; |
|---|
| 42 | unsigned begin_time, end_time; |
|---|
| 43 | unsigned no; // line number, used only by SubSerializer |
|---|
| 44 | } |
|---|
| 45 | -(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e; |
|---|
| 46 | @end |
|---|
| 47 | |
|---|
| 48 | @interface SubSerializer : NSObject |
|---|
| 49 | { |
|---|
| 50 | // input lines, sorted by 1. beginning time 2. original insertion order |
|---|
| 51 | NSMutableArray *lines; |
|---|
| 52 | BOOL finished; |
|---|
| 53 | |
|---|
| 54 | unsigned last_begin_time, last_end_time; |
|---|
| 55 | unsigned linesInput; |
|---|
| 56 | } |
|---|
| 57 | -(void)addLine:(SubLine *)sline; |
|---|
| 58 | -(void)setFinished:(BOOL)finished; |
|---|
| 59 | -(SubLine*)getSerializedPacket; |
|---|
| 60 | -(BOOL)isEmpty; |
|---|
| 61 | @end |
|---|
| 62 | |
|---|
| 63 | @interface VobSubSample : NSObject |
|---|
| 64 | { |
|---|
| 65 | @public |
|---|
| 66 | long timeStamp; |
|---|
| 67 | long fileOffset; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | - (id)initWithTime:(long)time offset:(long)offset; |
|---|
| 71 | @end |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | @interface VobSubTrack : NSObject |
|---|
| 75 | { |
|---|
| 76 | @public |
|---|
| 77 | NSData *privateData; |
|---|
| 78 | NSString *language; |
|---|
| 79 | int index; |
|---|
| 80 | NSMutableArray *samples; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | - (id)initWithPrivateData:(NSData *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex; |
|---|
| 84 | - (void)addSample:(VobSubSample *)sample; |
|---|
| 85 | - (void)addSampleTime:(long)time offset:(long)offset; |
|---|
| 86 | |
|---|
| 87 | @end |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | extern void SubLoadSSAFromPath(NSString *path, SubContext **meta, SubSerializer **lines, SubRenderer *renderer); |
|---|
| 91 | extern void SubLoadSRTFromPath(NSString *path, SubContext **meta, SubSerializer **lines, SubRenderer *renderer); |
|---|
| 92 | |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | #ifdef __cplusplus |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | class CXXSubSerializer |
|---|
| 99 | { |
|---|
| 100 | __strong void *priv; |
|---|
| 101 | |
|---|
| 102 | public: |
|---|
| 103 | CXXSubSerializer(); |
|---|
| 104 | ~CXXSubSerializer(); |
|---|
| 105 | |
|---|
| 106 | void pushLine(const char *line, size_t size, unsigned start, unsigned end); |
|---|
| 107 | void setFinished(); |
|---|
| 108 | const char *popPacket(size_t *size, unsigned *start, unsigned *end); |
|---|
| 109 | void release(); |
|---|
| 110 | void retain(); |
|---|
| 111 | bool empty(); |
|---|
| 112 | }; |
|---|
| 113 | |
|---|
| 114 | class CXXAutoreleasePool |
|---|
| 115 | { |
|---|
| 116 | __strong void *pool; |
|---|
| 117 | public: |
|---|
| 118 | CXXAutoreleasePool(); |
|---|
| 119 | ~CXXAutoreleasePool(); |
|---|
| 120 | }; |
|---|
| 121 | #endif |
|---|
| 122 | |
|---|
| 123 | #endif |
|---|