Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Ross Nicholson


> On 19 Apr 2020, at 20:30, Carl Eugen Hoyos  wrote:
> 
> Am So., 19. Apr. 2020 um 20:45 Uhr schrieb Ross Nicholson
> :
>> 
>> That’s really strange all my git config’s are just phunkyfish.
>> 
>> I don’t really mind which name is used but I guess I’ll update
>> everything to my real name going forward now that you mention it.
> 
> It is completely your decision which "name" you choose for
> your commits (invented or real) but please avoid top-posting
> on all FFmpeg mailing lists.
> 
> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Apologies Carl.

I only just learned what top-posting is. Won’t happen again.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Carl Eugen Hoyos
Am So., 19. Apr. 2020 um 19:55 Uhr schrieb Jean-Baptiste Kempf
:
>
> On Sun, Apr 19, 2020, at 16:28, Ross Nicholson wrote:
> > How do you mean? What’s that problem?
>
> You've used Ross Nicholson  for committing

It looks to me as if he has not done that.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Carl Eugen Hoyos
Am So., 19. Apr. 2020 um 20:45 Uhr schrieb Ross Nicholson
:
>
> That’s really strange all my git config’s are just phunkyfish.
>
> I don’t really mind which name is used but I guess I’ll update
> everything to my real name going forward now that you mention it.

It is completely your decision which "name" you choose for
your commits (invented or real) but please avoid top-posting
on all FFmpeg mailing lists.


Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Ross Nicholson
That’s really strange all my git config’s are just phunkyfish. 

I don’t really mind which name is used but I guess I’ll update everything to my 
real name going forward now that you mention it.

> On 19 Apr 2020, at 18:55, Jean-Baptiste Kempf  wrote:
> 
> On Sun, Apr 19, 2020, at 16:28, Ross Nicholson wrote:
>> How do you mean? What’s that problem?
> 
> You've used Ross Nicholson  for committing, and now you 
> only use 
> phunkyfish .
> 
> Since you are not anonymous, why not use your actual name?
> 
> 
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Jean-Baptiste Kempf
On Sun, Apr 19, 2020, at 16:28, Ross Nicholson wrote:
> How do you mean? What’s that problem?

You've used Ross Nicholson  for committing, and now you 
only use 
phunkyfish .

Since you are not anonymous, why not use your actual name?


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Carl Eugen Hoyos
Am So., 19. Apr. 2020 um 17:33 Uhr schrieb Ross Nicholson
:
>
> How do you mean? What’s that problem?
>
> I generally just use phunkyfish as the name and it’s corresponding gmail 
> address for stuff.
>
> Do you require my real name for git?

No, absolutely not.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Ross Nicholson
How do you mean? What’s that problem?

I generally just use phunkyfish as the name and it’s corresponding gmail 
address for stuff.

Do you require my real name for git?

> On 19 Apr 2020, at 14:23, Jean-Baptiste Kempf  wrote:
> 
> Ross,
> 
> Could you, please, fix your git email and name?
> 
> Thanks
> 
>> On Fri, Apr 17, 2020, at 13:07, Ross Nicholson wrote:
>> Ping
>> 
 On 15 Apr 2020, at 17:21, Ross Nicholson  wrote:
>>> 
>>> 
>>> Ping to hopefully apply this patch!
>>> 
> On 12 Apr 2020, at 16:54, Ross Nicholson  wrote:
> 
 
 User testing has been completed successfully so this is ready to be 
 applied.
 
 Thanks 
 
>> On 7 Apr 2020, at 23:50, Ross Nicholson  wrote:
>> 
> 
> Thank you for the explanation Marton. It's make perfect sense to me know. 
> So UNLIMITED would be the right choice here.
> 
> All of your other comments are addressed in the latest version. Thanks 
> again for reviewing.
> 
>> On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:
>> 
>> 
>> On Tue, 7 Apr 2020, Ross Nicholson wrote:
>> 
>>> Great, thanks again. 
>>> 
>>> A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for 
>>> when to use this versus unlimited?
>>> 
>>> Or is it that generally if you would have used a buffer of 1000 or less 
>>> automatic is the right choice?
>> 
>> It depends on what you want. With AUTOMATIC you limit length to 1000 
>> chars 
>> but you don't have to free the buffer. Otherwise you are not limiting 
>> the 
>> buffer size, but you have to free it. So if it is impossible to hit the 
>> limit, you should always use AUTOMATIC.
>> 
>> In this case you have to decide for yourself which to use, because I 
>> don't 
>> know if 1000 char buffer is big enough for the possible use cases. I 
>> only suggested to consider it, because you are using limited buffers for 
>> other strings, so it may not even be possible to outgrow 1000 chars. It 
>> is 
>> up to you decide depending on what you want to support.
>> 
>> Regards,
>> Marton
>> 
>>> 
 On 7 Apr 2020, at 20:50, Marton Balint  wrote:
 
 
 
> On Tue, 7 Apr 2020, phunkyfish wrote:
> 
> ---
> libavformat/rtsp.c | 48 +-
> 1 file changed, 39 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..dad3f7915e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -21,6 +21,7 @@
> #include "libavutil/avassert.h"
> #include "libavutil/base64.h"
> +#include "libavutil/bprint.h"
> #include "libavutil/avstring.h"
> #include "libavutil/intreadwrite.h"
> #include "libavutil/mathematics.h"
> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
> static int rtp_read_header(AVFormatContext *s)
> {
>   uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> +char host[500], filters_buf[1000];
>   int ret, port;
>   URLContext* in = NULL;
>   int payload_type;
> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>   AVIOContext pb;
>   socklen_t addrlen = sizeof(addr);
>   RTSPState *rt = s->priv_data;
> +const char *p;
> +AVBPrint sdp;
> 
>   if (!ff_network_init())
>   return AVERROR(EIO);
> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
>   av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>NULL, 0, s->url);
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : 
> "audio",
> - port, payload_type);
> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
 
 You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a 
 static buffer which will be limited (roughly 1000 chars) but you don't 
 have to free it with av_bprint_finalize().
 
> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
> +   addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, 
> {"block", "excl"}, {NULL, NULL}};
> +int i;
> +char 

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Jean-Baptiste Kempf
Ross,

Could you, please, fix your git email and name?

Thanks

On Fri, Apr 17, 2020, at 13:07, Ross Nicholson wrote:
> Ping
> 
> > On 15 Apr 2020, at 17:21, Ross Nicholson  wrote:
> > 
> > 
> > Ping to hopefully apply this patch!
> > 
> >>> On 12 Apr 2020, at 16:54, Ross Nicholson  wrote:
> >>> 
> >> 
> >> User testing has been completed successfully so this is ready to be 
> >> applied.
> >> 
> >> Thanks 
> >> 
>  On 7 Apr 2020, at 23:50, Ross Nicholson  wrote:
>  
> >>> 
> >>> Thank you for the explanation Marton. It's make perfect sense to me know. 
> >>> So UNLIMITED would be the right choice here.
> >>> 
> >>> All of your other comments are addressed in the latest version. Thanks 
> >>> again for reviewing.
> >>> 
>  On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:
>  
>  
>  On Tue, 7 Apr 2020, Ross Nicholson wrote:
>  
>  > Great, thanks again. 
>  >
>  > A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for 
>  > when to use this versus unlimited?
>  >
>  > Or is it that generally if you would have used a buffer of 1000 or 
>  > less automatic is the right choice?
>  
>  It depends on what you want. With AUTOMATIC you limit length to 1000 
>  chars 
>  but you don't have to free the buffer. Otherwise you are not limiting 
>  the 
>  buffer size, but you have to free it. So if it is impossible to hit the 
>  limit, you should always use AUTOMATIC.
>  
>  In this case you have to decide for yourself which to use, because I 
>  don't 
>  know if 1000 char buffer is big enough for the possible use cases. I 
>  only suggested to consider it, because you are using limited buffers for 
>  other strings, so it may not even be possible to outgrow 1000 chars. It 
>  is 
>  up to you decide depending on what you want to support.
>  
>  Regards,
>  Marton
>  
>  >
>  >> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
>  >> 
>  >> 
>  >> 
>  >>> On Tue, 7 Apr 2020, phunkyfish wrote:
>  >>> 
>  >>> ---
>  >>> libavformat/rtsp.c | 48 
>  >>> +-
>  >>> 1 file changed, 39 insertions(+), 9 deletions(-)
>  >>> 
>  >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>  >>> index cd6fc32a29..dad3f7915e 100644
>  >>> --- a/libavformat/rtsp.c
>  >>> +++ b/libavformat/rtsp.c
>  >>> @@ -21,6 +21,7 @@
>  >>> #include "libavutil/avassert.h"
>  >>> #include "libavutil/base64.h"
>  >>> +#include "libavutil/bprint.h"
>  >>> #include "libavutil/avstring.h"
>  >>> #include "libavutil/intreadwrite.h"
>  >>> #include "libavutil/mathematics.h"
>  >>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>  >>> static int rtp_read_header(AVFormatContext *s)
>  >>> {
>  >>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
>  >>> -char host[500], sdp[500];
>  >>> +char host[500], filters_buf[1000];
>  >>>int ret, port;
>  >>>URLContext* in = NULL;
>  >>>int payload_type;
>  >>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>  >>>AVIOContext pb;
>  >>>socklen_t addrlen = sizeof(addr);
>  >>>RTSPState *rt = s->priv_data;
>  >>> +const char *p;
>  >>> +AVBPrint sdp;
>  >>>
>  >>>if (!ff_network_init())
>  >>>return AVERROR(EIO);
>  >>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext 
>  >>> *s)
>  >>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>  >>> NULL, 0, s->url);
>  >>> -snprintf(sdp, sizeof(sdp),
>  >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
>  >>> - addr.ss_family == AF_INET ? 4 : 6, host,
>  >>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>  >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : 
>  >>> "audio",
>  >>> - port, payload_type);
>  >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>  >>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
>  >> 
>  >> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get 
>  >> a static buffer which will be limited (roughly 1000 chars) but you 
>  >> don't have to free it with av_bprint_finalize().
>  >> 
>  >>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
>  >>> +   addr.ss_family == AF_INET ? 4 : 6, host);
>  >>> +
>  >>> +p = strchr(s->url, '?');
>  >>> +if (p) {
>  >>> +static const char *filters[][2] = {{"sources", "incl"}, 
>  >>> {"block", "excl"}, {NULL, NULL}};
>  >>> +int i;
>  >>> +char *q;
>  >>> +for (i = 0; filters[i][0]; i++) {
>  >>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
>  

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-19 Thread Marton Balint



On Tue, 7 Apr 2020, phunkyfish wrote:


---
libavformat/rtsp.c | 48 +-
1 file changed, 39 insertions(+), 9 deletions(-)


Thanks, applied.

Regards,
Marton



diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..07ac371903 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@

#include "libavutil/avassert.h"
#include "libavutil/base64.h"
+#include "libavutil/bprint.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
static int rtp_read_header(AVFormatContext *s)
{
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
int ret, port;
URLContext* in = NULL;
int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
AVIOContext pb;
socklen_t addrlen = sizeof(addr);
RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;

if (!ff_network_init())
return AVERROR(EIO);
@@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
 NULL, 0, s->url);

-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (!av_bprint_is_complete())
+goto fail_nobuf;
avcodec_parameters_free();

-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, sdp.len, 0, NULL, NULL, NULL, NULL);
s->pb = 

/* sdp_read_header initializes this again */
@@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)

ret = sdp_read_header(s);
s->pb = NULL;
+av_bprint_finalize(, NULL);
return ret;

+fail_nobuf:
+ret = AVERROR(ENOMEM);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
fail:
+av_bprint_finalize(, NULL);
avcodec_parameters_free();
if (in)
ffurl_close(in);
--
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-17 Thread Ross Nicholson
Ping

> On 15 Apr 2020, at 17:21, Ross Nicholson  wrote:
> 
> 
> Ping to hopefully apply this patch!
> 
>>> On 12 Apr 2020, at 16:54, Ross Nicholson  wrote:
>>> 
>> 
>> User testing has been completed successfully so this is ready to be applied.
>> 
>> Thanks 
>> 
 On 7 Apr 2020, at 23:50, Ross Nicholson  wrote:
 
