Commit 096b563c authored by Romain Vimont's avatar Romain Vimont Committed by Geoffrey Métais

Add patches for current VLC 4 master branch

The patch adding SMB2 module is not necessary anymore, it is already
merged in master.

Adapt the other patches from vlc3/ to base them on the current VLC 4
master branch.
parent f23764ef
From 5b79f2cf244f0c144ed5b00ebd96db71e3b2efef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Thu, 28 Mar 2019 15:23:48 +0100
Subject: [PATCH 1/5] compat: Workaround sendmsg bug on android
This only happens on 64bits builds, see compat/sendmsg.c comments
---
compat/sendmsg.c | 24 ++++++++++++++++++++++++
configure.ac | 3 +++
include/vlc_network.h | 6 ++++++
3 files changed, 33 insertions(+)
diff --git a/compat/sendmsg.c b/compat/sendmsg.c
index 0b08ce0942..2ef542eb7b 100644
--- a/compat/sendmsg.c
+++ b/compat/sendmsg.c
@@ -133,6 +133,30 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
free(data);
return res;
}
+#elif defined(__ANDROID__) && defined(__aarch64__)
+
+#undef sendmsg
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+/**
+ * Since we bumped the NDK version from 14 to 18, some devices (at least up to
+ * Android 6) are returning errors on 4 bytes, even though ssize_t is actually
+ * 8 bytes. This causes `value < 0` checks to yield false, and consider the value
+ * as a non error.
+ * As the patch lies in either the NDK or the Android kernel, or the device libc
+ * we can only work around it. If errno is not 0 & we receive -1, on 32bits or
+ * 64bits, we assume an error was returned.
+ */
+ssize_t vlc_sendmsg(int fd, const struct msghdr *msg, int flags)
+{
+ errno = 0;
+ ssize_t ret = sendmsg(fd, msg, flags);
+ if ((ret < 0 || ret == 0xFFFFFFFF) && errno != 0)
+ return -1;
+ return ret;
+}
#else
#error sendmsg not implemented on your platform!
diff --git a/configure.ac b/configure.ac
index a86a9f8897..fa0375d1ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -401,6 +401,9 @@ AS_IF([test "$SYS" = linux],[
],[
HAVE_ANDROID="1"
AC_MSG_RESULT([yes])
+ AS_IF([test "${host_cpu}" = "aarch64"], [
+ AC_LIBOBJ([sendmsg])
+ ])
],[
AC_MSG_RESULT([no])
])
diff --git a/include/vlc_network.h b/include/vlc_network.h
index b4d5fabdd6..7b05183ab7 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -296,6 +296,12 @@ static inline int net_GetPeerAddress( int fd, char *address, int *port )
VLC_API char *vlc_getProxyUrl(const char *);
+#if defined(__ANDROID__) && defined(__aarch64__)
+struct msghdr;
+ssize_t vlc_sendmsg(int fd, const struct msghdr *msg, int flags);
+#define sendmsg(a, b, c) vlc_sendmsg(a,b,c)
+#endif
+
# ifdef __cplusplus
}
# endif
--
2.20.1
From 57d2653f9c5dc92b6ca6bbf40523479833ebfd76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Fri, 29 Mar 2019 10:56:26 +0100
Subject: [PATCH 2/5] network: tls: Handle errors from older kernels
If MSG_FASTOPEN is defined, but turns out to be unimplemented by the
underlying kernel (as is the case on android where the NDK claims to
support fast open but some older kernels don't) EPIPE is returned
instead of EOPNOTSUPP.
See net/ipv4/tcp.c:936 & net/core/stream.c:55
sk_stream_wait_connect will return EPIPE if no SYN was sent/received,
and sendmsg will propagate that error.
Treating EPIPE as a synonym for EOPNOTSUPP here allows for the
connection to proceed, and the first call to sendmsg to complete as
expected.
---
src/network/stream.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/network/stream.c b/src/network/stream.c
index 5a24bd7134..0b9b1573d7 100644
--- a/src/network/stream.c
+++ b/src/network/stream.c
@@ -383,8 +383,11 @@ static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls,
return -1;
}
else
- if (errno != EOPNOTSUPP)
+ if (errno != EOPNOTSUPP && errno != EPIPE)
+ { /* If MSG_FASTOPEN was defined but the kernel doesn't support fast open at
+ all, EPIPE will be returned instead of EOPNOTSUPP */
return -1;
+ }
/* Fast open not supported or disabled... fallback to normal mode */
#endif
--
2.20.1
From 6a8b6462c17a9268df7976c55749268203b63431 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Mon, 1 Oct 2018 15:37:57 +0200
Subject: [PATCH 3/5] access_output: file: Add error dialog for write/open
---
modules/access_output/file.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index c983e3a8f0..8a690fc41f 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -87,6 +87,9 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
{
if (errno == EINTR)
continue;
+ if (errno == ENOSPC)
+ vlc_dialog_display_error(p_access, "record",
+ "An error occurred during recording. Error: %s", vlc_strerror_c(errno));
block_ChainRelease (p_buffer);
msg_Err( p_access, "cannot write: %s", vlc_strerror_c(errno) );
return -1;
@@ -304,8 +307,13 @@ static int Open( vlc_object_t *p_this )
if (fd != -1)
break;
if (fd == -1)
+ {
msg_Err (p_access, "cannot create %s: %s", path,
vlc_strerror_c(errno));
+
+ vlc_dialog_display_error(p_access, "record",
+ "An error occurred during recording. Error: %s", vlc_strerror_c(errno));
+ }
if (overwrite || errno != EEXIST)
break;
flags &= ~O_EXCL;
--
2.20.1
From 6d161be5efad022d4249549661a739f04cb11255 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Thu, 27 Sep 2018 18:40:39 +0200
Subject: [PATCH 4/5] libvlc: events: Add callbacks for record
---
include/vlc/libvlc_events.h | 9 +++++++++
lib/media_player.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 62a81104da..22730b35e1 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -31,6 +31,8 @@
# ifdef __cplusplus
extern "C" {
+# else
+# include <stdbool.h>
# endif
typedef struct libvlc_renderer_item_t libvlc_renderer_item_t;
@@ -119,6 +121,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerAudioVolume,
libvlc_MediaPlayerAudioDevice,
libvlc_MediaPlayerChapterChanged,
+ libvlc_MediaPlayerRecordChanged,
/**
* A \link #libvlc_media_t media item\endlink was added to a
@@ -346,6 +349,12 @@ typedef struct libvlc_event_t
const char *device;
} media_player_audio_device;
+ struct
+ {
+ const char *file_path;
+ bool recording;
+ } media_player_record_changed;
+
struct
{
libvlc_renderer_item_t *item;
diff --git a/lib/media_player.c b/lib/media_player.c
index 106e7d26b0..bb41dbf17b 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -447,6 +447,22 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
}
}
}
+ else if ( newval.i_int == INPUT_EVENT_RECORD )
+ {
+ bool recording = var_GetBool( p_input, "record" );
+ char *file_path = NULL;
+
+ if ( !recording )
+ file_path = var_GetString( p_mi, "record-file" );
+
+ event.type = libvlc_MediaPlayerRecordChanged;
+ event.u.media_player_record_changed.file_path = file_path;
+ event.u.media_player_record_changed.recording = recording;
+
+ libvlc_event_send( &p_mi->event_manager, &event );
+
+ free( file_path );
+ }
return VLC_SUCCESS;
}
--
2.20.1
From 948de9b69af4735e06bd7533d51ae260166d6897 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Wed, 31 Oct 2018 10:08:55 +0100
Subject: [PATCH 5/5] libvlc: media_player: Add record method
---
include/vlc/libvlc_media_player.h | 11 +++++++++++
lib/media_player.c | 19 +++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index ca72a550d3..e2039a7b3f 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -2176,6 +2176,17 @@ LIBVLC_API int libvlc_media_player_get_role(libvlc_media_player_t *p_mi);
*/
LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *p_mi,
unsigned role);
+/**
+ * Start/stop recording
+ *
+ * \version LibVLC 4.0.0 and later.
+ *
+ * \param p_mi media player
+ * \param directory path of the recording directory or NULL to stop recording
+ * \return 0 on success, -1 on error
+ */
+LIBVLC_API int libvlc_media_player_record(libvlc_media_player_t *p_mi,
+ const char *directory);
/** @} audio */
diff --git a/lib/media_player.c b/lib/media_player.c
index bb41dbf17b..6c40602924 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -638,6 +638,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "rate", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT);
var_Create (mp, "sout", VLC_VAR_STRING);
var_Create (mp, "demux-filter", VLC_VAR_STRING);
+ var_Create (mp, "input-record-path", VLC_VAR_STRING);
/* Video */
var_Create (mp, "vout", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
@@ -2065,3 +2066,21 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
free(str);
return ret;
}
+
+int libvlc_media_player_record( libvlc_media_player_t *p_mi,
+ const char *directory )
+{
+ vlc_value_t val = { .psz_string = (char *)directory };
+ const bool enable = directory != NULL;
+ input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
+ if( !p_input_thread )
+ return VLC_EGENERIC;
+
+ if( enable )
+ var_Set( p_mi, "input-record-path", val );
+
+ var_SetBool( p_input_thread, "record", enable);
+
+ input_Release( p_input_thread );
+ return VLC_SUCCESS;
+}
--
2.20.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment