0022-libvlc-media_player-Add-record-method.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 9ad892cd04503c90a05ffefb0a4e7372e2f5c830 Mon Sep 17 00:00:00 2001
  2. From: Soomin Lee <bubu@mikan.io>
  3. Date: Wed, 31 Oct 2018 10:08:55 +0100
  4. Subject: [PATCH 22/26] libvlc: media_player: Add record method
  5. ---
  6. include/vlc/libvlc_media_player.h | 13 +++++++++++++
  7. lib/media_player.c | 21 +++++++++++++++++++++
  8. 2 files changed, 34 insertions(+)
  9. diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
  10. index 4e951292c9..363779fd3d 100644
  11. --- a/include/vlc/libvlc_media_player.h
  12. +++ b/include/vlc/libvlc_media_player.h
  13. @@ -2108,6 +2108,19 @@ LIBVLC_API int libvlc_media_player_get_role(libvlc_media_player_t *p_mi);
  14. */
  15. LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *p_mi,
  16. unsigned role);
  17. +/**
  18. + * Start/stop recording
  19. + *
  20. + * \version LibVLC 4.0.0 and later.
  21. + *
  22. + * \param p_mi media player
  23. + * \param enable true to start recording, false to stop
  24. + * \param path the path of the recording directory
  25. + * \return 0 on success, -1 on error
  26. + */
  27. +LIBVLC_API int libvlc_media_player_record(libvlc_media_player_t *p_mi,
  28. + bool enable,
  29. + const char *path);
  30. /** @} audio */
  31. diff --git a/lib/media_player.c b/lib/media_player.c
  32. index 29285065f0..7e714d247b 100644
  33. --- a/lib/media_player.c
  34. +++ b/lib/media_player.c
  35. @@ -622,6 +622,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
  36. var_Create (mp, "rate", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT);
  37. var_Create (mp, "sout", VLC_VAR_STRING);
  38. var_Create (mp, "demux-filter", VLC_VAR_STRING);
  39. + var_Create (mp, "input-record-path", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
  40. var_Create (mp, "http-cookies", VLC_VAR_ADDRESS);
  41. /* Video */
  42. @@ -2092,3 +2093,23 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
  43. free(str);
  44. return ret;
  45. }
  46. +
  47. +int libvlc_media_player_record( libvlc_media_player_t *p_mi,
  48. + bool enable,
  49. + const char *path)
  50. +{
  51. + vlc_value_t val = { .psz_string = (char *)path };
  52. + input_thread_t *p_input_thread;
  53. +
  54. + p_input_thread = libvlc_get_input_thread ( p_mi );
  55. + if( !p_input_thread )
  56. + return VLC_EGENERIC;
  57. +
  58. + if( enable )
  59. + var_Set( p_mi, "input-record-path", val );
  60. +
  61. + var_SetBool( p_input_thread, "record", enable);
  62. +
  63. + vlc_object_release( p_input_thread );
  64. + return VLC_SUCCESS;
  65. +}
  66. --
  67. 2.20.1