>>> 
>>> Thank you for the explanation Marton. It's make perfect sense to me know. 
>>> So UNLIMITED would be the right choice here.
>>> 
>>> All of your other comments are addressed in the latest version. Thanks 
>>> again for reviewing.
>>> 
 On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:
 
 
 On Tue, 7 Apr 2020, Ross Nicholson wrote:
 
 > Great, thanks again. 
 >
 > A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when 
 > to use this versus unlimited?
 >
 > Or is it that generally if you would have used a buffer of 1000 or less 
 > automatic is the right choice?
 
 It depends on what you want. With AUTOMATIC you limit length to 1000 chars 
 but you don't have to free the buffer. Otherwise you are not limiting the 
 buffer size, but you have to free it. So if it is impossible to hit the 
 limit, you should always use AUTOMATIC.
 
 In this case you have to decide for yourself which to use, because I don't 
 know if 1000 char buffer is big enough for the possible use cases. I 
 only suggested to consider it, because you are using limited buffers for 
 other strings, so it may not even be possible to outgrow 1000 chars. It is 
 up to you decide depending on what you want to support.
 
 Regards,
 Marton
 
 >
 >> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
 >> 
 >> 
 >> 
 >>> On Tue, 7 Apr 2020, phunkyfish wrote:
 >>> 
 >>> ---
 >>> libavformat/rtsp.c | 48 +-
 >>> 1 file changed, 39 insertions(+), 9 deletions(-)
 >>> 
 >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
 >>> index cd6fc32a29..dad3f7915e 100644
 >>> --- a/libavformat/rtsp.c
 >>> +++ b/libavformat/rtsp.c
 >>> @@ -21,6 +21,7 @@
 >>> #include "libavutil/avassert.h"
 >>> #include "libavutil/base64.h"
 >>> +#include "libavutil/bprint.h"
 >>> #include "libavutil/avstring.h"
 >>> #include "libavutil/intreadwrite.h"
 >>> #include "libavutil/mathematics.h"
 >>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
 >>> static int rtp_read_header(AVFormatContext *s)
 >>> {
 >>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
 >>> -char host[500], sdp[500];
 >>> +char host[500], filters_buf[1000];
 >>>int ret, port;
 >>>URLContext* in = NULL;
 >>>int payload_type;
 >>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
 >>>AVIOContext pb;
 >>>socklen_t addrlen = sizeof(addr);
 >>>RTSPState *rt = s->priv_data;
 >>> +const char *p;
 >>> +AVBPrint sdp;
 >>>
 >>>if (!ff_network_init())
 >>>return AVERROR(EIO);
 >>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
 >>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
 >>> NULL, 0, s->url);
 >>> -snprintf(sdp, sizeof(sdp),
 >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
 >>> - addr.ss_family == AF_INET ? 4 : 6, host,
 >>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
 >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : 
 >>> "audio",
 >>> - port, payload_type);
 >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 >>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
 >> 
 >> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a 
 >> static buffer which will be limited (roughly 1000 chars) but you don't 
 >> have to free it with av_bprint_finalize().
 >> 
 >>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
 >>> +   addr.ss_family == AF_INET ? 4 : 6, host);
 >>> +
 >>> +p = strchr(s->url, '?');
 >>> +if (p) {
 >>> +static const char *filters[][2] = {{"sources", "incl"}, 
 >>> {"block", "excl"}, {NULL, NULL}};
 >>> +int i;
 >>> +char *q;
 >>> +for (i = 0; filters[i][0]; i++) {
 >>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
 >>> filters[i][0], p)) {
 >>> +q = filters_buf;
 >>> +while ((q = strchr(q, ',')) != NULL)
 >>> +*q = ' ';
 >>> +av_bprintf(, "a=source-filter:%s IN IP%d %s 
 >>> %s\r\n",
 >>> +   filters[i][1],
 >>> +   addr.ss_family == AF_INET ? 4 : 6, host,
 >>> + 

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-15 Thread Ross Nicholson
Ping to hopefully apply this patch!

> On 12 Apr 2020, at 16:54, Ross Nicholson  wrote:
> 
> 
> User testing has been completed successfully so this is ready to be applied.
> 
> Thanks 
> 
>>> On 7 Apr 2020, at 23:50, Ross Nicholson  wrote:
>>> 
>> 
>> Thank you for the explanation Marton. It's make perfect sense to me know. So 
>> UNLIMITED would be the right choice here.
>> 
>> All of your other comments are addressed in the latest version. Thanks again 
>> for reviewing.
>> 
>>> On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:
>>> 
>>> 
>>> On Tue, 7 Apr 2020, Ross Nicholson wrote:
>>> 
>>> > Great, thanks again. 
>>> >
>>> > A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when 
>>> > to use this versus unlimited?
>>> >
>>> > Or is it that generally if you would have used a buffer of 1000 or less 
>>> > automatic is the right choice?
>>> 
>>> It depends on what you want. With AUTOMATIC you limit length to 1000 chars 
>>> but you don't have to free the buffer. Otherwise you are not limiting the 
>>> buffer size, but you have to free it. So if it is impossible to hit the 
>>> limit, you should always use AUTOMATIC.
>>> 
>>> In this case you have to decide for yourself which to use, because I don't 
>>> know if 1000 char buffer is big enough for the possible use cases. I 
>>> only suggested to consider it, because you are using limited buffers for 
>>> other strings, so it may not even be possible to outgrow 1000 chars. It is 
>>> up to you decide depending on what you want to support.
>>> 
>>> Regards,
>>> Marton
>>> 
>>> >
>>> >> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
>>> >> 
>>> >> 
>>> >> 
>>> >>> On Tue, 7 Apr 2020, phunkyfish wrote:
>>> >>> 
>>> >>> ---
>>> >>> libavformat/rtsp.c | 48 +-
>>> >>> 1 file changed, 39 insertions(+), 9 deletions(-)
>>> >>> 
>>> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>>> >>> index cd6fc32a29..dad3f7915e 100644
>>> >>> --- a/libavformat/rtsp.c
>>> >>> +++ b/libavformat/rtsp.c
>>> >>> @@ -21,6 +21,7 @@
>>> >>> #include "libavutil/avassert.h"
>>> >>> #include "libavutil/base64.h"
>>> >>> +#include "libavutil/bprint.h"
>>> >>> #include "libavutil/avstring.h"
>>> >>> #include "libavutil/intreadwrite.h"
>>> >>> #include "libavutil/mathematics.h"
>>> >>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>>> >>> static int rtp_read_header(AVFormatContext *s)
>>> >>> {
>>> >>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
>>> >>> -char host[500], sdp[500];
>>> >>> +char host[500], filters_buf[1000];
>>> >>>int ret, port;
>>> >>>URLContext* in = NULL;
>>> >>>int payload_type;
>>> >>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>>> >>>AVIOContext pb;
>>> >>>socklen_t addrlen = sizeof(addr);
>>> >>>RTSPState *rt = s->priv_data;
>>> >>> +const char *p;
>>> >>> +AVBPrint sdp;
>>> >>>
>>> >>>if (!ff_network_init())
>>> >>>return AVERROR(EIO);
>>> >>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
>>> >>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>>> >>> NULL, 0, s->url);
>>> >>> -snprintf(sdp, sizeof(sdp),
>>> >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
>>> >>> - addr.ss_family == AF_INET ? 4 : 6, host,
>>> >>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>>> >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
>>> >>> - port, payload_type);
>>> >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>>> >>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
>>> >> 
>>> >> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a 
>>> >> static buffer which will be limited (roughly 1000 chars) but you don't 
>>> >> have to free it with av_bprint_finalize().
>>> >> 
>>> >>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
>>> >>> +   addr.ss_family == AF_INET ? 4 : 6, host);
>>> >>> +
>>> >>> +p = strchr(s->url, '?');
>>> >>> +if (p) {
>>> >>> +static const char *filters[][2] = {{"sources", "incl"}, 
>>> >>> {"block", "excl"}, {NULL, NULL}};
>>> >>> +int i;
>>> >>> +char *q;
>>> >>> +for (i = 0; filters[i][0]; i++) {
>>> >>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
>>> >>> filters[i][0], p)) {
>>> >>> +q = filters_buf;
>>> >>> +while ((q = strchr(q, ',')) != NULL)
>>> >>> +*q = ' ';
>>> >>> +av_bprintf(, "a=source-filter:%s IN IP%d %s 
>>> >>> %s\r\n",
>>> >>> +   filters[i][1],
>>> >>> +   addr.ss_family == AF_INET ? 4 : 6, host,
>>> >>> +   filters_buf);
>>> >>> +}
>>> >>> +}
>>> >>> +}
>>> >>> +
>>> >>> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
>>> >>> +   par->codec_type == 

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-12 Thread Ross Nicholson
User testing has been completed successfully so this is ready to be applied.

Thanks 

> On 7 Apr 2020, at 23:50, Ross Nicholson  wrote:
> 
> 
> Thank you for the explanation Marton. It's make perfect sense to me know. So 
> UNLIMITED would be the right choice here.
> 
> All of your other comments are addressed in the latest version. Thanks again 
> for reviewing.
> 
>> On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:
>> 
>> 
>> On Tue, 7 Apr 2020, Ross Nicholson wrote:
>> 
>> > Great, thanks again. 
>> >
>> > A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when 
>> > to use this versus unlimited?
>> >
>> > Or is it that generally if you would have used a buffer of 1000 or less 
>> > automatic is the right choice?
>> 
>> It depends on what you want. With AUTOMATIC you limit length to 1000 chars 
>> but you don't have to free the buffer. Otherwise you are not limiting the 
>> buffer size, but you have to free it. So if it is impossible to hit the 
>> limit, you should always use AUTOMATIC.
>> 
>> In this case you have to decide for yourself which to use, because I don't 
>> know if 1000 char buffer is big enough for the possible use cases. I 
>> only suggested to consider it, because you are using limited buffers for 
>> other strings, so it may not even be possible to outgrow 1000 chars. It is 
>> up to you decide depending on what you want to support.
>> 
>> Regards,
>> Marton
>> 
>> >
>> >> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
>> >> 
>> >> 
>> >> 
>> >>> On Tue, 7 Apr 2020, phunkyfish wrote:
>> >>> 
>> >>> ---
>> >>> libavformat/rtsp.c | 48 +-
>> >>> 1 file changed, 39 insertions(+), 9 deletions(-)
>> >>> 
>> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>> >>> index cd6fc32a29..dad3f7915e 100644
>> >>> --- a/libavformat/rtsp.c
>> >>> +++ b/libavformat/rtsp.c
>> >>> @@ -21,6 +21,7 @@
>> >>> #include "libavutil/avassert.h"
>> >>> #include "libavutil/base64.h"
>> >>> +#include "libavutil/bprint.h"
>> >>> #include "libavutil/avstring.h"
>> >>> #include "libavutil/intreadwrite.h"
>> >>> #include "libavutil/mathematics.h"
>> >>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>> >>> static int rtp_read_header(AVFormatContext *s)
>> >>> {
>> >>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
>> >>> -char host[500], sdp[500];
>> >>> +char host[500], filters_buf[1000];
>> >>>int ret, port;
>> >>>URLContext* in = NULL;
>> >>>int payload_type;
>> >>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>> >>>AVIOContext pb;
>> >>>socklen_t addrlen = sizeof(addr);
>> >>>RTSPState *rt = s->priv_data;
>> >>> +const char *p;
>> >>> +AVBPrint sdp;
>> >>>
>> >>>if (!ff_network_init())
>> >>>return AVERROR(EIO);
>> >>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
>> >>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>> >>> NULL, 0, s->url);
>> >>> -snprintf(sdp, sizeof(sdp),
>> >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
>> >>> - addr.ss_family == AF_INET ? 4 : 6, host,
>> >>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>> >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
>> >>> - port, payload_type);
>> >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>> >>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
>> >> 
>> >> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a 
>> >> static buffer which will be limited (roughly 1000 chars) but you don't 
>> >> have to free it with av_bprint_finalize().
>> >> 
>> >>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
>> >>> +   addr.ss_family == AF_INET ? 4 : 6, host);
>> >>> +
>> >>> +p = strchr(s->url, '?');
>> >>> +if (p) {
>> >>> +static const char *filters[][2] = {{"sources", "incl"}, 
>> >>> {"block", "excl"}, {NULL, NULL}};
>> >>> +int i;
>> >>> +char *q;
>> >>> +for (i = 0; filters[i][0]; i++) {
>> >>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
>> >>> filters[i][0], p)) {
>> >>> +q = filters_buf;
>> >>> +while ((q = strchr(q, ',')) != NULL)
>> >>> +*q = ' ';
>> >>> +av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
>> >>> +   filters[i][1],
>> >>> +   addr.ss_family == AF_INET ? 4 : 6, host,
>> >>> +   filters_buf);
>> >>> +}
>> >>> +}
>> >>> +}
>> >>> +
>> >>> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
>> >>> +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>> >>> +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : 
>> >>> "audio",
>> >>> +   port, payload_type);
>> >>> +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
>> >>> +if 

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread Ross Nicholson
Thank you for the explanation Marton. It's make perfect sense to me know.
So UNLIMITED would be the right choice here.

All of your other comments are addressed in the latest version. Thanks
again for reviewing.

On Tue, 7 Apr 2020 at 22:03, Marton Balint  wrote:

>
>
> On Tue, 7 Apr 2020, Ross Nicholson wrote:
>
> > Great, thanks again.
> >
> > A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when
> to use this versus unlimited?
> >
> > Or is it that generally if you would have used a buffer of 1000 or less
> automatic is the right choice?
>
> It depends on what you want. With AUTOMATIC you limit length to 1000 chars
> but you don't have to free the buffer. Otherwise you are not limiting the
> buffer size, but you have to free it. So if it is impossible to hit the
> limit, you should always use AUTOMATIC.
>
> In this case you have to decide for yourself which to use, because I don't
> know if 1000 char buffer is big enough for the possible use cases. I
> only suggested to consider it, because you are using limited buffers for
> other strings, so it may not even be possible to outgrow 1000 chars. It is
> up to you decide depending on what you want to support.
>
> Regards,
> Marton
>
> >
> >> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
> >>
> >> 
> >>
> >>> On Tue, 7 Apr 2020, phunkyfish wrote:
> >>>
> >>> ---
> >>> libavformat/rtsp.c | 48 +-
> >>> 1 file changed, 39 insertions(+), 9 deletions(-)
> >>>
> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> >>> index cd6fc32a29..dad3f7915e 100644
> >>> --- a/libavformat/rtsp.c
> >>> +++ b/libavformat/rtsp.c
> >>> @@ -21,6 +21,7 @@
> >>> #include "libavutil/avassert.h"
> >>> #include "libavutil/base64.h"
> >>> +#include "libavutil/bprint.h"
> >>> #include "libavutil/avstring.h"
> >>> #include "libavutil/intreadwrite.h"
> >>> #include "libavutil/mathematics.h"
> >>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
> >>> static int rtp_read_header(AVFormatContext *s)
> >>> {
> >>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> >>> -char host[500], sdp[500];
> >>> +char host[500], filters_buf[1000];
> >>>int ret, port;
> >>>URLContext* in = NULL;
> >>>int payload_type;
> >>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
> >>>AVIOContext pb;
> >>>socklen_t addrlen = sizeof(addr);
> >>>RTSPState *rt = s->priv_data;
> >>> +const char *p;
> >>> +AVBPrint sdp;
> >>>
> >>>if (!ff_network_init())
> >>>return AVERROR(EIO);
> >>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
> >>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
> >>> NULL, 0, s->url);
> >>> -snprintf(sdp, sizeof(sdp),
> >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> >>> - addr.ss_family == AF_INET ? 4 : 6, host,
> >>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> >>> - port, payload_type);
> >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> >>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
> >>
> >> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a
> static buffer which will be limited (roughly 1000 chars) but you don't have
> to free it with av_bprint_finalize().
> >>
> >>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
> >>> +   addr.ss_family == AF_INET ? 4 : 6, host);
> >>> +
> >>> +p = strchr(s->url, '?');
> >>> +if (p) {
> >>> +static const char *filters[][2] = {{"sources", "incl"},
> {"block", "excl"}, {NULL, NULL}};
> >>> +int i;
> >>> +char *q;
> >>> +for (i = 0; filters[i][0]; i++) {
> >>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> >>> +q = filters_buf;
> >>> +while ((q = strchr(q, ',')) != NULL)
> >>> +*q = ' ';
> >>> +av_bprintf(, "a=source-filter:%s IN IP%d %s
> %s\r\n",
> >>> +   filters[i][1],
> >>> +   addr.ss_family == AF_INET ? 4 : 6, host,
> >>> +   filters_buf);
> >>> +}
> >>> +}
> >>> +}
> >>> +
> >>> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
> >>> +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> >>> +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> >>> +   port, payload_type);
> >>> +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
> >>> +if (av_bprint_is_complete())
> >>
> >> I think this check should be negated here, because you want to report
> error if the buffer is truncated, not if it is complete.
> >>
> >>> +goto fail_nobuf;
> >>>avcodec_parameters_free();
> >>> -ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL,
> NULL);

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread phunkyfish
---
 libavformat/rtsp.c | 48 +-
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..07ac371903 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
+#include "libavutil/bprint.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
 int ret, port;
 URLContext* in = NULL;
 int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (!av_bprint_is_complete())
