diff mbox series

[FFmpeg-devel,v3] avformat/icecast: Add option to use TLS connection

Message ID 20200613225244.64116-1-epirat07@gmail.com
State Accepted
Commit c0c45e238f126a28d91d48ee625a732f6fee1a88
Headers show
Series [FFmpeg-devel,v3] avformat/icecast: Add option to use TLS connection | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Marvin Scholz June 13, 2020, 10:52 p.m. UTC
---
 doc/protocols.texi    | 3 +++
 libavformat/icecast.c | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 14, 2020, 1:42 p.m. UTC | #1
On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
> ---
>  doc/protocols.texi    | 3 +++
>  libavformat/icecast.c | 6 +++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index 7aa758541c..32c829d2a3 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -520,6 +520,9 @@ audio/mpeg.
>  This enables support for Icecast versions < 2.4.0, that do not support the
>  HTTP PUT method but the SOURCE method.
>  
> +@item tls
> +Establish a TLS (HTTPS) connection to Icecast.
> +
>  @end table
>  
>  @example
> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
> index 38af16b99e..b06c53cabd 100644
> --- a/libavformat/icecast.c
> +++ b/libavformat/icecast.c
> @@ -43,6 +43,7 @@ typedef struct IcecastContext {
>      int public;
>      char *url;
>      char *user_agent;
> +    int tls;
>  } IcecastContext;
>  
>  #define DEFAULT_ICE_USER "source"
> @@ -62,6 +63,7 @@ static const AVOption options[] = {
>      { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
>      { "content_type", "set content-type, MUST be set if not audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
>      { "legacy_icecast", "use legacy SOURCE method, for Icecast < v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
> +    { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
>      { NULL }
>  };
>  
> @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const char *uri, int flags)
>      }
>  
>      // Build new URI for passing to http protocol
> -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path);
> +    ff_url_join(h_url, sizeof(h_url),
> +                s->tls ? "https" : "http",
> +                auth, host, port, "%s", path);
>      // Finally open http proto handler
>      ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL,
>                                 &opt_dict, h->protocol_whitelist, h->protocol_blacklist, h);

Is https support common or uncommon for icecast ?
if it is common then changing the default to enabled (in a seperate patch) 
would make sense

the patch should be ok

thx

[...]
Marvin Scholz June 14, 2020, 8:23 p.m. UTC | #2
On 14 Jun 2020, at 15:42, Michael Niedermayer wrote:

> On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
>> ---
>>  doc/protocols.texi    | 3 +++
>>  libavformat/icecast.c | 6 +++++-
>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>> index 7aa758541c..32c829d2a3 100644
>> --- a/doc/protocols.texi
>> +++ b/doc/protocols.texi
>> @@ -520,6 +520,9 @@ audio/mpeg.
>>  This enables support for Icecast versions < 2.4.0, that do not 
>> support the
>>  HTTP PUT method but the SOURCE method.
>>
>> +@item tls
>> +Establish a TLS (HTTPS) connection to Icecast.
>> +
>>  @end table
>>
>>  @example
>> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
>> index 38af16b99e..b06c53cabd 100644
>> --- a/libavformat/icecast.c
>> +++ b/libavformat/icecast.c
>> @@ -43,6 +43,7 @@ typedef struct IcecastContext {
>>      int public;
>>      char *url;
>>      char *user_agent;
>> +    int tls;
>>  } IcecastContext;
>>
>>  #define DEFAULT_ICE_USER "source"
>> @@ -62,6 +63,7 @@ static const AVOption options[] = {
>>      { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING, 
>> { .str = NULL }, 0, 0, E },
>>      { "content_type", "set content-type, MUST be set if not 
>> audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL 
>> }, 0, 0, E },
>>      { "legacy_icecast", "use legacy SOURCE method, for Icecast < 
>> v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
>> E },
>> +    { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL, 
>> { .i64 = 0 }, 0, 1, E },
>>      { NULL }
>>  };
>>
>> @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const char 
>> *uri, int flags)
>>      }
>>
>>      // Build new URI for passing to http protocol
>> -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, 
>> "%s", path);
>> +    ff_url_join(h_url, sizeof(h_url),
>> +                s->tls ? "https" : "http",
>> +                auth, host, port, "%s", path);
>>      // Finally open http proto handler
>>      ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE, 
>> NULL,
>>                                 &opt_dict, h->protocol_whitelist, 
>> h->protocol_blacklist, h);
>
> Is https support common or uncommon for icecast ?
> if it is common then changing the default to enabled (in a seperate 
> patch)
> would make sense
>
> the patch should be ok
>

