Go to the documentation of this file.
23 #include <libssh/sftp.h>
46 static const int verbosity = SSH_LOG_NOLOG;
48 if (!(libssh->
session = ssh_new())) {
52 ssh_options_set(libssh->
session, SSH_OPTIONS_HOST, hostname);
53 ssh_options_set(libssh->
session, SSH_OPTIONS_PORT, &port);
54 ssh_options_set(libssh->
session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
57 ssh_options_set(libssh->
session, SSH_OPTIONS_TIMEOUT_USEC, &timeout);
60 if (ssh_options_parse_config(libssh->
session,
NULL) < 0) {
64 if (ssh_connect(libssh->
session) != SSH_OK) {
78 ssh_options_set(libssh->
session, SSH_OPTIONS_USER, user);
80 if (ssh_userauth_none(libssh->
session,
NULL) == SSH_AUTH_SUCCESS)
83 auth_methods = ssh_userauth_list(libssh->
session,
NULL);
85 if (auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
88 ssh_private_key priv_key;
92 if (ssh_userauth_pubkey(libssh->
session,
NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {
93 av_log(libssh,
AV_LOG_DEBUG,
"Authentication successful with selected private key.\n");
100 }
else if (ssh_userauth_autopubkey(libssh->
session, password) == SSH_AUTH_SUCCESS) {
106 if (!authorized && password && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
107 if (ssh_userauth_password(libssh->
session,
NULL, password) == SSH_AUTH_SUCCESS) {
128 if (sftp_init(libssh->
sftp) != SSH_OK) {
141 access = O_CREAT | O_RDWR;
145 access = O_CREAT | O_WRONLY;
152 if (!(libssh->
file = sftp_open(libssh->
sftp, file, access, 0666))) {
162 sftp_attributes stat;
164 if (!(stat = sftp_fstat(libssh->
file))) {
169 sftp_attributes_free(stat);
177 sftp_close(libssh->
file);
181 sftp_free(libssh->
sftp);
185 ssh_disconnect(libssh->
session);
195 char proto[10], hostname[1024], credencials[1024];
201 credencials,
sizeof(credencials),
202 hostname,
sizeof(hostname),
211 if (port < 0 || port > 65535)
267 newpos = sftp_tell64(libssh->
file) + pos;
281 if (sftp_seek64(libssh->
file, newpos)) {
294 if ((bytes_read = sftp_read(libssh->
file,
buf,
size)) < 0) {
306 if ((bytes_written = sftp_write(libssh->
file,
buf,
size)) < 0) {
310 return bytes_written;
322 if (!(libssh->
dir = sftp_opendir(libssh->
sftp, path))) {
338 sftp_attributes attr =
NULL;
347 sftp_attributes_free(attr);
348 attr = sftp_readdir(libssh->
sftp, libssh->
dir);
351 if (sftp_dir_eof(libssh->
dir))
355 }
while (!strcmp(attr->name,
".") || !strcmp(attr->name,
".."));
360 entry->
size = attr->size;
363 entry->
filemode = attr->permissions & 0777;
365 case SSH_FILEXFER_TYPE_REGULAR:
368 case SSH_FILEXFER_TYPE_DIRECTORY:
371 case SSH_FILEXFER_TYPE_SYMLINK:
374 case SSH_FILEXFER_TYPE_SPECIAL:
377 case SSH_FILEXFER_TYPE_UNKNOWN:
381 sftp_attributes_free(attr);
389 sftp_closedir(libssh->
dir);
399 sftp_attributes attr =
NULL;
405 if (!(attr = sftp_stat(libssh->
sftp, path))) {
410 if (attr->type == SSH_FILEXFER_TYPE_DIRECTORY) {
411 if (sftp_rmdir(libssh->
sftp, path) < 0) {
416 if (sftp_unlink(libssh->
sftp, path) < 0) {
426 sftp_attributes_free(attr);
436 char hostname_src[1024], hostname_dst[1024];
437 char credentials_src[1024], credentials_dst[1024];
438 int port_src = 22, port_dst = 22;
441 credentials_src,
sizeof(credentials_src),
442 hostname_src,
sizeof(hostname_src),
444 path_src,
sizeof(path_src),
448 credentials_dst,
sizeof(credentials_dst),
449 hostname_dst,
sizeof(hostname_dst),
451 path_dst,
sizeof(path_dst),
454 if (strcmp(credentials_src, credentials_dst) ||
455 strcmp(hostname_src, hostname_dst) ||
456 port_src != port_dst) {
463 if (sftp_rename(libssh->
sftp, path_src, path_dst) < 0) {
475 #define OFFSET(x) offsetof(LIBSSHContext, x)
476 #define D AV_OPT_FLAG_DECODING_PARAM
477 #define E AV_OPT_FLAG_ENCODING_PARAM
479 {
"timeout",
"set timeout of socket I/O operations",
OFFSET(rw_timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold void libssh_stat_file(LIBSSHContext *libssh)
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
char * filename
specified URL
#define URL_PROTOCOL_FLAG_NETWORK
#define AVERROR_EOF
End of file.
static int64_t libssh_seek(URLContext *h, int64_t pos, int whence)
static av_cold int end(AVCodecContext *avctx)
static av_cold void cleanup(FlashSV2Context *s)
int type
Type of the entry.
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
static av_cold int libssh_open(URLContext *h, const char *url, int flags)
static int libssh_delete(URLContext *h)
static int libssh_move(URLContext *h_src, URLContext *h_dst)
int64_t access_timestamp
Time of last access in microseconds since unix epoch, -1 if unknown.
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
int64_t modification_timestamp
Time of last modification in microseconds since unix epoch, -1 if unknown.
static int libssh_open_dir(URLContext *h)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AVIO_ENTRY_SYMBOLIC_LINK
static av_cold int libssh_open_file(LIBSSHContext *libssh, int flags, const char *file)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
#define AVIO_FLAG_WRITE
write-only
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int libssh_close_dir(URLContext *h)
static av_cold int libssh_close(URLContext *h)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int libssh_read(URLContext *h, unsigned char *buf, int size)
static av_cold int libssh_connect(URLContext *h, const char *url, char *path, size_t path_size)
int64_t size
File size in bytes, -1 if unknown.
const char * av_default_item_name(void *ptr)
Return the context name.
int64_t group_id
Group ID of owner, -1 if unknown.
static av_always_inline av_const double trunc(double x)
int64_t filemode
Unix file mode, -1 if unknown.
static av_cold int libssh_create_sftp_session(LIBSSHContext *libssh)
static const AVOption options[]
static int libssh_read_dir(URLContext *h, AVIODirEntry **next)
static av_cold int libssh_create_ssh_session(LIBSSHContext *libssh, const char *hostname, unsigned int port)
Describes single entry of the directory.
int64_t user_id
User ID of owner, -1 if unknown.
AVIODirEntry * ff_alloc_dir_entry(void)
Allocate directory entry with default values.
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
const URLProtocol ff_libssh_protocol
static const AVClass libssh_context_class
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 av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password)
static int libssh_write(URLContext *h, const unsigned char *buf, int size)
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
#define flags(name, subs,...)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.