mirror of
https://github.com/Relintai/rpi_player.git
synced 2024-11-23 15:27:42 +01:00
More work on fixing black video screen.
This commit is contained in:
parent
8e7b0500e8
commit
b76f84c33e
@ -9,8 +9,8 @@
|
|||||||
class ImplApplication : public Application {
|
class ImplApplication : public Application {
|
||||||
public:
|
public:
|
||||||
ImplApplication() : Application() {
|
ImplApplication() : Application() {
|
||||||
//scene = new VLCScene();
|
scene = new VLCScene();
|
||||||
scene = new MainScene();
|
//scene = new MainScene();
|
||||||
}
|
}
|
||||||
~ImplApplication() {
|
~ImplApplication() {
|
||||||
delete scene;
|
delete scene;
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define VIDEOWIDTH 320
|
int VIDEOWIDTH = 0;
|
||||||
#define VIDEOHEIGHT 240
|
int VIDEOHEIGHT = 0;
|
||||||
|
|
||||||
// VLC prepares to render a video frame.
|
// VLC prepares to render a video frame.
|
||||||
static void *lock(void *data, void **p_pixels) {
|
static void *lock(void *data, void **p_pixels) {
|
||||||
@ -33,6 +33,7 @@ static void unlock(void *data, void *id, void *const *p_pixels) {
|
|||||||
uint16_t *pixels = (uint16_t *)*p_pixels;
|
uint16_t *pixels = (uint16_t *)*p_pixels;
|
||||||
|
|
||||||
// We can also render stuff.
|
// We can also render stuff.
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
for (y = 10; y < 40; y++) {
|
for (y = 10; y < 40; y++) {
|
||||||
for (x = 10; x < 40; x++) {
|
for (x = 10; x < 40; x++) {
|
||||||
@ -42,6 +43,8 @@ static void unlock(void *data, void *id, void *const *p_pixels) {
|
|||||||
// RV16 = 5+6+5 pixels per color, BGR.
|
// RV16 = 5+6+5 pixels per color, BGR.
|
||||||
pixels[y * VIDEOWIDTH + x] = 0x02ff;
|
pixels[y * VIDEOWIDTH + x] = 0x02ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pixels[y * VIDEOWIDTH + x] = 0x02ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +52,34 @@ static void unlock(void *data, void *id, void *const *p_pixels) {
|
|||||||
SDL_UnlockMutex(c->mutex);
|
SDL_UnlockMutex(c->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int formatSetup(void **opaque, char *chroma, unsigned *w, unsigned *h, unsigned *pitches, unsigned *lines) {
|
||||||
|
if (VLCScene::scene->texture) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(chroma, "RV16", sizeof("RV16") - 1);
|
||||||
|
|
||||||
|
VIDEOWIDTH = *w;
|
||||||
|
VIDEOHEIGHT = *h;
|
||||||
|
|
||||||
|
printf("%d %d\n", VIDEOWIDTH, VIDEOHEIGHT);
|
||||||
|
|
||||||
|
*pitches = VIDEOWIDTH * 2;
|
||||||
|
*lines = VIDEOHEIGHT;
|
||||||
|
|
||||||
|
VLCScene::scene->texture = SDL_CreateTexture(
|
||||||
|
Renderer::get_singleton()->get_renderer(),
|
||||||
|
SDL_PIXELFORMAT_BGR565, SDL_TEXTUREACCESS_STREAMING,
|
||||||
|
VIDEOWIDTH, VIDEOHEIGHT);
|
||||||
|
|
||||||
|
if (!VLCScene::scene->texture) {
|
||||||
|
fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// VLC wants to display a video frame.
|
// VLC wants to display a video frame.
|
||||||
static void display(void *data, void *id) {
|
static void display(void *data, void *id) {
|
||||||
|
|
||||||
@ -63,15 +94,15 @@ static void display(void *data, void *id) {
|
|||||||
rect.x = (int)((1. + .5 * sin(0.03 * c->n)) * (w - VIDEOWIDTH) / 2);
|
rect.x = (int)((1. + .5 * sin(0.03 * c->n)) * (w - VIDEOWIDTH) / 2);
|
||||||
rect.y = (int)((1. + .5 * cos(0.03 * c->n)) * (h - VIDEOHEIGHT) / 2);
|
rect.y = (int)((1. + .5 * cos(0.03 * c->n)) * (h - VIDEOHEIGHT) / 2);
|
||||||
|
|
||||||
Renderer::get_singleton()->set_draw_color(0, 80, 0, 255);
|
//Renderer::get_singleton()->set_draw_color(0, 80, 0, 255);
|
||||||
Renderer::get_singleton()->clear();
|
//Renderer::get_singleton()->clear();
|
||||||
SDL_RenderCopy(Renderer::get_singleton()->get_renderer(), c->texture, NULL, &rect);
|
//SDL_RenderCopy(Renderer::get_singleton()->get_renderer(), c->texture, NULL, &rect);
|
||||||
//Renderer::get_singleton()->present();
|
//Renderer::get_singleton()->present();
|
||||||
|
|
||||||
//SDL_SetRenderDrawColor(Renderer::get_singleton()->get_renderer(), 0, 80, 0, 255);
|
SDL_SetRenderDrawColor(Renderer::get_singleton()->get_renderer(), 0, 80, 0, 255);
|
||||||
//SDL_RenderClear(Renderer::get_singleton()->get_renderer());
|
SDL_RenderClear(Renderer::get_singleton()->get_renderer());
|
||||||
//SDL_RenderCopy(Renderer::get_singleton()->get_renderer(), c->texture, NULL, &rect);
|
SDL_RenderCopy(Renderer::get_singleton()->get_renderer(), c->texture, NULL, &rect);
|
||||||
//SDL_RenderPresent(Renderer::get_singleton()->get_renderer());
|
SDL_RenderPresent(Renderer::get_singleton()->get_renderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VLCScene::event(const SDL_Event &ev) {
|
void VLCScene::event(const SDL_Event &ev) {
|
||||||
@ -109,26 +140,19 @@ void VLCScene::render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VLCScene::VLCScene() {
|
VLCScene::VLCScene() {
|
||||||
|
scene = this;
|
||||||
r = false;
|
r = false;
|
||||||
done = 0;
|
done = 0;
|
||||||
action = 0;
|
action = 0;
|
||||||
pause = 0;
|
pause = 0;
|
||||||
|
texture = nullptr;
|
||||||
texture = SDL_CreateTexture(
|
|
||||||
Renderer::get_singleton()->get_renderer(),
|
|
||||||
SDL_PIXELFORMAT_BGR565, SDL_TEXTUREACCESS_STREAMING,
|
|
||||||
VIDEOWIDTH, VIDEOHEIGHT);
|
|
||||||
|
|
||||||
if (!texture) {
|
|
||||||
fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex = SDL_CreateMutex();
|
mutex = SDL_CreateMutex();
|
||||||
|
|
||||||
char const *vlc_argv[] = {
|
char const *vlc_argv[] = {
|
||||||
//"--no-audio", // Don't play audio.
|
//"--no-audio", // Don't play audio.
|
||||||
"--no-xlib", // Don't use Xlib.
|
"--no-xlib", // Don't use Xlib.
|
||||||
|
//"--verbose", "3",
|
||||||
|
|
||||||
// Apply a video filter.
|
// Apply a video filter.
|
||||||
//"--video-filter", "sepia",
|
//"--video-filter", "sepia",
|
||||||
@ -151,16 +175,21 @@ VLCScene::VLCScene() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = libvlc_media_new_path(libvlc, "./test.mp4");
|
m = libvlc_media_new_path(libvlc, "./test.mkv");
|
||||||
|
|
||||||
mp = libvlc_media_player_new_from_media(m);
|
mp = libvlc_media_player_new_from_media(m);
|
||||||
libvlc_media_release(m);
|
libvlc_media_release(m);
|
||||||
|
|
||||||
|
//memcpy(chroma, "RV16", 4);
|
||||||
|
|
||||||
|
libvlc_video_set_format_callbacks(mp, formatSetup, NULL);
|
||||||
|
|
||||||
libvlc_video_set_callbacks(mp, lock, unlock, display, this);
|
libvlc_video_set_callbacks(mp, lock, unlock, display, this);
|
||||||
libvlc_video_set_format(mp, "RV16", VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH * 2);
|
//libvlc_video_set_format(mp, chroma, VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
VLCScene::~VLCScene() {
|
VLCScene::~VLCScene() {
|
||||||
|
scene = nullptr;
|
||||||
|
|
||||||
// Stop stream and clean up libVLC.
|
// Stop stream and clean up libVLC.
|
||||||
libvlc_media_player_stop(mp);
|
libvlc_media_player_stop(mp);
|
||||||
@ -170,3 +199,5 @@ VLCScene::~VLCScene() {
|
|||||||
// Close window and clean up libSDL.
|
// Close window and clean up libSDL.
|
||||||
SDL_DestroyMutex(mutex);
|
SDL_DestroyMutex(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VLCScene *VLCScene::scene = nullptr;
|
@ -24,6 +24,10 @@ public:
|
|||||||
libvlc_media_t *m;
|
libvlc_media_t *m;
|
||||||
libvlc_media_player_t *mp;
|
libvlc_media_player_t *mp;
|
||||||
|
|
||||||
|
static VLCScene *scene;
|
||||||
|
|
||||||
|
char *chroma;
|
||||||
|
|
||||||
bool r;
|
bool r;
|
||||||
int done;
|
int done;
|
||||||
int action;
|
int action;
|
||||||
|
Loading…
Reference in New Issue
Block a user