+goto fail_nobuf;
 avcodec_parameters_free();
 
-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, sdp.len, 0, NULL, NULL, NULL, NULL);
 s->pb = 
 
 /* sdp_read_header initializes this again */
@@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)
 
 ret = sdp_read_header(s);
 s->pb = NULL;
+av_bprint_finalize(, NULL);
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOMEM);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
+av_bprint_finalize(, NULL);
 avcodec_parameters_free();
 if (in)
 ffurl_close(in);
-- 
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread Marton Balint



On Tue, 7 Apr 2020, Ross Nicholson wrote:

Great, thanks again. 


A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when to use 
this versus unlimited?

Or is it that generally if you would have used a buffer of 1000 or less 
automatic is the right choice?


It depends on what you want. With AUTOMATIC you limit length to 1000 chars 
but you don't have to free the buffer. Otherwise you are not limiting the 
buffer size, but you have to free it. So if it is impossible to hit the 
limit, you should always use AUTOMATIC.


In this case you have to decide for yourself which to use, because I don't 
know if 1000 char buffer is big enough for the possible use cases. I 
only suggested to consider it, because you are using limited buffers for 
other strings, so it may not even be possible to outgrow 1000 chars. It is 
up to you decide depending on what you want to support.


Regards,
Marton




On 7 Apr 2020, at 20:50, Marton Balint  wrote:




On Tue, 7 Apr 2020, phunkyfish wrote:

---
libavformat/rtsp.c | 48 +-
1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..dad3f7915e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@
#include "libavutil/avassert.h"
#include "libavutil/base64.h"
+#include "libavutil/bprint.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
static int rtp_read_header(AVFormatContext *s)
{
   uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
   int ret, port;
   URLContext* in = NULL;
   int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
   AVIOContext pb;
   socklen_t addrlen = sizeof(addr);
   RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;

   if (!ff_network_init())
   return AVERROR(EIO);
@@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
   av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
NULL, 0, s->url);
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);


You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a static 
buffer which will be limited (roughly 1000 chars) but you don't have to free it 
with av_bprint_finalize().


+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (av_bprint_is_complete())


I think this check should be negated here, because you want to report error if 
the buffer is truncated, not if it is complete.


+goto fail_nobuf;
   avcodec_parameters_free();
-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
NULL);


You can use sdp.len instead of strlen().


   s->pb = 

   /* sdp_read_header initializes this again */
@@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)

   ret = sdp_read_header(s);
   s->pb = NULL;
+av_bprint_finalize(, NULL);
   return ret;
+fail_nobuf:
+ret = AVERROR(ENOMEM);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
fail:
+av_bprint_finalize(, NULL);
   avcodec_parameters_free();
   if (in)
   ffurl_close(in);


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread Ross Nicholson
Great, thanks again. 

A question about AV_BPRINT_SIZE_AUTOMATIC. Is there a heuristic for when to use 
this versus unlimited?

Or is it that generally if you would have used a buffer of 1000 or less 
automatic is the right choice?

> On 7 Apr 2020, at 20:50, Marton Balint  wrote:
> 
> 
> 
>> On Tue, 7 Apr 2020, phunkyfish wrote:
>> 
>> ---
>> libavformat/rtsp.c | 48 +-
>> 1 file changed, 39 insertions(+), 9 deletions(-)
>> 
>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>> index cd6fc32a29..dad3f7915e 100644
>> --- a/libavformat/rtsp.c
>> +++ b/libavformat/rtsp.c
>> @@ -21,6 +21,7 @@
>> #include "libavutil/avassert.h"
>> #include "libavutil/base64.h"
>> +#include "libavutil/bprint.h"
>> #include "libavutil/avstring.h"
>> #include "libavutil/intreadwrite.h"
>> #include "libavutil/mathematics.h"
>> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>> static int rtp_read_header(AVFormatContext *s)
>> {
>>uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
>> -char host[500], sdp[500];
>> +char host[500], filters_buf[1000];
>>int ret, port;
>>URLContext* in = NULL;
>>int payload_type;
>> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>>AVIOContext pb;
>>socklen_t addrlen = sizeof(addr);
>>RTSPState *rt = s->priv_data;
>> +const char *p;
>> +AVBPrint sdp;
>> 
>>if (!ff_network_init())
>>return AVERROR(EIO);
>> @@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
>>av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>> NULL, 0, s->url);
>> -snprintf(sdp, sizeof(sdp),
>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
>> - addr.ss_family == AF_INET ? 4 : 6, host,
>> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
>> - port, payload_type);
>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
> 
> You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a static 
> buffer which will be limited (roughly 1000 chars) but you don't have to free 
> it with av_bprint_finalize().
> 
>> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
>> +   addr.ss_family == AF_INET ? 4 : 6, host);
>> +
>> +p = strchr(s->url, '?');
>> +if (p) {
>> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
>> "excl"}, {NULL, NULL}};
>> +int i;
>> +char *q;
>> +for (i = 0; filters[i][0]; i++) {
>> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
>> filters[i][0], p)) {
>> +q = filters_buf;
>> +while ((q = strchr(q, ',')) != NULL)
>> +*q = ' ';
>> +av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
>> +   filters[i][1],
>> +   addr.ss_family == AF_INET ? 4 : 6, host,
>> +   filters_buf);
>> +}
>> +}
>> +}
>> +
>> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
>> +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
>> +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
>> +   port, payload_type);
>> +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
>> +if (av_bprint_is_complete())
> 
> I think this check should be negated here, because you want to report error 
> if the buffer is truncated, not if it is complete.
> 
>> +goto fail_nobuf;
>>avcodec_parameters_free();
>> -ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
>> +ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
>> NULL);
> 
> You can use sdp.len instead of strlen().
> 
>>s->pb = 
>> 
>>/* sdp_read_header initializes this again */
>> @@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)
>> 
>>ret = sdp_read_header(s);
>>s->pb = NULL;
>> +av_bprint_finalize(, NULL);
>>return ret;
>> +fail_nobuf:
>> +ret = AVERROR(ENOMEM);
>> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
>> sdp-headers\n");
>> fail:
>> +av_bprint_finalize(, NULL);
>>avcodec_parameters_free();
>>if (in)
>>ffurl_close(in);
> 
> Regards,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread Marton Balint



