1
- /*
2
- AudioOutputSink .m
1
+ /*
2
+ VideoOutputSink .m
3
3
4
- Sink audio data to libavcodec.
4
+ Sink video data to libavcodec.
5
5
6
6
Copyright (C) 2022 Free Software Foundation, Inc.
7
7
58
58
*/
59
59
60
60
#include < libavcodec/avcodec.h>
61
+ #include " cmdutils.h"
61
62
62
63
#define INBUF_SIZE 4096
63
64
65
+ /*
66
+ AVDictionary *codec_opts;
67
+ AVDictionary *format_opts;
68
+ AVDictionary *swr_opts;
69
+ AVDictionary *sws_dict;
70
+ */
71
+
64
72
int video_main (NSMovie *movie, NSMovieView *view);
65
73
66
74
@interface VideoOutputSink : NSObject <GSVideoSink>
67
75
{
76
+ /*
68
77
AVCodec *_codec;
69
78
AVCodecParserContext *_parser;
70
79
AVCodecContext *_context; // = NULL;
71
80
AVPacket *_pkt;
72
81
AVFrame *_frame;
82
+ */
73
83
74
84
NSMovieView *_movieView;
75
85
}
@@ -97,13 +107,14 @@ - (void) display: (unsigned char *) buf
97
107
fwrite(buf + i * wrap, 1, xsize, f);
98
108
fclose(f);
99
109
*/
100
- NSLog (@" Playing..." );
110
+ NSLog (@" Playing... %d , %d , %d " , wrap, xsize, ysize );
101
111
}
102
112
103
113
104
114
105
115
- (void ) decode
106
116
{
117
+ /*
107
118
int ret;
108
119
109
120
ret = avcodec_send_packet(_context, _pkt);
@@ -129,8 +140,8 @@ - (void) decode
129
140
NSLog(@"saving frame %3d\n", _context->frame_number);
130
141
fflush(stdout);
131
142
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
134
145
// snprintf(buf, sizeof(buf), "%d", _context->frame_number);
135
146
[self display: _frame->data[0]
136
147
wrap: _frame->linesize[0]
@@ -140,16 +151,17 @@ - (void) decode
140
151
// pgm_save(frame->data[0], frame->linesize[0],
141
152
// frame->width, frame->height, buf);
142
153
}
154
+ */
143
155
}
144
156
145
157
- (void )dealloc
146
158
{
147
159
[self close ];
148
160
_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;
153
165
154
166
[super dealloc ];
155
167
}
@@ -161,10 +173,10 @@ - (id)init
161
173
if (self != nil )
162
174
{
163
175
_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;
168
180
}
169
181
170
182
return self;
@@ -182,6 +194,7 @@ - (NSMovieView *) movieView
182
194
183
195
- (BOOL )open
184
196
{
197
+ /*
185
198
_pkt = av_packet_alloc();
186
199
if (!_pkt)
187
200
{
@@ -210,7 +223,6 @@ - (BOOL)open
210
223
return NO;
211
224
}
212
225
213
- /* open it */
214
226
if (avcodec_open2(_context, _codec, NULL) < 0)
215
227
{
216
228
NSLog(@"Could not open codec\n");
@@ -225,10 +237,13 @@ - (BOOL)open
225
237
}
226
238
227
239
return YES;
240
+ */
241
+ return NO ;
228
242
}
229
243
230
244
- (void )close
231
245
{
246
+ /*
232
247
if (_parser != NULL)
233
248
{
234
249
av_parser_close(_parser);
@@ -248,15 +263,17 @@ - (void)close
248
263
{
249
264
av_packet_free(&_pkt);
250
265
}
266
+ */
251
267
}
252
268
253
269
- (void ) play
254
270
{
255
-
271
+ video_main ([_movieView movie ], _movieView);
256
272
}
257
273
258
274
- (BOOL )playBytes : (void *)bytes length : (NSUInteger )length
259
275
{
276
+ /*
260
277
int ret = av_parser_parse2(_parser, _context, &_pkt->data, &_pkt->size,
261
278
bytes, length, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
262
279
if (ret < 0)
@@ -284,6 +301,8 @@ - (BOOL)playBytes: (void *)bytes length: (NSUInteger)length
284
301
}
285
302
286
303
return YES;
304
+ */
305
+ return NO ;
287
306
}
288
307
289
308
- (void )setVolume : (float )volume
0 commit comments