[FFmpeg-cvslog] avformat/ftp: add AVOptions for authentication

2019-11-03 Thread Nicolas Frattaroli
ffmpeg | branch: master | Nicolas Frattaroli  | Sun Oct 27 
00:37:32 2019 +0200| [a8ec0685ac1cfbeb0e87f47b86d4f0b5cf75d745] | committer: 
Marton Balint

avformat/ftp: add AVOptions for authentication

This introduces two new AVOption options for the FTP protocol,
one named ftp-user to supply the username to be used for auth,
one named ftp-password to supply the password to be used for auth.

These are useful for when an API user does not wish to deal with
URL manipulation and percent encoding.

Setting them while also having credentials in the URL will use the
credentials from the URL. The rationale for this is that credentials
embedded in the URL are probably more specific to what the user is
trying to do than anything set by some API user.

Signed-off-by: Nicolas Frattaroli 
Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a8ec0685ac1cfbeb0e87f47b86d4f0b5cf75d745
---

 doc/protocols.texi|  8 
 libavformat/ftp.c | 21 -
 libavformat/version.h |  2 +-
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b03432e3e5..0e18a49dda 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -228,6 +228,14 @@ Set timeout in microseconds of socket I/O operations used 
by the underlying low
 operation. By default it is set to -1, which means that the timeout is
 not specified.
 
+@item ftp-user
+Set a user to be used for authenticating to the FTP server. This is overridden 
by the
+user in the FTP URL.
+
+@item ftp-password
+Set a password to be used for authenticating to the FTP server. This is 
overridden by
+the password in the FTP URL, or by @option{ftp-anonymous-password} if no user 
is set.
+
 @item ftp-anonymous-password
 Password used when login as anonymous user. Typically an e-mail address
 should be used.
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 3adc04ee1f..97ad80de0b 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -69,6 +69,8 @@ typedef struct {
 size_t dir_buffer_size;
 size_t dir_buffer_offset;
 int utf8;
+const char *option_user; /**< User to be used if none 
given in the URL */
+const char *option_password; /**< Password to be used if 
none given in the URL */
 } FTPContext;
 
 #define OFFSET(x) offsetof(FTPContext, x)
