Commit 4bcb1a6d authored by Soomin Lee's avatar Soomin Lee Committed by Carola Nitz

VLCMediaPlayer: add recording feature

Add recording method and errorcallback related patches for libvlc 22-24
Add recording methods and callbacks to VLCMediaPlayer
Add delegate callbacks and documentation
parent a02943a1
......@@ -29,12 +29,12 @@
#import <VLCKit/VLCMediaListPlayer.h>
#import <VLCKit/VLCMediaDiscoverer.h>
#import <VLCKit/VLCMediaPlayer.h>
#import <VLCKit/VLCMediaThumbnailer.h>
#import <VLCKit/VLCTime.h>
#import <VLCKit/VLCVideoView.h>
#import <VLCKit/VLCVideoLayer.h>
#import <VLCKit/VLCStreamSession.h>
#import <VLCKit/VLCStreamOutput.h>
#import <VLCKit/VLCMediaThumbnailer.h>
@class VLCMedia;
@class VLCMediaLibrary;
......
......@@ -40,6 +40,7 @@
#endif
@class VLCLibrary;
@class VLCMediaPlayer;
@class VLCRendererItem;
/* Notification Messages */
......@@ -135,6 +136,19 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
*/
- (void)mediaPlayerSnapshot:(NSNotification *)aNotification;
/**
* Sent by the default notification center whenever the player started recording.
* @param player the player who started recording
*/
- (void)mediaPlayerStartedRecording:(VLCMediaPlayer *)player;
/**
* Sent by the default notification center whenever the player stopped recording.
* @param player the player who stopped recording
* @param path the path to the file that the player recorded to
*/
- (void)mediaPlayer:(VLCMediaPlayer *)player recordStoppedAtPath:(NSString *)path;
@end
......@@ -875,6 +889,19 @@ extern NSString *const VLCTitleDescriptionIsMenu;
@property (NS_NONATOMIC_IOSONLY, readonly) NSImage *lastSnapshot;
#endif
/**
* Start recording at given **directory** path
* \param path directory where the recording should go
* \return an BOOL with the success status
*/
- (BOOL)startRecordingAtPath:(NSString *)path;
/**
* Stop current recording
* \return an BOOL with the success status
*/
- (BOOL)stopRecording;
#pragma mark -
#pragma mark Renderer
......
From f722ec6e0a507d9d6ac8d07b64d397e0005f7d36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Thu, 18 Dec 2014 22:14:55 +0100
Subject: [PATCH 01/21] arm_neon: work-around libtool issue
Subject: [PATCH 01/24] arm_neon: work-around libtool issue
---
modules/arm_neon/Makefile.am | 2 ++
......
From ec0833dc5c0de67ccb70aaad13b5cca1b53b2b63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 10 Dec 2014 22:14:55 +0100
Subject: [PATCH 02/21] disable neon volume plugin
Subject: [PATCH 02/24] disable neon volume plugin
---
modules/arm_neon/Makefile.am | 1 -
......
From e212978e2104a3b1b63c26a7844039d04ee2a3d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Fri, 22 Jul 2016 11:11:44 +0200
Subject: [PATCH 03/21] Enable System DL
Subject: [PATCH 03/24] Enable System DL
---
contrib/src/ffmpeg/patch-as-patch-can.patch | 20 ++++++++++++++++++++
......
From a6aab77007bd9037311dd318e7d0f6731a2d072c Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 16 Sep 2016 15:51:10 +0200
Subject: [PATCH 04/21] http: add vlc_http_cookies_clear
Subject: [PATCH 04/24] http: add vlc_http_cookies_clear
Clear all cookies without deleting the jar.
---
......
From 7ea0717450762464b257e5ee36624871a96b1d74 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 16 Sep 2016 15:51:11 +0200
Subject: [PATCH 05/21] libvlc_media: add cookie_jar API
Subject: [PATCH 05/24] libvlc_media: add cookie_jar API
---
include/vlc/libvlc_media.h | 35 +++++++++++++++++++++++++++++++++++
......
From 20fc6522b5fdc3b2e9cd43c20365e0449bf7370e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sun, 7 Dec 2014 20:02:18 +0100
Subject: [PATCH 06/21] contrib/gcrypt: work-around a libtool limitation
Subject: [PATCH 06/24] contrib/gcrypt: work-around a libtool limitation
---
contrib/src/gcrypt/rules.mak | 1 +
......
From 56de0725dec3e6bbb1e7c50bbdd27e6f71c9c1fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sat, 3 Oct 2015 22:45:14 +0200
Subject: [PATCH 07/21] contrib/gcrypt: fix tvOS compilation
Subject: [PATCH 07/24] contrib/gcrypt: fix tvOS compilation
---
.../src/gcrypt/fix-sha1-ssse3-for-clang.patch | 16 ++++++++++++++++
......
From 7eb426d0b581e6ca258c61185b9b58b75b59069a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 12 Sep 2016 17:03:37 +0200
Subject: [PATCH 08/21] contrib/gcrypt: update patches
Subject: [PATCH 08/24] contrib/gcrypt: update patches
---
.../src/gcrypt/fix-sha1-ssse3-for-clang.patch | 308 +++++++++++++++++-
......
From 3cd38bd0a11400577995f94b10a94ac0d601ddd0 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Mon, 17 Jul 2017 17:03:24 +0200
Subject: [PATCH 09/21] Replace thread local with pthread TSD
Subject: [PATCH 09/24] Replace thread local with pthread TSD
---
src/misc/interrupt.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
......
From a69b13b0a86f1f74be3b765484e75e6080547fea Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 29 Sep 2017 14:49:02 +0200
Subject: [PATCH 10/21] contrib: use live555 version that is compatible with
Subject: [PATCH 10/24] contrib: use live555 version that is compatible with
LGPL2
---
......
From fa00abf30e86d629dec8c39049267671ffa93494 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net>
Date: Sun, 17 Dec 2017 18:05:40 +0100
Subject: [PATCH 11/21] libvlc: add a basic API to change freetype's color,
Subject: [PATCH 11/24] libvlc: add a basic API to change freetype's color,
bold, font and size variables on-the-fly
---
......
From f48e06d158c35e5546e76e0bfde719f40b540553 Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 23 Feb 2018 13:16:41 +0100
Subject: [PATCH 12/21] Work around lack of __thread storage qualifier on old
Subject: [PATCH 12/24] Work around lack of __thread storage qualifier on old
macOS
---
......
From 800d701b0339f6f10f58f0f71fb828c93fe1d4a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Mon, 26 Mar 2018 16:44:44 +0200
Subject: [PATCH 13/21] modules:common: Use the full module name as MODULE_NAME
Subject: [PATCH 13/24] modules:common: Use the full module name as MODULE_NAME
This avoid conflicts when linking modules staticly on platforms that don't
have objdump
......
From bde8deaef81276f53e6c0680747ed1f25b564139 Mon Sep 17 00:00:00 2001
From: Luis Fernandes <zipleen@gmail.com>
Date: Mon, 30 Apr 2018 14:33:08 +0100
Subject: [PATCH 14/21] add auto deinterlacer-mode which is also valid
Subject: [PATCH 14/24] add auto deinterlacer-mode which is also valid
---
lib/video.c | 3 ++-
......
From d787329479948bbb4e08ccb6ea9fb1363ead5808 Mon Sep 17 00:00:00 2001
From: Luis Fernandes <zipleen@gmail.com>
Date: Wed, 9 May 2018 10:44:43 +0100
Subject: [PATCH 15/21] Users will be able to change the deinterlace mode
Subject: [PATCH 15/24] Users will be able to change the deinterlace mode
without forcing it.
---
......
From 939e1151740e3abb060a0afeac620a22a0cd70ef Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 27 Mar 2018 16:49:34 +0200
Subject: [PATCH 16/21] contrib: ffmpeg: enable videotoolbox encoder
Subject: [PATCH 16/24] contrib: ffmpeg: enable videotoolbox encoder
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
......
From a42d5d27f29f6239ee6a874b9a07e675e98fbfa8 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 27 Mar 2018 16:52:35 +0200
Subject: [PATCH 17/21] chromecast: use vt encoder from avcodec
Subject: [PATCH 17/24] chromecast: use vt encoder from avcodec
---
modules/stream_out/chromecast/cast.cpp | 13 +++++++++++++
......
From b7ac55bfbc294676bd6ae343a80269f104b4b8d0 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Mon, 18 Jun 2018 12:31:13 +0200
Subject: [PATCH 18/21] ffmpeg: backport vtenc patches
Subject: [PATCH 18/24] ffmpeg: backport vtenc patches
---
...lboxenc-fix-mutex-cond-leak-in-error.patch | 35 ++++++
......
From e9af8d3cf8a7d8dc142f09b0b6b500ca36b126d4 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Wed, 17 Jan 2018 10:06:13 +0200
Subject: [PATCH 19/21] core: expose config_AutoSaveConfigFile
Subject: [PATCH 19/24] core: expose config_AutoSaveConfigFile
---
include/vlc_configuration.h | 2 ++
......
From 70c8cec5bd26150631b662131ffb65ca6d395a21 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Wed, 17 Jan 2018 10:06:13 +0200
Subject: [PATCH 20/21] lib: save configuration after playback/parse
Subject: [PATCH 20/24] lib: save configuration after playback/parse
The configuration is also saved when the libvlc instance is terminated but this
doesn't happen often. Indeed, apps using libvlc will generally hold the libvlc
......
From b0ef8f7ad8ec99498fcde33989c2765ea2de9069 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net>
Date: Mon, 10 Sep 2018 20:55:11 +0200
Subject: [PATCH 21/21] http access: retain auth struct for the runtime of the
Subject: [PATCH 21/24] http access: retain auth struct for the runtime of the
module
Previously, it was retained for a given connection only, so all information needed for a digest login was lost as soon as the module was reconnecting due to the expected 401 on attempted basic login
......
From 6931f0c66a3978c0c169d8ec8688f1beb7eb3639 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Wed, 31 Oct 2018 10:08:55 +0100
Subject: [PATCH 22/24] libvlc: media_player: Add record method
---
include/vlc/libvlc_media_player.h | 13 +++++++++++++
lib/media_player.c | 21 +++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index cbb5ec251a..d58dc4ddcf 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -2108,6 +2108,19 @@ 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 enable true to start recording, false to stop
+ * \param path the path of the recording directory
+ * \return 0 on success, -1 on error
+ */
+LIBVLC_API int libvlc_media_player_record(libvlc_media_player_t *p_mi,
+ bool enable,
+ const char *path);
/** @} audio */
diff --git a/lib/media_player.c b/lib/media_player.c
index 29285065f0..7e714d247b 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -622,6 +622,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|VLC_VAR_DOINHERIT);
var_Create (mp, "http-cookies", VLC_VAR_ADDRESS);
/* Video */
@@ -2092,3 +2093,23 @@ 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,
+ bool enable,
+ const char *path)
+{
+ vlc_value_t val = { .psz_string = (char *)path };
+ input_thread_t *p_input_thread;
+
+ 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);
+
+ vlc_object_release( p_input_thread );
+ return VLC_SUCCESS;
+}
--
2.17.1
From 8ddb9512335005505493838b105a005b6a7be610 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Thu, 27 Sep 2018 18:40:39 +0200
Subject: [PATCH 23/24] 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 f8b0e9b5b2..bbc6bc0eec 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -32,6 +32,8 @@
# ifdef __cplusplus
extern "C" {
+# else
+# include <stdbool.h>
# endif
typedef struct libvlc_renderer_item_t libvlc_renderer_item_t;
@@ -86,6 +88,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerAudioVolume,
libvlc_MediaPlayerAudioDevice,
libvlc_MediaPlayerChapterChanged,
+ libvlc_MediaPlayerRecordChanged,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
@@ -275,6 +278,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 61cc0b0e0d..439910d053 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -446,6 +446,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->obj.libvlc, "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.19.1
From bb6baab0248c4534e25074e5e576c266f00ba057 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Mon, 1 Oct 2018 15:37:57 +0200
Subject: [PATCH 24/24] 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 fbefce0be8..a2a72db411 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -88,6 +88,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;
@@ -305,8 +308,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.19.0
......@@ -203,6 +203,17 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
}
}
static void HandleMediaPlayerRecord(const libvlc_event_t * event, void * self)
{
@autoreleasepool {
[[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
withMethod:@selector(mediaPlayerRecordChanged:)
withArgumentAsObject:@[@{@"filePath": [NSString stringWithFormat:@"%s", event->u.media_player_record_changed.file_path],
@"isRecording": @(event->u.media_player_record_changed.recording)
}]];
}
}
@interface VLCMediaPlayer ()
{
VLCLibrary *_privateLibrary; ///< Internal
......@@ -1328,6 +1339,17 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
return _playerInstance;
}
- (BOOL)startRecordingAtPath:(NSString *)path
{
return libvlc_media_player_record(_playerInstance, YES, [path UTF8String]);
}
- (BOOL)stopRecording
{
return libvlc_media_player_record(_playerInstance, NO, nil);
}
#pragma mark -
#pragma mark - Renderer
......@@ -1395,6 +1417,7 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
libvlc_event_attach(p_em, libvlc_MediaPlayerChapterChanged, HandleMediaChapterChanged, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaPlayerSnapshotTaken, HandleMediaPlayerSnapshot, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaPlayerRecordChanged, HandleMediaPlayerRecord, (__bridge void *)(self));
});
}
......@@ -1421,6 +1444,7 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
libvlc_event_detach(p_em, libvlc_MediaPlayerChapterChanged, HandleMediaChapterChanged, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaPlayerSnapshotTaken, HandleMediaPlayerSnapshot, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaPlayerRecordChanged, HandleMediaPlayerRecord, (__bridge void *)(self));
}
- (dispatch_queue_t)libVLCBackgroundQueue
......@@ -1521,4 +1545,13 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
}
}
- (void)mediaPlayerRecordChanged:(NSArray *)arguments
{
NSString *filePath = arguments.firstObject[@"filePath"];
BOOL isRecording = [arguments.firstObject[@"isRecording"] boolValue];
isRecording ? [_delegate mediaPlayerStartedRecording:self]
: [_delegate mediaPlayer:self recordStoppedAtPath:filePath];
}
@end
......@@ -704,6 +704,7 @@ buildLibVLC() {
fingerprinter
output_udp
output_livehttp
libmux
"
if [ "$SCARY" = "no" ]; then
......
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