Go to the documentation of this file.
28 #include <openssl/bio.h>
29 #include <openssl/ssl.h>
30 #include <openssl/err.h>
37 #if OPENSSL_VERSION_NUMBER >= 0x1010000fL
48 #if OPENSSL_VERSION_NUMBER < 0x10100000L
56 #include <openssl/crypto.h>
60 static void openssl_lock(
int mode,
int type,
const char *file,
int line)
62 if (
mode & CRYPTO_LOCK)
67 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
68 static unsigned long openssl_thread_id(
void)
70 return (intptr_t) pthread_self();
80 SSL_load_error_strings();
82 if (!CRYPTO_get_locking_callback()) {
85 if (!openssl_mutexes) {
90 for (
i = 0;
i < CRYPTO_num_locks();
i++)
92 CRYPTO_set_locking_callback(openssl_lock);
93 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
94 CRYPTO_set_id_callback(openssl_thread_id);
111 if (CRYPTO_get_locking_callback() == openssl_lock) {
113 CRYPTO_set_locking_callback(
NULL);
114 for (
i = 0;
i < CRYPTO_num_locks();
i++)
129 int err = SSL_get_error(
c->ssl,
ret);
130 if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
133 while ((e = ERR_get_error()) != 0) {
152 SSL_shutdown(
c->ssl);
156 SSL_CTX_free(
c->ctx);
158 #if OPENSSL_VERSION_NUMBER >= 0x1010000fL
159 if (
c->url_bio_method)
160 BIO_meth_free(
c->url_bio_method);
162 #if OPENSSL_VERSION_NUMBER < 0x10100000L
170 #if OPENSSL_VERSION_NUMBER >= 0x1010000fL
172 BIO_set_data(
b,
NULL);
187 #if OPENSSL_VERSION_NUMBER >= 0x1010000fL
188 #define GET_BIO_DATA(x) BIO_get_data(x)
190 #define GET_BIO_DATA(x) (x)->ptr
199 BIO_clear_retry_flags(
b);
203 BIO_set_retry_read(
b);
215 BIO_clear_retry_flags(
b);
219 BIO_set_retry_write(
b);
227 if (cmd == BIO_CTRL_FLUSH) {
228 BIO_clear_retry_flags(
b);
239 #if OPENSSL_VERSION_NUMBER < 0x1010000fL
241 .type = BIO_TYPE_SOURCE_SINK,
242 .name =
"urlprotocol bio",
260 #if OPENSSL_VERSION_NUMBER < 0x10100000L
272 p->
ctx = SSL_CTX_new(
c->listen ? SSLv23_server_method() : SSLv23_client_method());
278 SSL_CTX_set_options(p->
ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
280 if (!SSL_CTX_load_verify_locations(p->
ctx,
c->ca_file,
NULL))
283 if (
c->cert_file && !SSL_CTX_use_certificate_chain_file(p->
ctx,
c->cert_file)) {
285 c->cert_file, ERR_error_string(ERR_get_error(),
NULL));
289 if (
c->key_file && !SSL_CTX_use_PrivateKey_file(p->
ctx,
c->key_file, SSL_FILETYPE_PEM)) {
291 c->key_file, ERR_error_string(ERR_get_error(),
NULL));
298 SSL_CTX_set_verify(p->
ctx, SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
NULL);
305 #if OPENSSL_VERSION_NUMBER >= 0x1010000fL
306 p->url_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK,
"urlprotocol bio");
313 bio = BIO_new(p->url_bio_method);
314 BIO_set_data(bio, p);
319 SSL_set_bio(p->
ssl, bio, bio);
320 if (!
c->listen && !
c->numerichost)
321 SSL_set_tlsext_host_name(p->
ssl,
c->host);
322 ret =
c->listen ? SSL_accept(p->
ssl) : SSL_connect(p->
ssl);
327 }
else if (
ret < 0) {
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
#define URL_PROTOCOL_FLAG_NETWORK
#define AVERROR_EOF
End of file.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
void ff_openssl_deinit(void)
static int ff_mutex_unlock(AVMutex *mutex)
#define TLS_COMMON_OPTIONS(pstruct, options_field)
static const AVClass tls_class
int ffurl_get_short_seek(void *urlcontext)
Return the current short seek threshold value for this URL.
static int url_bio_create(BIO *b)
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 type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int tls_write(URLContext *h, const uint8_t *buf, int size)
const URLProtocol ff_tls_protocol
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static AVMutex openssl_mutex
const char * av_default_item_name(void *ptr)
Return the context name.
static long url_bio_ctrl(BIO *b, int cmd, long num, void *ptr)
int ff_openssl_init(void)
static int url_bio_destroy(BIO *b)
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
static int url_bio_bwrite(BIO *b, const char *buf, int len)
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
#define pthread_mutex_unlock(a)
static int url_bio_bread(BIO *b, char *buf, int len)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_MUTEX_INITIALIZER
static const AVOption options[]
static int ff_mutex_lock(AVMutex *mutex)
static int tls_get_file_handle(URLContext *h)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
#define i(width, name, range_min, range_max)
#define av_malloc_array(a, b)
static int print_tls_error(URLContext *h, int ret)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int tls_get_short_seek(URLContext *h)
static int tls_read(URLContext *h, uint8_t *buf, int size)
static BIO_METHOD url_bio_method
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
#define flags(name, subs,...)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static int tls_close(URLContext *h)
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
static int url_bio_bputs(BIO *b, const char *str)
#define pthread_mutex_lock(a)
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.