Skip to content

Commit 0ba3345

Browse files
committed
Update so code builds properly
1 parent 27a3d50 commit 0ba3345

File tree

7 files changed

+1065
-21
lines changed

7 files changed

+1065
-21
lines changed

Headers/Additions/GNUstepGUI/GSVideoSink.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
*/
5050
- (void) close;
5151

52+
/**
53+
* Play the entire video
54+
*/
55+
- (void) play;
56+
5257
/**
5358
* Plays the data in bytes
5459
*/
@@ -76,4 +81,3 @@
7681
@end
7782

7883
#endif // _GNUstep_H_GSVideoSink
79-

Source/GNUmakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ GSImageMagickImageRep.h \
655655
GSInstantiator.h \
656656
GSSoundSink.h \
657657
GSSoundSource.h \
658+
GSVideoSink.h \
659+
GSVideoSource.h \
658660
GSWindowDecorationView.h \
659661
GSXibElement.h \
660662
GSXibLoading.h \

Source/NSMovieView.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ - (void) _finished: (NSNumber *)finishedPlaying;
6868
@implementation NSMovieView (PrivateMethods)
6969
- (void) _stream
7070
{
71+
/*
7172
NSUInteger bytesRead;
7273
BOOL success = NO;
7374
void *buffer;
@@ -110,6 +111,9 @@ - (void) _stream
110111
withObject: [NSNumber numberWithBool: success]
111112
waitUntilDone: YES];
112113
RELEASE(self);
114+
*/
115+
[[_movie _sink] play];
116+
// video_main(_movie, self);
113117
}
114118

115119
- (void) _finished: (NSNumber *)finishedPlaying
@@ -159,7 +163,7 @@ - (NSMovie*) movie
159163
- (void) start: (id)sender
160164
{
161165
/*
162-
// If the locks exists this instance is already playing
166+
// If the locks exists this instance is already playing
163167
if (_readLock != nil && _playbackLock != nil)
164168
{
165169
return;
@@ -172,13 +176,14 @@ - (void) start: (id)sender
172176
{
173177
return;
174178
}
175-
179+
*/
176180
_shouldStop = NO;
177181
[NSThread detachNewThreadSelector: @selector(_stream)
178182
toTarget: self
179183
withObject: nil];
180184

181-
[_readLock unlockWithCondition: MOVIE_SHOULD_PLAY];
185+
// [_readLock unlockWithCondition: MOVIE_SHOULD_PLAY];
186+
182187
}
183188

184189
- (void) stop: (id)sender
@@ -196,7 +201,6 @@ - (void) stop: (id)sender
196201

197202
// Set to MOVIE_SHOULD_PLAY so that thread isn't blocked.
198203
[_readLock unlockWithCondition: MOVIE_SHOULD_PLAY];
199-
*/
200204
}
201205

202206
- (BOOL) isPlaying

Tools/video/GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ VideoOutput_LIB_DIRS += \
2121
# Build the bundles.
2222
VideoFile_OBJC_FILES = VideoFileSource.m
2323
VideoOutput_OBJC_FILES = VideoOutputSink.m ffplay.m
24+
VideoOutlet_C_FILES = cmdutils.c
2425

2526
VideoFile_PRINCIPAL_CLASS = VideoFileSource
2627
VideoOutput_PRINCIPAL_CLASS = VidioOutputSink

Tools/video/VideoOutputSink.m

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
2-
AudioOutputSink.m
1+
/*
2+
VideoOutputSink.m
33
4-
Sink audio data to libavcodec.
4+
Sink video data to libavcodec.
55
66
Copyright (C) 2022 Free Software Foundation, Inc.
77
@@ -58,18 +58,28 @@
5858
*/
5959

6060
#include <libavcodec/avcodec.h>
61+
#include "cmdutils.h"
6162

6263
#define INBUF_SIZE 4096
6364

65+
/*
66+
AVDictionary *codec_opts;
67+
AVDictionary *format_opts;
68+
AVDictionary *swr_opts;
69+
AVDictionary *sws_dict;
70+
*/
71+
6472
int video_main(NSMovie *movie, NSMovieView *view);
6573

