Skip to content

Instantly share code, notes, and snippets.

@tlhc
Last active August 29, 2015 14:11
Show Gist options
  • Save tlhc/5365980396bf449ef79f to your computer and use it in GitHub Desktop.
Save tlhc/5365980396bf449ef79f to your computer and use it in GitHub Desktop.
libvlc
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <vlc/vlc.h>
#include <time.h>
#include <signal.h>
#define UNUSED(x) (void)(x)
static const char* vlcArguments[] = {
"--intf=dummy",
"--ignore-config",
"--no-media-library",
"--no-one-instance",
"--no-osd",
"--no-snapshot-preview",
"--no-stats",
"--no-audio",
"--no-video-title-show",
"-vvv"
};
static libvlc_instance_t *instance = NULL;
static libvlc_media_t *media = NULL;
static libvlc_media_player_t *player = NULL;
void sig_handler(int signo) {
UNUSED(signo);
if(player != NULL && media != NULL && instance != NULL) {
libvlc_media_player_release(player);
libvlc_media_release(media);
libvlc_release(instance);
printf("%s\n", "relased!");
}
exit(0);
}
int main(int argc, char *argv[]) {
UNUSED(argc);
UNUSED(argv);
signal(SIGINT, sig_handler);
instance = libvlc_new(sizeof(vlcArguments) / sizeof(vlcArguments[0]), vlcArguments);
media = libvlc_media_new_path(instance, "/home/mars/low_work/siptest/onlyv.264");
player = libvlc_media_player_new_from_media(media);
libvlc_media_player_play(player);
while(1) {
usleep(1000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment