forked from samiamwork/Movist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMovie.m
executable file
·185 lines (159 loc) · 5.77 KB
/
MMovie.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//
// Movist
//
// Copyright 2006, 2007 Yong-Hoe Kim. All rights reserved.
// Yong-Hoe Kim <[email protected]>
//
// This file is part of Movist.
//
// Movist is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Movist is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "MMovie.h"
@implementation MTrack
- (NSString*)name { return nil; }
- (NSString*)format { return nil; }
- (BOOL)isEnabled { return FALSE; }
- (void)setEnabled:(BOOL)enabled {}
- (float)volume { return 0; }
- (void)setVolume:(float)volume {}
@end
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
@implementation MMovie
+ (NSArray*)movieTypes
{
return [NSArray arrayWithObjects:
@"avi", @"divx", // movie
@"mpe", @"mpeg", @"mpg", @"m1v", @"m2v", // MPEG
@"dat", @"ifo", @"vob", @"tp", // MPEG
@"mp4", @"m4v", // MPEG4
@"asf", @"asx", // Windows Media
@"wm", @"wmp", @"wmv", @"wmx", @"wvx", // Windows Media
@"rm", @"rmvb", // Real Media
@"ogm", // OGM
@"mov", // MOV
@"mqv", // MQV
@"mkv", // Matroska
//@"flv", @"swf", // Flash
//@"dmb", // DMB-TS
//@"3gp", @"dmskm", @"k3g", @"skm", @"lmp4",// Mobile Phone
nil];
}
+ (NSString*)name { return @""; }
- (id)initWithURL:(NSURL*)url error:(NSError**)error
{
TRACE(@"%s \"%@\"", __PRETTY_FUNCTION__, [url absoluteString]);
if ([url isFileURL]) {
NSFileManager* fileManager = [NSFileManager defaultManager];
NSString* path = [url path];
if (![fileManager fileExistsAtPath:path]) {
if (error) {
*error = [NSError errorWithDomain:@"Movist"
code:ERROR_FILE_NOT_EXIST userInfo:nil];
}
return nil;
}
if (![fileManager isReadableFileAtPath:path]) {
if (error) {
*error = [NSError errorWithDomain:@"Movist"
code:ERROR_FILE_NOT_READABLE userInfo:nil];
}
return nil;
}
}
_videoTracks = [[NSMutableArray alloc] initWithCapacity:1];
_audioTracks = [[NSMutableArray alloc] initWithCapacity:5];
_aspectRatio = ASPECT_RATIO_DEFAULT;
return [super init];
}
- (BOOL)setOpenGLContext:(NSOpenGLContext*)openGLContext
pixelFormat:(NSOpenGLPixelFormat*)openGLPixelFormat
error:(NSError**)error
{
TRACE(@"%s", __PRETTY_FUNCTION__);
return TRUE;
}
- (void)cleanup
{
TRACE(@"%s", __PRETTY_FUNCTION__);
[_audioTracks release];
[_videoTracks release];
[self release];
}
- (void)dealloc
{
TRACE(@"%s", __PRETTY_FUNCTION__);
[super dealloc];
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
- (NSArray*)videoTracks { return _videoTracks; }
- (float)duration { return 0; }
- (float)indexDuration { return 0; }
- (NSSize)size { return NSMakeSize(0, 0); }
- (int)aspectRatio { return _aspectRatio; }
- (void)setAspectRatio:(int)aspectRatio
{
TRACE(@"%s", __PRETTY_FUNCTION__);
_aspectRatio = aspectRatio;
}
- (NSSize)adjustedSize
{
//TRACE(@"%s", __PRETTY_FUNCTION__);
if (_aspectRatio == ASPECT_RATIO_DEFAULT) {
return [self size];
}
else {
float ratio[] = {
4.0 / 3.0, // ASPECT_RATIO_4_3
16.0 / 9.0, // ASPECT_RATIO_16_9
1.85 / 1.0, // ASPECT_RATIO_1_85
2.35 / 1.0, // ASPECT_RATIO_2_35
};
NSSize size = [self size];
size.height = size.width / ratio[_aspectRatio - 1];
return size;
}
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark audio
- (NSArray*)audioTracks { return _audioTracks; }
- (float)preferredVolume { return 0; }
- (float)volume { return 0; }
- (BOOL)muted { return FALSE; }
- (void)setVolume:(float)volume
{
TRACE(@"%s %g", __PRETTY_FUNCTION__, volume);
}
- (void)setMuted:(BOOL)muted
{
TRACE(@"%s %@", __PRETTY_FUNCTION__, muted ? @"muted" : @"unmuted");
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark playback
- (float)currentTime { TRACE(@"%s", __PRETTY_FUNCTION__); return 0; }
- (float)rate { TRACE(@"%s", __PRETTY_FUNCTION__); return 0; }
- (void)setRate:(float)rate { TRACE(@"%s %g", __PRETTY_FUNCTION__, rate); }
- (void)stepBackward { TRACE(@"%s", __PRETTY_FUNCTION__); }
- (void)stepForward { TRACE(@"%s", __PRETTY_FUNCTION__); }
- (void)gotoBeginning { TRACE(@"%s", __PRETTY_FUNCTION__); }
- (void)gotoEnd { TRACE(@"%s", __PRETTY_FUNCTION__); }
- (void)gotoTime:(float)time { TRACE(@"%s %g", __PRETTY_FUNCTION__, time); }
- (void)seekByTime:(float)dt { TRACE(@"%s %g", __PRETTY_FUNCTION__, dt); }
- (CVOpenGLTextureRef)nextImage:(const CVTimeStamp*)timeStamp
{ TRACE(@"%s", __PRETTY_FUNCTION__); return 0; }
- (void)idleTask { /*TRACE(@"%s", __PRETTY_FUNCTION__);*/ }
@end