On Tue, 7 Apr 2020, phunkyfish wrote:


---
libavformat/rtsp.c | 48 +-
1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..dad3f7915e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@

#include "libavutil/avassert.h"
#include "libavutil/base64.h"
+#include "libavutil/bprint.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
static int rtp_read_header(AVFormatContext *s)
{
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
int ret, port;
URLContext* in = NULL;
int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
AVIOContext pb;
socklen_t addrlen = sizeof(addr);
RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;

if (!ff_network_init())
return AVERROR(EIO);
@@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
 NULL, 0, s->url);

-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);


You may also use AV_BPRINT_SIZE_AUTOMATIC in which case you will get a 
static buffer which will be limited (roughly 1000 chars) but you don't 
have to free it with av_bprint_finalize().



+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (av_bprint_is_complete())


I think this check should be negated here, because you want to report 
error if the buffer is truncated, not if it is complete.



+goto fail_nobuf;
avcodec_parameters_free();

-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
NULL);


You can use sdp.len instead of strlen().


s->pb = 

/* sdp_read_header initializes this again */
@@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)

ret = sdp_read_header(s);
s->pb = NULL;
+av_bprint_finalize(, NULL);
return ret;

+fail_nobuf:
+ret = AVERROR(ENOMEM);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
fail:
+av_bprint_finalize(, NULL);
avcodec_parameters_free();
if (in)
ffurl_close(in);


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread Ross Nicholson
Hey Nicolas,

Thanks for the review. I have incorporated your comments in the latest
version.

I have to get some users local to the problematic streams to do the
testing, they are not available in my region. It has made it somewhat
problematic to get this far ;)

phunkyfish

On Mon, 6 Apr 2020 at 23:36, Nicolas George  wrote:

> phunkyfish (12020-04-06):
> > ---
> >  libavformat/rtsp.c | 50 +-
> >  1 file changed, 41 insertions(+), 9 deletions(-)
> >
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index cd6fc32a29..2b59a9330d 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -21,6 +21,7 @@
> >
> >  #include "libavutil/avassert.h"
> >  #include "libavutil/base64.h"
> > +#include "libavutil/bprint.h"
> >  #include "libavutil/avstring.h"
> >  #include "libavutil/intreadwrite.h"
> >  #include "libavutil/mathematics.h"
> > @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
> >  static int rtp_read_header(AVFormatContext *s)
> >  {
> >  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> > -char host[500], sdp[500];
> > +char host[500], filters_buf[1000];
> >  int ret, port;
> >  URLContext* in = NULL;
> >  int payload_type;
> > @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
> >  AVIOContext pb;
> >  socklen_t addrlen = sizeof(addr);
> >  RTSPState *rt = s->priv_data;
> > +const char *p;
> > +AVBPrint sdp;
> >
> >  if (!ff_network_init())
> >  return AVERROR(EIO);
> > @@ -2513,16 +2516,40 @@ static int rtp_read_header(AVFormatContext *s)
> >  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
> >   NULL, 0, s->url);
> >
> > -snprintf(sdp, sizeof(sdp),
> > - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> > - addr.ss_family == AF_INET ? 4 : 6, host,
> > - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> > - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> > - port, payload_type);
> > -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> > +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
> > +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
> > +   addr.ss_family == AF_INET ? 4 : 6, host);
> > +
> > +p = strchr(s->url, '?');
> > +if (p) {
> > +static const char *filters[][2] = {{"sources", "incl"},
> {"block", "excl"}, {NULL, NULL}};
> > +int i;
> > +char *q;
> > +for (i = 0; filters[i][0]; i++) {
> > +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> > +q = filters_buf;
> > +while ((q = strchr(q, ',')) != NULL)
> > +*q = ' ';
> > +av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
> > +   filters[i][1],
> > +   addr.ss_family == AF_INET ? 4 : 6, host,
> > +   filters_buf);
>
> > +if (sdp.len != sdp.size)
> > +goto fail_nobuf;
>
> Only check at the end.
>
> > +}
> > +}
> > +}
> > +
> > +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
> > +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> > +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> > +   port, payload_type);
> > +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
>
> > +if (sdp.len != sdp.size)
> > +goto fail_nobuf;
>
> av_bprint_is_complete(). Is this test even correct? Did you test the
> code?
>
> >  avcodec_parameters_free();
> >
> > -ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> > +ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL,
> NULL, NULL);
> >  s->pb = 
> >
> >  /* sdp_read_header initializes this again */
> > @@ -2532,9 +2559,14 @@ static int rtp_read_header(AVFormatContext *s)
> >
> >  ret = sdp_read_header(s);
> >  s->pb = NULL;
> > +av_bprint_finalize(, NULL);
> >  return ret;
> >
> > +fail_nobuf:
>
> > +ret = AVERROR(ENOBUFS);
>
> This is not the error code you are looking for.
>
> > +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space
> for sdp-headers\n");
> >  fail:
> > +av_bprint_finalize(, NULL);
> >  avcodec_parameters_free();
> >  if (in)
> >  ffurl_close(in);
>
> Regards,
>
> --
>   Nicolas George
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-07 Thread phunkyfish
---
 libavformat/rtsp.c | 48 +-
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..dad3f7915e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
+#include "libavutil/bprint.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
 int ret, port;
 URLContext* in = NULL;
 int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,16 +2516,38 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (av_bprint_is_complete())
+goto fail_nobuf;
 avcodec_parameters_free();
 
-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
NULL);
 s->pb = 
 
 /* sdp_read_header initializes this again */
@@ -2532,9 +2557,14 @@ static int rtp_read_header(AVFormatContext *s)
 
 ret = sdp_read_header(s);
 s->pb = NULL;
+av_bprint_finalize(, NULL);
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOMEM);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
+av_bprint_finalize(, NULL);
 avcodec_parameters_free();
 if (in)
 ffurl_close(in);
