source: trunk/Subtitles/SubImport.h @ 1322

Revision 1322, 3.2 KB checked in by astrange, 4 years ago (diff)

Bravely refactor the subtitle headers.

  • Name prefixes standardized
  • Order of types of declarations cleaned up
  • BEGIN_DECLS used instead of #ifdef cplusplus
  • Parsing functions all moved into SubParsing?
  • SubATSUIRenderer.h made an implementation detail
  • Some more

Still not happy with SubRenderer?.h / SubImport?.h because they have too many duties.
Also not happy with Span/Div?/ex as names.
Future cleanup might fix it.

Line 
1/*
2 * SubParsing.h
3 * Created by Alexander Strange on 7/24/07.
4 *
5 * This file is part of Perian.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef __SUBIMPORT_H__
23#define __SUBIMPORT_H__
24
25#include <QuickTime/QuickTime.h>
26
27__BEGIN_DECLS
28
29#ifdef __OBJC__
30#import <Cocoa/Cocoa.h>
31
32@interface SubLine : NSObject
33{
34        @public
35        NSString *line;
36        unsigned begin_time, end_time;
37        unsigned num; // line number, used only by SubSerializer
38}
39-(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e;
40@end
41
42@interface SubSerializer : NSObject
43{
44        // input lines, sorted by 1. beginning time 2. original insertion order
45        NSMutableArray *lines;
46        BOOL finished;
47       
48        unsigned last_begin_time, last_end_time;
49        unsigned num_lines_input;
50}
51-(void)addLine:(SubLine *)sline;
52-(void)setFinished:(BOOL)finished;
53-(SubLine*)getSerializedPacket;
54-(BOOL)isEmpty;
55@end
56
57@interface VobSubSample : NSObject
58{
59        @public
60        long            timeStamp;
61        long            fileOffset;
62}
63
64- (id)initWithTime:(long)time offset:(long)offset;
65@end
66
67@interface VobSubTrack : NSObject
68{
69        @public
70        NSData                  *privateData;
71        NSString                *language;
72        int                             index;
73        NSMutableArray  *samples;
74}
75
76- (id)initWithPrivateData:(NSData *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex;
77- (void)addSample:(VobSubSample *)sample;
78- (void)addSampleTime:(long)time offset:(long)offset;
79
80@end
81
82NSString *SubLoadSSAFromPath(NSString *path, SubSerializer *ss);
83void SubLoadSRTFromPath(NSString *path, SubSerializer *ss);
84void SubLoadSMIFromPath(NSString *path, SubSerializer *ss, int subCount);
85
86#endif // ___OBJC__
87
88short GetFilenameLanguage(CFStringRef filename);
89ComponentResult LoadExternalSubtitlesFromFileDataRef(Handle dataRef, OSType dataRefType, Movie theMovie);
90void SetSubtitleMediaHandlerTransparent(MediaHandler mh);
91Track CreatePlaintextSubTrack(Movie theMovie, ImageDescriptionHandle imgDesc, TimeScale timescale, Handle dataRef, OSType dataRefType, FourCharCode subType, Handle imageExtension, Rect movieBox);
92
93__END_DECLS
94
95#ifdef __cplusplus
96
97#ifndef __OBJC_GC__
98#define __strong
99#endif
100
101class CXXSubSerializer
102{
103        __strong void *priv;
104        int retainCount;
105       
106public:
107        CXXSubSerializer();
108        ~CXXSubSerializer();
109       
110        void pushLine(const char *line, size_t size, unsigned start, unsigned end);
111        void setFinished();
112        const char *popPacket(size_t *size, unsigned *start, unsigned *end);
113        void release();
114        void retain();
115        bool empty();
116};
117
118class CXXAutoreleasePool
119{
120        __strong void *pool;
121public:
122        CXXAutoreleasePool();
123        ~CXXAutoreleasePool();
124};
125
126#endif // __cplusplus
127
128#endif // __SUBIMPORT_H__
Note: See TracBrowser for help on using the repository browser.