@@ -78,6 +80,8 @@ static const AVOption options[] = {
 {"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
 {"ftp-write-seekable", "control seekability of connection during 
encoding", OFFSET(write_seekable), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
 {"ftp-anonymous-password", "password for anonymous login. E-mail address 
should be used.", OFFSET(anonymous_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, 
D|E },
+{"ftp-user", "user for FTP login. Overridden by whatever is in the URL.", 
OFFSET(option_user), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"ftp-password", "password for FTP login. Overridden by whatever is in the 
URL.", OFFSET(option_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
 {NULL}
 };
 
@@ -652,7 +656,7 @@ static int ftp_abort(URLContext *h)
 
 static int ftp_connect(URLContext *h, const char *url)
 {
-char proto[10], path[MAX_URL_SIZE], credencials[MAX_URL_SIZE], 
hostname[MAX_URL_SIZE];
+char proto[10], path[MAX_URL_SIZE], credentials[MAX_URL_SIZE], 
hostname[MAX_URL_SIZE];
 const char *tok_user = NULL, *tok_pass = NULL;
 char *end = NULL, *newpath = NULL;
 int err;
@@ -665,17 +669,24 @@ static int ftp_connect(URLContext *h, const char *url)
 s->features = NULL;
 
 av_url_split(proto, sizeof(proto),
- credencials, sizeof(credencials),
+ credentials, sizeof(credentials),
  hostname, sizeof(hostname),
  >server_control_port,
  path, sizeof(path),
  url);
 
-tok_user = av_strtok(credencials, ":", );
+tok_user = av_strtok(credentials, ":", );
 tok_pass = av_strtok(end, ":", );
 if (!tok_user) {
-tok_user = "anonymous";
-tok_pass = av_x_if_null(s->anonymous_password, "nopassword");
+if (!s->option_user) {
+tok_user = "anonymous";
+tok_pass = av_x_if_null(s->anonymous_password, "nopassword");
+} else {
+tok_user = s->option_user;
+}
+}
+if (!tok_pass) {
+tok_pass = s->option_password;
 }
 s->user = av_strdup(tok_user);
 s->password = av_strdup(tok_pass);
diff --git a/libavformat/version.h b/libavformat/version.h
index dce5a124c7..a978b34350 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @

[FFmpeg-cvslog] snowenc: fix use of deprecated API

2017-11-03 Thread Nicolas Frattaroli
ffmpeg | branch: master | Nicolas Frattaroli <ffm...@fratti.ch> | Thu Nov  2 
20:12:48 2017 +0100| [6a50a8f340161a0b65feb3537591b0381a6a6b38] | committer: 
Michael Niedermayer

snowenc: fix use of deprecated API

Replace avcodec_get_chroma_sub_sample with the recommended
av_pix_fmt_get_chroma_sub_sample, which fixes a compilation warning.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a50a8f340161a0b65feb3537591b0381a6a6b38
---

 libavcodec/snowenc.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index e7d670ac10..4fec377591 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -22,6 +22,7 @@
 #include "libavutil/libm.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "snow_dwt.h"
@@ -127,7 +128,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx, AV_LOG_ERROR, "pixel format not supported\n");
 return AVERROR_PATCHWELCOME;
 }
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, >chroma_h_shift, 
>chroma_v_shift);
+
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, >chroma_h_shift,
+   >chroma_v_shift);
+if (ret) {
+av_log(avctx, AV_LOG_ERROR, "pixel format invalid or unknown\n");
+return ret;
+}
 
 ff_set_cmp(>mecc, s->mecc.me_cmp, s->avctx->me_cmp);
 ff_set_cmp(>mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] diracdec: fix deprecated API usage

2017-11-02 Thread Nicolas Frattaroli
ffmpeg | branch: master | Nicolas Frattaroli <ffm...@fratti.ch> | Thu Nov  2 
23:39:53 2017 +0100| [1c06a32cfa5798332c1c879834a831e1e12c6f53] | committer: 
James Almer

diracdec: fix deprecated API usage

avcodec_get_chroma_sub_sample is deprecated and generates a warning
during build, so av_pix_fmt_get_chroma_sub_sample is used

Signed-off-by: Nicolas Frattaroli <ffm...@fratti.ch>
Signed-off-by: James Almer <jamr...@gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c06a32cfa5798332c1c879834a831e1e12c6f53
---

 libavcodec/diracdec.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 0abb8b0599..7157357d59 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -26,6 +26,7 @@
  * @author Marco Gerards <ma...@gnu.org>, David Conrad, Jordi Ortiz 
<nenjo...@gmail.com>
  */
 
+#include "libavutil/pixdesc.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
@@ -1927,7 +1928,10 @@ static int get_buffer_with_edge(AVCodecContext *avctx, 
AVFrame *f, int flags)
 {
 int ret, i;
 int chroma_x_shift, chroma_y_shift;
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, _x_shift, 
_y_shift);
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, _x_shift,
+   _y_shift);
+if (ret < 0)
+return ret;
 
 f->width  = avctx->width  + 2 * EDGE_WIDTH;
 f->height = avctx->height + 2 * EDGE_WIDTH + 2;
@@ -2126,7 +2130,11 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, 
const uint8_t *buf, int
 
 s->pshift = s->bit_depth > 8;
 
-avcodec_get_chroma_sub_sample(avctx->pix_fmt, >chroma_x_shift, 
>chroma_y_shift);
+ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
+   >chroma_x_shift,
+   >chroma_y_shift);
+if (ret < 0)
+return ret;
 
 ret = alloc_sequence_buffers(s);
 if (ret < 0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog