source: trunk/Subtitles/SubImport.h @ 1201

Revision 1201, 3.1 KB checked in by astrange, 4 years ago (diff)

Cleanup file path URLs in SubImport?.

  • Use CFURL instead of char[PATH_MAX].
  • Use -UTF8String to make language-code lookups shorter.

(-UTF8String is guaranteed to work; CFString functions aren't.)

Also avoid a copy of each line in MKV import.

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#ifndef __OBJC__
27#include "SubATSUIRenderer.h"
28#endif
29
30#ifndef __OBJC_GC__
31#ifndef __strong
32#define __strong
33#endif
34#endif
35
36#ifdef __cplusplus
37extern "C"
38{
39#endif
40
41short GetFilenameLanguage(CFStringRef filename);
42ComponentResult LoadExternalSubtitlesFromFileDataRef(Handle dataRef, OSType dataRefType, Movie theMovie);
43Track CreatePlaintextSubTrack(Movie theMovie, ImageDescriptionHandle imgDesc, TimeScale timescale, Handle dataRef, OSType dataRefType, FourCharCode subType, Handle imageExtension, Rect movieBox);
44
45#ifdef __OBJC__
46#import <Cocoa/Cocoa.h>
47#import "SubContext.h"
48#import "SubATSUIRenderer.h"
49
50@interface SubLine : NSObject
51{
52        @public
53        NSString *line;
54        unsigned begin_time, end_time;
55        unsigned no; // line number, used only by SubSerializer
56}
57-(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e;
58@end
59
60@interface SubSerializer : NSObject
61{
62        // input lines, sorted by 1. beginning time 2. original insertion order
63        NSMutableArray *lines;
64        BOOL finished;
65       
66        unsigned last_begin_time, last_end_time;
67        unsigned linesInput;
68}
69-(void)addLine:(SubLine *)sline;
70-(void)setFinished:(BOOL)finished;
71-(SubLine*)getSerializedPacket;
72-(BOOL)isEmpty;
73@end
74
75@interface VobSubSample : NSObject
76{
77        @public
78        long            timeStamp;
79        long            fileOffset;
80}
81
82- (id)initWithTime:(long)time offset:(long)offset;
83@end
84
85
86@interface VobSubTrack : NSObject
87{
88        @public
89        NSData                  *privateData;
90        NSString                *language;
91        int                             index;
92        NSMutableArray  *samples;
93}
94
95- (id)initWithPrivateData:(NSData *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex;
96- (void)addSample:(VobSubSample *)sample;
97- (void)addSampleTime:(long)time offset:(long)offset;
98
99@end
100
101extern NSString *LoadSSAFromPath(NSString *path, SubSerializer *ss);
102       
103#endif
104
105#ifdef __cplusplus
106}
107
108class CXXSubSerializer
109{
110        __strong void *priv;
111        int retainCount;
112       
113public:
114        CXXSubSerializer();
115        ~CXXSubSerializer();
116       
117        void pushLine(const char *line, size_t size, unsigned start, unsigned end);
118        void setFinished();
119        const char *popPacket(size_t *size, unsigned *start, unsigned *end);
120        void release();
121        void retain();
122        bool empty();
123};
124
125class CXXAutoreleasePool
126{
127        __strong void *pool;
128public:
129        CXXAutoreleasePool();
130        ~CXXAutoreleasePool();
131};
132#endif
133
134#endif
Note: See TracBrowser for help on using the repository browser.