FFmpeg
file.c
Go to the documentation of this file.
1 /*
2  * buffered file I/O
3  * Copyright (c) 2001 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg 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  * FFmpeg 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 #include "config_components.h"
23 
24 #include "libavutil/avstring.h"
25 #include "libavutil/file_open.h"
26 #include "libavutil/internal.h"
27 #include "libavutil/opt.h"
28 #include "avio.h"
29 #if HAVE_DIRENT_H
30 #include <dirent.h>
31 #endif
32 #include <fcntl.h>
33 #if HAVE_IO_H
34 #include <io.h>
35 #endif
36 #if HAVE_UNISTD_H
37 #include <unistd.h>
38 #endif
39 #include <sys/stat.h>
40 #include <stdlib.h>
41 #include "os_support.h"
42 #include "url.h"
43 
44 /* Some systems may not have S_ISFIFO */
45 #ifndef S_ISFIFO
46 # ifdef S_IFIFO
47 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
48 # else
49 # define S_ISFIFO(m) 0
50 # endif
51 #endif
52 
53 /* Not available in POSIX.1-1996 */
54 #ifndef S_ISLNK
55 # ifdef S_IFLNK
56 # define S_ISLNK(m) (((m) & S_IFLNK) == S_IFLNK)
57 # else
58 # define S_ISLNK(m) 0
59 # endif
60 #endif
61 
62 /* Not available in POSIX.1-1996 */
63 #ifndef S_ISSOCK
64 # ifdef S_IFSOCK
65 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
66 # else
67 # define S_ISSOCK(m) 0
68 # endif
69 #endif
70 
71 /* S_ISREG not available on Windows */
72 #ifndef S_ISREG
73 # ifdef S_IFREG
74 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
75 # else
76 # define S_ISREG(m) 0
77 # endif
78 #endif
79 
80 /* S_ISBLK not available on Windows */
81 #ifndef S_ISBLK
82 # ifdef S_IFBLK
83 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
84 # else
85 # define S_ISBLK(m) 0
86 # endif
87 #endif
88 
89 /* standard file protocol */
90 
91 typedef struct FileContext {
92  const AVClass *class;
93  int fd;
94  int trunc;
95  int blocksize;
96  int follow;
97  int seekable;
98 #if HAVE_DIRENT_H
99  DIR *dir;
100 #endif
102 } FileContext;
103 
104 static const AVOption file_options[] = {
105  { "truncate", "truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
106  { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
107  { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
108  { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
109  { NULL }
110 };
111 
112 static const AVOption pipe_options[] = {
113  { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
114  { "fd", "set file descriptor", offsetof(FileContext, fd), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
115  { NULL }
116 };
117 
118 static const AVClass file_class = {
119  .class_name = "file",
120  .item_name = av_default_item_name,
121  .option = file_options,
122  .version = LIBAVUTIL_VERSION_INT,
123 };
124 
125 static const AVClass pipe_class = {
126  .class_name = "pipe",
127  .item_name = av_default_item_name,
128  .option = pipe_options,
129  .version = LIBAVUTIL_VERSION_INT,
130 };
131 
132 static const AVClass fd_class = {
133  .class_name = "fd",
134  .item_name = av_default_item_name,
135  .option = pipe_options,
136  .version = LIBAVUTIL_VERSION_INT,
137 };
138 
139 static int file_read(URLContext *h, unsigned char *buf, int size)
140 {
141  FileContext *c = h->priv_data;
142  int ret;
143  size = FFMIN(size, c->blocksize);
144  ret = read(c->fd, buf, size);
145  if (ret == 0 && c->follow)
146  return AVERROR(EAGAIN);
147  if (ret == 0)
148  return AVERROR_EOF;
149  return (ret == -1) ? AVERROR(errno) : ret;
150 }
151 
152 static int file_write(URLContext *h, const unsigned char *buf, int size)
153 {
154  FileContext *c = h->priv_data;
155  int ret;
156  size = FFMIN(size, c->blocksize);
157  ret = write(c->fd, buf, size);
158  return (ret == -1) ? AVERROR(errno) : ret;
159 }
160 
162 {
163  FileContext *c = h->priv_data;
164  return c->fd;
165 }
166 
167 static int file_check(URLContext *h, int mask)
168 {
169  int ret = 0;
170  const char *filename = h->filename;
171  av_strstart(filename, "file:", &filename);
172 
173  {
174 #if HAVE_ACCESS && defined(R_OK)
175  if (access(filename, F_OK) < 0)
176  return AVERROR(errno);
177  if (mask&AVIO_FLAG_READ)
178  if (access(filename, R_OK) >= 0)
179  ret |= AVIO_FLAG_READ;
180  if (mask&AVIO_FLAG_WRITE)
181  if (access(filename, W_OK) >= 0)
182  ret |= AVIO_FLAG_WRITE;
183 #else
184  struct stat st;
185  ret = stat(filename, &st);
186  if (ret < 0)
187  return AVERROR(errno);
188 
189  ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
190  ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
191 #endif
192  }
193  return ret;
194 }
195 
196 static int fd_dup(URLContext *h, int oldfd)
197 {
198  int newfd;
199 
200 #ifdef F_DUPFD_CLOEXEC
201  newfd = fcntl(oldfd, F_DUPFD_CLOEXEC, 0);
202 #else
203  newfd = dup(oldfd);
204 #endif
205  if (newfd == -1)
206  return newfd;
207 
208 #if HAVE_FCNTL
209  if (fcntl(newfd, F_SETFD, FD_CLOEXEC) == -1)
210  av_log(h, AV_LOG_DEBUG, "Failed to set close on exec\n");
211 #endif
212 
213 #if HAVE_SETMODE
214  setmode(newfd, O_BINARY);
215 #endif
216  return newfd;
217 }
218 
219 static int file_close(URLContext *h)
220 {
221  FileContext *c = h->priv_data;
222  int ret;
223 
224  if (c->initial_pos >= 0 && !h->is_streamed)
225  lseek(c->fd, c->initial_pos, SEEK_SET);
226 
227  ret = close(c->fd);
228  return (ret == -1) ? AVERROR(errno) : 0;
229 }
230 
231 /* XXX: use llseek */
232 static int64_t file_seek(URLContext *h, int64_t pos, int whence)
233 {
234  FileContext *c = h->priv_data;
235  int64_t ret;
236 
237  if (whence == AVSEEK_SIZE) {
238  struct stat st;
239  ret = fstat(c->fd, &st);
240  return ret < 0 ? AVERROR(errno) : (S_ISFIFO(st.st_mode) ? 0 : st.st_size);
241  }
242 
243  ret = lseek(c->fd, pos, whence);
244 
245  return ret < 0 ? AVERROR(errno) : ret;
246 }
247 
248 #if CONFIG_FILE_PROTOCOL
249 
250 static int file_delete(URLContext *h)
251 {
252 #if HAVE_UNISTD_H
253  int ret;
254  const char *filename = h->filename;
255  av_strstart(filename, "file:", &filename);
256 
257  ret = rmdir(filename);
258  if (ret < 0 && (errno == ENOTDIR
259 # ifdef _WIN32
260  || errno == EINVAL
261 # endif
262  ))
263  ret = unlink(filename);
264  if (ret < 0)
265  return AVERROR(errno);
266 
267  return ret;
268 #else
269  return AVERROR(ENOSYS);
270 #endif /* HAVE_UNISTD_H */
271 }
272 
273 static int file_move(URLContext *h_src, URLContext *h_dst)
274 {
275  const char *filename_src = h_src->filename;
276  const char *filename_dst = h_dst->filename;
277  av_strstart(filename_src, "file:", &filename_src);
278  av_strstart(filename_dst, "file:", &filename_dst);
279 
280  if (rename(filename_src, filename_dst) < 0)
281  return AVERROR(errno);
282 
283  return 0;
284 }
285 
286 static int file_open(URLContext *h, const char *filename, int flags)
287 {
288  FileContext *c = h->priv_data;
289  int access;
290  int fd;
291  struct stat st;
292 
293  av_strstart(filename, "file:", &filename);
294 
295  c->initial_pos = -1;
297  access = O_CREAT | O_RDWR;
298  if (c->trunc)
299  access |= O_TRUNC;
300  } else if (flags & AVIO_FLAG_WRITE) {
301  access = O_CREAT | O_WRONLY;
302  if (c->trunc)
303  access |= O_TRUNC;
304  } else {
305  access = O_RDONLY;
306  }
307 #ifdef O_BINARY
308  access |= O_BINARY;
309 #endif
310  fd = avpriv_open(filename, access, 0666);
311  if (fd == -1)
312  return AVERROR(errno);
313  c->fd = fd;
314 
315  h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
316 
317  /* Buffer writes more than the default 32k to improve throughput especially
318  * with networked file systems */
319  if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
320  h->min_packet_size = h->max_packet_size = 262144;
321 
322  if (c->seekable >= 0)
323  h->is_streamed = !c->seekable;
324 
325  return 0;
326 }
327 
328 static int file_open_dir(URLContext *h)
329 {
330 #if HAVE_LSTAT
331  FileContext *c = h->priv_data;
332 
333  c->dir = opendir(h->filename);
334  if (!c->dir)
335  return AVERROR(errno);
336 
337  return 0;
338 #else
339  return AVERROR(ENOSYS);
340 #endif /* HAVE_LSTAT */
341 }
342 
343 static int file_read_dir(URLContext *h, AVIODirEntry **next)
344 {
345 #if HAVE_LSTAT
346  FileContext *c = h->priv_data;
347  struct dirent *dir;
348  char *fullpath = NULL;
349 
350  *next = ff_alloc_dir_entry();
351  if (!*next)
352  return AVERROR(ENOMEM);
353  do {
354  errno = 0;
355  dir = readdir(c->dir);
356  if (!dir) {
357  av_freep(next);
358  return AVERROR(errno);
359  }
360  } while (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."));
361 
362  fullpath = av_append_path_component(h->filename, dir->d_name);
363  if (fullpath) {
364  struct stat st;
365  if (!lstat(fullpath, &st)) {
366  if (S_ISDIR(st.st_mode))
367  (*next)->type = AVIO_ENTRY_DIRECTORY;
368  else if (S_ISFIFO(st.st_mode))
369  (*next)->type = AVIO_ENTRY_NAMED_PIPE;
370  else if (S_ISCHR(st.st_mode))
371  (*next)->type = AVIO_ENTRY_CHARACTER_DEVICE;
372  else if (S_ISBLK(st.st_mode))
373  (*next)->type = AVIO_ENTRY_BLOCK_DEVICE;
374  else if (S_ISLNK(st.st_mode))
375  (*next)->type = AVIO_ENTRY_SYMBOLIC_LINK;
376  else if (S_ISSOCK(st.st_mode))
377  (*next)->type = AVIO_ENTRY_SOCKET;
378  else if (S_ISREG(st.st_mode))
379  (*next)->type = AVIO_ENTRY_FILE;
380  else
381  (*next)->type = AVIO_ENTRY_UNKNOWN;
382 
383  (*next)->group_id = st.st_gid;
384  (*next)->user_id = st.st_uid;
385  (*next)->size = st.st_size;
386  (*next)->filemode = st.st_mode & 0777;
387  (*next)->modification_timestamp = INT64_C(1000000) * st.st_mtime;
388  (*next)->access_timestamp = INT64_C(1000000) * st.st_atime;
389  (*next)->status_change_timestamp = INT64_C(1000000) * st.st_ctime;
390  }
391  av_free(fullpath);
392  }
393 
394  (*next)->name = av_strdup(dir->d_name);
395  return 0;
396 #else
397  return AVERROR(ENOSYS);
398 #endif /* HAVE_LSTAT */
399 }
400 
401 static int file_close_dir(URLContext *h)
402 {
403 #if HAVE_LSTAT
404  FileContext *c = h->priv_data;
405  closedir(c->dir);
406  return 0;
407 #else
408  return AVERROR(ENOSYS);
409 #endif /* HAVE_LSTAT */
410 }
411 
413  .name = "file",
414  .url_open = file_open,
415  .url_read = file_read,
416  .url_write = file_write,
417  .url_seek = file_seek,
418  .url_close = file_close,
419  .url_get_file_handle = file_get_handle,
420  .url_check = file_check,
421  .url_delete = file_delete,
422  .url_move = file_move,
423  .priv_data_size = sizeof(FileContext),
424  .priv_data_class = &file_class,
425  .url_open_dir = file_open_dir,
426  .url_read_dir = file_read_dir,
427  .url_close_dir = file_close_dir,
428  .default_whitelist = "file,crypto,data"
429 };
430 
431 #endif /* CONFIG_FILE_PROTOCOL */
432 
433 #if CONFIG_PIPE_PROTOCOL
434 
435 static int pipe_open(URLContext *h, const char *filename, int flags)
436 {
437  FileContext *c = h->priv_data;
438  int fd;
439  char *final;
440 
441  if (c->fd < 0) {
442  av_strstart(filename, "pipe:", &filename);
443 
444  fd = strtol(filename, &final, 10);
445  if((filename == final) || *final ) {/* No digits found, or something like 10ab */
446  if (flags & AVIO_FLAG_WRITE) {
447  fd = 1;
448  } else {
449  fd = 0;
450  }
451  }
452  c->fd = fd;
453  }
454 
455  c->fd = fd_dup(h, c->fd);
456  if (c->fd == -1)
457  return AVERROR(errno);
458  h->is_streamed = 1;
459  return 0;
460 }
461 
463  .name = "pipe",
464  .url_open = pipe_open,
465  .url_read = file_read,
466  .url_write = file_write,
467  .url_close = file_close,
468  .url_get_file_handle = file_get_handle,
469  .url_check = file_check,
470  .priv_data_size = sizeof(FileContext),
471  .priv_data_class = &pipe_class,
472  .default_whitelist = "crypto,data"
473 };
474 
475 #endif /* CONFIG_PIPE_PROTOCOL */
476 
477 #if CONFIG_FD_PROTOCOL
478 
479 static int fd_open(URLContext *h, const char *filename, int flags)
480 {
481  FileContext *c = h->priv_data;
482  struct stat st;
483 
484  if (strcmp(filename, "fd:") != 0) {
485  av_log(h, AV_LOG_ERROR, "Doesn't support pass file descriptor via URL,"
486  " please set it via -fd {num}\n");
487  return AVERROR(EINVAL);
488  }
489 
490  if (c->fd < 0) {
491  if (flags & AVIO_FLAG_WRITE) {
492  c->fd = 1;
493  } else {
494  c->fd = 0;
495  }
496  }
497  if (fstat(c->fd, &st) < 0)
498  return AVERROR(errno);
499  h->is_streamed = !(S_ISREG(st.st_mode) || S_ISBLK(st.st_mode));
500  c->fd = fd_dup(h, c->fd);
501  if (c->fd == -1)
502  return AVERROR(errno);
503 
504  if (h->is_streamed)
505  c->initial_pos = -1;
506  else
507  c->initial_pos = lseek(c->fd, 0, SEEK_CUR);
508 
509  return 0;
510 }
511 
512 const URLProtocol ff_fd_protocol = {
513  .name = "fd",
514  .url_open = fd_open,
515  .url_read = file_read,
516  .url_write = file_write,
517  .url_seek = file_seek,
518  .url_close = file_close,
519  .url_get_file_handle = file_get_handle,
520  .url_check = file_check,
521  .priv_data_size = sizeof(FileContext),
522  .priv_data_class = &fd_class,
523  .default_whitelist = "crypto,data"
524 };
525 
526 #endif /* CONFIG_FD_PROTOCOL */
527 
528 #if CONFIG_ANDROID_CONTENT_PROTOCOL
529 #include <jni.h>
530 #include "libavcodec/ffjni.h"
531 #include "libavcodec/jni.h"
532 
533 typedef struct JFields {
534  jclass uri_class;
535  jmethodID parse_id;
536 
537  jclass context_class;
538  jmethodID get_content_resolver_id;
539 
540  jclass content_resolver_class;
541  jmethodID open_file_descriptor_id;
542 
543  jclass parcel_file_descriptor_class;
544  jmethodID detach_fd_id;
545 } JFields;
546 
547 #define OFFSET(x) offsetof(JFields, x)
548 static const struct FFJniField jfields_mapping[] = {
549  { "android/net/Uri", NULL, NULL, FF_JNI_CLASS, OFFSET(uri_class), 1 },
550  { "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", FF_JNI_STATIC_METHOD, OFFSET(parse_id), 1 },
551 
552  { "android/content/Context", NULL, NULL, FF_JNI_CLASS, OFFSET(context_class), 1 },
553  { "android/content/Context", "getContentResolver", "()Landroid/content/ContentResolver;", FF_JNI_METHOD, OFFSET(get_content_resolver_id), 1 },
554 
555  { "android/content/ContentResolver", NULL, NULL, FF_JNI_CLASS, OFFSET(content_resolver_class), 1 },
556  { "android/content/ContentResolver", "openFileDescriptor", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;", FF_JNI_METHOD, OFFSET(open_file_descriptor_id), 1 },
557 
558  { "android/os/ParcelFileDescriptor", NULL, NULL, FF_JNI_CLASS, OFFSET(parcel_file_descriptor_class), 1 },
559  { "android/os/ParcelFileDescriptor", "detachFd", "()I", FF_JNI_METHOD, OFFSET(detach_fd_id), 1 },
560 
561  { NULL }
562 };
563 #undef OFFSET
564 
565 static int android_content_open(URLContext *h, const char *filename, int flags)
566 {
567  FileContext *c = h->priv_data;
568  int fd, ret;
569  struct stat st;
570  const char *mode_str = "r";
571 
572  JNIEnv *env;
573  JFields jfields = { 0 };
574  jobject application_context = NULL;
575  jobject url = NULL;
576  jobject mode = NULL;
577  jobject uri = NULL;
578  jobject content_resolver = NULL;
579  jobject parcel_file_descriptor = NULL;
580 
581  env = ff_jni_get_env(c);
582  if (!env) {
583  return AVERROR(EINVAL);
584  }
585 
586  ret = ff_jni_init_jfields(env, &jfields, jfields_mapping, 0, c);
587  if (ret < 0) {
588  av_log(c, AV_LOG_ERROR, "failed to initialize jni fields\n");
589  return ret;
590  }
591 
592  application_context = av_jni_get_android_app_ctx();
593  if (!application_context) {
594  av_log(c, AV_LOG_ERROR, "application context is not set\n");
596  goto done;
597  }
598 
599  url = ff_jni_utf_chars_to_jstring(env, filename, c);
600  if (!url) {
602  goto done;
603  }
604 
606  mode_str = "rw";
607  else if (flags & AVIO_FLAG_WRITE)
608  mode_str = "w";
609 
610  mode = ff_jni_utf_chars_to_jstring(env, mode_str, c);
611  if (!mode) {
613  goto done;
614  }
615 
616  uri = (*env)->CallStaticObjectMethod(env, jfields.uri_class, jfields.parse_id, url);
617  ret = ff_jni_exception_check(env, 1, c);
618  if (ret < 0)
619  goto done;
620 
621  content_resolver = (*env)->CallObjectMethod(env, application_context, jfields.get_content_resolver_id);
622  ret = ff_jni_exception_check(env, 1, c);
623  if (ret < 0)
624  goto done;
625 
626  parcel_file_descriptor = (*env)->CallObjectMethod(env, content_resolver, jfields.open_file_descriptor_id, uri, mode);
627  ret = ff_jni_exception_check(env, 1, c);
628  if (ret < 0)
629  goto done;
630 
631  fd = (*env)->CallIntMethod(env, parcel_file_descriptor, jfields.detach_fd_id);
632  ret = ff_jni_exception_check(env, 1, c);
633  if (ret < 0)
634  goto done;
635 
636  if (fstat(fd, &st) < 0) {
637  close(fd);
638  return AVERROR(errno);
639  }
640 
641  c->fd = fd;
642  h->is_streamed = !(S_ISREG(st.st_mode) || S_ISBLK(st.st_mode));
643 
644 done:
645  (*env)->DeleteLocalRef(env, url);
646  (*env)->DeleteLocalRef(env, mode);
647  (*env)->DeleteLocalRef(env, uri);
648  (*env)->DeleteLocalRef(env, content_resolver);
649  (*env)->DeleteLocalRef(env, parcel_file_descriptor);
650  ff_jni_reset_jfields(env, &jfields, jfields_mapping, 0, c);
651 
652  return ret;
653 }
654 
655 static const AVOption android_content_options[] = {
656  { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
657  { NULL }
658 };
659 
660 static const AVClass android_content_class = {
661  .class_name = "android_content",
662  .item_name = av_default_item_name,
663  .option = android_content_options,
664  .version = LIBAVUTIL_VERSION_INT,
665 };
666 
668  .name = "content",
669  .url_open = android_content_open,
670  .url_read = file_read,
671  .url_write = file_write,
672  .url_seek = file_seek,
673  .url_close = file_close,
674  .url_get_file_handle = file_get_handle,
675  .url_check = NULL,
676  .priv_data_size = sizeof(FileContext),
677  .priv_data_class = &android_content_class,
678 };
679 
680 #endif /* CONFIG_ANDROID_CONTENT_PROTOCOL */
fd_dup
static int fd_dup(URLContext *h, int oldfd)
Definition: file.c:196
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
S_ISSOCK
#define S_ISSOCK(m)
Definition: file.c:67
URLContext::filename
char * filename
specified URL
Definition: url.h:39
ff_jni_utf_chars_to_jstring
jstring ff_jni_utf_chars_to_jstring(JNIEnv *env, const char *utf_chars, void *log_ctx)
Definition: ffjni.c:129
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
int64_t
long long int64_t
Definition: coverity.c:34
file_close
static int file_close(URLContext *h)
Definition: file.c:219
ff_jni_reset_jfields
int ff_jni_reset_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
Definition: ffjni.c:368
AVOption
AVOption.
Definition: opt.h:346
AVSEEK_SIZE
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
Definition: avio.h:468
AVIO_ENTRY_NAMED_PIPE
@ AVIO_ENTRY_NAMED_PIPE
Definition: avio.h:72
file_check
static int file_check(URLContext *h, int mask)
Definition: file.c:167
URLProtocol
Definition: url.h:51
os_support.h
AVIO_ENTRY_UNKNOWN
@ AVIO_ENTRY_UNKNOWN
Definition: avio.h:68
ff_jni_init_jfields
int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
Definition: ffjni.c:279
av_append_path_component
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
Definition: avstring.c:296
AVIO_ENTRY_DIRECTORY
@ AVIO_ENTRY_DIRECTORY
Definition: avio.h:71
trunc
static __device__ float trunc(float a)
Definition: cuda_runtime.h:179
AVIO_ENTRY_CHARACTER_DEVICE
@ AVIO_ENTRY_CHARACTER_DEVICE
Definition: avio.h:70
FF_JNI_CLASS
@ FF_JNI_CLASS
Definition: ffjni.h:91
ff_android_content_protocol
const URLProtocol ff_android_content_protocol
FileContext::blocksize
int blocksize
Definition: file.c:95
file_write
static int file_write(URLContext *h, const unsigned char *buf, int size)
Definition: file.c:152
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ff_fd_protocol
const URLProtocol ff_fd_protocol
file_read
static int file_read(URLContext *h, unsigned char *buf, int size)
Definition: file.c:139
AVIO_ENTRY_SYMBOLIC_LINK
@ AVIO_ENTRY_SYMBOLIC_LINK
Definition: avio.h:73
mask
static const uint16_t mask[17]
Definition: lzw.c:38
FileContext::seekable
int seekable
Definition: file.c:97
S_ISFIFO
#define S_ISFIFO(m)
Definition: file.c:49
avpriv_open
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
Definition: file_open.c:67
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
FileContext
Definition: file.c:91
pipe_class
static const AVClass pipe_class
Definition: file.c:125
file_open.h
FileContext::initial_pos
int64_t initial_pos
Definition: file.c:101
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
FF_JNI_METHOD
@ FF_JNI_METHOD
Definition: ffjni.h:94
NULL
#define NULL
Definition: coverity.c:32
S_ISBLK
#define S_ISBLK(m)
Definition: file.c:85
FFJniField
Definition: ffjni.h:103
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVIO_ENTRY_FILE
@ AVIO_ENTRY_FILE
Definition: avio.h:75
FileContext::fd
int fd
Definition: file.c:93
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:269
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
pipe_options
static const AVOption pipe_options[]
Definition: file.c:112
FileContext::follow
int follow
Definition: file.c:96
ff_file_protocol
const URLProtocol ff_file_protocol
size
int size
Definition: twinvq_data.h:10344
AVIODirEntry
Describes single entry of the directory.
Definition: avio.h:87
avio.h
URLProtocol::name
const char * name
Definition: url.h:52
FileContext::trunc
int trunc
Definition: file.c:94
file_seek
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
Definition: file.c:232
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
av_strstart
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:36
AVIO_ENTRY_SOCKET
@ AVIO_ENTRY_SOCKET
Definition: avio.h:74
ff_alloc_dir_entry
AVIODirEntry * ff_alloc_dir_entry(void)
Allocate directory entry with default values.
Definition: url.c:327
ff_jni_exception_check
int ff_jni_exception_check(JNIEnv *env, int log, void *log_ctx)
Definition: ffjni.c:246
URLContext
Definition: url.h:35
ffjni.h
file_options
static const AVOption file_options[]
Definition: file.c:104
av_jni_get_android_app_ctx
void * av_jni_get_android_app_ctx(void)
internal.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
url.h
file_class
static const AVClass file_class
Definition: file.c:118
S_ISLNK
#define S_ISLNK(m)
Definition: file.c:58
O_BINARY
#define O_BINARY
ff_pipe_protocol
const URLProtocol ff_pipe_protocol
AVIO_ENTRY_BLOCK_DEVICE
@ AVIO_ENTRY_BLOCK_DEVICE
Definition: avio.h:69
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
file_get_handle
static int file_get_handle(URLContext *h)
Definition: file.c:161
pos
unsigned int pos
Definition: spdifenc.c:413
OFFSET
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your see the OFFSET() macro
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
fd_class
static const AVClass fd_class
Definition: file.c:132
ff_jni_get_env
JNIEnv * ff_jni_get_env(void *log_ctx)
Definition: ffjni.c:53
AVIO_FLAG_READ
#define AVIO_FLAG_READ
read-only
Definition: avio.h:617
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:273
S_ISREG
#define S_ISREG(m)
Definition: file.c:76
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
FF_JNI_STATIC_METHOD
@ FF_JNI_STATIC_METHOD
Definition: ffjni.h:95
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2038
avstring.h
jni.h
read
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
Definition: bitstream_template.h:231