Skip to content
Snippets Groups Projects

Draft: type serialization module

Open Louis Régnier requested to merge louis/vlc:type_serializer into master
11 unresolved threads

This merge request introduce a module to serialize and de-serialize vlc data types.
It is part of a series of merge requests, which aim to delegate preparse tasks to a dedicated preparse process, mainly for the medialibrary and vlc playqueue use cases.

The preparse process integration will be splitted in four merge requests

  1. introduce module of serialization/deserialization
  2. preparse process basis
  3. implementation of vlc_spawn() for win32 (merged)
  4. integrate use of preparse process in the medialibrary module and vlc playqueue.

When vlc preparse resources, it generate and set input_item_t which imply es_format_t in association with the ressource.
The protocol of communication between vlc process and the preparse process (see !2980 ),
require to serialize resulting objects of the preparse on the preparse process side.
On the vlc side those objects needs to be deserialized.

Edited by Louis Régnier

Merge request reports

Members who can merge are allowed to add commits.

Merge request pipeline #293170 failed

Merge request pipeline failed for e6991641

Approval is optional
Merge blocked: 4 checks failed
Merge request must not be draft.
Unresolved discussions must be resolved.
Pipeline must succeed.
Merge request must be rebased, because a fast-forward merge is not possible.

Merge details

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 /*****************************************************************************
2 * vlc_serializer.h
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on commit c87ca9ec
  • 40 */
    41 typedef struct type_serializer_t
    42 {
    43 struct vlc_object_t obj;
    44
    45 void *type;
    46
    47 int ( * pf_serialize )( struct type_serializer_t * );
    48 int ( * pf_deserialize )( struct type_serializer_t * );
    49
    50 /* serialization */
    51 struct vlc_memstream *serialized_type;
    52
    53 /* deserialization */
    54 char *serialized;
    55 unsigned int buffer_size;
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on commit 6b7f02dd
  • 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14 * GNU Lesser General Public License for more details.
    15 *
    16 * You should have received a copy of the GNU Lesser General Public License
    17 * along with this program; if not, write to the Free Software Foundation,
    18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
    19 *****************************************************************************/
    20
    21 #ifdef HAVE_CONFIG_H
    22 # include "config.h"
    23 #endif
    24
    25 #include <vlc_common.h>
    26 #include <vlc_plugin.h>
    27
    28 vlc_module_begin()
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on an outdated change in commit c56ed399
  • 24 24
    25 25 #include <vlc_common.h>
    26 26 #include <vlc_plugin.h>
    27 #include <vlc_input_item.h>
  • Steve Lhomme changed milestone to %4.0

    changed milestone to %4.0

  • Why use modules over fixed functions in libvlc/libvlccore/libvlcserialize? I'ts not like you're going to have several modules with the same capability.

    Edited by Denis Charmet
  • Denis Charmet
    Denis Charmet @typx started a thread on commit c2e0e152
  • 27 #include <vlc_memstream.h>
    28 #include <vlc_es.h>
    29
    30 /*****************************************************************************
    31 * Local prototypes
    32 *****************************************************************************/
    33 int serialize_es_format(type_serializer_t *serializer);
    34 int deserialize_es_format(type_serializer_t *serializer);
    35
    36 int serialize_es_format(type_serializer_t *serializer)
    37 {
    38 es_format_t *es = (es_format_t *)serializer->type;
    39 struct vlc_memstream *serialized_format = serializer->serialized_type;
    40
    41 vlc_memstream_write(serialized_format, &es->i_cat, sizeof(es->i_cat));
    42 vlc_memstream_write(serialized_format, &es->i_codec, sizeof(es->i_codec));
    • NIT: As a rule of thumb, when you serialize, you should stick to fixed and known size containers or send their size too. Here it works because it's planned to be used in the same machine but if we start imagining process running on different machines you'd have to take different size and endianness into account.

    • Please register or sign in to reply
  • Thomas Guillem
    Thomas Guillem @tguillem started a thread on commit c87ca9ec
  • 26 /**
    27 * Structure received by serializer/deserializer modules.
    28 *
    29 * The caller has to fill the structure following:
    30 * - serialization:
    31 * 1. type to serialize.
    32 * 2. valid vlc_memstream, which will be filled with type content as raw bytes
    33 * by the serializer.
    34 *
    35 * - deserialization:
    36 * 1. type which will initialized from the content of the raw type buffer by
    37 * the deserializer.
    38 * 2. buffer of the type serialized.
    39 * 3. buffer size
    40 */
    41 typedef struct type_serializer_t
  • Thomas Guillem
    Thomas Guillem @tguillem started a thread on commit c87ca9ec
  • 33 * by the serializer.
    34 *
    35 * - deserialization:
    36 * 1. type which will initialized from the content of the raw type buffer by
    37 * the deserializer.
    38 * 2. buffer of the type serialized.
    39 * 3. buffer size
    40 */
    41 typedef struct type_serializer_t
    42 {
    43 struct vlc_object_t obj;
    44
    45 void *type;
    46
    47 int ( * pf_serialize )( struct type_serializer_t * );
    48 int ( * pf_deserialize )( struct type_serializer_t * );
  • Thomas Guillem
    Thomas Guillem @tguillem started a thread on commit c87ca9ec
  • 38 * 2. buffer of the type serialized.
    39 * 3. buffer size
    40 */
    41 typedef struct type_serializer_t
    42 {
    43 struct vlc_object_t obj;
    44
    45 void *type;
    46
    47 int ( * pf_serialize )( struct type_serializer_t * );
    48 int ( * pf_deserialize )( struct type_serializer_t * );
    49
    50 /* serialization */
    51 struct vlc_memstream *serialized_type;
    52
    53 /* deserialization */
  • Thomas Guillem
    Thomas Guillem @tguillem started a thread on commit c87ca9ec
  • 30 * - serialization:
    31 * 1. type to serialize.
    32 * 2. valid vlc_memstream, which will be filled with type content as raw bytes
    33 * by the serializer.
    34 *
    35 * - deserialization:
    36 * 1. type which will initialized from the content of the raw type buffer by
    37 * the deserializer.
    38 * 2. buffer of the type serialized.
    39 * 3. buffer size
    40 */
    41 typedef struct type_serializer_t
    42 {
    43 struct vlc_object_t obj;
    44
    45 void *type;
  • Thomas Guillem
    Thomas Guillem @tguillem started a thread on commit c2e0e152
  • 111 vlc_memstream_write(serialized_format, es->p_extra, es->i_extra);
    112
    113 return VLC_SUCCESS;
    114 }
    115
    116 #define BOUNDARY_CHECK(offset) \
    117 do { \
    118 if (cur_pos + offset >= (serialized_format + size)) \
    119 goto error; \
    120 } while (0);
    121
    122 int deserialize_es_format(type_serializer_t *serializer)
    123 {
    124 const char *serialized_format = serializer->serialized;
    125 const char *cur_pos = serialized_format;
    126 es_format_t *es = (es_format_t *)serializer->type;
  • Denis Charmet mentioned in merge request !6024

    mentioned in merge request !6024

  • Please register or sign in to reply
    Loading