-- 
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Nicolas George
phunkyfish (12020-04-06):
> ---
>  libavformat/rtsp.c | 50 +-
>  1 file changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..2b59a9330d 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -21,6 +21,7 @@
>  
>  #include "libavutil/avassert.h"
>  #include "libavutil/base64.h"
> +#include "libavutil/bprint.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mathematics.h"
> @@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> +char host[500], filters_buf[1000];
>  int ret, port;
>  URLContext* in = NULL;
>  int payload_type;
> @@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
> +AVBPrint sdp;
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,16 +2516,40 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
> +av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
> +   addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
> +   filters[i][1],
> +   addr.ss_family == AF_INET ? 4 : 6, host,
> +   filters_buf);

> +if (sdp.len != sdp.size)
> +goto fail_nobuf;

Only check at the end.

> +}
> +}
> +}
> +
> +av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
> +   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> +   port, payload_type);
> +av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);

> +if (sdp.len != sdp.size)
> +goto fail_nobuf;

av_bprint_is_complete(). Is this test even correct? Did you test the
code?

>  avcodec_parameters_free();
>  
> -ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> +ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
> NULL);
>  s->pb = 
>  
>  /* sdp_read_header initializes this again */
> @@ -2532,9 +2559,14 @@ static int rtp_read_header(AVFormatContext *s)
>  
>  ret = sdp_read_header(s);
>  s->pb = NULL;
> +av_bprint_finalize(, NULL);
>  return ret;
>  
> +fail_nobuf:

> +ret = AVERROR(ENOBUFS);

This is not the error code you are looking for.

> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
> sdp-headers\n");
>  fail:
> +av_bprint_finalize(, NULL);
>  avcodec_parameters_free();
>  if (in)
>  ffurl_close(in);

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Ross Nicholson
Ok, latest patch uses AVBPrint. Please let me know if my usage is correct,
I have not used it before.

In the meantime I will get some users to test this.

On Mon, 6 Apr 2020 at 20:57, Marton Balint  wrote:

>
>
> On Mon, 6 Apr 2020, phunkyfish wrote:
>
> > ---
> > libavformat/rtsp.c | 47 ++
> > 1 file changed, 39 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index cd6fc32a29..0d0bc2be0d 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
> > static int rtp_read_header(AVFormatContext *s)
> > {
> > uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> > -char host[500], sdp[500];
> > -int ret, port;
> > +char host[500], sdp[1000], filters_buf[1000];
> > +int ret, port, sdp_length, nc;
> > URLContext* in = NULL;
> > int payload_type;
> > AVCodecParameters *par = NULL;
> > @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
> > AVIOContext pb;
> > socklen_t addrlen = sizeof(addr);
> > RTSPState *rt = s->priv_data;
> > +const char *p;
> >
> > if (!ff_network_init())
> > return AVERROR(EIO);
> > @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
> > av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
> >  NULL, 0, s->url);
> >
> > -snprintf(sdp, sizeof(sdp),
> > - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> > - addr.ss_family == AF_INET ? 4 : 6, host,
> > - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> > - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> > - port, payload_type);
> > +sdp_length = snprintf(sdp, sizeof(sdp),
> > +  "v=0\r\nc=IN IP%d %s\r\n",
> > +  addr.ss_family == AF_INET ? 4 : 6, host);
>
> Please use an AVBPrint buffer instead of snprintf()-ing to sdp.
>
> Thanks,
> Marton
>
> > +
> > +p = strchr(s->url, '?');
> > +if (p) {
> > +static const char *filters[][2] = {{"sources", "incl"},
> {"block", "excl"}, {NULL, NULL}};
> > +int i;
> > +char *q;
> > +for (i = 0; filters[i][0]; i++) {
> > +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> > +q = filters_buf;
> > +while ((q = strchr(q, ',')) != NULL)
> > +*q = ' ';
> > +nc = snprintf(sdp + sdp_length, sizeof(sdp) -
> sdp_length,
> > +  "a=source-filter:%s IN IP%d %s %s\r\n",
> > +  filters[i][1],
> > +  addr.ss_family == AF_INET ? 4 : 6, host,
> > +  filters_buf);
> > +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> > +goto fail_nobuf;
> > +sdp_length += nc;
> > +}
> > +}
> > +}
> > +
> > +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> > +  "m=%s %d RTP/AVP %d\r\n",
> > +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application"
> :
> > +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> > +  port, payload_type);
> > av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> > +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> > +goto fail_nobuf;
> > avcodec_parameters_free();
> >
> > ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> > @@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
> > s->pb = NULL;
> > return ret;
> >
> > +fail_nobuf:
> > +ret = AVERROR(ENOBUFS);
> > +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space
> for sdp-headers\n");
> > fail:
> > avcodec_parameters_free();
> > if (in)
> > --
> > 2.24.1 (Apple Git-126)
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread phunkyfish
---
 libavformat/rtsp.c | 50 +-
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..2b59a9330d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
+#include "libavutil/bprint.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
@@ -2447,7 +2448,7 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
+char host[500], filters_buf[1000];
 int ret, port;
 URLContext* in = NULL;
 int payload_type;
@@ -2456,6 +2457,8 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
+AVBPrint sdp;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,16 +2516,40 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
-av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(, "v=0\r\nc=IN IP%d %s\r\n",
+   addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+av_bprintf(, "a=source-filter:%s IN IP%d %s %s\r\n",
+   filters[i][1],
+   addr.ss_family == AF_INET ? 4 : 6, host,
+   filters_buf);
+if (sdp.len != sdp.size)
+goto fail_nobuf;
+}
+}
+}
+
+av_bprintf(, "m=%s %d RTP/AVP %d\r\n",
+   par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+   par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+   port, payload_type);
+av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp.str);
+if (sdp.len != sdp.size)
+goto fail_nobuf;
 avcodec_parameters_free();
 
-ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(, sdp.str, strlen(sdp.str), 0, NULL, NULL, NULL, 
NULL);
 s->pb = 
 
 /* sdp_read_header initializes this again */
@@ -2532,9 +2559,14 @@ static int rtp_read_header(AVFormatContext *s)
 
 ret = sdp_read_header(s);
 s->pb = NULL;
+av_bprint_finalize(, NULL);
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
+av_bprint_finalize(, NULL);
 avcodec_parameters_free();
 if (in)
 ffurl_close(in);
-- 
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Marton Balint



On Mon, 6 Apr 2020, phunkyfish wrote:


---
libavformat/rtsp.c | 47 ++
1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..0d0bc2be0d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
static int rtp_read_header(AVFormatContext *s)
{
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
URLContext* in = NULL;
int payload_type;
AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
AVIOContext pb;
socklen_t addrlen = sizeof(addr);
RTSPState *rt = s->priv_data;
+const char *p;

if (!ff_network_init())
return AVERROR(EIO);
@@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
 NULL, 0, s->url);

-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);


Please use an AVBPrint buffer instead of snprintf()-ing to sdp.

Thanks,
Marton


+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
avcodec_parameters_free();

ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
@@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
s->pb = NULL;
return ret;