It's getting more common now but most people are probably still used to
have http enabled for use with source clients as most of the older
ones do not yet support TLS at all.

Ideally it would default to auto-detect but it seems thats not easily 
possible
with how the ffmpeg protocols work.

> thx
>
> [...]
> -- 
> Michael     GnuPG fingerprint: 
> 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Breaking DRM is a little like attempting to break through a door even
> though the window is wide open and the only thing in the house is a 
> bunch
> of things you dont want and which you would get tomorrow for free 
> anyway
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marvin Scholz June 18, 2020, 9:16 p.m. UTC | #3
Ping? Anything else needed to get this merged?

On 14 Jun 2020, at 22:23, Marvin Scholz wrote:

> On 14 Jun 2020, at 15:42, Michael Niedermayer wrote:
>
>> On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
>>> ---
>>>  doc/protocols.texi    | 3 +++
>>>  libavformat/icecast.c | 6 +++++-
>>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>>> index 7aa758541c..32c829d2a3 100644
>>> --- a/doc/protocols.texi
>>> +++ b/doc/protocols.texi
>>> @@ -520,6 +520,9 @@ audio/mpeg.
>>>  This enables support for Icecast versions < 2.4.0, that do not 
>>> support the
>>>  HTTP PUT method but the SOURCE method.
>>>
>>> +@item tls
>>> +Establish a TLS (HTTPS) connection to Icecast.
>>> +
>>>  @end table
>>>
>>>  @example
>>> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
>>> index 38af16b99e..b06c53cabd 100644
>>> --- a/libavformat/icecast.c
>>> +++ b/libavformat/icecast.c
>>> @@ -43,6 +43,7 @@ typedef struct IcecastContext {
>>>      int public;
>>>      char *url;
>>>      char *user_agent;
>>> +    int tls;
>>>  } IcecastContext;
>>>
>>>  #define DEFAULT_ICE_USER "source"
>>> @@ -62,6 +63,7 @@ static const AVOption options[] = {
>>>      { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING, 
>>> { .str = NULL }, 0, 0, E },
>>>      { "content_type", "set content-type, MUST be set if not 
>>> audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL 
>>> }, 0, 0, E },
>>>      { "legacy_icecast", "use legacy SOURCE method, for Icecast < 
>>> v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
>>> E },
>>> +    { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL, 
>>> { .i64 = 0 }, 0, 1, E },
>>>      { NULL }
>>>  };
>>>
>>> @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const 
>>> char *uri, int flags)
>>>      }
>>>
>>>      // Build new URI for passing to http protocol
>>> -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, 
>>> "%s", path);
>>> +    ff_url_join(h_url, sizeof(h_url),
>>> +                s->tls ? "https" : "http",
>>> +                auth, host, port, "%s", path);
>>>      // Finally open http proto handler
>>>      ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE, 
>>> NULL,
>>>                                 &opt_dict, h->protocol_whitelist, 
>>> h->protocol_blacklist, h);
>>
>> Is https support common or uncommon for icecast ?
>> if it is common then changing the default to enabled (in a seperate 
>> patch)
>> would make sense
>>
>> the patch should be ok
>>
>
> It's getting more common now but most people are probably still used 
> to
> have http enabled for use with source clients as most of the older
> ones do not yet support TLS at all.
>
> Ideally it would default to auto-detect but it seems thats not easily 
> possible
> with how the ffmpeg protocols work.
>
>> thx
>>
>> [...]
>> -- 
>> Michael     GnuPG fingerprint: 
>> 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> Breaking DRM is a little like attempting to break through a door even
>> though the window is wide open and the only thing in the house is a 
>> bunch
>> of things you dont want and which you would get tomorrow for free 
>> anyway
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marvin Scholz June 28, 2020, 8:43 p.m. UTC | #4
Ping

