FFmpeg
Loading...
Searching...
No Matches
tls_securetransport.c File Reference
#include <errno.h>
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "network.h"
#include "os_support.h"
#include "url.h"
#include "tls.h"
#include "libavcodec/internal.h"
#include "libavutil/attributes.h"
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include <Security/Security.h>
#include <Security/SecureTransport.h>
#include <CoreFoundation/CoreFoundation.h>

Go to the source code of this file.

Data Structures

struct  TLSContext
 

Macros

#define ioErr   -36
 
#define CHECK_ERROR(func, ...)
 

Functions

SecIdentityRef SecIdentityCreate (CFAllocatorRef allocator, SecCertificateRef certificate, SecKeyRef privateKey)
 
static int print_tls_error (URLContext *h, int ret)
 
static int import_pem (URLContext *h, char *path, CFArrayRef *array)
 
static int load_ca (URLContext *h)
 
static int load_cert (URLContext *h)
 
static OSStatus tls_read_cb (SSLConnectionRef connection, void *data, size_t *dataLength)
 
static OSStatus tls_write_cb (SSLConnectionRef connection, const void *data, size_t *dataLength)
 
static int tls_close (URLContext *h)
 
static int tls_open (URLContext *h, const char *uri, int flags, AVDictionary **options)
 
static int map_ssl_error (OSStatus status, size_t processed)
 
static int tls_read (URLContext *h, uint8_t *buf, int size)
 
static int tls_write (URLContext *h, const uint8_t *buf, int size)
 
static int tls_get_file_handle (URLContext *h)
 
static int tls_get_short_seek (URLContext *h)
 

Variables

static const AVOption options []
 
static const AVClass tls_class
 
const URLProtocol ff_tls_protocol
 

Macro Definition Documentation

◆ ioErr

#define ioErr   -36

Definition at line 44 of file tls_securetransport.c.

Referenced by print_tls_error(), tls_read_cb(), and tls_write_cb().

◆ CHECK_ERROR

#define CHECK_ERROR ( func,
... )
Value:
do { \
OSStatus status = func(__VA_ARGS__); \
if (status != noErr) { \
ret = AVERROR_UNKNOWN; \
av_log(h, AV_LOG_ERROR, #func ": Error %i\n", (int)status); \
goto fail; \
} \
} while (0)
#define fail
Definition test.h:479
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition error.h:73
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition jacosubdec.c:66

Definition at line 259 of file tls_securetransport.c.

Referenced by tls_open().

Function Documentation

◆ SecIdentityCreate()

SecIdentityRef SecIdentityCreate ( CFAllocatorRef allocator,
SecCertificateRef certificate,
SecKeyRef privateKey )

Referenced by load_cert().

◆ print_tls_error()

static int print_tls_error ( URLContext * h,
int ret )
static

Definition at line 53 of file tls_securetransport.c.

Referenced by tls_read(), and tls_write().

◆ import_pem()

static int import_pem ( URLContext * h,
char * path,
CFArrayRef * array )
static

Definition at line 71 of file tls_securetransport.c.

Referenced by load_ca(), and load_cert().

◆ load_ca()

static int load_ca ( URLContext * h)
static

Definition at line 134 of file tls_securetransport.c.

Referenced by tls_open().

◆ load_cert()

static int load_cert ( URLContext * h)
static

Definition at line 154 of file tls_securetransport.c.

Referenced by tls_open().

◆ tls_read_cb()

static OSStatus tls_read_cb ( SSLConnectionRef connection,
void * data,
size_t * dataLength )
static

Definition at line 197 of file tls_securetransport.c.

Referenced by tls_open().

◆ tls_write_cb()

static OSStatus tls_write_cb ( SSLConnectionRef connection,
const void * data,
size_t * dataLength )
static

Definition at line 226 of file tls_securetransport.c.

Referenced by tls_open().

◆ tls_close()

static int tls_close ( URLContext * h)
static

Definition at line 246 of file tls_securetransport.c.

Referenced by tls_open().

◆ tls_open()

static int tls_open ( URLContext * h,
const char * uri,
int flags,
AVDictionary ** options )
static

Definition at line 268 of file tls_securetransport.c.

◆ map_ssl_error()

static int map_ssl_error ( OSStatus status,
size_t processed )
static

Definition at line 348 of file tls_securetransport.c.

Referenced by tls_read(), and tls_write().

◆ tls_read()

static int tls_read ( URLContext * h,
uint8_t * buf,
int size )
static

Definition at line 365 of file tls_securetransport.c.

◆ tls_write()

static int tls_write ( URLContext * h,
const uint8_t * buf,
int size )
static

Definition at line 382 of file tls_securetransport.c.

◆ tls_get_file_handle()

static int tls_get_file_handle ( URLContext * h)
static

Definition at line 395 of file tls_securetransport.c.

◆ tls_get_short_seek()

static int tls_get_short_seek ( URLContext * h)
static

Definition at line 401 of file tls_securetransport.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ NULL }
}
#define NULL
Definition coverity.c:32
#define TLS_COMMON_OPTIONS(pstruct, options_field)
Definition tls.h:101

Definition at line 407 of file tls_securetransport.c.

◆ tls_class

const AVClass tls_class
static
Initial value:
= {
.class_name = "tls",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 412 of file tls_securetransport.c.

◆ ff_tls_protocol

const URLProtocol ff_tls_protocol
Initial value:
= {
.name = "tls",
.url_open2 = tls_open,
.url_read = tls_read,
.url_write = tls_write,
.url_close = tls_close,
.url_get_file_handle = tls_get_file_handle,
.url_get_short_seek = tls_get_short_seek,
.priv_data_size = sizeof(TLSContext),
.priv_data_class = &tls_class,
}
#define flags(name, subs,...)
Definition cbs_h264.c:74
static int tls_close(URLContext *h)
Definition tls_gnutls.c:419
static const AVClass tls_class
Definition tls_gnutls.c:764
static int tls_read(URLContext *h, uint8_t *buf, int size)
Definition tls_gnutls.c:707
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
Definition tls_gnutls.c:532
static int tls_get_short_seek(URLContext *h)
Definition tls_gnutls.c:753
static int tls_write(URLContext *h, const uint8_t *buf, int size)
Definition tls_gnutls.c:724
static int tls_get_file_handle(URLContext *h)
Definition tls_gnutls.c:747
#define URL_PROTOCOL_FLAG_NETWORK
Definition url.h:33

Definition at line 419 of file tls_securetransport.c.