..  _record_server:

Record Server
=============

The rsb recordserver consists of an ``rsbag record`` process that stores component
communication data from all scopes in the apartment (with some `Exceptions`_).

As a base component, the server is running 24/7 and awaits recording commands. Its
main purpose is to start recording whenever it is needed. Currently, the recording
is triggered only by the :ref:`auto_recording` component but in principle it can also
be used to record study data for example.

.. warning:: Currently (with rsb <0.13), the record server **crashes** after a certain amount
    of **events**. Make sure to restart it from time to time.


Related resources
-----------------

Component repository:
 - Browse component repository: `rsbag <https://code.cor-lab.de/projects/rsbag/repository/>`_.
 - ``git clone --recursive https://code.cor-lab.org/git/rsbag.git``

System startup:
 - The coordination can be found in ``lsp-csra-base.sh`` on the ``default`` tab.
 - The component script is called ``component_rsb_recordserver``

Related projects:
 - Component :ref:`auto_recording`
 - Browse repository `rsb <https://code.cor-lab.de/projects/rsb>`_.

Interfaces
-----------------

The component can be controlled via method invokation only. Recording can be
started (and stopped/resumed multiple times) after a file has been successfully
opened. If the recording has been stopped, the file should be closed again.

=========================================== ===================== ==================
Scope (Local Server) + Method               Argument Type         Return Type
=========================================== ===================== ==================
 ``/logger/rsbag/all/open()``               String: filename      void
 ``/logger/rsbag/all/start()``              void                  void
 ``/logger/rsbag/all/isstarted()``          void                  bool: recording?
 ``/logger/rsbag/all/stop()``               void                  void
 ``/logger/rsbag/all/close()``              void                  void
=========================================== ===================== ==================

Exceptions
----------

**Not** recorded are raw audio and video packets. Apart from most raw video data
being excluded from the main spread ring (see e.g. :ref:`hookah`, :ref:`rgbdgrabber`)
and therefore not reorded, a filter is applied additionally. In particular, it
consists of the following scopes:

.. code-block:: common-lisp

    'and :children #.(list (rsb.filter:filter (quote (:and
        ((:not (:scope :scope "/citec/csra/home/kitchen/video")))
        ((:not (:scope :scope "/citec/csra/home/hallway/entrance/video")))
        ((:not (:scope :scope "/citec/csra/home/kitchen/assistance/asc7/audio/in")))
        ((:not (:scope :scope "/citec/csra/home/living/lounge/asc9/audio/in/default")))
        ((:not (:scope :scope "/citec/csra/home/hallway/entrance/asc10/audio/in/default")))
    ))))'


Examples
--------------
Record a temporary file:

.. code-block:: bash

    tools0.12 call '/logger/rsbag/all/open("/tmp/tmprecord.tide")'
    tools0.12 call '/logger/rsbag/all/start()'
    # actions that you want to record
    tools0.12 call '/logger/rsbag/all/stop()'
    tools0.12 call '/logger/rsbag/all/close()'