On 18 Jun 2020, at 23:16, Marvin Scholz wrote:

> Ping? Anything else needed to get this merged?
>
> On 14 Jun 2020, at 22:23, Marvin Scholz wrote:
>
>> On 14 Jun 2020, at 15:42, Michael Niedermayer wrote:
>>
>>> On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
>>>> ---
>>>>  doc/protocols.texi    | 3 +++
>>>>  libavformat/icecast.c | 6 +++++-
>>>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>>>> index 7aa758541c..32c829d2a3 100644
>>>> --- a/doc/protocols.texi
>>>> +++ b/doc/protocols.texi
>>>> @@ -520,6 +520,9 @@ audio/mpeg.
>>>>  This enables support for Icecast versions < 2.4.0, that do not 
>>>> support the
>>>>  HTTP PUT method but the SOURCE method.
>>>>
>>>> +@item tls
>>>> +Establish a TLS (HTTPS) connection to Icecast.
>>>> +
>>>>  @end table
>>>>
>>>>  @example
>>>> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
>>>> index 38af16b99e..b06c53cabd 100644
>>>> --- a/libavformat/icecast.c
>>>> +++ b/libavformat/icecast.c
>>>> @@ -43,6 +43,7 @@ typedef struct IcecastContext {
>>>>      int public;
>>>>      char *url;
>>>>      char *user_agent;
>>>> +    int tls;
>>>>  } IcecastContext;
>>>>
>>>>  #define DEFAULT_ICE_USER "source"
>>>> @@ -62,6 +63,7 @@ static const AVOption options[] = {
>>>>      { "password", "set password", OFFSET(pass), 
>>>> AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
>>>>      { "content_type", "set content-type, MUST be set if not 
>>>> audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = 
>>>> NULL }, 0, 0, E },
>>>>      { "legacy_icecast", "use legacy SOURCE method, for Icecast < 
>>>> v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 
>>>> 1, E },
>>>> +    { "tls", "use a TLS connection", OFFSET(tls), 
>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
>>>>      { NULL }
>>>>  };
>>>>
>>>> @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const 
>>>> char *uri, int flags)
>>>>      }
>>>>
>>>>      // Build new URI for passing to http protocol
>>>> -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, 
>>>> "%s", path);
>>>> +    ff_url_join(h_url, sizeof(h_url),
>>>> +                s->tls ? "https" : "http",
>>>> +                auth, host, port, "%s", path);
>>>>      // Finally open http proto handler
>>>>      ret = ffurl_open_whitelist(&s->hd, h_url, 
>>>> AVIO_FLAG_READ_WRITE, NULL,
>>>>                                 &opt_dict, h->protocol_whitelist, 
>>>> h->protocol_blacklist, h);
>>>
>>> Is https support common or uncommon for icecast ?
>>> if it is common then changing the default to enabled (in a seperate 
>>> patch)
>>> would make sense
>>>
>>> the patch should be ok
>>>
>>
>> It's getting more common now but most people are probably still used 
>> to
>> have http enabled for use with source clients as most of the older
>> ones do not yet support TLS at all.
>>
>> Ideally it would default to auto-detect but it seems thats not easily 
>> possible
>> with how the ffmpeg protocols work.
>>
>>> thx
>>>
>>> [...]
>>> -- 
>>> Michael     GnuPG fingerprint: 
>>> 9FF2128B147EF6730BADF133611EC787040B0FAB
>>>
>>> Breaking DRM is a little like attempting to break through a door 
>>> even
>>> though the window is wide open and the only thing in the house is a 
>>> bunch
>>> of things you dont want and which you would get tomorrow for free 
>>> anyway
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marvin Scholz July 1, 2020, 11:22 p.m. UTC | #5
Ping for merge, again :)

On 28 Jun 2020, at 22:43, Marvin Scholz wrote:

