21 #include <libsmbclient.h>
39 char *workgroup,
int workgroup_len,
40 char *username,
int username_len,
41 char *password,
int password_len)
51 libsmbc->
ctx = smbc_new_context();
57 if (!smbc_init_context(libsmbc->
ctx)) {
62 smbc_set_context(libsmbc->
ctx);
64 smbc_setOptionUserData(libsmbc->
ctx, h);
68 smbc_setTimeout(libsmbc->
ctx, libsmbc->
timeout);
72 if (smbc_init(
NULL, 0) < 0) {
83 if (libsmbc->
fd >= 0) {
84 smbc_close(libsmbc->
fd);
88 smbc_free_context(libsmbc->
ctx, 1);
107 access = O_CREAT | O_RDWR;
110 }
else if (flags & AVIO_FLAG_WRITE) {
111 access = O_CREAT | O_WRONLY;
118 if ((libsmbc->
fd = smbc_open(url, access, 0666)) < 0) {
124 if (smbc_fstat(libsmbc->
fd, &st) < 0)
148 if ((newpos = smbc_lseek(libsmbc->
fd, pos, whence)) < 0) {
162 if ((bytes_read = smbc_read(libsmbc->
fd, buf, size)) < 0) {
176 if ((bytes_written = smbc_write(libsmbc->
fd, buf, size)) < 0) {
182 return bytes_written;
185 #define OFFSET(x) offsetof(LIBSMBContext, x)
186 #define D AV_OPT_FLAG_DECODING_PARAM
187 #define E AV_OPT_FLAG_ENCODING_PARAM
189 {
"timeout",
"set timeout in ms of socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
210 .priv_data_class = &libsmbclient_context_class,
#define URL_PROTOCOL_FLAG_NETWORK
static const AVOption options[]
static void libsmbc_get_auth_data(SMBCCTX *c, const char *server, const char *share, char *workgroup, int workgroup_len, char *username, int username_len, char *password, int password_len)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
static av_cold int libsmbc_connect(URLContext *h)
static av_cold int libsmbc_close(URLContext *h)
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 int64_t libsmbc_seek(URLContext *h, int64_t pos, int whence)
static int libsmbc_write(URLContext *h, const unsigned char *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline av_const double trunc(double x)
static int libsmbc_read(URLContext *h, unsigned char *buf, int size)
Describe the class of an AVClass context structure.
#define AVSEEK_SIZE
Passing this as the "whence" parameter to a seek function causes it to return the filesize without se...
URLProtocol ff_libsmbclient_protocol
static const AVClass libsmbclient_context_class
unbuffered private I/O API
static av_cold int libsmbc_open(URLContext *h, const char *url, int flags)