On Sat, Feb 16, 2019 at 09:40:06PM +0100, Thomas Jammet wrote: > Hi everybody, > > You will find in attachment a patch proposal to add an optional RTMFP > support in ffmpeg using librtmfp. > > For more information : https://github.com/MonaSolutions/librtmfp > > *--* > > *Thomas JAMMET*
> configure | 4 > doc/protocols.texi | 120 ++++++++++++++++++++++ > libavformat/Makefile | 1 > libavformat/librtmfp.c | 260 > ++++++++++++++++++++++++++++++++++++++++++++++++ > libavformat/protocols.c | 1 > 5 files changed, 386 insertions(+) > a4c87a2eea01d1e0886f6bdcfb96a39f5b38cd97 > 0001-Added-RTMFP-protocol-to-ffmpeg.patch > From 2d6877f5cb7a9eeb65ed93fe1f6e1ba06229159d Mon Sep 17 00:00:00 2001 > From: Jammet Thomas <jammettho...@gmail.com> > Date: Sat, 16 Feb 2019 21:35:46 +0100 > Subject: [PATCH] Added RTMFP protocol to ffmpeg > > --- > configure | 4 + > doc/protocols.texi | 120 ++++++++++++++++++++++ > libavformat/Makefile | 1 + > libavformat/librtmfp.c | 260 > ++++++++++++++++++++++++++++++++++++++++++++++++ > libavformat/protocols.c | 1 + > 5 files changed, 386 insertions(+) > create mode 100644 libavformat/librtmfp.c > > diff --git a/configure b/configure > index bf40c1dcb9..1b1fae433d 100755 > --- a/configure > +++ b/configure > @@ -257,6 +257,7 @@ External library support: > --enable-librsvg enable SVG rasterization via librsvg [no] > --enable-librubberband enable rubberband needed for rubberband filter > [no] > --enable-librtmp enable RTMP[E] support via librtmp [no] > + --enable-librtmfp enable RTMFP support via librtmfp [no] > --enable-libshine enable fixed-point MP3 encoding via libshine [no] > --enable-libsmbclient enable Samba protocol via libsmbclient [no] > --enable-libsnappy enable Snappy compression, needed for hap > encoding [no] > @@ -1754,6 +1755,7 @@ EXTERNAL_LIBRARY_LIST=" > libpulse > librsvg > librtmp > + librtmfp > libshine > libsmbclient > libsnappy > @@ -3365,6 +3367,7 @@ librtmpe_protocol_deps="librtmp" > librtmps_protocol_deps="librtmp" > librtmpt_protocol_deps="librtmp" > librtmpte_protocol_deps="librtmp" > +librtmfp_protocol_deps="librtmfp" > libsmbclient_protocol_deps="libsmbclient gplv3" > libsrt_protocol_deps="libsrt" > libsrt_protocol_select="network" > @@ -6169,6 +6172,7 @@ enabled libopus && { > enabled libpulse && require_pkg_config libpulse libpulse > pulse/pulseaudio.h pa_context_new > enabled librsvg && require_pkg_config librsvg librsvg-2.0 > librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo > enabled librtmp && require_pkg_config librtmp librtmp > librtmp/rtmp.h RTMP_Socket > +enabled librtmfp && require_pkg_config librtmfp librtmfp > librtmfp/librtmfp.h RTMFP_Connect > enabled librubberband && require_pkg_config librubberband "rubberband >= > 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append > librubberband_extralibs "-lstdc++" > enabled libshine && require_pkg_config libshine shine > shine/layer3.h shine_encode_buffer > enabled libsmbclient && { check_pkg_config libsmbclient smbclient > libsmbclient.h smbc_init || > diff --git a/doc/protocols.texi b/doc/protocols.texi > index fb7725e058..e2e974a5cb 100644 > --- a/doc/protocols.texi > +++ b/doc/protocols.texi > @@ -834,6 +834,126 @@ To play the same stream using @command{ffplay}: > ffplay "rtmp://myserver/live/mystream live=1" > @end example > > +@section librtmfp > + > +Real-Time Media Flow Protocol. > + > +Requires the presence of the librtmfp headers and library during > +configuration. You need to explicitly configure the build with > +"--enable-librtmfp". > + > +This protocol provides most functionalities of the UDP protocol RTMFP : > +unicast, direct p2p and multicast (via NetGroup). > + > +The required syntax for an RTMFP URL is: > +@example > +rtmfp://@var{hostname}[:@var{port}][/@var{app}][/@var{playpath}] > +@end example > + > +The accepted parameters are: > +@table @option > + > +@item hostname > +The address of the RTMFP server. > + > +@item port > +The number of the UDP port to use (by default is 1935). > + > +@item app > +It is the name of the application to access. It usually corresponds to the > +path where the application is installed on the RTMFP server (e.g. > +/ondemand/,/flash/live/, etc.). > + > +@item playpath > +It is the path or name of the resource to play with reference to the > +application specified in app. > +@end table > + > +Additionally, the following parameters can be set via command line options > +(or in code via @code{AVOption}s): > +@table @option > + > +@item rtmfp_socketReceiveSize > +Socket receive buffer size. > + > +@item rtmfp_socketSendSize > +Socket send buffer size. > + > +@item rtmfp_audioUnbuffered > +Unbuffered audio mode (default to false). > + > +@item rtmfp_videoUnbuffered > +Unbuffered video mode (default to false). > + > +@item rtmfp_peerId > +Connect to a peer for playing. > + > +@item rtmfp_p2pPublishing > +Publish the stream in p2p mode (default to false). > + > +@item rtmfp_netgroup > +Publish/Play the stream into a NetGroup (multicast). > + > +@item rtmfp_fallbackUrl > +(Only with @code{rtmfp_negtroup}) Try to play an RTMFP unicast stream url > +until the NetGroup connection is not ready. Can produce undefined behavior > +if the stream codecs are different. > + > +@item rtmfp_fallbackTimeout > +(Only with @code{rtmfp_negtroup}) Set the timeout in milliseconds to start > +fallback to unicast. > + > +@item rtmfp_disableRateControl > +(Only with @code{rtmfp_negtroup}) Disable the P2P connection rate control > +to avoid unwanted disconnection. > + > +@item rtmfp_pushLimit > +(Only with @code{rtmfp_negtroup}) Specifies the maximum number (-1) of > +peers to which we will send push fragments. > + > +@item rtmfp_updatePeriod > +(Only with @code{rtmfp_negtroup}) Specifies the interval in milliseconds > +between messages sent to peers informating them that the local node has > +new p2p multicast media fragments available. > + > +@item rtmfp_windowDuration > +(Only with @code{rtmfp_negtroup}) Specifies the duration in milliseconds > +of the p2p multicast reassembly window. > + > +@item rtmfp_swfurl > +URL of the SWF player. By default no value will be sent. > + > +@item rtmfp_app > +Name of application to connect to on the RTMFP server (by default 'live'). > + > +@item rtmfp_pageurl > +URL of the web page in which the media was embedded. By default no value > +will be sent. > + > +@item rtmfp_flashver > +Version of the Flash plugin used to run the SWF player. By default > +@code{WIN 20,0,0,286}. > + > +@item rtmfp_host > +IPv4 host address to bind to (use this if you ave multiple interfaces). > + > +@item rtmfp_hostIPv6 > +IPv6 host address to bind to (use this if you ave multiple interfaces). > +@end table > + > +For example to read with @command{ffplay} a multimedia resource named > +"sample" from the application "vod" from an RTMFP server "myserver": > +@example > +ffplay rtmfp://myserver/vod/sample > +@end example > + > +To publish a multimedia resource named "sample" to an RTMFP server: > +@example > +ffmpeg -re -i <input> -f flv rtmfp://myserver/sample > +@end example > + > +For more information see: @url{https://github.com/MonaSolutions/librtmfp}. > + > @section rtp > > Real-time Transport Protocol. > diff --git a/libavformat/Makefile b/libavformat/Makefile > index c010fc83f9..fb3ccb9006 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -626,6 +626,7 @@ OBJS-$(CONFIG_LIBRTMPE_PROTOCOL) += librtmp.o > OBJS-$(CONFIG_LIBRTMPS_PROTOCOL) += librtmp.o > OBJS-$(CONFIG_LIBRTMPT_PROTOCOL) += librtmp.o > OBJS-$(CONFIG_LIBRTMPTE_PROTOCOL) += librtmp.o > +OBJS-$(CONFIG_LIBRTMFP_PROTOCOL) += librtmfp.o > OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL) += libsmbclient.o > OBJS-$(CONFIG_LIBSRT_PROTOCOL) += libsrt.o > OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o > diff --git a/libavformat/librtmfp.c b/libavformat/librtmfp.c > new file mode 100644 > index 0000000000..2e914deb88 > --- /dev/null > +++ b/libavformat/librtmfp.c > @@ -0,0 +1,260 @@ > +/* > + * RTMFP network protocol > + * Copyright (c) 2019 Thomas Jammet > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +/** > + * @file > + * RTMFP protocol based on https://github.com/MonaSolutions/librtmfp librtmfp > + */ > + > +#include "libavutil/avstring.h" > +#include "libavutil/opt.h" > +#include "avformat.h" > +#if CONFIG_NETWORK > +#include "network.h" > +#endif > +#include <sys/time.h> > + > +#include <librtmfp/librtmfp.h> > + > +typedef struct LibRTMFPContext { > + const AVClass* class; > + RTMFPConfig rtmfp; > + unsigned int id; > + int audioUnbuffered; > + int videoUnbuffered; > + int p2pPublishing; > + char* peerId; > + char* publication; > + unsigned short streamId; > + const char* swfUrl; > + const char* app; > + const char* pageUrl; > + const char* flashVer; > + const char* host; > + const char* hostIPv6; > + > + // General options > + int socketReceiveSize; > + int socketSendSize; > + > + // NetGroup members > + RTMFPGroupConfig group; > + char* netgroup; > + unsigned int updatePeriod; > + unsigned int windowDuration; > + unsigned int pushLimit; > + char* fallbackUrl; > + unsigned int fallbackTimeout; > + int disableRateCtl; > +} LibRTMFPContext; > + > +static void rtmfp_log(unsigned int level, const char* fileName, long line, > const char* message) > +{ > + const char* strLevel = ""; > + time_t today2 ; > + struct tm *today = NULL; > + struct timeval tv; > + > + switch (level) { > + default: > + case 1: level = AV_LOG_FATAL; strLevel = "FATAL"; break; > + case 2: > + case 3: level = AV_LOG_ERROR; strLevel = "ERROR"; break; > + case 4: level = AV_LOG_WARNING; strLevel = "WARN"; break; > + case 5: > + case 6: level = AV_LOG_INFO; strLevel = "INFO"; break; > + case 7: level = AV_LOG_DEBUG; strLevel = "DEBUG"; break; > + case 8: level = AV_LOG_TRACE; strLevel = "TRACE"; break; > + } > + > + today2 = time(NULL); > + today = localtime(&today2); > + gettimeofday(&tv, NULL); > + av_log(NULL, level, "%.2d:%.2d:%.2d.%d [%s] %s\n", today->tm_hour, > today->tm_min, today->tm_sec, (int)((tv.tv_usec / 1000) / 100), strLevel, > message); iam not sure adding the time is a good idea, but it should be ommited when bitexact mode is used to keep messages repeatable also localtime is not thread safe > +} > + > +/*static void rtmfp_dump(const char* header, const void* data, unsigned int > size) { > + av_log(NULL, AV_LOG_DEBUG, "%s\n%.*s", header, size, (const char*)data); > +}*/ this doesnt belong in the patch > + > +static int rtmfp_close(URLContext *s) > +{ > + LibRTMFPContext *ctx = s->priv_data; > + > + av_log(NULL, AV_LOG_INFO, "Closing RTMFP connection...\n"); missing log context [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel