libeplayer3: let neutrino handle bitmap subtitles

This commit is contained in:
martii
2014-03-16 07:29:38 +01:00
parent 0e55c3f01b
commit f60e040d03
19 changed files with 111 additions and 593 deletions

View File

@@ -119,10 +119,6 @@ static void OutputAdd(Context_t * context, char *port)
context->output->subtitle = AvailableOutput[i];
return;
}
if (!strcmp("dvbsubtitle", port)) {
context->output->dvbsubtitle = AvailableOutput[i];
return;
}
if (!strcmp("teletext", port)) {
context->output->teletext = AvailableOutput[i];
return;
@@ -140,8 +136,6 @@ static void OutputDel(Context_t * context, char *port)
context->output->video = NULL;
else if (!strcmp("subtitle", port))
context->output->subtitle = NULL;
else if (!strcmp("dvbsubtitle", port))
context->output->dvbsubtitle = NULL;
else if (!strcmp("teletext", port))
context->output->teletext = NULL;
@@ -173,11 +167,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
context->output->subtitle->Command(context,
OUTPUT_OPEN,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -204,11 +193,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
context->output->subtitle->Command(context,
OUTPUT_CLOSE,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -252,11 +236,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
OUTPUT_PLAY,
"subtitle");
}
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -284,11 +263,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
context->output->subtitle->Command(context,
OUTPUT_STOP,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -382,11 +356,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
"audio");
//if (context->playback->isSubtitle)
// ret |= context->output->subtitle->Command(context, OUTPUT_CONTINUE, "subtitle");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -424,11 +393,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
"audio");
//if (context->playback->isSubtitle && (argument == NULL || *(char *) argument == 's'))
// ret |= context->output->subtitle->Command(context, OUTPUT_CLEAR, "subtitle");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -464,11 +428,6 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
return context->output->video->Command(context,
OUTPUT_SWITCH,
"video");
if (context->playback->isDvbSubtitle)
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |=
context->output->teletext->Command(context,
@@ -552,7 +511,6 @@ OutputHandler_t OutputHandler = {
NULL,
NULL,
NULL,
NULL, // dvbsubtitle
NULL, // teletext
&Command
};

View File

@@ -71,10 +71,8 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x );
#define cERR_PIPE_ERROR -1
static const char TELETEXTPIPE[] = "/tmp/.eplayer3_teletext";
static const char DVBSUBTITLEPIPE[] = "/tmp/.eplayer3_dvbsubtitle";
static int teletextfd = -1;
static int dvbsubtitlefd = -1;
pthread_mutex_t Pipemutex;
@@ -114,9 +112,8 @@ void releasePipeMutex(const char *filename
int PipeOpen(Context_t * context __attribute__ ((unused)), char *type)
{
unsigned char teletext = !strcmp("teletext", type);
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
pipe_printf(10, "t%d\n", teletext);
if (teletext && teletextfd == -1) {
mkfifo(TELETEXTPIPE, 0644);
@@ -129,27 +126,15 @@ int PipeOpen(Context_t * context __attribute__ ((unused)), char *type)
return cERR_PIPE_ERROR;
}
}
if (dvbsubtitle && dvbsubtitlefd == -1) {
mkfifo(DVBSUBTITLEPIPE, 0644);
dvbsubtitlefd = open(DVBSUBTITLEPIPE, O_RDWR | O_NONBLOCK);
if (dvbsubtitlefd < 0) {
pipe_err("failed to open %s - errno %d\n", DVBSUBTITLEPIPE,
errno);
pipe_err("%s\n", strerror(errno));
return cERR_PIPE_ERROR;
}
}
return cERR_PIPE_NO_ERROR;
}
int PipeClose(Context_t * context, char *type)
{
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
pipe_printf(10, "t%d\n", teletext);
/* closing stand alone is not allowed, so prevent
* user from closing and dont call stop. stop will
@@ -159,10 +144,6 @@ int PipeClose(Context_t * context, char *type)
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
close(dvbsubtitlefd);
dvbsubtitlefd = -1;
}
if (teletext && teletextfd != -1) {
close(teletextfd);
teletextfd = -1;
@@ -178,13 +159,10 @@ int PipePlay(Context_t * context __attribute__ ((unused)), char *type
int ret = cERR_PIPE_NO_ERROR;
#if 0
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
pipe_printf(10, "t%d\n", teletext);
if (dvbsubtitle && dvbsubtitlefd != -1) {
}
if (teletext && teletextfd != -1) {
}
#endif
@@ -197,15 +175,12 @@ int PipeStop(Context_t * context __attribute__ ((unused)), char *type
int ret = cERR_PIPE_NO_ERROR;
#if 0
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
pipe_printf(10, "t%d\n", teletext);
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
}
if (teletext && teletextfd != -1) {
}
@@ -217,19 +192,13 @@ int PipeStop(Context_t * context __attribute__ ((unused)), char *type
int PipeFlush(Context_t * context __attribute__ ((unused)), char *type)
{
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "t%d d%d\n", teletext, dvbsubtitle);
pipe_printf(10, "t%d\n", teletext);
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
if (teletext && teletextfd != -1) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
char buf[65536];
while (0 < read(dvbsubtitlefd, buf, sizeof(buf)));
}
if (teletext && teletextfd != -1) {
char buf[65536];
while (0 < read(teletextfd, buf, sizeof(buf)));
@@ -246,19 +215,13 @@ int PipeFlush(Context_t * context __attribute__ ((unused)), char *type)
int PipeClear(Context_t * context __attribute__ ((unused)), char *type)
{
int ret = cERR_PIPE_NO_ERROR;
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "v%d a%d\n", dvbsubtitle, teletext);
pipe_printf(10, "v%d\n", teletext);
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
if (teletext && teletextfd != -1) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
char buf[65536];
while (0 < read(dvbsubtitlefd, buf, sizeof(buf)));
}
if (teletext && teletextfd != -1) {
char buf[65536];
while (0 < read(teletextfd, buf, sizeof(buf)));
@@ -276,21 +239,16 @@ int PipeSwitch(Context_t * context __attribute__ ((unused)), char *type
__attribute__ ((unused)))
{
#if 0
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
pipe_printf(10, "v%d a%d\n", dvbsubtitle, teletext);
pipe_printf(10, "t%d\n", teletext);
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
if (teletext && teletextfd != -1) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (teletext && teletextfd != -1) {
}
if (dvbsubtitle && dvbsubtitlefd != -1) {
}
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
}
@@ -327,54 +285,11 @@ static int writePESDataTeletext(int fd, unsigned char *data,
return len;
}
static int writePESDataDvbsubtitle(int fd, unsigned char *data,
size_t data_len, int64_t pts)
{
int len = 0;
if (data_len > 0) {
len = data_len + 10;
char header[16];
memset(header, 0, sizeof(header));
header[2] = 0x01;
header[3] = 0xbd;
header[4] = (len >> 8) & 0xff;
header[5] = len & 0xff;
if (pts) {
header[7] = 0x80;
header[13] = 0x01 | ((pts << 1) & 0xff);
pts >>= 7;
header[12] = pts & 0xff;
pts >>= 8;
header[11] = 0x01 | ((pts << 1) & 0xff);
pts >>= 7;
header[10] = pts & 0xff;
pts >>= 8;
header[9] = 0x21 | ((pts << 1) & 0xff);
}
header[8] = 14 - 9;
header[14] = 0x20;
struct iovec iov[2];
iov[0].iov_base = header;
iov[0].iov_len = 16;
iov[1].iov_base = data;
iov[1].iov_len = data_len;
len = writev(fd, iov, 2);
if (len != (int) (iov[0].iov_len + iov[1].iov_len)) {
// writing to pipe failed, clear it.
char buf[65536];
while (0 < read(fd, buf, sizeof(buf)));
}
}
return len;
}
static int Write(void *_context __attribute__ ((unused)), void *_out)
{
AudioVideoOut_t *out = (AudioVideoOut_t *) _out;
int ret = cERR_PIPE_NO_ERROR;
int res = 0;
unsigned char dvbsubtitle;
unsigned char teletext;
if (out == NULL) {
@@ -382,23 +297,14 @@ static int Write(void *_context __attribute__ ((unused)), void *_out)
return cERR_PIPE_ERROR;
}
dvbsubtitle = !strcmp("dvbsubtitle", out->type);
teletext = !strcmp("teletext", out->type);
pipe_printf(20,
"DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n",
out->len, out->extralen, out->pts, out->frameRate);
pipe_printf(20, "v%d a%d\n", dvbsubtitle, teletext);
pipe_printf(20, "t%d\n", teletext);
if (dvbsubtitle) {
res =
writePESDataDvbsubtitle(dvbsubtitlefd, out->data, out->len,
out->pts);
if (res <= 0) {
ret = cERR_PIPE_ERROR;
}
} else if (teletext) {
if (teletext) {
res = writePESDataTeletext(teletextfd, out->data, out->len);
if (res <= 0) {
@@ -466,10 +372,10 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
return ret;
}
static char *PipeCapabilities[] = { "teletext", "dvbsubtitle", NULL };
static char *PipeCapabilities[] = { "teletext", NULL };
struct Output_s PipeOutput = {
"DVBSubTitle",
"TeleText",
&Command,
&Write,
PipeCapabilities

View File

@@ -38,6 +38,8 @@
#include "output.h"
#include "subtitle.h"
#include <libavcodec/avcodec.h>
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
@@ -108,6 +110,7 @@ static int screen_height = 0;
static int destStride = 0;
static void (*framebufferBlit) = NULL;
static uint32_t *destination = NULL;
void (*dvbsubWrite)(AVSubtitle *, int64_t) = NULL;
/* ***************************** */
/* Prototypes */
@@ -784,6 +787,7 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
out->screen_width = screen_width;
out->screen_height = screen_height;
out->framebufferBlit = framebufferBlit;
out->dvbsubWrite = (void (*)(void *, int64_t))dvbsubWrite;
out->destination = destination;
out->destStride = destStride;
break;
@@ -793,6 +797,7 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
screen_width = out->screen_width;
screen_height = out->screen_height;
framebufferBlit = out->framebufferBlit;
dvbsubWrite = (void (*)(AVSubtitle *, int64_t))out->dvbsubWrite;
destination = out->destination;
destStride = out->destStride;
break;