+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
fail:
avcodec_parameters_free();
if (in)
--
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread Ross Nicholson
> sdp_length is used uninitialized here it is used uninitialized in the
> version that was merged as b71685865fe761925feedda3cd0b288224d9a509. The
> newer versions [2], [3] don't exhibit this flaw.
>
> [3] and [1] also have a flaw in common that [2] and this one are
> lacking: The semicolon of the definition of const char *p is missing.
>
> Finally, neither of these versions here seems to have been based upon
> git master which contains a call to av_log() directly after the above
> snprintf.
>
> - Andreas

Andreas,

Apologies I did not get back to you sooner I was indisposed.

I have updated the patch now which should be correct, addressing your
comments.

On Mon, 6 Apr 2020 at 17:56, phunkyfish  wrote:

> ---
>  libavformat/rtsp.c | 47 ++
>  1 file changed, 39 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..0d0bc2be0d 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
>
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp, sizeof(sdp),
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block",
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf),
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "a=source-filter:%s IN IP%d %s %s\r\n",
> +  filters[i][1],
> +  addr.ss_family == AF_INET ? 4 : 6, host,
> +  filters_buf);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> +sdp_length += nc;
> +}
> +}
> +}
> +
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "m=%s %d RTP/AVP %d\r\n",
> +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" :
> "audio",
> +  port, payload_type);
>  av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
>  avcodec_parameters_free();
>
>  ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
> @@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
>  s->pb = NULL;
>  return ret;
>
> +fail_nobuf:
> +ret = AVERROR(ENOBUFS);
> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space
> for sdp-headers\n");
>  fail:
>  avcodec_parameters_free();
>  if (in)
> --
> 2.24.1 (Apple Git-126)
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-04-06 Thread phunkyfish
---
 libavformat/rtsp.c | 47 ++
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..0d0bc2be0d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
 avcodec_parameters_free();
 
 ffio_init_context(, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
@@ -2534,6 +2562,9 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.24.1 (Apple Git-126)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread Andreas Rheinhardt
phunkyfish:
> ---
>  libavformat/rtsp.c | 49 ++
>  1 file changed, 41 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..d23ec5723e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,12 +2514,41 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +

sdp_length is used uninitialized here it is used uninitialized in the
version that was merged as b71685865fe761925feedda3cd0b288224d9a509. The
newer versions [2], [3] don't exhibit this flaw.

[3] and [1] also have a flaw in common that [2] and this one are
lacking: The semicolon of the definition of const char *p is missing.

Finally, neither of these versions here seems to have been based upon
git master which contains a call to av_log() directly after the above
snprintf.

- Andreas

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/257887.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/257989.html
[3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259128.html
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread Andreas Rheinhardt
phunkyfish:
> ---
>  libavformat/rtsp.c | 46 ++
>  1 file changed, 38 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..1aec070382 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,12 +2514,39 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp, sizeof(sdp),
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "a=source-filter:%s IN IP%d %s %s\r\n",
> +  filters[i][1],
> +  addr.ss_family == AF_INET ? 4 : 6, host,
> +  filters_buf);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> +sdp_length += nc;
> +}
> +}
> +}
> +
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "m=%s %d RTP/AVP %d\r\n",
> +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> +  port, payload_type);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
>  av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>  avcodec_parameters_free();
>  
> @@ -2534,6 +2562,8 @@ static int rtp_read_header(AVFormatContext *s)
>  s->pb = NULL;
>  return ret;
>  
> +fail_nobuf:
> +ret = AVERROR(ENOBUFS);
>  fail:
>  avcodec_parameters_free();
>  if (in)
> 
The version of this patch that has been applied as
b71685865fe761925feedda3cd0b288224d9a509 (which doesn't coincide with
any of the versions on the ML) broke the FATE box [1].

- Andreas

[1]:
http://fate.ffmpeg.org/report.cgi?slot=x86_64-freebsd10-mingw32=20200327193738
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread phunkyfish
---
 libavformat/rtsp.c | 46 ++
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..1aec070382 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,12 +2514,39 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 avcodec_parameters_free();
 
@@ -2534,6 +2562,8 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.21.1 (Apple Git-122.3)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-24 Thread Ross Nicholson
This patch will correctly pass any sources or block filters from the URL via 
SDP to the underlying protocol.

Example URL: rtp://232.0.10.234:1?sources=87.141.215.251

Prior to this patch the sources params would be ignored and the stream reading 
would fail.

> On 4 Mar 2020, at 23:47, phunkyfish  wrote:
> 
> ---
> libavformat/rtsp.c | 48 ++
> 1 file changed, 40 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..f6d66526b0 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
> static int rtp_read_header(AVFormatContext *s)
> {
> uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
> URLContext* in = NULL;
> int payload_type;
> AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
> AVIOContext pb;
> socklen_t addrlen = sizeof(addr);
> RTSPState *rt = s->priv_data;
> +const char *p;
> 
> if (!ff_network_init())
> return AVERROR(EIO);
> @@ -2513,12 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
> av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>  NULL, 0, s->url);
> 
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp, sizeof(sdp),
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
> filters[i][0], p)) {
> +/* av_log(s, AV_LOG_VERBOSE, "rtp_read_header() found %s 
> %s\n", filters[i][0], filters_buf); */
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "a=source-filter:%s IN IP%d %s %s\r\n",
> +  filters[i][1],
> +  addr.ss_family == AF_INET ? 4 : 6, host,
> +  filters_buf);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> +sdp_length += nc;
> +}
> +}
> +}
> +
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "m=%s %d RTP/AVP %d\r\n",
> +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> +  port, payload_type);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> avcodec_parameters_free();
> 
> @@ -2534,6 +2563,9 @@ static int rtp_read_header(AVFormatContext *s)
> s->pb = NULL;
> return ret;
> 
> +fail_nobuf:
> +ret = AVERROR(ENOBUFS);
> +av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
> sdp-headers\n");
> fail:
> avcodec_parameters_free();
> if (in)
> -- 
> 2.20.1 (Apple Git-117)
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-04 Thread phunkyfish
---
 libavformat/rtsp.c | 48 ++
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..f6d66526b0 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,12 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+/* av_log(s, AV_LOG_VERBOSE, "rtp_read_header() found %s 
%s\n", filters[i][0], filters_buf); */
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 avcodec_parameters_free();
 
@@ -2534,6 +2563,9 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.20.1 (Apple Git-117)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-02 Thread phunkyfish
---
 libavformat/rtsp.c | 49 ++
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..d23ec5723e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p;
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,12 +2514,41 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+/* av_log(s, AV_LOG_VERBOSE, "rtp_read_header() found %s 
%s\n", filters[i][0], filters_buf); */
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 avcodec_parameters_free();
 
@@ -2534,6 +2564,9 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.20.1 (Apple Git-117)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-02 Thread phunkyfish
---
 libavformat/rtsp.c | 49 ++
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..c744e403c6 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,12 +2514,41 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+/* av_log(s, AV_LOG_VERBOSE, "rtp_read_header() found %s 
%s\n", filters[i][0], filters_buf); */
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 avcodec_parameters_free();
 
@@ -2534,6 +2564,9 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
+av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for 
sdp-headers\n");
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.20.1 (Apple Git-117)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".