Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/VLC/test/libvlc/   (VLC Media Plyer ©)  Datei vom 23.9.2026 mit Größe 3 kB image not shown  

Quelle  media_player_record.c   Sprache: C

 

/*****************************************************************************
 * media_player_record.c - libvlc record test with ENABLE_SOUT
 **********************************************************************
 * Copyright (C) 2023 Videolabs
 *
 * Authors: Alexandre Janniaux <ajanni@videolabs.io>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/


#include "test.h"
#include "media_player.h"
#include <vlc_common.h>

static const struct libvlc_media_player_cbs recording_cbs = {
    .version = 0,
    .on_recording_changed = mp_on_recording_changed,
};

static void test_media_player_record(const char** argv, int argc)
{
    test_log ("Testing record\n");

    const char file[] = "mock://video_track_count=1;audio_track_count=1;can_record=0";

    /* Avoid leaks from various dlopen... */
    const char *new_argv[argc+1];
    for (int i = 0; i < argc; ++i)
        new_argv[i] = argv[i];
    new_argv[argc++] = "--codec=araw,rawvideo,subsdec,none";

    /* Load the mock media */
    libvlc_instance_t *vlc = libvlc_new (argc, new_argv);
    assert (vlc != NULL);
    libvlc_media_t *md = libvlc_media_new_location(file);
    assert (md != NULL);
    struct mp_event_ctx ctx;
    mp_event_ctx_init(&ctx);
    libvlc_media_player_t *mp = libvlc_media_player_new (vlc, &recording_cbs, &ctx);
    assert (mp != NULL);
    mp_event_ctx_set_mp(&ctx, mp);
    libvlc_media_player_set_media (mp, md);
    libvlc_media_release (md);

    libvlc_media_player_play (mp);

    const char path[] = "./";
    char *filepath;

    libvlc_media_player_record(mp, true, path);

    /* Enabling */
    {
        struct mp_event *ev = mp_event_ctx_wait_event(&ctx);
        assert(ev->type == EVENT_TYPE_RECORDING_CHANGED);
        assert(ev->recording_changed.recording);
        mp_event_delete(ev);
    }

    /* Disabling */
    {
        libvlc_media_player_record(mp, false, path);
        struct mp_event *ev = mp_event_ctx_wait_event(&ctx);
        assert(ev->type == EVENT_TYPE_RECORDING_CHANGED);
        assert(!ev->recording_changed.recording);
        assert(ev->recording_changed.file_path != NULL);

        filepath = strdup(ev->recording_changed.file_path);
        assert(filepath != NULL);

        mp_event_delete(ev);
    }

    libvlc_media_player_stop_async (mp);
    libvlc_media_player_release (mp);
    libvlc_release (vlc);

    unlink(filepath);
    /** TODO:
     * We should check assert(res == 0);, but the record is currently
     * creating a stream output pipeline instance for recording with
     * a specific mux after the end of the Open() of the recording
     * module, with a file{no-overwrite} option. It means that the
     * file might not exist yet. */

    free(filepath);
}

int main(void)
{
#ifndef ENABLE_SOUT
    (void)test_media_player_record;
    return 77;
#endif

    test_init();
    test_media_player_record (test_defaults_args, test_defaults_nargs);
    return 0;
}

Messung
CHZG
849610093

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.