mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
libeplayer3: change teletext handling to directly inject packets in tuxtext
Origin commit data
------------------
Branch: master
Commit: daaa1ca8df
Author: martii <m4rtii@gmx.de>
Date: 2014-03-23 (Sun, 23 Mar 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -9,7 +9,7 @@ libeplayer3_la_SOURCES = \
|
||||
container/container.c container/container_ffmpeg.c \
|
||||
manager/audio.c manager/manager.c manager/subtitle.c manager/video.c \
|
||||
manager/teletext.c manager/chapter.c \
|
||||
output/linuxdvb.c output/output.c output/output_pipe.c \
|
||||
output/linuxdvb.c output/output.c \
|
||||
playback/playback.c output/writer/writer.c output/writer/aac.c output/writer/wmv.c \
|
||||
output/writer/ac3.c output/writer/divx.c output/writer/wma.c output/writer/pes.c \
|
||||
output/writer/dts.c output/writer/mpeg2.c output/writer/mp3.c output/writer/misc.c \
|
||||
|
@@ -229,10 +229,12 @@ long long int calcPts(AVStream * stream, int64_t pts)
|
||||
/* Worker Thread */
|
||||
/* **************************** */
|
||||
|
||||
// from neutrino-mp/lib/dvbsub.cpp
|
||||
// from neutrino-mp/lib/libdvbsubtitle/dvbsub.cpp
|
||||
extern void dvbsub_write(AVSubtitle *, int64_t);
|
||||
extern void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid);
|
||||
extern void dvbsub_ass_clear(void);
|
||||
// from neutrino-mp/lib/lib/libtuxtxt/tuxtxt_common.h
|
||||
extern void teletext_write(int pid, uint8_t *data, int size);
|
||||
|
||||
static void FFMPEGThread(Context_t * context)
|
||||
{
|
||||
@@ -631,24 +633,7 @@ static void FFMPEGThread(Context_t * context)
|
||||
}
|
||||
} /* duration */
|
||||
} else if (teletextTrack && (teletextTrack->Id == pid)) {
|
||||
teletextTrack->pts = pts = calcPts(teletextTrack->stream, packet.pts);
|
||||
|
||||
ffmpeg_printf(200, "TeleText index = %d\n", pid);
|
||||
|
||||
avOut.data = packet_data;
|
||||
avOut.len = packet_size;
|
||||
avOut.pts = pts;
|
||||
avOut.extradata = NULL;
|
||||
avOut.extralen = 0;
|
||||
avOut.frameRate = 0;
|
||||
avOut.timeScale = 0;
|
||||
avOut.width = 0;
|
||||
avOut.height = 0;
|
||||
avOut.type = "teletext";
|
||||
|
||||
if (context->output->teletext->Write(context, &avOut) < 0) {
|
||||
//ffmpeg_err("writing data to teletext fifo failed\n");
|
||||
}
|
||||
teletext_write(pid, packet_data, packet_size);
|
||||
}
|
||||
|
||||
av_free_packet(&packet);
|
||||
|
@@ -55,7 +55,6 @@ typedef struct Output_s {
|
||||
|
||||
extern Output_t LinuxDvbOutput;
|
||||
extern Output_t SubtitleOutput;
|
||||
extern Output_t PipeOutput;
|
||||
|
||||
typedef struct OutputHandler_s {
|
||||
char *Name;
|
||||
|
@@ -57,7 +57,6 @@ extern Writer_t WriterVideoMSCOMP;
|
||||
extern Writer_t WriterVideoH263;
|
||||
extern Writer_t WriterVideoFLV;
|
||||
extern Writer_t WriterVideoVC1;
|
||||
extern Writer_t WriterPipe;
|
||||
|
||||
Writer_t *getWriter(char *encoding);
|
||||
|
||||
|
@@ -65,7 +65,6 @@ static const char *FILENAME = "output.c";
|
||||
|
||||
static Output_t *AvailableOutput[] = {
|
||||
&LinuxDvbOutput,
|
||||
&PipeOutput,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -114,10 +113,6 @@ static void OutputAdd(Context_t * context, char *port)
|
||||
context->output->video = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
if (!strcmp("teletext", port)) {
|
||||
context->output->teletext = AvailableOutput[i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,382 +0,0 @@
|
||||
/*
|
||||
* Pipe Output handling.
|
||||
*
|
||||
* 2012 by martii
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <memory.h>
|
||||
#include <asm/types.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "writer.h"
|
||||
#include "misc.h"
|
||||
#include "pes.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define PIPE_DEBUG
|
||||
|
||||
static short debug_level = 0;
|
||||
|
||||
static const char FILENAME[] = __FILE__;
|
||||
|
||||
#ifdef PIPE_DEBUG
|
||||
#define pipe_printf(level, fmt, x...) do { \
|
||||
if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x ); } while (0)
|
||||
#else
|
||||
#define pipe_printf(x...)
|
||||
#endif
|
||||
|
||||
#ifndef PIPE_SILENT
|
||||
#define pipe_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0)
|
||||
#else
|
||||
#define pipe_err(x...)
|
||||
#endif
|
||||
|
||||
#define cERR_PIPE_NO_ERROR 0
|
||||
#define cERR_PIPE_ERROR -1
|
||||
|
||||
static const char TELETEXTPIPE[] = "/tmp/.eplayer3_teletext";
|
||||
|
||||
static int teletextfd = -1;
|
||||
|
||||
pthread_mutex_t Pipemutex;
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
int PipeStop(Context_t * context, char *type);
|
||||
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
void getPipeMutex(const char *filename
|
||||
__attribute__ ((unused)), const char *function
|
||||
__attribute__ ((unused)), int line
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
|
||||
pipe_printf(250, "requesting mutex\n");
|
||||
|
||||
pthread_mutex_lock(&Pipemutex);
|
||||
|
||||
pipe_printf(250, "received mutex\n");
|
||||
}
|
||||
|
||||
void releasePipeMutex(const char *filename
|
||||
__attribute__ ((unused)), const char *function
|
||||
__attribute__ ((unused)), int line
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
pthread_mutex_unlock(&Pipemutex);
|
||||
|
||||
pipe_printf(250, "released mutex\n");
|
||||
|
||||
}
|
||||
|
||||
int PipeOpen(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
if (teletext && teletextfd == -1) {
|
||||
mkfifo(TELETEXTPIPE, 0644);
|
||||
teletextfd = open(TELETEXTPIPE, O_RDWR | O_NONBLOCK);
|
||||
|
||||
if (teletextfd < 0) {
|
||||
pipe_err("failed to open %s - errno %d\n", TELETEXTPIPE,
|
||||
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 teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
/* closing stand alone is not allowed, so prevent
|
||||
* user from closing and dont call stop. stop will
|
||||
* set default values for us (speed and so on).
|
||||
*/
|
||||
PipeStop(context, type);
|
||||
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
close(teletextfd);
|
||||
teletextfd = -1;
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
int PipePlay(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
#if 0
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeStop(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
#if 0
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeFlush(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
char buf[65536];
|
||||
while (0 < read(teletextfd, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
pipe_printf(10, "exiting\n");
|
||||
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
int PipeClear(Context_t * context __attribute__ ((unused)), char *type)
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "v%d\n", teletext);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
char buf[65536];
|
||||
while (0 < read(teletextfd, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
pipe_printf(10, "exiting\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int PipeSwitch(Context_t * context __attribute__ ((unused)), char *type
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
#if 0
|
||||
unsigned char teletext = !strcmp("teletext", type);
|
||||
|
||||
pipe_printf(10, "t%d\n", teletext);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
if (teletext && teletextfd != -1) {
|
||||
}
|
||||
|
||||
releasePipeMutex(FILENAME, __FUNCTION__, __LINE__);
|
||||
|
||||
}
|
||||
|
||||
pipe_printf(10, "exiting\n");
|
||||
#endif
|
||||
return cERR_PIPE_NO_ERROR;
|
||||
}
|
||||
|
||||
static int writePESDataTeletext(int fd, unsigned char *data,
|
||||
size_t data_len)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
if (data_len > 0) {
|
||||
len = data_len + 39;
|
||||
char header[45];
|
||||
memset(header, 0, sizeof(header));
|
||||
header[2] = 0x01;
|
||||
header[3] = 0xbd;
|
||||
header[4] = (len >> 8) & 0xff;
|
||||
header[5] = len & 0xff;
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = header;
|
||||
iov[0].iov_len = 45;
|
||||
iov[1].iov_base = data;
|
||||
iov[1].iov_len = data_len;
|
||||
len = writev(fd, iov, 2);
|
||||
if (len != 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 teletext;
|
||||
|
||||
if (out == NULL) {
|
||||
pipe_err("null pointer passed\n");
|
||||
return cERR_PIPE_ERROR;
|
||||
}
|
||||
|
||||
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, "t%d\n", teletext);
|
||||
|
||||
if (teletext) {
|
||||
res = writePESDataTeletext(teletextfd, out->data, out->len);
|
||||
|
||||
if (res <= 0) {
|
||||
ret = cERR_PIPE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int reset(Context_t * context __attribute__ ((unused)))
|
||||
{
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int Command(void *_context, OutputCmd_t command, void *argument)
|
||||
{
|
||||
Context_t *context = (Context_t *) _context;
|
||||
int ret = cERR_PIPE_NO_ERROR;
|
||||
|
||||
pipe_printf(50, "Command %d\n", command);
|
||||
|
||||
switch (command) {
|
||||
case OUTPUT_OPEN:{
|
||||
ret = PipeOpen(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLOSE:{
|
||||
ret = PipeClose(context, (char *) argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_PLAY:{ // 4
|
||||
ret = PipePlay(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_STOP:{
|
||||
reset(context);
|
||||
ret = PipeStop(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_FLUSH:{
|
||||
ret = PipeFlush(context, (char *) argument);
|
||||
reset(context);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_CLEAR:{
|
||||
ret = PipeClear(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
case OUTPUT_SWITCH:{
|
||||
ret = PipeSwitch(context, (char *) argument);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pipe_err("ContainerCmd %d not supported!\n", command);
|
||||
ret = cERR_PIPE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
pipe_printf(50, "exiting with value %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *PipeCapabilities[] = { "teletext", NULL };
|
||||
|
||||
struct Output_s PipeOutput = {
|
||||
"TeleText",
|
||||
&Command,
|
||||
&Write,
|
||||
PipeCapabilities
|
||||
};
|
@@ -66,7 +66,6 @@ bool cPlayback::Open(playmode_t PlayMode)
|
||||
if(player && player->output) {
|
||||
player->output->Command(player,OUTPUT_ADD, (void*)"audio");
|
||||
player->output->Command(player,OUTPUT_ADD, (void*)"video");
|
||||
player->output->Command(player,OUTPUT_ADD, (void*)"teletext");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -249,8 +248,6 @@ bool cPlayback::Stop(void)
|
||||
if(player && player->output) {
|
||||
player->output->Command(player,OUTPUT_DEL, (void*)"audio");
|
||||
player->output->Command(player,OUTPUT_DEL, (void*)"video");
|
||||
player->output->Command(player,OUTPUT_DEL, (void*)"subtitle");
|
||||
player->output->Command(player,OUTPUT_DEL, (void*)"teletext");
|
||||
}
|
||||
|
||||
if(player && player->playback)
|
||||
@@ -572,7 +569,7 @@ void cPlayback::FindAllTeletextsubtitlePids(int *pids, unsigned int *numpids, st
|
||||
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
|
||||
if (j < max_numpids) {
|
||||
int _pid;
|
||||
if (2 != sscanf(TrackList[i], "%d %*s %d %*d %*d", &_pid, &type))
|
||||
if (2 != sscanf(TrackList[i], "%*d %d %*s %d %*d %*d", &_pid, &type))
|
||||
continue;
|
||||
if (type != 2 && type != 5) // return subtitles only
|
||||
continue;
|
||||
@@ -602,11 +599,11 @@ int cPlayback::GetTeletextPid(void)
|
||||
for (i = 0; TrackList[i] != NULL; i+=2) {
|
||||
int type = 0;
|
||||
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
|
||||
if (!pid) {
|
||||
if (2 != sscanf(TrackList[i], "%d %*s %d %*d %*d", &pid, &type))
|
||||
if (pid < 0) {
|
||||
if (2 != sscanf(TrackList[i], "%*d %d %*s %d %*d %*d", &pid, &type))
|
||||
continue;
|
||||
if (type != 1)
|
||||
pid = 0;
|
||||
pid = -1;
|
||||
}
|
||||
free(TrackList[i]);
|
||||
free(TrackList[i+1]);
|
||||
|
Reference in New Issue
Block a user