> Ping
>
> On 18 Jun 2020, at 23:16, Marvin Scholz wrote:
>
>> Ping? Anything else needed to get this merged?
>>
>> On 14 Jun 2020, at 22:23, Marvin Scholz wrote:
>>
>>> On 14 Jun 2020, at 15:42, Michael Niedermayer wrote:
>>>
>>>> On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
>>>>> ---
>>>>>  doc/protocols.texi    | 3 +++
>>>>>  libavformat/icecast.c | 6 +++++-
>>>>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/doc/protocols.texi b/doc/protocols.texi
>>>>> index 7aa758541c..32c829d2a3 100644
>>>>> --- a/doc/protocols.texi
>>>>> +++ b/doc/protocols.texi
>>>>> @@ -520,6 +520,9 @@ audio/mpeg.
>>>>>  This enables support for Icecast versions < 2.4.0, that do not 
>>>>> support the
>>>>>  HTTP PUT method but the SOURCE method.
>>>>>
>>>>> +@item tls
>>>>> +Establish a TLS (HTTPS) connection to Icecast.
>>>>> +
>>>>>  @end table
>>>>>
>>>>>  @example
>>>>> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
>>>>> index 38af16b99e..b06c53cabd 100644
>>>>> --- a/libavformat/icecast.c
>>>>> +++ b/libavformat/icecast.c
>>>>> @@ -43,6 +43,7 @@ typedef struct IcecastContext {
>>>>>      int public;
>>>>>      char *url;
>>>>>      char *user_agent;
>>>>> +    int tls;
>>>>>  } IcecastContext;
>>>>>
>>>>>  #define DEFAULT_ICE_USER "source"
>>>>> @@ -62,6 +63,7 @@ static const AVOption options[] = {
>>>>>      { "password", "set password", OFFSET(pass), 
>>>>> AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
>>>>>      { "content_type", "set content-type, MUST be set if not 
>>>>> audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = 
>>>>> NULL }, 0, 0, E },
>>>>>      { "legacy_icecast", "use legacy SOURCE method, for Icecast < 
>>>>> v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 
>>>>> 1, E },
>>>>> +    { "tls", "use a TLS connection", OFFSET(tls), 
>>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
>>>>>      { NULL }
>>>>>  };
>>>>>
>>>>> @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const 
>>>>> char *uri, int flags)
>>>>>      }
>>>>>
>>>>>      // Build new URI for passing to http protocol
>>>>> -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, 
>>>>> "%s", path);
>>>>> +    ff_url_join(h_url, sizeof(h_url),
>>>>> +                s->tls ? "https" : "http",
>>>>> +                auth, host, port, "%s", path);
>>>>>      // Finally open http proto handler
>>>>>      ret = ffurl_open_whitelist(&s->hd, h_url, 
>>>>> AVIO_FLAG_READ_WRITE, NULL,
>>>>>                                 &opt_dict, h->protocol_whitelist, 
>>>>> h->protocol_blacklist, h);
>>>>
>>>> Is https support common or uncommon for icecast ?
>>>> if it is common then changing the default to enabled (in a seperate 
>>>> patch)
>>>> would make sense
>>>>
>>>> the patch should be ok
>>>>
>>>
>>> It's getting more common now but most people are probably still used 
>>> to
>>> have http enabled for use with source clients as most of the older
>>> ones do not yet support TLS at all.
>>>
>>> Ideally it would default to auto-detect but it seems thats not 
>>> easily possible
>>> with how the ffmpeg protocols work.
>>>
>>>> thx
>>>>
>>>> [...]
>>>> -- 
>>>> Michael     GnuPG fingerprint: 
>>>> 9FF2128B147EF6730BADF133611EC787040B0FAB
>>>>
>>>> Breaking DRM is a little like attempting to break through a door 
>>>> even
>>>> though the window is wide open and the only thing in the house is a 
>>>> bunch
>>>> of things you dont want and which you would get tomorrow for free 
>>>> anyway
>>>> _______________________________________________
>>>> ffmpeg-devel mailing list
>>>> ffmpeg-devel@ffmpeg.org
>>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>> To unsubscribe, visit link above, or email
>>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer July 2, 2020, 3:10 p.m. UTC | #6
On Sun, Jun 14, 2020 at 10:23:40PM +0200, Marvin Scholz wrote:
> On 14 Jun 2020, at 15:42, Michael Niedermayer wrote:
> 
> > On Sun, Jun 14, 2020 at 12:52:44AM +0200, Marvin Scholz wrote:
> > > ---
> > >  doc/protocols.texi    | 3 +++
> > >  libavformat/icecast.c | 6 +++++-
> > >  2 files changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > > index 7aa758541c..32c829d2a3 100644
> > > --- a/doc/protocols.texi
> > > +++ b/doc/protocols.texi
> > > @@ -520,6 +520,9 @@ audio/mpeg.
> > >  This enables support for Icecast versions < 2.4.0, that do not
> > > support the
> > >  HTTP PUT method but the SOURCE method.
> > > 
> > > +@item tls
> > > +Establish a TLS (HTTPS) connection to Icecast.
> > > +
> > >  @end table
> > > 
> > >  @example
> > > diff --git a/libavformat/icecast.c b/libavformat/icecast.c
> > > index 38af16b99e..b06c53cabd 100644
> > > --- a/libavformat/icecast.c
> > > +++ b/libavformat/icecast.c
> > > @@ -43,6 +43,7 @@ typedef struct IcecastContext {
> > >      int public;
> > >      char *url;
> > >      char *user_agent;
> > > +    int tls;
> > >  } IcecastContext;
> > > 
> > >  #define DEFAULT_ICE_USER "source"
> > > @@ -62,6 +63,7 @@ static const AVOption options[] = {
> > >      { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING,
> > > { .str = NULL }, 0, 0, E },
> > >      { "content_type", "set content-type, MUST be set if not
> > > audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL
> > > }, 0, 0, E },
> > >      { "legacy_icecast", "use legacy SOURCE method, for Icecast <
> > > v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
> > > E },
> > > +    { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL,
> > > { .i64 = 0 }, 0, 1, E },
> > >      { NULL }
> > >  };
> > > 
> > > @@ -162,7 +164,9 @@ static int icecast_open(URLContext *h, const
> > > char *uri, int flags)
> > >      }
> > > 
> > >      // Build new URI for passing to http protocol
> > > -    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port,
> > > "%s", path);
> > > +    ff_url_join(h_url, sizeof(h_url),
> > > +                s->tls ? "https" : "http",
> > > +                auth, host, port, "%s", path);
> > >      // Finally open http proto handler
> > >      ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE,
> > > NULL,
> > >                                 &opt_dict, h->protocol_whitelist,
> > > h->protocol_blacklist, h);
> > 
> > Is https support common or uncommon for icecast ?
> > if it is common then changing the default to enabled (in a seperate
> > patch)
> > would make sense
> > 
> > the patch should be ok
> > 
> 
> It's getting more common now but most people are probably still used to
> have http enabled for use with source clients as most of the older
> ones do not yet support TLS at all.
> 
> Ideally it would default to auto-detect but it seems thats not easily
> possible
> with how the ffmpeg protocols work.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 7aa758541c..32c829d2a3 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -520,6 +520,9 @@  audio/mpeg.
 This enables support for Icecast versions < 2.4.0, that do not support the
 HTTP PUT method but the SOURCE method.
 
+@item tls
+Establish a TLS (HTTPS) connection to Icecast.
+
 @end table
 
 @example
diff --git a/libavformat/icecast.c b/libavformat/icecast.c
index 38af16b99e..b06c53cabd 100644
--- a/libavformat/icecast.c
+++ b/libavformat/icecast.c
@@ -43,6 +43,7 @@  typedef struct IcecastContext {
     int public;
     char *url;
     char *user_agent;
+    int tls;
 } IcecastContext;
 
 #define DEFAULT_ICE_USER "source"
@@ -62,6 +63,7 @@  static const AVOption options[] = {
     { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
     { "content_type", "set content-type, MUST be set if not audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
     { "legacy_icecast", "use legacy SOURCE method, for Icecast < v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
+    { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
     { NULL }
 };
 
@@ -162,7 +164,9 @@  static int icecast_open(URLContext *h, const char *uri, int flags)
     }
 
     // Build new URI for passing to http protocol
-    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path);
+    ff_url_join(h_url, sizeof(h_url),
+                s->tls ? "https" : "http",
+                auth, host, port, "%s", path);
     // Finally open http proto handler
     ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL,
                                &opt_dict, h->protocol_whitelist, h->protocol_blacklist, h);