6674
@interface VideoOutputSink : NSObject <GSVideoSink>
6775
{
76+
/*
6877
AVCodec *_codec;
6978
AVCodecParserContext *_parser;
7079
AVCodecContext *_context; // = NULL;
7180
AVPacket *_pkt;
7281
AVFrame *_frame;
82+
*/
7383

7484
NSMovieView *_movieView;
7585
}
@@ -97,13 +107,14 @@ - (void) display: (unsigned char *) buf
97107
fwrite(buf + i * wrap, 1, xsize, f);
98108
fclose(f);
99109
*/
100-
NSLog(@"Playing...");
110+
NSLog(@"Playing... %d, %d, %d", wrap, xsize, ysize);
101111
}
102112

103113

104114

105115
- (void) decode
106116
{
117+
/*
107118
int ret;
108119
109120
ret = avcodec_send_packet(_context, _pkt);
@@ -129,8 +140,8 @@ - (void) decode
129140
NSLog(@"saving frame %3d\n", _context->frame_number);
130141
fflush(stdout);
131142
132-
/* the picture is allocated by the decoder. no need to
133-
free it */
143+
// the picture is allocated by the decoder. no need to
144+
// free it
134145
// snprintf(buf, sizeof(buf), "%d", _context->frame_number);
135146
[self display: _frame->data[0]
136147
wrap: _frame->linesize[0]
@@ -140,16 +151,17 @@ - (void) decode
140151
// pgm_save(frame->data[0], frame->linesize[0],
141152
// frame->width, frame->height, buf);
142153
}
154+
*/
143155
}
144156

145157
- (void)dealloc
146158
{
147159
[self close];
148160
_movieView = nil;
149-
_pkt = NULL;
150-
_context = NULL;
151-
_parser = NULL;
152-
_frame = NULL;
161+
//_pkt = NULL;
162+
//_context = NULL;
163+
//_parser = NULL;
164+
//_frame = NULL;
153165

154166
[super dealloc];
155167
}
@@ -161,10 +173,10 @@ - (id)init
161173
if (self != nil)
162174
{
163175
_movieView = nil;
164-
_pkt = NULL;
165-
_context = NULL;
166-
_parser = NULL;
167-
_frame = NULL;
176+
// _pkt = NULL;
177+
//_context = NULL;
178+
//_parser = NULL;
179+
//_frame = NULL;
168180
}
169181

170182
return self;
@@ -182,6 +194,7 @@ - (NSMovieView *) movieView
182194

183195
- (BOOL)open
184196
{
197+
/*
185198
_pkt = av_packet_alloc();
186199
if (!_pkt)
187200
{
@@ -210,7 +223,6 @@ - (BOOL)open
210223
return NO;
211224
}
212225
213-
/* open it */
214226
if (avcodec_open2(_context, _codec, NULL) < 0)
215227
{
216228
NSLog(@"Could not open codec\n");
@@ -225,10 +237,13 @@ - (BOOL)open
225237
}
226238
227239
return YES;
240+
*/
241+
return NO;
228242
}
229243

230244
- (void)close
231245
{
246+
/*
232247
if (_parser != NULL)
233248
{
234249
av_parser_close(_parser);
@@ -248,15 +263,17 @@ - (void)close
248263
{
249264
av_packet_free(&_pkt);
250265
}
266+
*/
251267
}
252268

253269
- (void) play
254270
{
255-
271+
video_main([_movieView movie], _movieView);
256272
}
257273

258274
- (BOOL)playBytes: (void *)bytes length: (NSUInteger)length
259275
{
276+
/*
260277
int ret = av_parser_parse2(_parser, _context, &_pkt->data, &_pkt->size,
261278
bytes, length, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
262279
if (ret < 0)
@@ -284,6 +301,8 @@ - (BOOL)playBytes: (void *)bytes length: (NSUInteger)length
284301
}
285302
286303
return YES;
304+
*/
305+
return NO;
287306
}
288307

289308
- (void)setVolume: (float)volume

0 commit comments

Comments
 (0)