| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Unbuffered io for ffmpeg system | 2 * Unbuffered io for ffmpeg system |
| 3 * Copyright (c) 2001 Fabrice Bellard | 3 * Copyright (c) 2001 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #define _XOPEN_SOURCE 600 | 23 #define _XOPEN_SOURCE 600 |
| 24 #include <unistd.h> | 24 #include <unistd.h> |
| 25 #include "libavutil/avstring.h" | 25 #include "libavutil/avstring.h" |
| 26 #include "libavcodec/opt.h" | 26 #include "libavcodec/opt.h" |
| 27 #include "os_support.h" | 27 #include "os_support.h" |
| 28 #include "avformat.h" | 28 #include "avformat.h" |
| 29 #if CONFIG_NETWORK | 29 #if CONFIG_NETWORK |
| 30 #include "network.h" | 30 #include "network.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 #if LIBAVFORMAT_VERSION_MAJOR >= 53 | 33 #if FF_API_URL_CLASS |
| 34 /** @name Logging context. */ | 34 /** @name Logging context. */ |
| 35 /*@{*/ | 35 /*@{*/ |
| 36 static const char *urlcontext_to_name(void *ptr) | 36 static const char *urlcontext_to_name(void *ptr) |
| 37 { | 37 { |
| 38 URLContext *h = (URLContext *)ptr; | 38 URLContext *h = (URLContext *)ptr; |
| 39 if(h->prot) return h->prot->name; | 39 if(h->prot) return h->prot->name; |
| 40 else return "NULL"; | 40 else return "NULL"; |
| 41 } | 41 } |
| 42 static const AVOption options[] = {{NULL}}; | 42 static const AVOption options[] = {{NULL}}; |
| 43 static const AVClass urlcontext_class = | 43 static const AVClass urlcontext_class = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 memcpy(temp, protocol, size); | 64 memcpy(temp, protocol, size); |
| 65 protocol = temp; | 65 protocol = temp; |
| 66 } | 66 } |
| 67 p = &first_protocol; | 67 p = &first_protocol; |
| 68 while (*p != NULL) p = &(*p)->next; | 68 while (*p != NULL) p = &(*p)->next; |
| 69 *p = protocol; | 69 *p = protocol; |
| 70 protocol->next = NULL; | 70 protocol->next = NULL; |
| 71 return 0; | 71 return 0; |
| 72 } | 72 } |
| 73 | 73 |
| 74 #if LIBAVFORMAT_VERSION_MAJOR < 53 | 74 #if FF_API_REGISTER_PROTOCOL |
| 75 /* The layout of URLProtocol as of when major was bumped to 52 */ | 75 /* The layout of URLProtocol as of when major was bumped to 52 */ |
| 76 struct URLProtocol_compat { | 76 struct URLProtocol_compat { |
| 77 const char *name; | 77 const char *name; |
| 78 int (*url_open)(URLContext *h, const char *filename, int flags); | 78 int (*url_open)(URLContext *h, const char *filename, int flags); |
| 79 int (*url_read)(URLContext *h, unsigned char *buf, int size); | 79 int (*url_read)(URLContext *h, unsigned char *buf, int size); |
| 80 int (*url_write)(URLContext *h, unsigned char *buf, int size); | 80 int (*url_write)(URLContext *h, unsigned char *buf, int size); |
| 81 int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); | 81 int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); |
| 82 int (*url_close)(URLContext *h); | 82 int (*url_close)(URLContext *h); |
| 83 struct URLProtocol *next; | 83 struct URLProtocol *next; |
| 84 }; | 84 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 102 | 102 |
| 103 #if CONFIG_NETWORK | 103 #if CONFIG_NETWORK |
| 104 if (!ff_network_init()) | 104 if (!ff_network_init()) |
| 105 return AVERROR(EIO); | 105 return AVERROR(EIO); |
| 106 #endif | 106 #endif |
| 107 uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1); | 107 uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1); |
| 108 if (!uc) { | 108 if (!uc) { |
| 109 err = AVERROR(ENOMEM); | 109 err = AVERROR(ENOMEM); |
| 110 goto fail; | 110 goto fail; |
| 111 } | 111 } |
| 112 #if LIBAVFORMAT_VERSION_MAJOR >= 53 | 112 #if FF_API_URL_CLASS |
| 113 uc->av_class = &urlcontext_class; | 113 uc->av_class = &urlcontext_class; |
| 114 #endif | 114 #endif |
| 115 uc->filename = (char *) &uc[1]; | 115 uc->filename = (char *) &uc[1]; |
| 116 strcpy(uc->filename, filename); | 116 strcpy(uc->filename, filename); |
| 117 uc->prot = up; | 117 uc->prot = up; |
| 118 uc->flags = flags; | 118 uc->flags = flags; |
| 119 uc->is_streamed = 0; /* default = not streamed */ | 119 uc->is_streamed = 0; /* default = not streamed */ |
| 120 uc->max_packet_size = 0; /* default: stream file */ | 120 uc->max_packet_size = 0; /* default: stream file */ |
| 121 if (up->priv_data_size) { | 121 if (up->priv_data_size) { |
| 122 uc->priv_data = av_mallocz(up->priv_data_size); | 122 uc->priv_data = av_mallocz(up->priv_data_size); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return h->prot->url_read_pause(h, pause); | 337 return h->prot->url_read_pause(h, pause); |
| 338 } | 338 } |
| 339 | 339 |
| 340 int64_t av_url_read_seek(URLContext *h, | 340 int64_t av_url_read_seek(URLContext *h, |
| 341 int stream_index, int64_t timestamp, int flags) | 341 int stream_index, int64_t timestamp, int flags) |
| 342 { | 342 { |
| 343 if (!h->prot->url_read_seek) | 343 if (!h->prot->url_read_seek) |
| 344 return AVERROR(ENOSYS); | 344 return AVERROR(ENOSYS); |
| 345 return h->prot->url_read_seek(h, stream_index, timestamp, flags); | 345 return h->prot->url_read_seek(h, stream_index, timestamp, flags); |
| 346 } | 346 } |
| OLD | NEW |