[FFmpeg-cvslog] avformat/udp: support w32pthreads compat

2020-03-08 Thread phunkyfish
ffmpeg | branch: master | phunkyfish  | Mon Mar  2 
20:48:41 2020 +| [0830e9116f786572865a9c800a9156d0c4294f27] | committer: 
Marton Balint

avformat/udp: support w32pthreads compat

Signed-off-by: Marton Balint 

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

 compat/w32pthreads.h | 8 
 libavformat/udp.c| 7 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 7df33b7da4..6405e72b64 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -63,6 +63,9 @@ typedef CONDITION_VARIABLE pthread_cond_t;
 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
 #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
 
+#define PTHREAD_CANCEL_ENABLE 1
+#define PTHREAD_CANCEL_DISABLE 0
+
 static av_unused unsigned __stdcall attribute_align_arg 
win32thread_worker(void *arg)
 {
 pthread_t *h = (pthread_t*)arg;
@@ -180,4 +183,9 @@ static inline int pthread_cond_signal(pthread_cond_t *cond)
 return 0;
 }
 
+static inline int pthread_setcancelstate(int state, int *oldstate)
+{
+return 0;
+}
+
 #endif /* COMPAT_W32PTHREADS_H */
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 23c3773c64..ad6992c57d 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -61,8 +61,13 @@
 #define IPPROTO_UDPLITE  136
 #endif
 
+#if HAVE_W32THREADS
+#undef HAVE_PTHREAD_CANCEL
+#define HAVE_PTHREAD_CANCEL 1
+#endif
+
 #if HAVE_PTHREAD_CANCEL
-#include 
+#include "libavutil/thread.h"
 #endif
 
 #ifndef IPV6_ADD_MEMBERSHIP

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

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

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

2020-03-27 Thread phunkyfish
ffmpeg | branch: master | phunkyfish  | Mon Mar  2 
19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | committer: 
Aman Gupta

avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

Signed-off-by: Aman Gupta 

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

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

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..a69484d78b 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), &port,
  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);
+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)) {
+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;
 avcodec_parameters_free(&par);
 
 ffio_init_context(&pb, 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(&par);
 if (in)

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

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

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

2020-03-27 Thread phunkyfish
ffmpeg | branch: release/4.2 | phunkyfish  | Mon Mar  2 
19:21:09 2020 +| [635ca9aa012c1e4059789b22381f26b2c96216d2] | committer: 
Aman Gupta

avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

Signed-off-by: Aman Gupta 
(cherry picked from commit b71685865fe761925feedda3cd0b288224d9a509)

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

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

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 859defa592..9c237d5bfd 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), &port,
  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);
+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)) {
+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;
 avcodec_parameters_free(&par);
 
 ffio_init_context(&pb, 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(&par);
 if (in)

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

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

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

2020-04-19 Thread phunkyfish
ffmpeg | branch: master | phunkyfish  | Tue Apr  7 
23:38:29 2020 +0100| [2a322906b765f7247cc9c872d4934e41f0f466b4] | committer: 
Marton Balint

avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

Signed-off-by: Marton Balint 

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

 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), &port,
  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(&sdp, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprintf(&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 = ' ';
+av_bprintf(&sdp, "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(&sdp, "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(&sdp))
+goto fail_nobuf;
 avcodec_parameters_free(&par);
 
-ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
+ffio_init_context(&pb, sdp.str, sdp.len, 0, NULL, NULL, NULL, NULL);
 s->pb = &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(&sdp, 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(&sdp, NULL);
 avcodec_parameters_free(&par);
 if (in)
 ffurl_close(in);

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

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