libeplayer3: run through indent, no binary change

Origin commit data
------------------
Branch: master
Commit: 2d652aab01
Author: martii <m4rtii@gmx.de>
Date: 2013-11-21 (Thu, 21 Nov 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2013-11-21 19:40:47 +01:00
parent 3957f023dd
commit b1c4c4a8b8
48 changed files with 6645 additions and 5857 deletions

View File

@@ -49,7 +49,8 @@ static Container_t * AvailableContainer[] = {
NULL
};
static void printContainerCapabilities() {
static void printContainerCapabilities()
{
int i, j;
container_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
@@ -57,24 +58,30 @@ static void printContainerCapabilities() {
for (i = 0; AvailableContainer[i] != NULL; i++)
for (j = 0; AvailableContainer[i]->Capabilities[j] != NULL; j++)
container_printf(10, "%s ", AvailableContainer[i]->Capabilities[j]);
container_printf(10, "%s ",
AvailableContainer[i]->Capabilities[j]);
container_printf(10, "\n");
}
static int selectContainer(Context_t *context, char * extension __attribute__((unused))) {
static int selectContainer(Context_t * context, char *extension
__attribute__ ((unused)))
{
#if 0
int i, j;
int ret = -1;
container_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
for (i = 0; AvailableContainer[i] != NULL; i++)
{
for (i = 0; AvailableContainer[i] != NULL; i++) {
for (j = 0; AvailableContainer[i]->Capabilities[j] != NULL; j++)
if (!strcasecmp(AvailableContainer[i]->Capabilities[j], extension)) {
context->container->selectedContainer = AvailableContainer[i];
if (!strcasecmp
(AvailableContainer[i]->Capabilities[j], extension)) {
context->container->selectedContainer =
AvailableContainer[i];
container_printf(10, "Selected Container: %s\n", context->container->selectedContainer->Name);
container_printf(10, "Selected Container: %s\n",
context->container->selectedContainer->
Name);
ret = 0;
break;
}
@@ -94,7 +101,8 @@ static int selectContainer(Context_t *context, char * extension __attribute__((
}
static int Command(void *_context, ContainerCmd_t command, void * argument) {
static int Command(void *_context, ContainerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = 0;
@@ -114,7 +122,8 @@ static int Command(void *_context, ContainerCmd_t command, void * argument) {
break;
}
default:
container_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
container_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
__FUNCTION__, command);
break;
}

View File

@@ -92,8 +92,7 @@ typedef struct ass_s {
float duration;
} ass_t;
typedef struct region_s
{
typedef struct region_s {
unsigned int x;
unsigned int y;
unsigned int w;
@@ -140,7 +139,9 @@ static region_t* firstRegion = NULL;
/* MISC Functions */
/* ***************************** */
void ass_msg_callback(int level __attribute__((unused)), const char *format, va_list va, void *ctx __attribute__((unused)))
void ass_msg_callback(int level
__attribute__ ((unused)), const char *format,
va_list va, void *ctx __attribute__ ((unused)))
{
int n;
char *str;
@@ -155,7 +156,8 @@ void ass_msg_callback(int level __attribute__((unused)), const char *format, va_
}
}
static void getMutex(int line) {
static void getMutex(int line)
{
ass_printf(150, "%d requesting mutex\n", line);
pthread_mutex_lock(&mutex);
@@ -163,7 +165,8 @@ static void getMutex(int line) {
ass_printf(150, "%d received mutex\n", line);
}
static void releaseMutex(int line) {
static void releaseMutex(int line)
{
pthread_mutex_unlock(&mutex);
ass_printf(150, "%d released mutex\n", line);
@@ -185,16 +188,13 @@ void releaseRegions()
writer = getDefaultFramebufferWriter();
if (writer == NULL)
{
if (writer == NULL) {
ass_err("no framebuffer writer found!\n");
}
next = firstRegion;
while (next)
{
if (writer)
{
while (next) {
if (writer) {
WriterFBCallData_t out;
ass_printf(100, "release: w %d h %d x %d y %d\n",
@@ -239,20 +239,17 @@ void checkRegions()
writer = getDefaultFramebufferWriter();
if (!writer)
{
if (!writer) {
ass_err("no framebuffer writer found!\n");
}
prev = next = firstRegion;
while (next)
{
if (now > next->undisplay + cDeltaTime)
{
ass_printf(100, "undisplay: %ld > %ld\n", now, next->undisplay + cDeltaTime);
while (next) {
if (now > next->undisplay + cDeltaTime) {
ass_printf(100, "undisplay: %ld > %ld\n", now,
next->undisplay + cDeltaTime);
if (writer)
{
if (writer) {
WriterFBCallData_t out;
ass_printf(100, "release: w %d h %d x %d y %d\n",
@@ -279,8 +276,7 @@ void checkRegions()
if (old == firstRegion)
firstRegion = next;
free(old);
} else
{
} else {
prev = next;
next = next->next;
}
@@ -288,7 +284,8 @@ void checkRegions()
}
/* store a display region for later release */
void storeRegion(unsigned int x, unsigned int y, unsigned int w, unsigned int h, time_t undisplay)
void storeRegion(unsigned int x, unsigned int y, unsigned int w,
unsigned int h, time_t undisplay)
{
region_t **new = &firstRegion;
@@ -311,7 +308,8 @@ void storeRegion(unsigned int x, unsigned int y, unsigned int w, unsigned int h,
/* Worker Thread */
/* **************************** */
static void ASSThread(Context_t *context) {
static void ASSThread(Context_t * context)
{
char threadname[17];
strncpy(threadname, __func__, sizeof(threadname));
threadname[16] = 0;
@@ -320,8 +318,7 @@ static void ASSThread(Context_t *context) {
ass_printf(10, "\n");
while ( context->playback->isCreationPhase )
{
while (context->playback->isCreationPhase) {
ass_err("Thread waiting for end of init phase...\n");
usleep(1000);
}
@@ -330,8 +327,7 @@ static void ASSThread(Context_t *context) {
writer = getDefaultFramebufferWriter();
if (writer == NULL)
{
if (writer == NULL) {
ass_err("no framebuffer writer found!\n");
}
@@ -352,18 +348,16 @@ static void ASSThread(Context_t *context) {
continue;
}
if ((isContainerRunning) && (ass_track))
{
if ((isContainerRunning) && (ass_track)) {
ASS_Image *img = NULL;
int change = 0;
unsigned long int playPts;
if (context && context->playback)
{
if (context->playback->Command(context, PLAYBACK_PTS, &playPts) < 0)
if (context && context->playback) {
if (context->playback->
Command(context, PLAYBACK_PTS, &playPts) < 0)
continue;
}
//FIXME: durch den sleep bleibt die cpu usage zw. 5 und 13%, ohne
// steigt sie bei Verwendung von subtiteln bis auf 95%.
// ich hoffe dadurch gehen keine subtitle verloren, wenn die playPts
@@ -376,12 +370,14 @@ static void ASSThread(Context_t *context) {
checkRegions();
if (ass_renderer && ass_track)
img = ass_render_frame(ass_renderer, ass_track, playPts / 90.0, &change);
img =
ass_render_frame(ass_renderer, ass_track,
playPts / 90.0, &change);
ass_printf(150, "img %p pts %lu %f\n", img, playPts, playPts / 90.0);
ass_printf(150, "img %p pts %lu %f\n", img, playPts,
playPts / 90.0);
if(img && ass_renderer && ass_track)
{
if (img && ass_renderer && ass_track) {
/* the spec says, that if a new set of regions is present
* the complete display switches to the new state. So lets
* release the old regions on display.
@@ -393,7 +389,8 @@ static void ASSThread(Context_t *context) {
time_t undisplay = now + 10;
if (ass_track && ass_track->events)
undisplay = now + (ass_track->events->Duration + 500) / 90000;
undisplay =
now + (ass_track->events->Duration + 500) / 90000;
ASS_Image *it;
int x0 = screen_width - 1;
@@ -412,13 +409,15 @@ static void ASSThread(Context_t *context) {
y1 = it->dst_y + it->h;
}
}
if (x1 > 0 && y1 > 0)
{
if (x1 > 0 && y1 > 0) {
x1++;
y1++;
int x, y;
uint32_t *dst = destination + y0 * destStride/sizeof(uint32_t) + x0;
int destStrideDiff = destStride/sizeof(uint32_t) - (x1 - x0);
uint32_t *dst =
destination + y0 * destStride / sizeof(uint32_t) +
x0;
int destStrideDiff =
destStride / sizeof(uint32_t) - (x1 - x0);
for (y = y0; y < y1; y++) {
for (x = x0; x < x1; x++)
*dst++ = 0x80808080;
@@ -428,20 +427,20 @@ static void ASSThread(Context_t *context) {
needsBlit = 1;
}
while (context && context->playback && context->playback->isPlaying && img)
{
while (context && context->playback
&& context->playback->isPlaying && img) {
WriterFBCallData_t out;
ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n",
img->w, img->h, img->stride,
img->dst_x, img->dst_y, img->color,
change, now, undisplay);
ass_printf(100,
"w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n",
img->w, img->h, img->stride, img->dst_x,
img->dst_y, img->color, change, now,
undisplay);
/* api docu said w and h can be zero which
* means image should not be rendered
*/
if ((img->w != 0) && (img->h != 0) && writer)
{
if ((img->w != 0) && (img->h != 0) && writer) {
out.data = img->bitmap;
out.Width = img->w;
out.Height = img->h;
@@ -455,7 +454,8 @@ static void ASSThread(Context_t *context) {
out.destination = destination;
out.destStride = destStride;
if(context && context->playback && context->playback->isPlaying && writer)
if (context && context->playback
&& context->playback->isPlaying && writer)
writer->writeData(&out);
needsBlit = 1;
@@ -466,8 +466,7 @@ static void ASSThread(Context_t *context) {
}
}
releaseMutex(__LINE__);
} else
{
} else {
usleep(1000);
}
@@ -526,7 +525,8 @@ int container_ass_init(Context_t *context)
return cERR_CONTAINER_ASS_ERROR;
}
context->output->subtitle->Command(context, OUTPUT_GET_SUBTITLE_OUTPUT, &output);
context->output->subtitle->Command(context, OUTPUT_GET_SUBTITLE_OUTPUT,
&output);
screen_width = output.screen_width;
screen_height = output.screen_height;
@@ -537,8 +537,10 @@ int container_ass_init(Context_t *context)
ass_printf(10, "width %d, height %d\n", screen_width, screen_height);
ass_set_frame_size(ass_renderer, screen_width, screen_height);
ass_set_margins(ass_renderer, (int)(0.03 * screen_height), (int)(0.03 * screen_height) ,
(int)(0.03 * screen_width ), (int)(0.03 * screen_width ) );
ass_set_margins(ass_renderer, (int) (0.03 * screen_height),
(int) (0.03 * screen_height),
(int) (0.03 * screen_width),
(int) (0.03 * screen_width));
ass_set_use_margins(ass_renderer, 1);
// ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0);
@@ -554,25 +556,24 @@ int container_ass_init(Context_t *context)
return cERR_CONTAINER_ASS_NO_ERROR;
}
int container_ass_process_data(Context_t *context __attribute__((unused)), SubtitleData_t* data)
int container_ass_process_data(Context_t * context
__attribute__ ((unused)),
SubtitleData_t * data)
{
int first_kiss;
ass_printf(20, ">\n");
if (!isContainerRunning)
{
if (!isContainerRunning) {
ass_err("Container not running\n");
return cERR_CONTAINER_ASS_ERROR;
}
if (ass_track == NULL)
{
if (ass_track == NULL) {
first_kiss = 1;
ass_track = ass_new_track(ass_library);
if (ass_track == NULL)
{
if (ass_track == NULL) {
ass_err("error creating ass_track\n");
return cERR_CONTAINER_ASS_ERROR;
}
@@ -580,15 +581,14 @@ int container_ass_process_data(Context_t *context __attribute__((unused)), Subti
ass_track->PlayResY = screen_height;
}
if ((data->extradata) && (first_kiss))
{
if ((data->extradata) && (first_kiss)) {
ass_printf(30, "processing private %d bytes\n", data->extralen);
ass_process_codec_private(ass_track, (char*) data->extradata, data->extralen);
ass_process_codec_private(ass_track, (char *) data->extradata,
data->extralen);
ass_printf(30, "processing private done\n");
}
if (data->data)
{
if (data->data) {
ass_printf(30, "processing data %d bytes\n", data->len);
ass_process_data(ass_track, (char *) data->data, data->len);
ass_printf(30, "processing data done\n");
@@ -597,21 +597,23 @@ int container_ass_process_data(Context_t *context __attribute__((unused)), Subti
return cERR_CONTAINER_ASS_NO_ERROR;
}
static int container_ass_stop(Context_t *context __attribute__((unused))) {
static int container_ass_stop(Context_t * context __attribute__ ((unused)))
{
int ret = cERR_CONTAINER_ASS_NO_ERROR;
int wait_time = 20;
Writer_t *writer;
ass_printf(10, "\n");
if (!isContainerRunning)
{
if (!isContainerRunning) {
ass_err("Container not running\n");
return cERR_CONTAINER_ASS_ERROR;
}
while ((hasPlayThreadStarted != 0) && (--wait_time) > 0) {
ass_printf(10, "Waiting for ass thread to terminate itself, will try another %d times\n", wait_time);
ass_printf(10,
"Waiting for ass thread to terminate itself, will try another %d times\n",
wait_time);
usleep(100000);
}
@@ -655,7 +657,8 @@ static int container_ass_stop(Context_t *context __attribute__((unused))) {
return ret;
}
static int container_ass_switch_subtitle(Context_t* context, int* arg __attribute__((unused)))
static int container_ass_switch_subtitle(Context_t * context, int *arg
__attribute__ ((unused)))
{
int error;
int ret = cERR_CONTAINER_ASS_NO_ERROR;
@@ -663,16 +666,14 @@ static int container_ass_switch_subtitle(Context_t* context, int* arg __attribut
ass_printf(10, "\n");
if (!isContainerRunning)
{
if (!isContainerRunning) {
ass_err("Container not running\n");
return cERR_CONTAINER_ASS_ERROR;
}
if (context && context->playback && context->playback->isPlaying) {
ass_printf(10, "is Playing\n");
}
else {
} else {
ass_printf(10, "is NOT Playing\n");
}
@@ -680,19 +681,20 @@ static int container_ass_switch_subtitle(Context_t* context, int* arg __attribut
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if((error = pthread_create(&PlayThread, &attr, (void *)&ASSThread, context)) != 0) {
ass_printf(10, "Error creating thread, error:%d:%s\n", error,strerror(error));
if ((error =
pthread_create(&PlayThread, &attr, (void *) &ASSThread,
context)) != 0) {
ass_printf(10, "Error creating thread, error:%d:%s\n", error,
strerror(error));
hasPlayThreadStarted = 0;
ret = cERR_CONTAINER_ASS_ERROR;
}
else {
} else {
ass_printf(10, "Created thread\n");
hasPlayThreadStarted = 1;
}
}
else {
} else {
ass_printf(10, "A thread already exists!\n");
ret = cERR_CONTAINER_ASS_ERROR;
@@ -725,8 +727,7 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
ass_printf(50, "Command %d\n", command);
switch(command)
{
switch (command) {
case CONTAINER_INIT:{
ret = container_ass_init(context);
break;

File diff suppressed because it is too large Load Diff

View File

@@ -100,15 +100,15 @@ static int hasThreadStarted = 0;
/* MISC Functions */
/* ***************************** */
void data_to_manager(Context_t *context, char* Text, unsigned long long int Pts, double Duration)
void data_to_manager(Context_t * context, char *Text,
unsigned long long int Pts, double Duration)
{
srt_printf(20, "--> Text= \"%s\"\n", Text);
if( context &&
context->playback &&
context->playback->isPlaying){
if (context && context->playback && context->playback->isPlaying) {
int sl = strlen(Text) - 1;
while(sl && (Text[sl]=='\n' || Text[sl]=='\r')) Text[sl--]='\0'; /*Delete last \n or \r */
while (sl && (Text[sl] == '\n' || Text[sl] == '\r'))
Text[sl--] = '\0'; /*Delete last \n or \r */
unsigned char *line = text_to_ass(Text, Pts, Duration);
srt_printf(50, "Sub text is %s\n", Text);
srt_printf(50, "Sub line is %s\n", line);
@@ -120,7 +120,8 @@ void data_to_manager(Context_t *context, char* Text, unsigned long long int Pts,
data.pts = Pts * 90;
data.duration = Duration;
context->container->assContainer->Command(context, CONTAINER_DATA, &data);
context->container->assContainer->Command(context, CONTAINER_DATA,
&data);
free(line);
}
@@ -131,7 +132,8 @@ void data_to_manager(Context_t *context, char* Text, unsigned long long int Pts,
/* Worker Thread */
/* ***************************** */
static void* SrtSubtitleThread(void *data) {
static void *SrtSubtitleThread(void *data)
{
int pos = 0;
char Data[MAXLINELENGTH];
unsigned long long int Pts = 0;
@@ -142,30 +144,38 @@ static void* SrtSubtitleThread(void *data) {
srt_printf(10, "\n");
while(context && context->playback && context->playback->isPlaying && fsub && fgets(Data, MAXLINELENGTH, fsub)) {
while (context && context->playback && context->playback->isPlaying
&& fsub && fgets(Data, MAXLINELENGTH, fsub)) {
srt_printf(20, "pos=%d\n", pos);
if(pos == 0)
{
if(Data[0] == '\n' || Data[0] == '\0' || Data[0] == 13 /* ^M */)
if (pos == 0) {
if (Data[0] == '\n' || Data[0] == '\0'
|| Data[0] == 13 /* ^M */ )
continue; /* Empty line not allowed here */
pos++;
} else if(pos == 1)
{
int ret, horIni, minIni, secIni, milIni, horFim, minFim, secFim, milFim;
} else if (pos == 1) {
int ret, horIni, minIni, secIni, milIni, horFim, minFim,
secFim, milFim;
ret = sscanf(Data, "%d:%d:%d,%d --> %d:%d:%d,%d", &horIni, &minIni, &secIni, &milIni, &horFim, &minFim, &secFim, &milFim);
if (ret!=8) continue; /* Data is not in correct format */
ret =
sscanf(Data, "%d:%d:%d,%d --> %d:%d:%d,%d", &horIni,
&minIni, &secIni, &milIni, &horFim, &minFim,
&secFim, &milFim);
if (ret != 8)
continue; /* Data is not in correct format */
Pts = (horIni * 3600 + minIni * 60 + secIni) * 1000 + milIni;
Duration = ((horFim*3600 + minFim*60 + secFim) * 1000 + milFim - Pts) / 1000.0;
Duration =
((horFim * 3600 + minFim * 60 + secFim) * 1000 + milFim -
Pts) / 1000.0;
pos++;
} else if (pos == 2) {
srt_printf(20, "Data[0] = %d \'%c\'\n", Data[0], Data[0]);
if(Data[0] == '\n' || Data[0] == '\0' || Data[0] == 13 /* ^M */) {
if (Data[0] == '\n' || Data[0] == '\0'
|| Data[0] == 13 /* ^M */ ) {
if (Text == NULL)
Text = strdup(" \n"); /* better to display at least one character */
@@ -180,7 +190,9 @@ static void* SrtSubtitleThread(void *data) {
if (!Text) {
Text = strdup(Data);
} else {
int length = strlen(Text) /* \0 -> \n */ + strlen(Data) + 2 /* \0 */;
int length =
strlen(Text) /* \0 -> \n */ +strlen(Data) +
2 /* \0 */ ;
char *tmpText = Text;
Text = (char *) malloc(length);
@@ -208,7 +220,9 @@ static void* SrtSubtitleThread(void *data) {
/* Functions */
/* ***************************** */
static void SrtManagerAdd(Context_t *context __attribute__((unused)), SrtTrack_t track) {
static void SrtManagerAdd(Context_t * context
__attribute__ ((unused)), SrtTrack_t track)
{
srt_printf(10, "%s %d\n", track.File, track.Id);
if (Tracks == NULL) {
@@ -223,7 +237,8 @@ static void SrtManagerAdd(Context_t *context __attribute__((unused)), SrtTrack_
}
#if 0
static char ** SrtManagerList(Context_t *context __attribute__((unused))) {
static char **SrtManagerList(Context_t * context __attribute__ ((unused)))
{
char **tracklist = NULL;
srt_printf(10, "\n");
@@ -247,7 +262,8 @@ static char ** SrtManagerList(Context_t *context __attribute__((unused))) {
}
#endif
static void SrtManagerDel(Context_t * context __attribute__((unused))) {
static void SrtManagerDel(Context_t * context __attribute__ ((unused)))
{
int i = 0;
srt_printf(10, "\n");
@@ -267,7 +283,8 @@ static void SrtManagerDel(Context_t * context __attribute__((unused))) {
}
static int SrtGetSubtitle(Context_t *context, char * Filename) {
static int SrtGetSubtitle(Context_t * context, char *Filename)
{
struct dirent *dirzeiger;
DIR *dir;
int i = TEXTSRTOFFSET;
@@ -278,8 +295,7 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
srt_printf(10, "\n");
if (Filename == NULL)
{
if (Filename == NULL) {
srt_err("Filename NULL\n");
return cERR_SRT_ERROR;
}
@@ -288,8 +304,7 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
copyFilename = strdup(Filename);
if (copyFilename == NULL)
{
if (copyFilename == NULL) {
srt_err("copyFilename NULL\n");
return cERR_SRT_ERROR;
}
@@ -300,8 +315,7 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
FilenameExtension = getExtension(copyFilename);
if (FilenameExtension == NULL)
{
if (FilenameExtension == NULL) {
srt_err("FilenameExtension NULL\n");
free(copyFilename);
return cERR_SRT_ERROR;
@@ -312,10 +326,12 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
FilenameShort = basename(copyFilename);
/* cut extension */
FilenameShort[strlen(FilenameShort) - strlen(FilenameExtension) - 1] = '\0';
FilenameShort[strlen(FilenameShort) - strlen(FilenameExtension) - 1] =
'\0';
srt_printf(10, "basename: %s\n", FilenameShort);
srt_printf(10, "%s\n%s | %s | %s\n", copyFilename, FilenameFolder, FilenameShort, FilenameExtension);
srt_printf(10, "%s\n%s | %s | %s\n", copyFilename, FilenameFolder,
FilenameShort, FilenameExtension);
if ((dir = opendir(FilenameFolder)) != NULL) {
while ((dirzeiger = readdir(dir)) != NULL) {
@@ -336,18 +352,22 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
continue;
/* cut extension */
subtitleFilename[strlen(subtitleFilename) - strlen(subtitleExtension) - 1] = '\0';
subtitleFilename[strlen(subtitleFilename) -
strlen(subtitleExtension) - 1] = '\0';
srt_printf(10, "%s %s\n", FilenameShort, subtitleFilename);
if (strncmp(FilenameShort, subtitleFilename,strlen(FilenameShort)) == 0)
{
if (strncmp
(FilenameShort, subtitleFilename,
strlen(FilenameShort)) == 0) {
char absSubtitleFileName[PATH_MAX];
/* found something of interest, so now make an absolut path name */
sprintf(absSubtitleFileName, "%s/%s.%s", FilenameFolder, subtitleFilename, subtitleExtension);
sprintf(absSubtitleFileName, "%s/%s.%s", FilenameFolder,
subtitleFilename, subtitleExtension);
srt_printf(10, "SRT: %s [%s]\n", subtitleExtension, subtitleFilename);
srt_printf(10, "SRT: %s [%s]\n", subtitleExtension,
subtitleFilename);
srt_printf(10, "\t->%s\n", absSubtitleFileName);
SrtTrack_t SrtSubtitle = {
@@ -362,19 +382,23 @@ static int SrtGetSubtitle(Context_t *context, char * Filename) {
Subtitle.Name = subtitleExtension;
Subtitle.Encoding = "S_TEXT/SRT";
Subtitle.Id = i++,
context->manager->subtitle->Command(context, MANAGER_ADD, &Subtitle);
context->manager->subtitle->Command(context,
MANAGER_ADD,
&Subtitle);
}
} /* while */
closedir(dir);
} /* if dir */
}
/* if dir */
free(copyFilename);
srt_printf(10, "<\n");
return cERR_SRT_NO_ERROR;
}
static int SrtOpenSubtitle(Context_t *context __attribute__((unused)), int pid) {
static int SrtOpenSubtitle(Context_t * context
__attribute__ ((unused)), int pid)
{
srt_printf(10, "\n");
if (pid < TEXTSRTOFFSET) {
@@ -398,15 +422,15 @@ static int SrtOpenSubtitle(Context_t *context __attribute__((unused)), int pid)
srt_printf(10, "%s\n", fsub ? "fsub!=NULL" : "fsub==NULL");
if(!fsub)
{
if (!fsub) {
srt_err("cannot open file %s\n", Tracks[trackid].File);
return cERR_SRT_ERROR;
}
return cERR_SRT_NO_ERROR;
}
static int SrtCloseSubtitle(Context_t *context __attribute__((unused))) {
static int SrtCloseSubtitle(Context_t * context __attribute__ ((unused)))
{
srt_printf(10, "\n");
if (fsub)
@@ -420,15 +444,16 @@ static int SrtCloseSubtitle(Context_t *context __attribute__((unused))) {
return cERR_SRT_NO_ERROR;
}
static int SrtSwitchSubtitle(Context_t *context, int* arg) {
static int SrtSwitchSubtitle(Context_t * context, int *arg)
{
int ret = cERR_SRT_NO_ERROR;
srt_printf(10, "arg:%d\n", *arg);
ret = SrtCloseSubtitle(context);
if (( (ret |= SrtOpenSubtitle(context, *arg)) == cERR_SRT_NO_ERROR) && (!hasThreadStarted))
{
if (((ret |= SrtOpenSubtitle(context, *arg)) == cERR_SRT_NO_ERROR)
&& (!hasThreadStarted)) {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -440,7 +465,8 @@ static int SrtSwitchSubtitle(Context_t *context, int* arg) {
return ret;
}
static int SrtDel(Context_t *context) {
static int SrtDel(Context_t * context)
{
int ret = cERR_SRT_NO_ERROR;
srt_printf(10, "\n");
@@ -451,7 +477,8 @@ static int SrtDel(Context_t *context) {
return ret;
}
static int Command(void *_context, ContainerCmd_t command, void * argument) {
static int Command(void *_context, ContainerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_SRT_NO_ERROR;

View File

@@ -110,29 +110,26 @@ char *SSAgetLine()
k = tamAux = 0;
if(SSA_BUFFER_SIZE>0)
{
if (SSA_BUFFER_SIZE > 0) {
strInput = (char *) malloc(1 * sizeof(char));
strInput[0] = '\0';
while(tamAux!=1)
{
while (tamAux != 1) {
if((ch = fgetc(fssa))!=EOF)
{
if ((ch = fgetc(fssa)) != EOF) {
ungetc(ch, fssa);
fgets(c, SSA_BUFFER_SIZE, fssa);
strAux = (char *) strchr(c, '\n');
tam = strlen(c);
if(strAux != NULL)
{
if (strAux != NULL) {
tamAux = strlen(strAux);
tam--;
}
k = k + tam;
strInput = (char*)realloc(strInput, (k+1)*sizeof(char));
strInput =
(char *) realloc(strInput, (k + 1) * sizeof(char));
if (k != tam)
strncat(strInput, c, tam);
@@ -141,8 +138,7 @@ char *SSAgetLine()
strInput[k] = '\0';
}
else {
} else {
tamAux = 1;
fclose(fssa);
fssa = NULL;
@@ -158,7 +154,8 @@ char *SSAgetLine()
/* ***************************** */
/* Worker Thread */
/* ***************************** */
static void* SsaSubtitleThread(void *Data) {
static void *SsaSubtitleThread(void *Data)
{
Context_t *context = (Context_t *) Data;
char *head = malloc(sizeof(char) * 1);
@@ -166,11 +163,11 @@ static void* SsaSubtitleThread(void *Data) {
head[0] = '\0';
while ( context && context->playback && context->playback->isPlaying && fssa ) {
while (context && context->playback && context->playback->isPlaying
&& fssa) {
char *line = NULL;
do
{
do {
line = SSAgetLine();
if (strncmp(line, "Dialogue: ", 10)) {
int head_len = strlen(head);
@@ -183,9 +180,7 @@ static void* SsaSubtitleThread(void *Data) {
} while (strncmp(line, "Dialogue: ", 10) != 0 && fssa);
/*Hellmaster 1024 since we have waited, we have to check if we are still paying */
if( context &&
context->playback &&
context->playback->isPlaying) {
if (context && context->playback && context->playback->isPlaying) {
SubtitleData_t data;
data.data = (unsigned char *) line;
@@ -194,7 +189,9 @@ static void* SsaSubtitleThread(void *Data) {
data.extralen = strlen(head);
data.pts = 0;
data.duration = 0.0;
context->container->assContainer->Command(context, CONTAINER_DATA, &data);
context->container->assContainer->Command(context,
CONTAINER_DATA,
&data);
}
free(line);
line = NULL;
@@ -217,7 +214,9 @@ static void* SsaSubtitleThread(void *Data) {
/* Functions */
/* ***************************** */
static void SsaManagerAdd(Context_t *context __attribute__((unused)), SsaTrack_t track) {
static void SsaManagerAdd(Context_t * context
__attribute__ ((unused)), SsaTrack_t track)
{
ssa_printf(10, "%s %d\n", track.File, track.Id);
if (Tracks == NULL) {
@@ -232,7 +231,8 @@ static void SsaManagerAdd(Context_t *context __attribute__((unused)), SsaTrack_
}
#if 0
static char ** SsaManagerList(Context_t *context __attribute__((unused))) {
static char **SsaManagerList(Context_t * context __attribute__ ((unused)))
{
char **tracklist = NULL;
ssa_printf(10, "\n");
@@ -256,7 +256,8 @@ static char ** SsaManagerList(Context_t *context __attribute__((unused))) {
}
#endif
static void SsaManagerDel(Context_t * context __attribute__((unused))) {
static void SsaManagerDel(Context_t * context __attribute__ ((unused)))
{
int i = 0;
ssa_printf(10, "\n");
@@ -274,7 +275,8 @@ static void SsaManagerDel(Context_t * context __attribute__((unused))) {
TrackCount = 0;
}
static int SsaGetSubtitle(Context_t *context, char * Filename) {
static int SsaGetSubtitle(Context_t * context, char *Filename)
{
struct dirent *dirzeiger;
DIR *dir;
int i = TEXTSSAOFFSET;
@@ -285,8 +287,7 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
ssa_printf(10, "\n");
if (Filename == NULL)
{
if (Filename == NULL) {
ssa_err("Filename NULL\n");
return cERR_SSA_ERROR;
}
@@ -295,8 +296,7 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
copyFilename = strdup(Filename);
if (copyFilename == NULL)
{
if (copyFilename == NULL) {
ssa_err("copyFilename NULL\n");
return cERR_SSA_ERROR;
}
@@ -307,8 +307,7 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
FilenameExtension = getExtension(copyFilename);
if (FilenameExtension == NULL)
{
if (FilenameExtension == NULL) {
ssa_err("FilenameExtension NULL\n");
free(copyFilename);
return cERR_SSA_ERROR;
@@ -319,10 +318,12 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
FilenameShort = basename(copyFilename);
/* cut extension */
FilenameShort[strlen(FilenameShort) - strlen(FilenameExtension) - 1] = '\0';
FilenameShort[strlen(FilenameShort) - strlen(FilenameExtension) - 1] =
'\0';
ssa_printf(10, "basename: %s\n", FilenameShort);
ssa_printf(10, "%s\n%s | %s | %s\n", copyFilename, FilenameFolder, FilenameShort, FilenameExtension);
ssa_printf(10, "%s\n%s | %s | %s\n", copyFilename, FilenameFolder,
FilenameShort, FilenameExtension);
if ((dir = opendir(FilenameFolder)) != NULL) {
while ((dirzeiger = readdir(dir)) != NULL) {
@@ -339,22 +340,27 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
if (subtitleExtension == NULL)
continue;
if ( strcmp(subtitleExtension, "ssa") != 0 && strcmp(subtitleExtension, "ass") != 0 )
if (strcmp(subtitleExtension, "ssa") != 0
&& strcmp(subtitleExtension, "ass") != 0)
continue;
/* cut extension */
subtitleFilename[strlen(subtitleFilename) - strlen(subtitleExtension) - 1] = '\0';
subtitleFilename[strlen(subtitleFilename) -
strlen(subtitleExtension) - 1] = '\0';
ssa_printf(10, "%s %s\n", FilenameShort, subtitleFilename);
if (strncmp(FilenameShort, subtitleFilename,strlen(FilenameShort)) == 0)
{
if (strncmp
(FilenameShort, subtitleFilename,
strlen(FilenameShort)) == 0) {
char absSubtitleFileName[PATH_MAX];
/* found something of interest, so now make an absolut path name */
sprintf(absSubtitleFileName, "%s/%s.%s", FilenameFolder, subtitleFilename, subtitleExtension);
sprintf(absSubtitleFileName, "%s/%s.%s", FilenameFolder,
subtitleFilename, subtitleExtension);
ssa_printf(10, "SSA: %s [%s]\n", subtitleExtension, subtitleFilename);
ssa_printf(10, "SSA: %s [%s]\n", subtitleExtension,
subtitleFilename);
ssa_printf(10, "\t->%s\n", absSubtitleFileName);
SsaTrack_t SsaSubtitle = {
@@ -369,19 +375,22 @@ static int SsaGetSubtitle(Context_t *context, char * Filename) {
Subtitle.Name = subtitleExtension;
Subtitle.Encoding = "S_TEXT/SSA";
Subtitle.Id = i++;
context->manager->subtitle->Command(context, MANAGER_ADD, &Subtitle);
context->manager->subtitle->Command(context, MANAGER_ADD,
&Subtitle);
}
} /* while */
closedir(dir);
} /* if dir */
}
/* if dir */
free(copyFilename);
ssa_printf(10, "<\n");
return cERR_SSA_NO_ERROR;
}
static int SsaOpenSubtitle(Context_t *context __attribute__((unused)), int pid) {
static int SsaOpenSubtitle(Context_t * context
__attribute__ ((unused)), int pid)
{
ssa_printf(10, "\n");
if (pid < TEXTSSAOFFSET) {
@@ -405,15 +414,15 @@ static int SsaOpenSubtitle(Context_t *context __attribute__((unused)), int pid)
ssa_printf(10, "%s\n", fssa ? "fssa!=NULL" : "fssa==NULL");
if (!fssa)
{
if (!fssa) {
ssa_err("cannot open file %s\n", Tracks[trackid].File);
return cERR_SSA_ERROR;
}
return cERR_SSA_NO_ERROR;
}
static int SsaCloseSubtitle(Context_t *context __attribute__((unused))) {
static int SsaCloseSubtitle(Context_t * context __attribute__ ((unused)))
{
ssa_printf(10, "\n");
if (fssa)
@@ -427,15 +436,16 @@ static int SsaCloseSubtitle(Context_t *context __attribute__((unused))) {
return cERR_SSA_NO_ERROR;
}
static int SsaSwitchSubtitle(Context_t *context, int* arg) {
static int SsaSwitchSubtitle(Context_t * context, int *arg)
{
int ret = cERR_SSA_NO_ERROR;
ssa_printf(10, "\n");
ret = SsaCloseSubtitle(context);
if (((ret |= SsaOpenSubtitle(context, *arg)) == cERR_SSA_NO_ERROR) && (!hasThreadStarted))
{
if (((ret |= SsaOpenSubtitle(context, *arg)) == cERR_SSA_NO_ERROR)
&& (!hasThreadStarted)) {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -447,7 +457,8 @@ static int SsaSwitchSubtitle(Context_t *context, int* arg) {
return ret;
}
static int SsaDel(Context_t *context) {
static int SsaDel(Context_t * context)
{
int ret = cERR_SSA_NO_ERROR;
ssa_printf(10, "\n");
@@ -459,7 +470,8 @@ static int SsaDel(Context_t *context) {
return ret;
}
static int Command(void *_context, ContainerCmd_t command, void * argument) {
static int Command(void *_context, ContainerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_SSA_NO_ERROR;

View File

@@ -14,5 +14,6 @@ typedef struct Context_s {
ManagerHandler_t *manager;
} Context_t;
int container_ffmpeg_update_tracks(Context_t *context, char *filename, int initial);
int container_ffmpeg_update_tracks(Context_t * context, char *filename,
int initial);
#endif

View File

@@ -8,8 +8,7 @@ static inline void Hexdump(unsigned char *Data, int length)
{
int k;
for (k = 0; k < length; k++)
{
for (k = 0; k < length; k++) {
printf("%02x ", Data[k]);
if (((k + 1) & 31) == 0)
printf("\n");

View File

@@ -11,8 +11,7 @@
/* metatdata map list:
*/
char* metadata_map[] =
{
char *metadata_map[] = {
/* our tags ffmpeg tag / id3v2 */
"Title", "TIT2",
"Title", "TT2",

View File

@@ -9,8 +9,7 @@
/* Types */
/* ***************************** */
typedef struct BitPacker_s
{
typedef struct BitPacker_s {
unsigned char *Ptr; /* write pointer */
unsigned int BitBuffer; /* bitreader shifter */
int Remaining; /* number of remaining in the shifter */
@@ -53,8 +52,7 @@ static inline char * basename(char * name)
int i = 0;
int pos = 0;
while(name[i] != 0)
{
while (name[i] != 0) {
if (name[i] == '/')
pos = i;
i++;
@@ -73,8 +71,7 @@ static inline char * dirname(char * name)
unsigned int i = 0;
int pos = 0;
while((name[i] != 0) && (i < sizeof(path)))
{
while ((name[i] != 0) && (i < sizeof(path))) {
if (name[i] == '/')
pos = i;
path[i] = name[i];

View File

@@ -32,8 +32,7 @@ typedef enum {
OUTPUT_SET_SUBTITLE_OUTPUT
} OutputCmd_t;
typedef struct
{
typedef struct {
unsigned char *data;
unsigned int len;

View File

@@ -20,8 +20,7 @@
#ifndef pcm_h_
#define pcm_h_
typedef struct pcmPrivateData_s
{
typedef struct pcmPrivateData_s {
int uNoOfChannels;
int uSampleRate;
int uBitsPerSample;

View File

@@ -26,7 +26,8 @@
#define VC1_VIDEO_PES_START_CODE 0xfd
#define AAC_AUDIO_PES_START_CODE 0xcf
int InsertPesHeader (unsigned char *data, int size, unsigned char stream_id, unsigned long long int pts, int pic_start_code);
int InsertPesHeader(unsigned char *data, int size, unsigned char stream_id,
unsigned long long int pts, int pic_start_code);
int InsertVideoPrivateDataHeader(unsigned char *data, int payload_size);
#endif

View File

@@ -2,7 +2,15 @@
#define PLAYBACK_H_
#include <sys/types.h>
typedef enum {PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS, PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO, PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION, PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT, PLAYBACK_SWITCH_TELETEXT, PLAYBACK_SWITCH_DVBSUBTITLE, PLAYBACK_FRAMEBUFFER_LOCK, PLAYBACK_FRAMEBUFFER_UNLOCK} PlaybackCmd_t;
typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP,
PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM,
PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS,
PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO,
PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION,
PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT,
PLAYBACK_SWITCH_TELETEXT, PLAYBACK_SWITCH_DVBSUBTITLE,
PLAYBACK_FRAMEBUFFER_LOCK,
PLAYBACK_FRAMEBUFFER_UNLOCK } PlaybackCmd_t;
typedef struct PlaybackHandler_s {
char *Name;

View File

@@ -33,7 +33,8 @@ Style: Default,Arial,64,16777215,0,16777215,0,0,0,2,2,2,2,20,20,10,0\n\n\
[Events]\n\
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n\n\n"
static inline unsigned char* text_to_ass(char *text, long long int pts, double duration)
static inline unsigned char *text_to_ass(char *text, long long int pts,
double duration)
{
char buf[1024];
unsigned int x, pos = 0;
@@ -41,7 +42,8 @@ static inline unsigned char* text_to_ass(char *text, long long int pts, double d
if (text[x] == '\n') {
buf[pos++] = '\\';
buf[pos++] = 'N';
}else if(text[x]!='\r')buf[pos++]=text[x];
} else if (text[x] != '\r')
buf[pos++] = text[x];
}
buf[pos++] = '\0';
int len = 80 + strlen(buf);
@@ -50,34 +52,38 @@ static inline unsigned char* text_to_ass(char *text, long long int pts, double d
int sc = pts / 10;
int ec = end_pts / 10;
int sh, sm, ss, eh, em, es;
sh = sc/360000; sc -= 360000*sh;
sm = sc/ 6000; sc -= 6000*sm;
ss = sc/ 100; sc -= 100*ss;
eh = ec/360000; ec -= 360000*eh;
em = ec/ 6000; ec -= 6000*em;
es = ec/ 100; ec -= 100*es;
snprintf(line,len,"Dialogue: Marked=0,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,Default,NTP,0000,0000,0000,!Effect,%s\n",
sh = sc / 360000;
sc -= 360000 * sh;
sm = sc / 6000;
sc -= 6000 * sm;
ss = sc / 100;
sc -= 100 * ss;
eh = ec / 360000;
ec -= 360000 * eh;
em = ec / 6000;
ec -= 6000 * em;
es = ec / 100;
ec -= 100 * es;
snprintf(line, len,
"Dialogue: Marked=0,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,Default,NTP,0000,0000,0000,!Effect,%s\n",
sh, sm, ss, sc, eh, em, es, ec, buf);
return (unsigned char *) line;
}
typedef enum
{
typedef enum {
eSub_Gfx,
eSub_Txt
} SubType_t;
typedef struct
{
typedef struct {
unsigned char *data;
int len;
} SubText_t;
typedef struct
{
typedef struct {
unsigned char *data;
unsigned int Width;
unsigned int Height;
@@ -87,21 +93,18 @@ typedef struct
unsigned int color;
} SubGfx_t;
typedef struct
{
typedef struct {
SubType_t type;
long long int pts;
float duration;
union
{
union {
SubText_t text;
SubGfx_t gfx;
} u;
} SubtitleOut_t;
typedef struct
{
typedef struct {
unsigned char *data;
int len;
@@ -112,8 +115,7 @@ typedef struct
float duration;
} SubtitleData_t;
typedef struct
{
typedef struct {
uint32_t *destination;
unsigned int screen_width;
unsigned int screen_height;

View File

@@ -77,9 +77,12 @@ static int CurrentTrack = 0; //TRACK[0] as default.
/* Functions */
/* ***************************** */
static int ManagerAdd(Context_t *context, Track_t track) {
static int ManagerAdd(Context_t * context, Track_t track)
{
audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", FILENAME, __FUNCTION__, track.Name, track.Encoding, track.Id);
audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n",
FILENAME, __FUNCTION__, track.Name, track.Encoding,
track.Id);
if (Tracks == NULL) {
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -88,8 +91,7 @@ static int ManagerAdd(Context_t *context, Track_t track) {
Tracks[i].Id = -1;
}
if (Tracks == NULL)
{
if (Tracks == NULL) {
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return cERR_AUDIO_MGR_ERROR;
}
@@ -106,7 +108,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
copyTrack(&Tracks[TrackCount], &track);
TrackCount++;
} else {
audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME,
__FUNCTION__, TrackCount, TRACKWRAP);
return cERR_AUDIO_MGR_ERROR;
}
@@ -118,7 +121,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_AUDIO_MGR_NO_ERROR;
}
static char ** ManagerList(Context_t *context __attribute__((unused))) {
static char **ManagerList(Context_t * context __attribute__ ((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
@@ -128,8 +132,7 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
if (tracklist == NULL) {
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return NULL;
}
@@ -146,12 +149,14 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist[j] = NULL;
}
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t * context) {
static int ManagerDel(Context_t * context)
{
int i = 0;
@@ -163,9 +168,9 @@ static int ManagerDel(Context_t * context) {
}
free(Tracks);
Tracks = NULL;
} else
{
audio_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
} else {
audio_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
return cERR_AUDIO_MGR_ERROR;
}
@@ -173,13 +178,15 @@ static int ManagerDel(Context_t * context) {
CurrentTrack = 0;
context->playback->isAudio = 0;
audio_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
return cERR_AUDIO_MGR_NO_ERROR;
}
static int Command(void *_context, ManagerCmd_t command, void * argument) {
static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_AUDIO_MGR_NO_ERROR;
@@ -193,12 +200,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
container_ffmpeg_update_tracks(context, context->playback->uri,
0);
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, __FUNCTION__);
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
@@ -207,31 +216,36 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_GET_TRACK:{
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((Track_t**)argument) = (Track_t*) &Tracks[CurrentTrack];
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETENCODING:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_GETNAME:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_SET:{
int i;
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, *((int*)argument));
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
__FUNCTION__, *((int *) argument));
for (i = 0; i < TrackCount; i++)
if (Tracks[i].Id == *((int *) argument)) {
@@ -240,7 +254,8 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
}
if (i == TrackCount) {
audio_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int*)argument));
audio_mgr_err("%s::%s track id %d unknown\n", FILENAME,
__FUNCTION__, *((int *) argument));
ret = cERR_AUDIO_MGR_ERROR;
}
break;
@@ -256,12 +271,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
default:
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
__FUNCTION__, command);
ret = cERR_AUDIO_MGR_ERROR;
break;
}
audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,ret);
audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,
ret);
return ret;
}

View File

@@ -77,9 +77,13 @@ static int CurrentTrack = -1;
/* Functions */
/* ***************************** */
static int ManagerAdd(Context_t *context, Track_t track) {
static int ManagerAdd(Context_t * context, Track_t track)
{
dvbsubtitle_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", FILENAME, __FUNCTION__, track.Name, track.Encoding, track.Id);
dvbsubtitle_mgr_printf(10,
"%s::%s name=\"%s\" encoding=\"%s\" id=%d\n",
FILENAME, __FUNCTION__, track.Name,
track.Encoding, track.Id);
if (Tracks == NULL) {
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -88,9 +92,9 @@ static int ManagerAdd(Context_t *context, Track_t track) {
Tracks[i].Id = -1;
}
if (Tracks == NULL)
{
dvbsubtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
if (Tracks == NULL) {
dvbsubtitle_mgr_err("%s:%s malloc failed\n", FILENAME,
__FUNCTION__);
return cERR_DVBSUBTITLE_MGR_ERROR;
}
@@ -106,7 +110,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
copyTrack(&Tracks[TrackCount], &track);
TrackCount++;
} else {
dvbsubtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
dvbsubtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n",
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_DVBSUBTITLE_MGR_ERROR;
}
@@ -118,7 +123,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_DVBSUBTITLE_MGR_NO_ERROR;
}
static char ** ManagerList(Context_t *context __attribute__((unused))) {
static char **ManagerList(Context_t * context __attribute__ ((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
@@ -128,9 +134,9 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
dvbsubtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
if (tracklist == NULL) {
dvbsubtitle_mgr_err("%s:%s malloc failed\n", FILENAME,
__FUNCTION__);
return NULL;
}
@@ -146,12 +152,14 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist[j] = NULL;
}
dvbsubtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
dvbsubtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t * context) {
static int ManagerDel(Context_t * context)
{
int i = 0;
@@ -163,9 +171,9 @@ static int ManagerDel(Context_t * context) {
}
free(Tracks);
Tracks = NULL;
} else
{
dvbsubtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
} else {
dvbsubtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
return cERR_DVBSUBTITLE_MGR_ERROR;
}
@@ -173,13 +181,15 @@ static int ManagerDel(Context_t * context) {
CurrentTrack = -1;
context->playback->isDvbSubtitle = 0;
dvbsubtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
dvbsubtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
return cERR_DVBSUBTITLE_MGR_NO_ERROR;
}
static int Command(void *_context, ManagerCmd_t command, void * argument) {
static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_DVBSUBTITLE_MGR_NO_ERROR;
@@ -193,12 +203,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
container_ffmpeg_update_tracks(context, context->playback->uri,
0);
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, __FUNCTION__);
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
@@ -207,31 +219,37 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_GET_TRACK:{
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n",
FILENAME, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((Track_t**)argument) = (Track_t*) &Tracks[CurrentTrack];
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETENCODING:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_GETNAME:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_SET:{
int i;
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, *((int*)argument));
dvbsubtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n",
FILENAME, __FUNCTION__,
*((int *) argument));
for (i = 0; i < TrackCount; i++)
if (Tracks[i].Id == *((int *) argument)) {
@@ -240,7 +258,9 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
}
if (i == TrackCount) {
dvbsubtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int*)argument));
dvbsubtitle_mgr_err("%s::%s track id %d unknown\n",
FILENAME, __FUNCTION__,
*((int *) argument));
ret = cERR_DVBSUBTITLE_MGR_ERROR;
}
break;
@@ -256,12 +276,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
default:
dvbsubtitle_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
dvbsubtitle_mgr_err("%s::%s ContainerCmd %d not supported!\n",
FILENAME, __FUNCTION__, command);
ret = cERR_DVBSUBTITLE_MGR_ERROR;
break;
}
dvbsubtitle_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,ret);
dvbsubtitle_mgr_printf(10, "%s:%s: returning %d\n", FILENAME,
__FUNCTION__, ret);
return ret;
}

View File

@@ -47,9 +47,7 @@ ManagerHandler_t ManagerHandler = {
"ManagerHandler",
&AudioManager,
&VideoManager,
&SubtitleManager
, &DvbSubtitleManager
, &TeletextManager
&SubtitleManager, &DvbSubtitleManager, &TeletextManager
};
/* ***************************** */

View File

@@ -76,9 +76,11 @@ static int CurrentTrack = -1; //no as default.
/* Functions */
/* ***************************** */
static int ManagerAdd(Context_t *context, Track_t track) {
static int ManagerAdd(Context_t * context, Track_t track)
{
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__, track.Name, track.Encoding, track.Id);
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__,
track.Name, track.Encoding, track.Id);
if (Tracks == NULL) {
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -87,8 +89,7 @@ static int ManagerAdd(Context_t *context, Track_t track) {
Tracks[i].Id = -1;
}
if (Tracks == NULL)
{
if (Tracks == NULL) {
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR;
}
@@ -106,7 +107,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
TrackCount++;
} else {
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n",
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_SUBTITLE_MGR_ERROR;
}
@@ -118,7 +120,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_SUBTITLE_MGR_NO_ERROR;
}
static char ** ManagerList(Context_t *context __attribute__((unused))) {
static char **ManagerList(Context_t * context __attribute__ ((unused)))
{
char **tracklist = NULL;
int i = 0, j = 0;
@@ -127,9 +130,9 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
if (Tracks != NULL) {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
if (tracklist == NULL) {
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME,
__FUNCTION__);
return NULL;
}
@@ -146,12 +149,14 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist[j] = NULL;
}
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t * context) {
static int ManagerDel(Context_t * context)
{
int i = 0;
@@ -164,9 +169,9 @@ static int ManagerDel(Context_t * context) {
free(Tracks);
Tracks = NULL;
} else
{
subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
} else {
subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR;
}
@@ -174,16 +179,19 @@ static int ManagerDel(Context_t * context) {
CurrentTrack = -1;
context->playback->isSubtitle = 0;
subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
return cERR_SUBTITLE_MGR_NO_ERROR;
}
static int Command(void *_context, ManagerCmd_t command, void * argument) {
static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, command);
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__,
command);
switch (command) {
case MANAGER_ADD:{
@@ -192,7 +200,8 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
container_ffmpeg_update_tracks(context, context->playback->uri,
0);
*((char ***) argument) = (char **) ManagerList(context);
break;
}
@@ -206,13 +215,12 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
case MANAGER_GET_TRACK:{
//subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >=0))
{
subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack, &Tracks[CurrentTrack]);
*((Track_t**)argument) = (Track_t*) &Tracks[CurrentTrack];
}
else
{
if ((TrackCount > 0) && (CurrentTrack >= 0)) {
subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack,
&Tracks[CurrentTrack]);
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
} else {
subtitle_mgr_printf(20, "return NULL\n");
*((Track_t **) argument) = NULL;
}
@@ -220,21 +228,24 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
}
case MANAGER_GETENCODING:{
if (TrackCount > 0 && CurrentTrack >= 0)
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_GETNAME:{
if (TrackCount > 0 && CurrentTrack >= 0)
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_SET:{
int i;
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, *((int*)argument));
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
__FUNCTION__, *((int *) argument));
for (i = 0; i < TrackCount; i++)
if (Tracks[i].Id == *((int *) argument)) {
@@ -242,7 +253,8 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
if (i == TrackCount) {
subtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int*)argument));
subtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME,
__FUNCTION__, *((int *) argument));
ret = cERR_SUBTITLE_MGR_ERROR;
}
break;
@@ -258,12 +270,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
default:
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, __FUNCTION__);
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME,
__FUNCTION__);
ret = cERR_SUBTITLE_MGR_ERROR;
break;
}
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,ret);
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME,
__FUNCTION__, ret);
return ret;
}

View File

@@ -77,9 +77,12 @@ static int CurrentTrack = -1;
/* Functions */
/* ***************************** */
static int ManagerAdd(Context_t *context, Track_t track) {
static int ManagerAdd(Context_t * context, Track_t track)
{
teletext_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", FILENAME, __FUNCTION__, track.Name, track.Encoding, track.Id);
teletext_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n",
FILENAME, __FUNCTION__, track.Name, track.Encoding,
track.Id);
if (Tracks == NULL) {
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -88,8 +91,7 @@ static int ManagerAdd(Context_t *context, Track_t track) {
Tracks[i].Id = -1;
}
if (Tracks == NULL)
{
if (Tracks == NULL) {
teletext_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return cERR_TELETEXT_MGR_ERROR;
}
@@ -106,7 +108,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
copyTrack(&Tracks[TrackCount], &track);
TrackCount++;
} else {
teletext_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
teletext_mgr_err("%s:%s TrackCount out if range %d - %d\n",
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_TELETEXT_MGR_ERROR;
}
@@ -118,7 +121,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_TELETEXT_MGR_NO_ERROR;
}
static char ** ManagerList(Context_t *context __attribute__((unused))) {
static char **ManagerList(Context_t * context __attribute__ ((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
@@ -128,9 +132,9 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
teletext_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
if (tracklist == NULL) {
teletext_mgr_err("%s:%s malloc failed\n", FILENAME,
__FUNCTION__);
return NULL;
}
@@ -146,12 +150,14 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist[j] = NULL;
}
teletext_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
teletext_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t * context) {
static int ManagerDel(Context_t * context)
{
int i = 0;
@@ -163,9 +169,9 @@ static int ManagerDel(Context_t * context) {
}
free(Tracks);
Tracks = NULL;
} else
{
teletext_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
} else {
teletext_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
return cERR_TELETEXT_MGR_ERROR;
}
@@ -173,13 +179,15 @@ static int ManagerDel(Context_t * context) {
CurrentTrack = -1;
context->playback->isTeletext = 0;
teletext_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
teletext_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
return cERR_TELETEXT_MGR_NO_ERROR;
}
static int Command(void *_context, ManagerCmd_t command, void * argument) {
static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_TELETEXT_MGR_NO_ERROR;
@@ -193,12 +201,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
container_ffmpeg_update_tracks(context, context->playback->uri,
0);
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
teletext_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, __FUNCTION__);
teletext_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
@@ -207,31 +217,36 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_GET_TRACK:{
teletext_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
teletext_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((Track_t**)argument) = (Track_t*) &Tracks[CurrentTrack];
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETENCODING:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_GETNAME:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_SET:{
int i;
teletext_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, *((int*)argument));
teletext_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
__FUNCTION__, *((int *) argument));
for (i = 0; i < TrackCount; i++)
if (Tracks[i].Id == *((int *) argument)) {
@@ -240,7 +255,8 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
}
if (i == TrackCount) {
teletext_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int*)argument));
teletext_mgr_err("%s::%s track id %d unknown\n", FILENAME,
__FUNCTION__, *((int *) argument));
ret = cERR_TELETEXT_MGR_ERROR;
}
break;
@@ -256,12 +272,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
default:
teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n",
FILENAME, __FUNCTION__, command);
ret = cERR_TELETEXT_MGR_ERROR;
break;
}
teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,ret);
teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME,
__FUNCTION__, ret);
return ret;
}

View File

@@ -76,7 +76,8 @@ static int CurrentTrack = 0; //TRACK[0] as default.
/* Functions */
/* ***************************** */
static int ManagerAdd(Context_t *context, Track_t track) {
static int ManagerAdd(Context_t * context, Track_t track)
{
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
if (Tracks == NULL) {
@@ -86,8 +87,7 @@ static int ManagerAdd(Context_t *context, Track_t track) {
Tracks[i].Id = -1;
}
if (Tracks == NULL)
{
if (Tracks == NULL) {
video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return cERR_VIDEO_MGR_ERROR;
}
@@ -105,7 +105,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
TrackCount++;
} else {
video_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
video_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME,
__FUNCTION__, TrackCount, TRACKWRAP);
return cERR_VIDEO_MGR_ERROR;
}
@@ -117,7 +118,8 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_VIDEO_MGR_NO_ERROR;
}
static char ** ManagerList(Context_t *context __attribute__((unused))) {
static char **ManagerList(Context_t * context __attribute__ ((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
@@ -127,8 +129,7 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
if (tracklist == NULL) {
video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
return NULL;
}
@@ -145,12 +146,14 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
tracklist[j] = NULL;
}
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t * context) {
static int ManagerDel(Context_t * context)
{
int i = 0;
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
@@ -161,9 +164,9 @@ static int ManagerDel(Context_t * context) {
}
free(Tracks);
Tracks = NULL;
} else
{
video_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
} else {
video_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
return cERR_VIDEO_MGR_ERROR;
}
@@ -171,12 +174,14 @@ static int ManagerDel(Context_t * context) {
CurrentTrack = 0;
context->playback->isVideo = 0;
video_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
return cERR_VIDEO_MGR_NO_ERROR;
}
static int Command(void *_context, ManagerCmd_t command, void * argument) {
static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_VIDEO_MGR_NO_ERROR;
@@ -189,7 +194,8 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
container_ffmpeg_update_tracks(context, context->playback->uri,
0);
*((char ***) argument) = (char **) ManagerList(context);
break;
}
@@ -201,24 +207,28 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
case MANAGER_GET_TRACK:{
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
__FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((Track_t**)argument) = (Track_t*) &Tracks[CurrentTrack];
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETENCODING:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
else
*((char **) argument) = (char *) strdup("");
break;
}
case MANAGER_GETNAME:{
if ((TrackCount > 0) && (CurrentTrack >= 0))
*((char**)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
else
*((char **) argument) = (char *) strdup("");
break;
@@ -232,9 +242,9 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
if (i == TrackCount)
{
video_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int*)argument));
if (i == TrackCount) {
video_mgr_err("%s::%s track id %d unknown\n", FILENAME,
__FUNCTION__, *((int *) argument));
ret = cERR_VIDEO_MGR_ERROR;
}
break;
@@ -250,12 +260,14 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
break;
}
default:
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
__FUNCTION__, command);
ret = cERR_VIDEO_MGR_ERROR;
break;
}
video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,ret);
video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,
ret);
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@@ -78,7 +78,8 @@ static Output_t * AvailableOutput[] = {
/* MISC Functions */
/* ***************************** */
static void printOutputCapabilities() {
static void printOutputCapabilities()
{
int i, j;
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
@@ -97,7 +98,8 @@ static void printOutputCapabilities() {
/* Output Functions */
/* ***************************** */
static void OutputAdd(Context_t *context, char * port) {
static void OutputAdd(Context_t * context, char *port)
{
int i, j;
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
@@ -128,7 +130,8 @@ static void OutputAdd(Context_t *context, char * port) {
}
}
static void OutputDel(Context_t *context, char * port) {
static void OutputDel(Context_t * context, char *port)
{
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
if (!strcmp("audio", port))
@@ -144,25 +147,42 @@ static void OutputDel(Context_t *context, char * port) {
}
static int Command(void *_context, OutputCmd_t command, void * argument) {
static int Command(void *_context, OutputCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_OUTPUT_NO_ERROR;
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__, command);
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__,
command);
switch (command) {
case OUTPUT_OPEN:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_OPEN, "video");
ret |=
context->output->video->Command(context,
OUTPUT_OPEN,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_OPEN, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_OPEN,
"audio");
if (context->playback->isSubtitle)
ret |= context->output->subtitle->Command(context, OUTPUT_OPEN, "subtitle");
ret |=
context->output->subtitle->Command(context,
OUTPUT_OPEN,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -170,15 +190,30 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_CLOSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_CLOSE, "video");
ret |=
context->output->video->Command(context,
OUTPUT_CLOSE,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_CLOSE, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_CLOSE,
"audio");
if (context->playback->isSubtitle)
ret |= context->output->subtitle->Command(context, OUTPUT_CLOSE, "subtitle");
ret |=
context->output->subtitle->Command(context,
OUTPUT_CLOSE,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -198,20 +233,35 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_PLAY:{ // 4
if (context && context->playback) {
if (context->playback->isVideo)
ret = context->output->video->Command(context, OUTPUT_PLAY, "video");
ret =
context->output->video->Command(context,
OUTPUT_PLAY,
"video");
if (!ret) { // success or not executed, dunn care
if (context->playback->isAudio)
ret = context->output->audio->Command(context, OUTPUT_PLAY, "audio");
ret =
context->output->audio->Command(context,
OUTPUT_PLAY,
"audio");
if (!ret) { // success or not executed, dunn care
if (context->playback->isSubtitle)
ret = context->output->subtitle->Command(context, OUTPUT_PLAY, "subtitle");
ret =
context->output->subtitle->Command(context,
OUTPUT_PLAY,
"subtitle");
}
if (context->playback->isDvbSubtitle)
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
}
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
@@ -220,15 +270,30 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_STOP:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_STOP, "video");
ret |=
context->output->video->Command(context,
OUTPUT_STOP,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_STOP, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_STOP,
"audio");
if (context->playback->isSubtitle)
ret |= context->output->subtitle->Command(context, OUTPUT_STOP, "subtitle");
ret |=
context->output->subtitle->Command(context,
OUTPUT_STOP,
"subtitle");
if (context->playback->isDvbSubtitle)
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -236,9 +301,15 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_FLUSH:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_FLUSH, "video");
ret |=
context->output->video->Command(context,
OUTPUT_FLUSH,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_FLUSH, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_FLUSH,
"audio");
//if (context->playback->isSubtitle)
// ret |= context->output->subtitle->Command(context, OUTPUT_FLUSH, "subtitle");
} else
@@ -248,9 +319,15 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_PAUSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_PAUSE, "video");
ret |=
context->output->video->Command(context,
OUTPUT_PAUSE,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_PAUSE, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_PAUSE,
"audio");
//if (context->playback->isSubtitle)
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
} else
@@ -260,9 +337,15 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_FASTFORWARD:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_FASTFORWARD, "video");
ret |=
context->output->video->Command(context,
OUTPUT_FASTFORWARD,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_FASTFORWARD, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_FASTFORWARD,
"audio");
//if (context->playback->isSubtitle)
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
} else
@@ -272,9 +355,15 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_REVERSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_REVERSE, "video");
ret |=
context->output->video->Command(context,
OUTPUT_REVERSE,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_REVERSE, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_REVERSE,
"audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -282,39 +371,69 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_CONTINUE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_CONTINUE, "video");
ret |=
context->output->video->Command(context,
OUTPUT_CONTINUE,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_CONTINUE, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_CONTINUE,
"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");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_AVSYNC:{
if (context && context->playback) {
if (context->playback->isVideo && context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_AVSYNC, "audio");
if (context->playback->isVideo
&& context->playback->isAudio)
ret |=
context->output->audio->Command(context,
OUTPUT_AVSYNC,
"audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_CLEAR:{
if (context && context->playback) {
if (context->playback->isVideo && (argument == NULL || *(char *) argument == 'v'))
ret |= context->output->video->Command(context, OUTPUT_CLEAR, "video");
if (context->playback->isAudio && (argument == NULL || *(char *) argument == 'a'))
ret |= context->output->audio->Command(context, OUTPUT_CLEAR, "audio");
if (context->playback->isVideo
&& (argument == NULL || *(char *) argument == 'v'))
ret |=
context->output->video->Command(context,
OUTPUT_CLEAR,
"video");
if (context->playback->isAudio
&& (argument == NULL || *(char *) argument == 'a'))
ret |=
context->output->audio->Command(context,
OUTPUT_CLEAR,
"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");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -322,9 +441,13 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_PTS:{
if (context && context->playback) {
if (context->playback->isVideo)
return context->output->video->Command(context, OUTPUT_PTS, argument);
return context->output->video->Command(context,
OUTPUT_PTS,
argument);
if (context->playback->isAudio)
return context->output->audio->Command(context, OUTPUT_PTS, argument);
return context->output->audio->Command(context,
OUTPUT_PTS,
argument);
//if (context->playback->isSubtitle)
// return context->output->subtitle->Command(context, OUTPUT_PTS, "subtitle");
} else
@@ -334,13 +457,23 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_SWITCH:{
if (context && context->playback) {
if (context->playback->isAudio)
return context->output->audio->Command(context, OUTPUT_SWITCH, "audio");
return context->output->audio->Command(context,
OUTPUT_SWITCH,
"audio");
if (context->playback->isVideo)
return context->output->video->Command(context, OUTPUT_SWITCH, "video");
return context->output->video->Command(context,
OUTPUT_SWITCH,
"video");
if (context->playback->isDvbSubtitle)
ret |= context->output->dvbsubtitle->Command(context, command, "dvbsubtitle");
ret |=
context->output->dvbsubtitle->Command(context,
command,
"dvbsubtitle");
if (context->playback->isTeletext)
ret |= context->output->teletext->Command(context, command, "teletext");
ret |=
context->output->teletext->Command(context,
command,
"teletext");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -348,9 +481,15 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_SLOWMOTION:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_SLOWMOTION, "video");
ret |=
context->output->video->Command(context,
OUTPUT_SLOWMOTION,
"video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_SLOWMOTION, "audio");
ret |=
context->output->audio->Command(context,
OUTPUT_SLOWMOTION,
"audio");
//if (context->playback->isSubtitle)
// ret |= context->output->subtitle->Command(context, OUTPUT_PAUSE, "subtitle");
} else
@@ -360,7 +499,10 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_AUDIOMUTE:{
if (context && context->playback) {
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (char*) argument);
ret |=
context->output->audio->Command(context,
OUTPUT_AUDIOMUTE,
(char *) argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -368,7 +510,10 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_DISCONTINUITY_REVERSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (void*) argument);
ret |=
context->output->video->Command(context,
OUTPUT_DISCONTINUITY_REVERSE,
(void *) argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
@@ -376,9 +521,13 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
case OUTPUT_GET_FRAME_COUNT:{
if (context && context->playback) {
if (context->playback->isVideo)
return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, argument);
return context->output->video->Command(context,
OUTPUT_GET_FRAME_COUNT,
argument);
if (context->playback->isAudio)
return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, argument);
return context->output->audio->Command(context,
OUTPUT_GET_FRAME_COUNT,
argument);
//if (context->playback->isSubtitle)
// return context->output->subtitle->Command(context, OUTPUT_GET_FRAME_COUNT, "subtitle");
} else
@@ -386,12 +535,14 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
break;
}
default:
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME,
__FUNCTION__, command);
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
output_printf(10, "%s::%s exiting with value %d\n", FILENAME, __FUNCTION__, ret);
output_printf(10, "%s::%s exiting with value %d\n", FILENAME,
__FUNCTION__, ret);
return ret;
}

View File

@@ -87,7 +87,11 @@ 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))) {
void getPipeMutex(const char *filename
__attribute__ ((unused)), const char *function
__attribute__ ((unused)), int line
__attribute__ ((unused)))
{
pipe_printf(250, "requesting mutex\n");
@@ -96,14 +100,19 @@ void getPipeMutex(const char *filename __attribute__((unused)), const char *func
pipe_printf(250, "received mutex\n");
}
void releasePipeMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) {
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) {
int PipeOpen(Context_t * context __attribute__ ((unused)), char *type)
{
unsigned char teletext = !strcmp("teletext", type);
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
@@ -113,9 +122,9 @@ int PipeOpen(Context_t *context __attribute__((unused)), char * type) {
mkfifo(TELETEXTPIPE, 0644);
teletextfd = open(TELETEXTPIPE, O_RDWR | O_NONBLOCK);
if (teletextfd < 0)
{
pipe_err("failed to open %s - errno %d\n", TELETEXTPIPE, errno);
if (teletextfd < 0) {
pipe_err("failed to open %s - errno %d\n", TELETEXTPIPE,
errno);
pipe_err("%s\n", strerror(errno));
return cERR_PIPE_ERROR;
}
@@ -124,9 +133,9 @@ int PipeOpen(Context_t *context __attribute__((unused)), char * type) {
mkfifo(DVBSUBTITLEPIPE, 0644);
dvbsubtitlefd = open(DVBSUBTITLEPIPE, O_RDWR | O_NONBLOCK);
if (dvbsubtitlefd < 0)
{
pipe_err("failed to open %s - errno %d\n", DVBSUBTITLEPIPE, errno);
if (dvbsubtitlefd < 0) {
pipe_err("failed to open %s - errno %d\n", DVBSUBTITLEPIPE,
errno);
pipe_err("%s\n", strerror(errno));
return cERR_PIPE_ERROR;
}
@@ -135,7 +144,8 @@ int PipeOpen(Context_t *context __attribute__((unused)), char * type) {
return cERR_PIPE_NO_ERROR;
}
int PipeClose(Context_t *context, char * type) {
int PipeClose(Context_t * context, char *type)
{
unsigned char dvbsubtitle = !strcmp("dvbsubtitle", type);
unsigned char teletext = !strcmp("teletext", type);
@@ -162,7 +172,9 @@ int PipeClose(Context_t *context, char * type) {
return cERR_PIPE_NO_ERROR;
}
int PipePlay(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
int PipePlay(Context_t * context __attribute__ ((unused)), char *type
__attribute__ ((unused)))
{
int ret = cERR_PIPE_NO_ERROR;
#if 0
@@ -179,7 +191,9 @@ int PipePlay(Context_t *context __attribute__((unused)), char * type __attribut
return ret;
}
int PipeStop(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
int PipeStop(Context_t * context __attribute__ ((unused)), char *type
__attribute__ ((unused)))
{
int ret = cERR_PIPE_NO_ERROR;
#if 0
@@ -201,13 +215,15 @@ int PipeStop(Context_t *context __attribute__((unused)), char * type __attribut
return ret;
}
int PipeFlush(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);
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
@@ -227,14 +243,16 @@ int PipeFlush(Context_t *context __attribute__((unused)), char * type) {
return cERR_PIPE_NO_ERROR;
}
int PipeClear(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);
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (dvbsubtitle && dvbsubtitlefd != -1) {
@@ -254,14 +272,17 @@ int PipeClear(Context_t *context __attribute__((unused)), char * type) {
return ret;
}
int PipeSwitch(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {
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);
if ( (dvbsubtitle && dvbsubtitlefd != -1) || (teletext && teletextfd != -1) ) {
if ((dvbsubtitle && dvbsubtitlefd != -1)
|| (teletext && teletextfd != -1)) {
getPipeMutex(FILENAME, __FUNCTION__, __LINE__);
if (teletext && teletextfd != -1) {
@@ -279,7 +300,8 @@ int PipeSwitch(Context_t *context __attribute__((unused)), char * type __attrib
return cERR_PIPE_NO_ERROR;
}
static int writePESDataTeletext(int fd, unsigned char *data, size_t data_len)
static int writePESDataTeletext(int fd, unsigned char *data,
size_t data_len)
{
unsigned int len = 0;
if (data_len > 0) {
@@ -305,7 +327,8 @@ static int writePESDataTeletext(int fd, unsigned char *data, size_t data_len)
return len;
}
static int writePESDataDvbsubtitle(int fd, unsigned char *data, size_t data_len, int64_t pts)
static int writePESDataDvbsubtitle(int fd, unsigned char *data,
size_t data_len, int64_t pts)
{
int len = 0;
if (data_len > 0) {
@@ -354,8 +377,7 @@ static int Write(void *_context __attribute__((unused)), void* _out)
unsigned char dvbsubtitle;
unsigned char teletext;
if (out == NULL)
{
if (out == NULL) {
pipe_err("null pointer passed\n");
return cERR_PIPE_ERROR;
}
@@ -363,22 +385,23 @@ static int Write(void *_context __attribute__((unused)), void* _out)
dvbsubtitle = !strcmp("dvbsubtitle", out->type);
teletext = !strcmp("teletext", out->type);
pipe_printf(20, "DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n",
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);
if (dvbsubtitle) {
res = writePESDataDvbsubtitle(dvbsubtitlefd, out->data, out->len, out->pts);
res =
writePESDataDvbsubtitle(dvbsubtitlefd, out->data, out->len,
out->pts);
if (res <= 0)
{
if (res <= 0) {
ret = cERR_PIPE_ERROR;
}
} else if (teletext) {
res = writePESDataTeletext(teletextfd, out->data, out->len);
if (res <= 0)
{
if (res <= 0) {
ret = cERR_PIPE_ERROR;
}
}
@@ -393,7 +416,8 @@ static int reset(Context_t *context __attribute__((unused)))
return ret;
}
static int Command(void *_context, OutputCmd_t command, void * argument) {
static int Command(void *_context, OutputCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_PIPE_NO_ERROR;

View File

@@ -116,7 +116,8 @@ static uint32_t *destination = NULL;
/* ***************************** */
/* MISC Functions */
/* ***************************** */
static void getMutex(int line) {
static void getMutex(int line)
{
subtitle_printf(100, "%d requesting mutex\n", line);
pthread_mutex_lock(&mutex);
@@ -124,13 +125,15 @@ static void getMutex(int line) {
subtitle_printf(100, "%d received mutex\n", line);
}
static void releaseMutex(int line) {
static void releaseMutex(int line)
{
pthread_mutex_unlock(&mutex);
subtitle_printf(100, "%d released mutex\n", line);
}
void replace_all(char ** string, char * search, char * replace) {
void replace_all(char **string, char *search, char *replace)
{
int len = 0;
char *ptr = NULL;
char tempString[512];
@@ -138,8 +141,8 @@ void replace_all(char ** string, char * search, char * replace) {
newString[0] = '\0';
if ((string == NULL) || (*string == NULL) || (search == NULL) || (replace == NULL))
{
if ((string == NULL) || (*string == NULL) || (search == NULL)
|| (replace == NULL)) {
subtitle_err("null pointer passed\n");
return;
}
@@ -170,13 +173,13 @@ void replace_all(char ** string, char * search, char * replace) {
}
int subtitle_ParseASS (char **Line) {
int subtitle_ParseASS(char **Line)
{
char *Text;
int i;
char *ptr1;
if ((Line == NULL) || (*Line == NULL))
{
if ((Line == NULL) || (*Line == NULL)) {
subtitle_err("null pointer passed\n");
return cERR_SUBTITLE_ERROR;
}
@@ -210,10 +213,10 @@ int subtitle_ParseASS (char **Line) {
return cERR_SUBTITLE_NO_ERROR;
}
int subtitle_ParseSRT (char **Line) {
if ((Line == NULL) || (*Line == NULL))
int subtitle_ParseSRT(char **Line)
{
if ((Line == NULL) || (*Line == NULL)) {
subtitle_err("null pointer passed\n");
return cERR_SUBTITLE_ERROR;
}
@@ -237,10 +240,10 @@ int subtitle_ParseSRT (char **Line) {
return cERR_SUBTITLE_NO_ERROR;
}
int subtitle_ParseSSA (char **Line) {
if ((Line == NULL) || (*Line == NULL))
int subtitle_ParseSSA(char **Line)
{
if ((Line == NULL) || (*Line == NULL)) {
subtitle_err("null pointer passed\n");
return cERR_SUBTITLE_ERROR;
}
@@ -264,31 +267,29 @@ int subtitle_ParseSSA (char **Line) {
return cERR_SUBTITLE_NO_ERROR;
}
void addSub(Context_t *context, char * text, unsigned long long int pts, unsigned long int milliDuration) {
void addSub(Context_t * context, char *text, unsigned long long int pts,
unsigned long int milliDuration)
{
int count = 20;
subtitle_printf(50, "index %d\n", writePointer);
if(context && context->playback && !context->playback->isPlaying)
{
if (context && context->playback && !context->playback->isPlaying) {
subtitle_err("1. aborting ->no playback\n");
return;
}
if (text == NULL)
{
if (text == NULL) {
subtitle_err("null pointer passed\n");
return;
}
if (pts == 0)
{
if (pts == 0) {
subtitle_err("pts 0\n");
return;
}
if (milliDuration == 0)
{
if (milliDuration == 0) {
subtitle_err("duration 0\n");
return;
}
@@ -296,8 +297,7 @@ void addSub(Context_t *context, char * text, unsigned long long int pts, unsign
while (subPuffer[writePointer].text != NULL) {
//List is full, wait till we got some free space
if(context && context->playback && !context->playback->isPlaying)
{
if (context && context->playback && !context->playback->isPlaying) {
subtitle_err("2. aborting ->no playback\n");
return;
}
@@ -306,23 +306,23 @@ void addSub(Context_t *context, char * text, unsigned long long int pts, unsign
* is available we start ring from the beginning and loose some stuff
* which is acceptable!
*/
subtitle_printf(10, "waiting on free buffer %d - %d (%d) ...\n", writePointer, readPointer, count);
subtitle_printf(10, "waiting on free buffer %d - %d (%d) ...\n",
writePointer, readPointer, count);
usleep(10000);
count--;
if (count == 0)
{
if (count == 0) {
subtitle_err("abort waiting on buffer...\n");
break;
}
}
subtitle_printf(20, "from mkv: %s pts:%lld milliDuration:%lud\n",text,pts,milliDuration);
subtitle_printf(20, "from mkv: %s pts:%lld milliDuration:%lud\n", text,
pts, milliDuration);
getMutex(__LINE__);
if (count == 0)
{
if (count == 0) {
int i;
subtitle_err("freeing not delivered data\n");
@@ -348,8 +348,7 @@ void addSub(Context_t *context, char * text, unsigned long long int pts, unsign
if (writePointer == PUFFERSIZE)
writePointer = 0;
if (writePointer == readPointer)
{
if (writePointer == readPointer) {
/* this should not happen, and means that there is nor reader or
* the reader has performance probs ;)
* the recovery is done at startup of this function - but next time
@@ -362,20 +361,20 @@ void addSub(Context_t *context, char * text, unsigned long long int pts, unsign
subtitle_printf(10, "<\n");
}
int getNextSub(char ** text, unsigned long long int * pts, long int * milliDuration) {
int getNextSub(char **text, unsigned long long int *pts,
long int *milliDuration)
{
subtitle_printf(50, "index %d\n", readPointer);
if (text == NULL)
{
if (text == NULL) {
subtitle_err("null pointer passed\n");
return cERR_SUBTITLE_ERROR;
}
getMutex(__LINE__);
if (subPuffer[readPointer].text == NULL)
{
if (subPuffer[readPointer].text == NULL) {
/* this is acutally not an error, because it may happen
* that there is no subtitle for a while
*/
@@ -399,13 +398,13 @@ int getNextSub(char ** text, unsigned long long int * pts, long int * milliDurat
if (readPointer == PUFFERSIZE)
readPointer = 0;
if (writePointer == readPointer)
{
if (writePointer == readPointer) {
/* this may happen, in normal case the reader is ones ahead the
* writer. So this is the normal case that we eat the data
* and have the reader reached.
*/
subtitle_printf(20, "ups something went wrong. no more writers? \n");
subtitle_printf(20,
"ups something went wrong. no more writers? \n");
}
releaseMutex(__LINE__);
@@ -420,7 +419,8 @@ int getNextSub(char ** text, unsigned long long int * pts, long int * milliDurat
/* Worker Thread */
/* **************************** */
static void* SubtitleThread(void* data) {
static void *SubtitleThread(void *data)
{
Context_t *context = (Context_t *) data;
char *subText = NULL;
long int subMilliDuration = 0;
@@ -436,14 +436,13 @@ static void* SubtitleThread(void* data) {
subtitle_printf(10, "done\n");
while ( context &&
context->playback &&
context->playback->isPlaying) {
while (context && context->playback && context->playback->isPlaying) {
int curtrackid = -1;
if (context && context->manager && context->manager->subtitle)
context->manager->subtitle->Command(context, MANAGER_GET, &curtrackid);
context->manager->subtitle->Command(context, MANAGER_GET,
&curtrackid);
subtitle_printf(50, "curtrackid %d\n", curtrackid);
@@ -455,7 +454,8 @@ static void* SubtitleThread(void* data) {
if (context && context->playback)
context->playback->Command(context, PLAYBACK_PTS, &Pts);
else return NULL;
else
return NULL;
if (Pts > subPts) {
subtitle_printf(10, "subtitle is to late, ignoring\n");
@@ -464,12 +464,12 @@ static void* SubtitleThread(void* data) {
continue;
}
subtitle_printf(20, "Pts:%llu < subPts%llu duration %ld\n", Pts, subPts,subMilliDuration);
subtitle_printf(20, "Pts:%llu < subPts%llu duration %ld\n",
Pts, subPts, subMilliDuration);
while (context &&
context->playback &&
context->playback->isPlaying &&
Pts < subPts) {
context->playback->isPlaying && Pts < subPts) {
unsigned long int diff = subPts - Pts;
diff = (diff * 1000) / 90.0;
@@ -480,24 +480,28 @@ static void* SubtitleThread(void* data) {
usleep(diff);
if (context && context->playback)
context->playback->Command(context, PLAYBACK_PTS, &Pts);
else
{
context->playback->Command(context, PLAYBACK_PTS,
&Pts);
else {
subtitle_err("no playback ? terminated?\n");
break;
}
subtitle_printf(20, "cur: %llu wanted: %llu\n", Pts, subPts);
subtitle_printf(20, "cur: %llu wanted: %llu\n", Pts,
subPts);
}
if (context &&
context->playback &&
context->playback->isPlaying &&
subText != NULL ) {
context->playback->isPlaying && subText != NULL) {
if (clientFunction != NULL)
clientFunction(subMilliDuration, strlen(subText), subText, clientData);
clientFunction(subMilliDuration, strlen(subText),
subText, clientData);
else
subtitle_printf(10, "writing Sub failed (%ld) (%d) \"%s\"\n", subMilliDuration, strlen(subText), subText);
subtitle_printf(10,
"writing Sub failed (%ld) (%d) \"%s\"\n",
subMilliDuration, strlen(subText),
subText);
free(subText);
}
@@ -519,7 +523,8 @@ static void* SubtitleThread(void* data) {
/* Functions */
/* ***************************** */
static int Write(void* _context, void *data) {
static int Write(void *_context, void *data)
{
Context_t *context = (Context_t *) _context;
char *Encoding = NULL;
char *Text;
@@ -530,19 +535,16 @@ static int Write(void* _context, void *data) {
subtitle_printf(10, "\n");
if (data == NULL)
{
if (data == NULL) {
subtitle_err("null pointer passed\n");
return cERR_SUBTITLE_ERROR;
}
out = (SubtitleOut_t *) data;
if (out->type == eSub_Txt)
{
if (out->type == eSub_Txt) {
Text = strdup((const char *) out->u.text.data);
} else
{
} else {
/* fixme handle gfx subs from container_ass and send it to
* the callback. this must be implemented also in e2/neutrino
* then.
@@ -555,16 +557,17 @@ static int Write(void* _context, void *data) {
Pts = out->pts;
Duration = out->duration;
context->manager->subtitle->Command(context, MANAGER_GETENCODING, &Encoding);
context->manager->subtitle->Command(context, MANAGER_GETENCODING,
&Encoding);
if (Encoding == NULL)
{
if (Encoding == NULL) {
subtitle_err("encoding unknown\n");
free(Text);
return cERR_SUBTITLE_ERROR;
}
subtitle_printf(20, "Encoding:%s Text:%s Len:%d\n", Encoding,Text, DataLength);
subtitle_printf(20, "Encoding:%s Text:%s Len:%d\n", Encoding, Text,
DataLength);
if (!strncmp("S_TEXT/SSA", Encoding, 10) ||
!strncmp("S_SSA", Encoding, 5))
@@ -577,8 +580,7 @@ static int Write(void* _context, void *data) {
else if (!strncmp("S_TEXT/SRT", Encoding, 10) ||
!strncmp("S_SRT", Encoding, 5))
subtitle_ParseSRT(&Text);
else
{
else {
subtitle_err("unknown encoding %s\n", Encoding);
return cERR_SUBTITLE_ERROR;
}
@@ -595,13 +597,13 @@ static int Write(void* _context, void *data) {
return cERR_SUBTITLE_NO_ERROR;
}
static int subtitle_Open(Context_t* context __attribute__((unused))) {
static int subtitle_Open(Context_t * context __attribute__ ((unused)))
{
int i;
subtitle_printf(10, "\n");
if (isSubtitleOpened == 1)
{
if (isSubtitleOpened == 1) {
subtitle_err("already opened! ignoring\n");
return cERR_SUBTITLE_ERROR;
}
@@ -627,7 +629,8 @@ static int subtitle_Open(Context_t* context __attribute__((unused))) {
return cERR_SUBTITLE_NO_ERROR;
}
static int subtitle_Close(Context_t* context __attribute__((unused))) {
static int subtitle_Close(Context_t * context __attribute__ ((unused)))
{
int i;
subtitle_printf(10, "\n");
@@ -656,29 +659,26 @@ static int subtitle_Close(Context_t* context __attribute__((unused))) {
return cERR_SUBTITLE_NO_ERROR;
}
static int subtitle_Play(Context_t* context) {
static int subtitle_Play(Context_t * context)
{
subtitle_printf(10, "\n");
if (hasThreadStarted == 0)
{
if (hasThreadStarted == 0) {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create (&thread_sub, &attr, &SubtitleThread, (void*) context) != 0)
{
if (pthread_create
(&thread_sub, &attr, &SubtitleThread, (void *) context) != 0) {
subtitle_err("Error creating thread\n");
hasThreadStarted = 0;
} else
{
} else {
subtitle_printf(10, "Created thread\n");
hasThreadStarted = 1;
}
}
else
{
} else {
subtitle_err("thread already created.\n");
return cERR_SUBTITLE_ERROR;
}
@@ -688,14 +688,17 @@ static int subtitle_Play(Context_t* context) {
return cERR_SUBTITLE_NO_ERROR;
}
static int subtitle_Stop(Context_t* context __attribute__((unused))) {
static int subtitle_Stop(Context_t * context __attribute__ ((unused)))
{
int wait_time = 20;
int i;
subtitle_printf(10, "\n");
while ((hasThreadStarted != 0) && (--wait_time) > 0) {
subtitle_printf(10, "Waiting for subtitle thread to terminate itself, will try another %d times\n", wait_time);
subtitle_printf(10,
"Waiting for subtitle thread to terminate itself, will try another %d times\n",
wait_time);
usleep(100000);
}
@@ -747,7 +750,8 @@ void subtitle_SignalConnectBuffer(void* data)
clientData = data;
}
static int Command(void *_context, OutputCmd_t command, void * argument) {
static int Command(void *_context, OutputCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_SUBTITLE_NO_ERROR;

View File

@@ -192,7 +192,8 @@ else
static unsigned char DefaultAACHeader[] = {
0xff,
0xf1,
/*0x00, 0x00*/0x50, //((Profile & 0x03) << 6) | (SampleIndex << 2) | ((Channels >> 2) & 0x01);s
/*0x00, 0x00 */ 0x50,
//((Profile & 0x03) << 6) | (SampleIndex << 2) | ((Channels >> 2) & 0x01);s
0x80, //(Channels & 0x03) << 6;
0x00,
0x1f,
@@ -221,8 +222,7 @@ static int writeData(void* _call)
aac_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
aac_err("call data is NULL...\n");
return 0;
}
@@ -231,31 +231,29 @@ static int writeData(void* _call)
PacketLength = call->len + AAC_HEADER_LENGTH;
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
aac_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
aac_err("file pointer < 0. ignoring ...\n");
return 0;
}
if (call->private_data == NULL)
{
if (call->private_data == NULL) {
aac_printf(10, "private_data = NULL\n");
memcpy(ExtraData, DefaultAACHeader, AAC_HEADER_LENGTH);
}
else
} else
memcpy(ExtraData, call->private_data, AAC_HEADER_LENGTH);
ExtraData[3] |= (PacketLength >> 11) & 0x3;
ExtraData[4] = (PacketLength >> 3) & 0xff;
ExtraData[5] |= (PacketLength << 5) & 0xe0;
unsigned int HeaderLength = InsertPesHeader (PesHeader, PacketLength, AAC_AUDIO_PES_START_CODE, call->Pts, 0);
unsigned int HeaderLength =
InsertPesHeader(PesHeader, PacketLength, AAC_AUDIO_PES_START_CODE,
call->Pts, 0);
struct iovec iov[3];
iov[0].iov_base = PesHeader;

View File

@@ -99,22 +99,19 @@ static int writeData(void* _call)
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
if (call == NULL)
{
if (call == NULL) {
ac3_err("call data is NULL...\n");
return 0;
}
ac3_printf(10, "AudioPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
ac3_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
ac3_err("file pointer < 0. ignoring ...\n");
return 0;
}
@@ -122,7 +119,9 @@ static int writeData(void* _call)
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, PRIVATE_STREAM_1_PES_START_CODE, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->len,
PRIVATE_STREAM_1_PES_START_CODE, call->Pts, 0);
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;

View File

@@ -99,26 +99,24 @@ static int writeData(void* _call)
unsigned char FakeHeaders[64]; // 64bytes should be enough to make the fake headers
unsigned int FakeHeaderLength;
unsigned char Version = 5;
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
unsigned int FakeStartCode =
(Version << 8) | PES_VERSION_FAKE_START_CODE;
unsigned int usecPerFrame = 41708; /* Hellmaster1024: default value */
BitPacker_t ld = { FakeHeaders, 0, 32 };
divx_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
divx_err("call data is NULL...\n");
return 0;
}
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
divx_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
divx_err("file pointer < 0. ignoring ...\n");
return 0;
}
@@ -149,7 +147,9 @@ static int writeData(void* _call)
struct iovec iov[4];
int ic = 0;
iov[ic].iov_base = PesHeader;
iov[ic++].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode);
iov[ic++].iov_len =
InsertPesHeader(PesHeader, call->len, MPEG_VIDEO_PES_START_CODE,
call->Pts, FakeStartCode);
iov[ic].iov_base = FakeHeaders;
iov[ic++].iov_len = FakeHeaderLength;

View File

@@ -101,34 +101,29 @@ static int writeData(void* _call)
dts_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
dts_err("call data is NULL...\n");
return 0;
}
dts_printf(10, "AudioPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
dts_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
dts_err("file pointer < 0. ignoring ...\n");
return 0;
}
// #define DO_BYTESWAP
#ifdef DO_BYTESWAP
unsigned char *Data = (unsigned char *) malloc(call->len);
memcpy(Data, call->data, call->len);
/* 16-bit byte swap all data before injecting it */
for (i=0; i< call->len; i+=2)
{
for (i = 0; i < call->len; i += 2) {
unsigned char Tmp = Data[i];
Data[i] = Data[i + 1];
Data[i + 1] = Tmp;
@@ -138,7 +133,11 @@ static int writeData(void* _call)
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_AUDIO_PES_START_CODE/*PRIVATE_STREAM_1_PES_START_CODE*/, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->len,
MPEG_AUDIO_PES_START_CODE
/*PRIVATE_STREAM_1_PES_START_CODE */ , call->Pts,
0);
#ifdef DO_BYTESPWAP
iov[1].iov_base = Data;
#else

View File

@@ -97,29 +97,28 @@ static int writeData(void* _call)
flac_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
flac_err("call data is NULL...\n");
return 0;
}
flac_printf(10, "AudioPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
flac_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
flac_err("file pointer < 0. ignoring ...\n");
return 0;
}
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->len , MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE,
call->Pts, 0);
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;

View File

@@ -106,14 +106,12 @@ static int writeData(void* _call)
fb_printf(100, "\n");
if (!call)
{
if (!call) {
fb_err("call data is NULL...\n");
return 0;
}
if (!call->destination)
{
if (!call->destination) {
fb_err("frame buffer == NULL. ignoring ...\n");
return 0;
}
@@ -122,8 +120,7 @@ static int writeData(void* _call)
int dst_delta = dst_stride - call->Width;
uint32_t *dst = call->destination + call->y * dst_stride + call->x;
if (call->data)
{
if (call->data) {
int src_delta = call->Stride - call->Width;
unsigned char *src = call->data;
static uint32_t last_color = 0, colortable[256];
@@ -159,7 +156,8 @@ static int writeData(void* _call)
}
}
} else {
uint32_t *dst_final = dst + call->Width + call->Height * dst_stride;
uint32_t *dst_final =
dst + call->Width + call->Height * dst_stride;
for (; dst < dst_final; dst += dst_delta) {
uint32_t *dst_end = dst + call->Width;
for (; dst < dst_end; dst++)

View File

@@ -98,31 +98,33 @@ static int writeData(void* _call)
h263_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
h263_err("call data is NULL...\n");
return 0;
}
h263_printf(10, "VideoPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
h263_err("NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
h263_err("file pointer < 0. ignoring ...\n");
return 0;
}
int HeaderLength = InsertPesHeader(PesHeader, call->len, H263_VIDEO_PES_START_CODE, call->Pts,0);
int HeaderLength =
InsertPesHeader(PesHeader, call->len, H263_VIDEO_PES_START_CODE,
call->Pts, 0);
int PrivateHeaderLength = InsertVideoPrivateDataHeader (&PesHeader[HeaderLength], call->len);
int PrivateHeaderLength =
InsertVideoPrivateDataHeader(&PesHeader[HeaderLength], call->len);
int PesLength = PesHeader[PES_LENGTH_BYTE_0] + (PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
int PesLength =
PesHeader[PES_LENGTH_BYTE_0] +
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;

View File

@@ -75,8 +75,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
/* ***************************** */
/* Types */
/* ***************************** */
typedef struct avcC_s
{
typedef struct avcC_s {
unsigned char Version; /* configurationVersion */
unsigned char Profile; /* AVCProfileIndication */
unsigned char Compatibility; /* profile_compatibility */
@@ -91,6 +90,7 @@ typedef struct avcC_s
/* Varaibles */
/* ***************************** */
const unsigned char Head[] = { 0, 0, 0, 1 };
static int initialHeader = 1;
static unsigned int NalLengthBytes = 1;
@@ -121,8 +121,7 @@ static int writeData(void* _call)
struct iovec iov[128];
h264_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
h264_err("call data is NULL...\n");
return 0;
}
@@ -131,25 +130,28 @@ static int writeData(void* _call)
TimeScale = call->FrameScale;
VideoPts = call->Pts;
h264_printf(10, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta, TimeScale);
h264_printf(10, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta,
TimeScale);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
h264_err("NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
h264_err("file pointer < 0. ignoring ...\n");
return 0;
}
if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))
{
if ((call->len > 3)
&&
((call->data[0] == 0x00 && call->data[1] == 0x00
&& call->data[2] == 0x00 && call->data[3] == 0x01)
|| (call->data[0] == 0xff && call->data[1] == 0xff
&& call->data[2] == 0xff && call->data[3] == 0xff))) {
unsigned int PacketLength = 0;
unsigned int FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE;
unsigned int FakeStartCode =
(call->Version << 8) | PES_VERSION_FAKE_START_CODE;
iov[ic++].iov_base = PesHeader;
if (initialHeader) {
initialHeader = 0;
@@ -165,12 +167,14 @@ static int writeData(void* _call)
by the player */
iov[ic].iov_base = "";
iov[ic++].iov_len = 1;
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode);
iov[0].iov_len =
InsertPesHeader(PesHeader, PacketLength,
MPEG_VIDEO_PES_START_CODE, call->Pts,
FakeStartCode);
return writev(call->fd, iov, ic);
}
if (initialHeader)
{
if (initialHeader) {
avcC_t *avcCHeader = (avcC_t *) call->private_data;
unsigned int i;
unsigned int ParamSets;
@@ -184,7 +188,8 @@ static int writeData(void* _call)
}
if (avcCHeader->Version != 1)
h264_err("Error unknown avcC version (%x). Expect problems.\n", avcCHeader->Version);
h264_err("Error unknown avcC version (%x). Expect problems.\n",
avcCHeader->Version);
ParametersLength = 0;
@@ -192,7 +197,8 @@ static int writeData(void* _call)
HeaderData[ParametersLength++] = 0x00; // Start code
HeaderData[ParametersLength++] = 0x00;
HeaderData[ParametersLength++] = 0x01;
HeaderData[ParametersLength++] = NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
HeaderData[ParametersLength++] =
NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
// Container message version - changes when/if we vary the format of the message
HeaderData[ParametersLength++] = CONTAINER_PARAMETERS_VERSION;
HeaderData[ParametersLength++] = 0xff; // Field separator
@@ -219,7 +225,10 @@ static int writeData(void* _call)
ic = 0;
iov[ic].iov_base = PesHeader;
iov[ic++].iov_len = InsertPesHeader (PesHeader, ParametersLength, MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
iov[ic++].iov_len =
InsertPesHeader(PesHeader, ParametersLength,
MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
0);
iov[ic].iov_base = HeaderData;
iov[ic++].iov_len = ParametersLength;
len = writev(call->fd, iov, ic);
@@ -230,20 +239,29 @@ static int writeData(void* _call)
ParamSets = avcCHeader->NumParamSets & 0x1f;
h264_printf(20, "avcC contents:\n");
h264_printf(20, " version: %d\n", avcCHeader->Version);
h264_printf(20, " profile: %d\n", avcCHeader->Profile);
h264_printf(20, " profile compatibility: %d\n", avcCHeader->Compatibility);
h264_printf(20, " level: %d\n", avcCHeader->Level);
h264_printf(20, " nal length bytes: %d\n", NalLengthBytes);
h264_printf(20, " number of sequence param sets: %d\n", ParamSets);
h264_printf(20, " version: %d\n",
avcCHeader->Version);
h264_printf(20, " profile: %d\n",
avcCHeader->Profile);
h264_printf(20, " profile compatibility: %d\n",
avcCHeader->Compatibility);
h264_printf(20, " level: %d\n",
avcCHeader->Level);
h264_printf(20, " nal length bytes: %d\n",
NalLengthBytes);
h264_printf(20, " number of sequence param sets: %d\n",
ParamSets);
ParamOffset = 0;
ic = 0;
iov[ic++].iov_base = PesHeader;
for (i = 0; i < ParamSets; i++) {
unsigned int PsLength = (avcCHeader->Params[ParamOffset] << 8) + avcCHeader->Params[ParamOffset+1];
unsigned int PsLength =
(avcCHeader->Params[ParamOffset] << 8) +
avcCHeader->Params[ParamOffset + 1];
h264_printf(20, " sps %d has length %d\n", i, PsLength);
h264_printf(20, " sps %d has length %d\n", i,
PsLength);
iov[ic].iov_base = (char *) Head;
iov[ic++].iov_len = sizeof(Head);
@@ -256,13 +274,17 @@ static int writeData(void* _call)
ParamSets = avcCHeader->Params[ParamOffset];
h264_printf(20, " number of picture param sets: %d\n", ParamSets);
h264_printf(20, " number of picture param sets: %d\n",
ParamSets);
ParamOffset++;
for (i = 0; i < ParamSets; i++) {
unsigned int PsLength = (avcCHeader->Params[ParamOffset] << 8) + avcCHeader->Params[ParamOffset+1];
unsigned int PsLength =
(avcCHeader->Params[ParamOffset] << 8) +
avcCHeader->Params[ParamOffset + 1];
h264_printf (20, " pps %d has length %d\n", i, PsLength);
h264_printf(20, " pps %d has length %d\n", i,
PsLength);
iov[ic].iov_base = (char *) Head;
iov[ic++].iov_len = sizeof(Head);
@@ -273,7 +295,10 @@ static int writeData(void* _call)
ParamOffset += PsLength + 2;
}
iov[0].iov_len = InsertPesHeader (PesHeader, InitialHeaderLength, MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, InitialHeaderLength,
MPEG_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
0);
ssize_t l = writev(call->fd, iov, ic);
if (l < 0)
return l;
@@ -295,16 +320,30 @@ static int writeData(void* _call)
VideoPosition += NalLengthBytes;
NalStart += NalLengthBytes;
switch (NalLengthBytes) {
case 1: NalLength = (NalData[0]); break;
case 2: NalLength = (NalData[0] << 8) | (NalData[1]); break;
case 3: NalLength = (NalData[0] << 16) | (NalData[1] << 8) | (NalData[2]); break;
default: NalLength = (NalData[0] << 24) | (NalData[1] << 16) | (NalData[2] << 8) | (NalData[3]); break;
case 1:
NalLength = (NalData[0]);
break;
case 2:
NalLength = (NalData[0] << 8) | (NalData[1]);
break;
case 3:
NalLength =
(NalData[0] << 16) | (NalData[1] << 8) | (NalData[2]);
break;
default:
NalLength =
(NalData[0] << 24) | (NalData[1] << 16) | (NalData[2] << 8)
| (NalData[3]);
break;
}
h264_printf(20, "NalStart = %u + NalLength = %u > SampleSize = %u\n", NalStart, NalLength, SampleSize);
h264_printf(20,
"NalStart = %u + NalLength = %u > SampleSize = %u\n",
NalStart, NalLength, SampleSize);
if (NalStart + NalLength > SampleSize) {
h264_printf(20, "nal length past end of buffer - size %u frame offset %u left %u\n",
h264_printf(20,
"nal length past end of buffer - size %u frame offset %u left %u\n",
NalLength, NalStart, SampleSize - NalStart);
NalStart = SampleSize;
@@ -325,7 +364,9 @@ static int writeData(void* _call)
h264_printf(20, " pts=%llu\n", VideoPts);
iov[0].iov_len = InsertPesHeader (PesHeader, NalLength, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, NalLength,
MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
ssize_t l = writev(call->fd, iov, ic);
if (l < 0)
return l;
@@ -335,8 +376,7 @@ static int writeData(void* _call)
}
} while (NalStart < SampleSize);
if (len < 0)
{
if (len < 0) {
h264_err("error writing data errno = %d\n", errno);
h264_err("%s\n", strerror(errno));
}
@@ -351,28 +391,26 @@ static int writeReverseData(void* _call)
h264_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
h264_err("call data is NULL...\n");
return 0;
}
h264_printf(10, "VideoPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
h264_err("NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
h264_err("file pointer < 0. ignoring ...\n");
return 0;
}
return 0;
}
/* ***************************** */
/* Writer Definition */
/* ***************************** */

View File

@@ -72,17 +72,15 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
#ifdef DEBUG_PUTBITS
if (ld->debug)
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n", code, length, bit_buf, bit_left);
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n",
code, length, bit_buf, bit_left);
#endif /* DEBUG_PUTBITS */
if (length < bit_left)
{
if (length < bit_left) {
/* fits into current buffer */
bit_buf = (bit_buf << length) | code;
bit_left -= length;
}
else
{
} else {
/* doesn't fit */
bit_buf <<= bit_left;
bit_buf |= code >> (length - bit_left);
@@ -110,8 +108,7 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
void FlushBits(BitPacker_t * ld)
{
ld->BitBuffer <<= ld->Remaining;
while (ld->Remaining < 32)
{
while (ld->Remaining < 32) {
#ifdef DEBUG_PUTBITS
if (ld->debug)
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);

View File

@@ -97,29 +97,28 @@ static int writeData(void* _call)
mp3_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
mp3_err("call data is NULL...\n");
return 0;
}
mp3_printf(10, "AudioPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
mp3_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
mp3_err("file pointer < 0. ignoring ...\n");
return 0;
}
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->len , MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE,
call->Pts, 0);
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;

View File

@@ -100,22 +100,19 @@ static int writeData(void* _call)
mpeg2_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
mpeg2_err("call data is NULL...\n");
return 0;
}
mpeg2_printf(10, "VideoPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
mpeg2_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
mpeg2_err("file pointer < 0. ignoring ...\n");
return 0;
}
@@ -126,11 +123,13 @@ static int writeData(void* _call)
int Remaining = call->len - Position - PacketLength;
mpeg2_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
mpeg2_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
PacketLength, Remaining, Position);
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, PacketLength, 0xe0, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, PacketLength, 0xe0, call->Pts, 0);
iov[1].iov_base = call->data + Position;
iov[1].iov_len = PacketLength;

View File

@@ -108,7 +108,9 @@ static unsigned int breakBufferFillSize = 0;
/* MISC Functions */
/* ***************************** */
static int prepareClipPlay(int uNoOfChannels, int uSampleRate, int uBitsPerSample, int bLittleEndian __attribute__((unused)))
static int prepareClipPlay(int uNoOfChannels, int uSampleRate,
int uBitsPerSample, int bLittleEndian
__attribute__ ((unused)))
{
printf("rate: %d ch: %d bits: %d (%d bps)\n",
uSampleRate /*Format->dwSamplesPerSec */ ,
@@ -126,24 +128,31 @@ static int prepareClipPlay(int uNoOfChannels, int uSampleRate, int uBitsPerSampl
//figure out size of subframe
//and set up sample rate
switch (uSampleRate) {
case 48000: SubFrameLen = 40;
break;
case 96000: lpcm_prv[8] |= 0x10;
SubFrameLen = 80;
break;
case 192000: lpcm_prv[8] |= 0x20;
SubFrameLen = 160;
break;
case 44100: lpcm_prv[8] |= 0x80;
case 48000:
SubFrameLen = 40;
break;
case 88200: lpcm_prv[8] |= 0x90;
case 96000:
lpcm_prv[8] |= 0x10;
SubFrameLen = 80;
break;
case 176400: lpcm_prv[8] |= 0xA0;
case 192000:
lpcm_prv[8] |= 0x20;
SubFrameLen = 160;
break;
default: break;
case 44100:
lpcm_prv[8] |= 0x80;
SubFrameLen = 40;
break;
case 88200:
lpcm_prv[8] |= 0x90;
SubFrameLen = 80;
break;
case 176400:
lpcm_prv[8] |= 0xA0;
SubFrameLen = 160;
break;
default:
break;
}
SubFrameLen *= uNoOfChannels;
@@ -163,7 +172,8 @@ static int prepareClipPlay(int uNoOfChannels, int uSampleRate, int uBitsPerSampl
case 16:
break;
default:
printf("inappropriate bits per sample (%d) - must be 16 or 24\n",uBitsPerSample);
printf("inappropriate bits per sample (%d) - must be 16 or 24\n",
uBitsPerSample);
return 1;
}
@@ -201,12 +211,15 @@ static int writeData(void* _call)
return 0;
}
pcmPrivateData_t* pcmPrivateData = (pcmPrivateData_t*)call->private_data;
pcmPrivateData_t *pcmPrivateData =
(pcmPrivateData_t *) call->private_data;
if (initialHeader) {
initialHeader = 0;
prepareClipPlay(pcmPrivateData->uNoOfChannels, pcmPrivateData->uSampleRate,
pcmPrivateData->uBitsPerSample, pcmPrivateData->bLittleEndian);
prepareClipPlay(pcmPrivateData->uNoOfChannels,
pcmPrivateData->uSampleRate,
pcmPrivateData->uBitsPerSample,
pcmPrivateData->bLittleEndian);
}
unsigned char *buffer = call->data;
@@ -216,27 +229,27 @@ static int writeData(void* _call)
unsigned char *injectBuffer = (unsigned char *) malloc(SubFrameLen);
unsigned int pos;
for(pos = 0; pos < size; )
{
for (pos = 0; pos < size;) {
//printf("PCM %s - Position=%d\n", __FUNCTION__, pos);
if((size - pos) < SubFrameLen)
{
if ((size - pos) < SubFrameLen) {
breakBufferFillSize = size - pos;
memcpy(breakBuffer, &buffer[pos], sizeof(unsigned char) * breakBufferFillSize);
memcpy(breakBuffer, &buffer[pos],
sizeof(unsigned char) * breakBufferFillSize);
//printf("PCM %s - Unplayed=%d\n", __FUNCTION__, breakBufferFillSize);
break;
}
//get first PES's worth
if(breakBufferFillSize > 0)
{
memcpy(injectBuffer, breakBuffer, sizeof(unsigned char)*breakBufferFillSize);
memcpy(&injectBuffer[breakBufferFillSize], &buffer[pos], sizeof(unsigned char)*(SubFrameLen - breakBufferFillSize));
if (breakBufferFillSize > 0) {
memcpy(injectBuffer, breakBuffer,
sizeof(unsigned char) * breakBufferFillSize);
memcpy(&injectBuffer[breakBufferFillSize], &buffer[pos],
sizeof(unsigned char) * (SubFrameLen -
breakBufferFillSize));
pos += (SubFrameLen - breakBufferFillSize);
breakBufferFillSize = 0;
} else
{
memcpy(injectBuffer, &buffer[pos], sizeof(unsigned char)*SubFrameLen);
} else {
memcpy(injectBuffer, &buffer[pos],
sizeof(unsigned char) * SubFrameLen);
pos += SubFrameLen;
}
@@ -278,7 +291,9 @@ static int writeData(void* _call)
//increment err... subframe count?
lpcm_prv[1] = ((lpcm_prv[1] + SubFramesPerPES) & 0x1F);
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len + iov[2].iov_len, PCM_PES_START_CODE, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, iov[1].iov_len + iov[2].iov_len,
PCM_PES_START_CODE, call->Pts, 0);
int len = writev(call->fd, iov, 3);
if (len < 0)
break;

View File

@@ -86,7 +86,8 @@ int InsertVideoPrivateDataHeader(unsigned char *data, int payload_size)
}
int InsertPesHeader (unsigned char *data, int size, unsigned char stream_id, unsigned long long int pts, int pic_start_code)
int InsertPesHeader(unsigned char *data, int size, unsigned char stream_id,
unsigned long long int pts, int pic_start_code)
{
BitPacker_t ld2 = { data, 0, 32 };
@@ -127,8 +128,7 @@ int InsertPesHeader (unsigned char *data, int size, unsigned char stream_id, uns
PutBits(&ld2, 0x0, 8); // PES_header_data_length
//9 = 8+1
if (pts!=INVALID_PTS_VALUE)
{
if (pts != INVALID_PTS_VALUE) {
PutBits(&ld2, 0x2, 4);
PutBits(&ld2, (pts >> 30) & 0x7, 3);
PutBits(&ld2, 0x1, 1);
@@ -139,8 +139,7 @@ int InsertPesHeader (unsigned char *data, int size, unsigned char stream_id, uns
}
//14 = 9+5
if (pic_start_code)
{
if (pic_start_code) {
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x1, 8); // Start Code

View File

@@ -85,11 +85,11 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
/* Types */
/* ***************************** */
static const unsigned char SequenceLayerStartCode[] = {0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE};
static const unsigned char SequenceLayerStartCode[] =
{ 0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE };
static const unsigned char Metadata[] =
{
static const unsigned char Metadata[] = {
0x00, 0x00, 0x00, 0xc5,
0x04, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile */
@@ -168,7 +168,8 @@ static int writeData(void* _call)
PesPtr = PesPayload;
memcpy (PesPtr, SequenceLayerStartCode, sizeof(SequenceLayerStartCode));
memcpy(PesPtr, SequenceLayerStartCode,
sizeof(SequenceLayerStartCode));
PesPtr += sizeof(SequenceLayerStartCode);
memcpy(PesPtr, Metadata, sizeof(Metadata));
@@ -195,14 +196,20 @@ static int writeData(void* _call)
iov[0].iov_base = PesHeader;
iov[1].iov_base = PesPayload;
iov[1].iov_len = PesPtr - PesPayload;
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, iov[1].iov_len,
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
0);
len = writev(call->fd, iov, 2);
/* For VC1 the codec private data is a standard vc1 sequence header so we just copy it to the output */
iov[0].iov_base = PesHeader;
iov[1].iov_base = call->private_data;
iov[1].iov_len = call->private_size;
iov[0].iov_len = InsertPesHeader (PesHeader, iov[1].iov_len, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, iov[1].iov_len,
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
0);
len = writev(call->fd, iov, 2);
initialHeader = 0;
@@ -214,18 +221,24 @@ static int writeData(void* _call)
while (Position < call->len) {
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
(call->len - Position) : MAX_PES_PACKET_SIZE;
int PacketLength =
(call->len - Position) <=
MAX_PES_PACKET_SIZE ? (call->len -
Position) : MAX_PES_PACKET_SIZE;
int Remaining = call->len - Position - PacketLength;
vc1_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
vc1_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
PacketLength, Remaining, Position);
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
int HeaderLength = InsertPesHeader (PesHeader, PacketLength, VC1_VIDEO_PES_START_CODE, call->Pts, 0);
int HeaderLength =
InsertPesHeader(PesHeader, PacketLength,
VC1_VIDEO_PES_START_CODE, call->Pts, 0);
if (insertSampleHeader) {
const unsigned char Vc1FrameStartCode[] = {0, 0, 1, VC1_FRAME_START_CODE};
const unsigned char Vc1FrameStartCode[] =
{ 0, 0, 1, VC1_FRAME_START_CODE };
/*
vc1_printf(10, "Data Start: {00 00 01 0d} - ");
@@ -234,11 +247,12 @@ static int writeData(void* _call)
vc1_printf(10, "\n");
*/
if (!FrameHeaderSeen && (call->len > 3) && (memcmp (call->data, Vc1FrameStartCode, 4) == 0))
if (!FrameHeaderSeen && (call->len > 3)
&& (memcmp(call->data, Vc1FrameStartCode, 4) == 0))
FrameHeaderSeen = 1;
if (!FrameHeaderSeen)
{
memcpy (&PesHeader[HeaderLength], Vc1FrameStartCode, sizeof(Vc1FrameStartCode));
if (!FrameHeaderSeen) {
memcpy(&PesHeader[HeaderLength], Vc1FrameStartCode,
sizeof(Vc1FrameStartCode));
HeaderLength += sizeof(Vc1FrameStartCode);
}
insertSampleHeader = 0;

View File

@@ -101,22 +101,19 @@ static int writeData(void* _call)
wma_printf(10, "\n");
if (call == NULL)
{
if (call == NULL) {
wma_err("call data is NULL...\n");
return 0;
}
wma_printf(10, "AudioPts %lld\n", call->Pts);
if ((call->data == NULL) || (call->len <= 0))
{
if ((call->data == NULL) || (call->len <= 0)) {
wma_err("parsing NULL Data. ignoring...\n");
return 0;
}
if (call->fd < 0)
{
if (call->fd < 0) {
wma_err("file pointer < 0. ignoring ...\n");
return 0;
}
@@ -125,8 +122,7 @@ static int writeData(void* _call)
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
if ((call->private_size <= 0) || (call->private_data == NULL))
{
if ((call->private_size <= 0) || (call->private_data == NULL)) {
wma_err("private NULL.\n");
return -1;
}
@@ -134,7 +130,9 @@ static int writeData(void* _call)
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->private_size, MPEG_AUDIO_PES_START_CODE, 0, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->private_size,
MPEG_AUDIO_PES_START_CODE, 0, 0);
iov[1].iov_base = call->private_data;
iov[1].iov_len = call->private_size;
@@ -143,14 +141,15 @@ static int writeData(void* _call)
initialHeader = 0;
}
if (len > -1 && call->len > 0 && call->data)
{
if (len > -1 && call->len > 0 && call->data) {
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
iov[0].iov_len =
InsertPesHeader(PesHeader, call->len,
MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;

View File

@@ -81,16 +81,14 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
/* Types */
/* ***************************** */
typedef struct
{
typedef struct {
unsigned char privateData[WMV3_PRIVATE_DATA_LENGTH];
unsigned int width;
unsigned int height;
unsigned int framerate;
} awmv_t;
static const unsigned char Metadata[] =
{
static const unsigned char Metadata[] = {
0x00, 0x00, 0x00, 0xc5,
0x04, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x00, 0x00, /* Struct C set for for advanced profile */
@@ -148,7 +146,9 @@ static int writeData(void* _call)
wmv_printf(10, "Got Private Size %d\n", call->private_size);
memcpy(private_data.privateData, call->private_data,
call->private_size>WMV3_PRIVATE_DATA_LENGTH?WMV3_PRIVATE_DATA_LENGTH:call->private_size);
call->private_size >
WMV3_PRIVATE_DATA_LENGTH ? WMV3_PRIVATE_DATA_LENGTH : call->
private_size);
private_data.width = call->Width;
private_data.height = call->Height;
@@ -195,7 +195,10 @@ static int writeData(void* _call)
MetadataLength = PesPtr - &PesPacket[PES_MIN_HEADER_SIZE];
int HeaderLength = InsertPesHeader (PesPacket, MetadataLength, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
int HeaderLength =
InsertPesHeader(PesPacket, MetadataLength,
VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE,
0);
len = write(call->fd, PesPacket, HeaderLength + MetadataLength);
@@ -207,30 +210,38 @@ static int writeData(void* _call)
unsigned char insertSampleHeader = 1;
while (Position < call->len) {
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
(call->len - Position) : MAX_PES_PACKET_SIZE;
int PacketLength =
(call->len - Position) <=
MAX_PES_PACKET_SIZE ? (call->len -
Position) : MAX_PES_PACKET_SIZE;
int Remaining = call->len - Position - PacketLength;
wmv_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
wmv_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n",
PacketLength, Remaining, Position);
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
memset(PesHeader, '0', PES_MAX_HEADER_SIZE);
int HeaderLength = InsertPesHeader (PesHeader, PacketLength, VC1_VIDEO_PES_START_CODE, call->Pts, 0);
int HeaderLength =
InsertPesHeader(PesHeader, PacketLength,
VC1_VIDEO_PES_START_CODE, call->Pts, 0);
unsigned char *PacketStart;
if (insertSampleHeader) {
unsigned int PesLength;
unsigned int PrivateHeaderLength;
PrivateHeaderLength = InsertVideoPrivateDataHeader (&PesHeader[HeaderLength],
PrivateHeaderLength =
InsertVideoPrivateDataHeader(&PesHeader[HeaderLength],
call->len);
/* Update PesLength */
PesLength = PesHeader[PES_LENGTH_BYTE_0] +
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
(PesHeader[PES_LENGTH_BYTE_1] << 8) +
PrivateHeaderLength;
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] += PrivateHeaderLength;
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] +=
PrivateHeaderLength;
PesHeader[PES_FLAGS_BYTE] |= PES_EXTENSION_DATA_PRESENT;
HeaderLength += PrivateHeaderLength;
@@ -239,9 +250,11 @@ static int writeData(void* _call)
PacketStart = malloc(call->len + HeaderLength);
memcpy(PacketStart, PesHeader, HeaderLength);
memcpy (PacketStart + HeaderLength, call->data + Position, PacketLength);
memcpy(PacketStart + HeaderLength, call->data + Position,
PacketLength);
len = write(call->fd, PacketStart, PacketLength + HeaderLength);
len =
write(call->fd, PacketStart, PacketLength + HeaderLength);
free(PacketStart);
Position += PacketLength;

View File

@@ -97,16 +97,17 @@ Writer_t* getWriter(char* encoding)
{
int i;
for (i = 0; AvailableWriter[i] != NULL; i++)
{
if (strcmp(AvailableWriter[i]->caps->textEncoding, encoding) == 0)
{
writer_printf(50, "%s: found writer \"%s\" for \"%s\"\n", __func__, AvailableWriter[i]->caps->name, encoding);
for (i = 0; AvailableWriter[i] != NULL; i++) {
if (strcmp(AvailableWriter[i]->caps->textEncoding, encoding) == 0) {
writer_printf(50, "%s: found writer \"%s\" for \"%s\"\n",
__func__, AvailableWriter[i]->caps->name,
encoding);
return AvailableWriter[i];
}
}
writer_printf(1, "%s: no writer found for \"%s\"\n", __func__, encoding);
writer_printf(1, "%s: no writer found for \"%s\"\n", __func__,
encoding);
return NULL;
}
@@ -115,11 +116,10 @@ Writer_t* getDefaultVideoWriter()
{
int i;
for (i = 0; AvailableWriter[i] != NULL; i++)
{
if (strcmp(AvailableWriter[i]->caps->textEncoding, "V_MPEG2") == 0)
{
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
for (i = 0; AvailableWriter[i] != NULL; i++) {
if (strcmp(AvailableWriter[i]->caps->textEncoding, "V_MPEG2") == 0) {
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
AvailableWriter[i]->caps->name);
return AvailableWriter[i];
}
}
@@ -133,11 +133,10 @@ Writer_t* getDefaultAudioWriter()
{
int i;
for (i = 0; AvailableWriter[i] != NULL; i++)
{
if (strcmp(AvailableWriter[i]->caps->textEncoding, "A_MP3") == 0)
{
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
for (i = 0; AvailableWriter[i] != NULL; i++) {
if (strcmp(AvailableWriter[i]->caps->textEncoding, "A_MP3") == 0) {
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
AvailableWriter[i]->caps->name);
return AvailableWriter[i];
}
}
@@ -151,12 +150,12 @@ Writer_t* getDefaultFramebufferWriter()
{
int i;
for (i = 0; AvailableWriter[i] != NULL; i++)
{
for (i = 0; AvailableWriter[i] != NULL; i++) {
writer_printf(10, "%s\n", AvailableWriter[i]->caps->textEncoding);
if (strcmp(AvailableWriter[i]->caps->textEncoding, "framebuffer") == 0)
{
writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name);
if (strcmp(AvailableWriter[i]->caps->textEncoding, "framebuffer")
== 0) {
writer_printf(50, "%s: found writer \"%s\"\n", __func__,
AvailableWriter[i]->caps->name);
return AvailableWriter[i];
}
}

View File

@@ -71,7 +71,8 @@ static int PlaybackTerminate(Context_t *context);
/* Supervisor Thread */
/* **************************** */
static void SupervisorThread(Context_t *context) {
static void SupervisorThread(Context_t * context)
{
int status = 0, lastStatus = 0;
long long int playPts = -1;
long long int lastPts = -1;
@@ -80,27 +81,32 @@ static void SupervisorThread(Context_t *context) {
playback_printf(10, ">\n");
while ( context && context->playback && context->playback->isPlaying )
{
while (context && context->playback && context->playback->isPlaying) {
if (context->container->selectedContainer != NULL)
context->container->selectedContainer->Command(context, CONTAINER_STATUS, &status);
context->container->selectedContainer->Command(context,
CONTAINER_STATUS,
&status);
else
dieNow = 1;
if (context->container->selectedContainer != NULL)
context->container->selectedContainer->Command(context, CONTAINER_LAST_PTS, &lastPts);
context->container->selectedContainer->Command(context,
CONTAINER_LAST_PTS,
&lastPts);
#ifdef FRAMECOUNT_WORKS
// This is a good place to implement buffer managment
long long int frameCount = -1;
int ret = context->playback->Command(context, PLAYBACK_GET_FRAME_COUNT, &frameCount);
int ret =
context->playback->Command(context, PLAYBACK_GET_FRAME_COUNT,
&frameCount);
playback_printf(1, "Framecount = %ull\n", frameCount);
status = 1;
#endif
if ((status == 0) && (status != lastStatus))
{
playback_printf(1, "container has ended, syncing to playback pts ...\n");
if ((status == 0) && (status != lastStatus)) {
playback_printf(1,
"container has ended, syncing to playback pts ...\n");
#define FLUSH_AFTER_CONTAINER_ENDED
#ifdef FLUSH_AFTER_CONTAINER_ENDED
@@ -108,36 +114,37 @@ status = 1;
// As this is a thread, the call should block the thread as long as frames are beeing played.
// The main thread should not be blocked by this.
// This also helps for files which dont have any pts at all
if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0)
{
if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0) {
playback_err("failed to flush output.\n");
}
#endif
while (!dieNow)
{
if (context && context->playback && context->playback->abortRequested)
while (!dieNow) {
if (context && context->playback
&& context->playback->abortRequested)
dieNow = 1;
else if (context && context->playback && context->playback->isPlaying)
{
int ret = context->playback->Command(context, PLAYBACK_PTS, &playPts);
else if (context && context->playback
&& context->playback->isPlaying) {
int ret =
context->playback->Command(context, PLAYBACK_PTS,
&playPts);
playback_err("playbackPts %lld ->lastPts %lld ret %d\n", playPts, lastPts, ret);
playback_err
("playbackPts %lld ->lastPts %lld ret %d\n",
playPts, lastPts, ret);
if (ret != cERR_PLAYBACK_NO_ERROR || playPts + (2 * 90000) >= lastPts)
if (ret != cERR_PLAYBACK_NO_ERROR
|| playPts + (2 * 90000) >= lastPts)
dieNow = 1;
}
else
{
} else {
playback_err("playback already died ?\n");
dieNow = 1;
}
count++;
if (count == 200)
{
if (count == 200) {
// playback_err("something went wrong, expect end but never reached?\n");
dieNow = 1;
}
@@ -168,7 +175,8 @@ status = 1;
static int PlaybackStop(Context_t * context);
static int PlaybackOpen(Context_t *context, char * uri) {
static int PlaybackOpen(Context_t * context, char *uri)
{
if (context->playback->isPlaying)
PlaybackStop(context);
@@ -200,13 +208,23 @@ static int PlaybackOpen(Context_t *context, char * uri) {
//CHECK FOR SUBTITLES
if (context->container && context->container->textSrtContainer)
context->container->textSrtContainer->Command(context, CONTAINER_INIT, context->playback->uri+7);
context->container->textSrtContainer->Command(context,
CONTAINER_INIT,
context->
playback->uri +
7);
if (context->container && context->container->textSsaContainer)
context->container->textSsaContainer->Command(context, CONTAINER_INIT, context->playback->uri+7);
context->container->textSsaContainer->Command(context,
CONTAINER_INIT,
context->
playback->uri +
7);
if (context->container && context->container->assContainer)
context->container->assContainer->Command(context, CONTAINER_INIT, NULL);
context->container->assContainer->Command(context,
CONTAINER_INIT,
NULL);
} else if (strstr(uri, "://")) {
context->playback->isHttp = 1;
@@ -224,9 +242,11 @@ static int PlaybackOpen(Context_t *context, char * uri) {
return cERR_PLAYBACK_ERROR;
}
if ((context->container->Command(context, CONTAINER_ADD, extension) < 0)
if ((context->container->Command(context, CONTAINER_ADD, extension) <
0)
|| (!context->container->selectedContainer)
|| (context->container->selectedContainer->Command(context, CONTAINER_INIT, context->playback->uri) < 0))
|| (context->container->selectedContainer->
Command(context, CONTAINER_INIT, context->playback->uri) < 0))
return cERR_PLAYBACK_ERROR;
playback_printf(10, "exiting with value 0\n");
@@ -234,21 +254,23 @@ static int PlaybackOpen(Context_t *context, char * uri) {
return cERR_PLAYBACK_NO_ERROR;
}
static int PlaybackClose(Context_t *context) {
static int PlaybackClose(Context_t * context)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
if (context->container->Command(context, CONTAINER_DEL, NULL) < 0)
{
if (context->container->Command(context, CONTAINER_DEL, NULL) < 0) {
playback_err("container delete failed\n");
}
if (context->container && context->container->textSrtContainer)
context->container->textSrtContainer->Command(context, CONTAINER_DEL, NULL);
context->container->textSrtContainer->Command(context,
CONTAINER_DEL, NULL);
if (context->container && context->container->textSsaContainer)
context->container->textSsaContainer->Command(context, CONTAINER_DEL, NULL);
context->container->textSsaContainer->Command(context,
CONTAINER_DEL, NULL);
context->manager->audio->Command(context, MANAGER_DEL, NULL);
context->manager->video->Command(context, MANAGER_DEL, NULL);
@@ -272,7 +294,8 @@ static int PlaybackClose(Context_t *context) {
return ret;
}
static int PlaybackPlay(Context_t *context) {
static int PlaybackPlay(Context_t * context)
{
pthread_attr_t attr;
int ret = cERR_PLAYBACK_NO_ERROR;
@@ -304,17 +327,20 @@ static int PlaybackPlay(Context_t *context) {
if (hasThreadStarted == 0) {
int error;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_DETACHED);
if((error = pthread_create(&supervisorThread, &attr, (void *)&SupervisorThread, context)) != 0)
{
playback_printf(10, "Error creating thread, error:%d:%s\n", error,strerror(error));
if ((error =
pthread_create(&supervisorThread, &attr,
(void *) &SupervisorThread,
context)) != 0) {
playback_printf(10,
"Error creating thread, error:%d:%s\n",
error, strerror(error));
hasThreadStarted = 0;
ret = cERR_PLAYBACK_ERROR;
}
else
{
} else {
playback_printf(10, "Created thread\n");
hasThreadStarted = 1;
@@ -325,15 +351,17 @@ static int PlaybackPlay(Context_t *context) {
context->playback->isCreationPhase = 0; // allow thread to go into next state
ret = context->container->selectedContainer->Command(context, CONTAINER_PLAY, NULL);
ret =
context->container->selectedContainer->Command(context,
CONTAINER_PLAY,
NULL);
if (ret != 0) {
playback_err("CONTAINER_PLAY failed!\n");
}
}
} else
{
} else {
playback_err("playback already running\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -343,7 +371,8 @@ static int PlaybackPlay(Context_t *context) {
return ret;
}
static int PlaybackPause(Context_t *context) {
static int PlaybackPause(Context_t * context)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
@@ -364,8 +393,7 @@ static int PlaybackPause(Context_t *context) {
}
context->playback->SlowMotion = 0;
context->playback->Speed = 1;
} else
{
} else {
playback_err("playback not playing or already in pause mode\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -375,13 +403,16 @@ static int PlaybackPause(Context_t *context) {
return ret;
}
static int PlaybackContinue(Context_t *context) {
static int PlaybackContinue(Context_t * context)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
if (context->playback->isPlaying &&
(context->playback->isPaused || context->playback->isForwarding || context->playback->BackWard || context->playback->SlowMotion)) {
(context->playback->isPaused || context->playback->isForwarding
|| context->playback->BackWard
|| context->playback->SlowMotion)) {
if (context->playback->SlowMotion)
context->output->Command(context, OUTPUT_CLEAR, NULL);
@@ -397,8 +428,7 @@ static int PlaybackContinue(Context_t *context) {
}
context->playback->SlowMotion = 0;
context->playback->Speed = 1;
} else
{
} else {
playback_err("continue not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -408,7 +438,8 @@ static int PlaybackContinue(Context_t *context) {
return ret;
}
static int PlaybackStop(Context_t *context) {
static int PlaybackStop(Context_t * context)
{
int ret = cERR_PLAYBACK_NO_ERROR;
int wait_time = 20;
@@ -427,16 +458,19 @@ static int PlaybackStop(Context_t *context) {
context->playback->Speed = 0;
context->output->Command(context, OUTPUT_STOP, NULL);
context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
context->container->selectedContainer->Command(context,
CONTAINER_STOP,
NULL);
} else
{
} else {
playback_err("stop not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
while ((hasThreadStarted != 0) && (--wait_time) > 0) {
playback_printf(10, "Waiting for supervisor thread to terminate itself, will try another %d times\n", wait_time);
playback_printf(10,
"Waiting for supervisor thread to terminate itself, will try another %d times\n",
wait_time);
usleep(100000);
}
@@ -452,7 +486,8 @@ static int PlaybackStop(Context_t *context) {
return ret;
}
static int PlaybackTerminate(Context_t *context) {
static int PlaybackTerminate(Context_t * context)
{
int ret = cERR_PLAYBACK_NO_ERROR;
int wait_time = 20;
@@ -461,12 +496,14 @@ static int PlaybackTerminate(Context_t *context) {
if (context && context->playback && context->playback->isPlaying) {
//First Flush and than delete container, else e2 cant read length of file anymore
if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0)
{
if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0) {
playback_err("failed to flush output.\n");
}
ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
ret =
context->container->selectedContainer->Command(context,
CONTAINER_STOP,
NULL);
context->playback->isPaused = 0;
context->playback->isPlaying = 0;
@@ -475,9 +512,9 @@ static int PlaybackTerminate(Context_t *context) {
context->playback->SlowMotion = 0;
context->playback->Speed = 0;
} else
{
playback_err("%p %p %d\n", context, context->playback, context->playback->isPlaying);
} else {
playback_err("%p %p %d\n", context, context->playback,
context->playback->isPlaying);
/* fixme: konfetti: we should return an error here but this seems to be a condition which
* can happen and is not a real error, which leads to a dead neutrino. should investigate
@@ -486,7 +523,9 @@ static int PlaybackTerminate(Context_t *context) {
}
while ((hasThreadStarted != 0) && (--wait_time) > 0) {
playback_printf(10, "Waiting for supervisor thread to terminate itself, will try another %d times\n", wait_time);
playback_printf(10,
"Waiting for supervisor thread to terminate itself, will try another %d times\n",
wait_time);
usleep(100000);
}
@@ -502,28 +541,32 @@ static int PlaybackTerminate(Context_t *context) {
return ret;
}
static int PlaybackFastForward(Context_t *context, int* speed) {
static int PlaybackFastForward(Context_t * context, int *speed)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "speed %d\n", *speed);
/* Audio only forwarding not supported */
if (context->playback->isVideo && !context->playback->isHttp && !context->playback->BackWard && (!context->playback->isPaused || context->playback->isPlaying)) {
if (context->playback->isVideo && !context->playback->isHttp
&& !context->playback->BackWard && (!context->playback->isPaused
|| context->playback->
isPlaying)) {
if ((*speed <= 0) || (*speed > cMaxSpeed_ff))
{
playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff);
if ((*speed <= 0) || (*speed > cMaxSpeed_ff)) {
playback_err("speed %d out of range (1 - %d) \n", *speed,
cMaxSpeed_ff);
return cERR_PLAYBACK_ERROR;
}
context->playback->isForwarding = 1;
context->playback->Speed = *speed;
playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed);
playback_printf(20, "Speed: %d x {%d}\n", *speed,
context->playback->Speed);
context->output->Command(context, OUTPUT_FASTFORWARD, NULL);
} else
{
} else {
playback_err("fast forward not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -533,44 +576,44 @@ static int PlaybackFastForward(Context_t *context, int* speed) {
return ret;
}
static int PlaybackFastBackward(Context_t *context,int* speed) {
static int PlaybackFastBackward(Context_t * context, int *speed)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "speed = %d\n", *speed);
/* Audio only reverse play not supported */
if (context->playback->isVideo && !context->playback->isForwarding && (!context->playback->isPaused || context->playback->isPlaying)) {
if (context->playback->isVideo && !context->playback->isForwarding
&& (!context->playback->isPaused
|| context->playback->isPlaying)) {
if ((*speed > 0) || (*speed < cMaxSpeed_fr))
{
playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr);
if ((*speed > 0) || (*speed < cMaxSpeed_fr)) {
playback_err("speed %d out of range (0 - %d) \n", *speed,
cMaxSpeed_fr);
return cERR_PLAYBACK_ERROR;
}
if (*speed == 0)
{
if (*speed == 0) {
context->playback->BackWard = 0;
context->playback->Speed = 0; /* reverse end */
} else
{
} else {
context->playback->isSeeking = 1;
context->playback->Speed = *speed;
context->playback->BackWard = 1;
playback_printf(1, "S %d B %d\n", context->playback->Speed, context->playback->BackWard);
playback_printf(1, "S %d B %d\n", context->playback->Speed,
context->playback->BackWard);
}
context->output->Command(context, OUTPUT_CLEAR, NULL);
if (context->output->Command(context, OUTPUT_REVERSE, NULL) < 0)
{
if (context->output->Command(context, OUTPUT_REVERSE, NULL) < 0) {
playback_err("OUTPUT_REVERSE failed\n");
context->playback->BackWard = 0;
context->playback->Speed = 1;
context->playback->isSeeking = 0;
ret = cERR_PLAYBACK_ERROR;
}
} else
{
} else {
playback_err("fast backward not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -583,13 +626,15 @@ static int PlaybackFastBackward(Context_t *context,int* speed) {
return ret;
}
static int PlaybackSlowMotion(Context_t *context,int* speed) {
static int PlaybackSlowMotion(Context_t * context, int *speed)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
//Audio only forwarding not supported
if (context->playback->isVideo && !context->playback->isHttp && context->playback->isPlaying) {
if (context->playback->isVideo && !context->playback->isHttp
&& context->playback->isPlaying) {
if (context->playback->isPaused)
PlaybackContinue(context);
@@ -605,11 +650,11 @@ static int PlaybackSlowMotion(Context_t *context,int* speed) {
break;
}
playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion);
playback_printf(20, "SlowMotion: %d x {%d}\n", *speed,
context->playback->SlowMotion);
context->output->Command(context, OUTPUT_SLOWMOTION, NULL);
} else
{
} else {
playback_err("slowmotion not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -619,25 +664,31 @@ static int PlaybackSlowMotion(Context_t *context,int* speed) {
return ret;
}
static int PlaybackSeek(Context_t *context, float * pos, int absolute) {
static int PlaybackSeek(Context_t * context, float *pos, int absolute)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "pos: %f\n", *pos);
if (context->playback->isPlaying && !context->playback->isForwarding && !context->playback->BackWard && !context->playback->SlowMotion && !context->playback->isPaused) {
if (context->playback->isPlaying && !context->playback->isForwarding
&& !context->playback->BackWard && !context->playback->SlowMotion
&& !context->playback->isPaused) {
context->playback->isSeeking = 1;
context->output->Command(context, OUTPUT_CLEAR, NULL);
if (absolute)
context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, pos);
context->container->selectedContainer->Command(context,
CONTAINER_SEEK_ABS,
pos);
else
context->container->selectedContainer->Command(context, CONTAINER_SEEK, pos);
context->container->selectedContainer->Command(context,
CONTAINER_SEEK,
pos);
context->playback->isSeeking = 0;
} else
{
} else {
playback_err("not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -647,7 +698,8 @@ static int PlaybackSeek(Context_t *context, float * pos, int absolute) {
return ret;
}
static int PlaybackPts(Context_t *context, unsigned long long int* pts) {
static int PlaybackPts(Context_t * context, unsigned long long int *pts)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(20, "\n");
@@ -656,8 +708,7 @@ static int PlaybackPts(Context_t *context, unsigned long long int* pts) {
if (context->playback->isPlaying) {
ret = context->output->Command(context, OUTPUT_PTS, pts);
} else
{
} else {
playback_err("not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -667,7 +718,9 @@ static int PlaybackPts(Context_t *context, unsigned long long int* pts) {
return ret;
}
static int PlaybackGetFrameCount(Context_t *context, unsigned long long int* frameCount) {
static int PlaybackGetFrameCount(Context_t * context,
unsigned long long int *frameCount)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(20, "\n");
@@ -675,9 +728,10 @@ static int PlaybackGetFrameCount(Context_t *context, unsigned long long int* fr
*frameCount = 0;
if (context->playback->isPlaying) {
ret = context->output->Command(context, OUTPUT_GET_FRAME_COUNT, frameCount);
} else
{
ret =
context->output->Command(context, OUTPUT_GET_FRAME_COUNT,
frameCount);
} else {
playback_err("not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -687,7 +741,8 @@ static int PlaybackGetFrameCount(Context_t *context, unsigned long long int* fr
return ret;
}
static int PlaybackLength(Context_t *context, double* length) {
static int PlaybackLength(Context_t * context, double *length)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(20, "\n");
@@ -696,9 +751,10 @@ static int PlaybackLength(Context_t *context, double* length) {
if (context->playback->isPlaying) {
if (context->container && context->container->selectedContainer)
context->container->selectedContainer->Command(context, CONTAINER_LENGTH, length);
} else
{
context->container->selectedContainer->Command(context,
CONTAINER_LENGTH,
length);
} else {
playback_err("not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -708,7 +764,8 @@ static int PlaybackLength(Context_t *context, double* length) {
return ret;
}
static int PlaybackSwitchAudio(Context_t *context, int* track) {
static int PlaybackSwitchAudio(Context_t * context, int *track)
{
int ret = cERR_PLAYBACK_NO_ERROR;
int curtrackid = 0;
int nextrackid = 0;
@@ -717,9 +774,11 @@ static int PlaybackSwitchAudio(Context_t *context, int* track) {
if (context->playback->isPlaying) {
if (context->manager && context->manager->audio) {
context->manager->audio->Command(context, MANAGER_GET, &curtrackid);
context->manager->audio->Command(context, MANAGER_GET,
&curtrackid);
context->manager->audio->Command(context, MANAGER_SET, track);
context->manager->audio->Command(context, MANAGER_GET, &nextrackid);
context->manager->audio->Command(context, MANAGER_GET,
&nextrackid);
}
if (nextrackid != curtrackid) {
@@ -727,15 +786,18 @@ static int PlaybackSwitchAudio(Context_t *context, int* track) {
//PlaybackPause(context);
if (context->output && context->output->audio)
context->output->audio->Command(context, OUTPUT_SWITCH, (void*)"audio");
context->output->audio->Command(context, OUTPUT_SWITCH,
(void *) "audio");
if (context->container && context->container->selectedContainer)
context->container->selectedContainer->Command(context, CONTAINER_SWITCH_AUDIO, &nextrackid);
if (context->container
&& context->container->selectedContainer)
context->container->selectedContainer->Command(context,
CONTAINER_SWITCH_AUDIO,
&nextrackid);
//PlaybackContinue(context);
}
} else
{
} else {
playback_err("switch audio not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -745,7 +807,8 @@ static int PlaybackSwitchAudio(Context_t *context, int* track) {
return ret;
}
static int PlaybackSwitchSubtitle(Context_t *context, int* track) {
static int PlaybackSwitchSubtitle(Context_t * context, int *track)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "Track: %d\n", *track);
@@ -754,51 +817,68 @@ static int PlaybackSwitchSubtitle(Context_t *context, int* track) {
if (context->manager && context->manager->subtitle) {
int trackid;
if (context->manager->subtitle->Command(context, MANAGER_SET, track) < 0)
{
if (context->manager->subtitle->
Command(context, MANAGER_SET, track) < 0) {
playback_err("manager set track failed\n");
}
#if 0
if (*track < 0) {
//CHECK FOR SUBTITLES
if (context->container && context->container->textSrtContainer)
context->container->textSrtContainer->Command(context, CONTAINER_INIT, context->playback->uri+7);
if (context->container
&& context->container->textSrtContainer)
context->container->textSrtContainer->Command(context,
CONTAINER_INIT,
context->
playback->
uri + 7);
if (context->container && context->container->textSsaContainer)
context->container->textSsaContainer->Command(context, CONTAINER_INIT, context->playback->uri+7);
if (context->container
&& context->container->textSsaContainer)
context->container->textSsaContainer->Command(context,
CONTAINER_INIT,
context->
playback->
uri + 7);
if (context->container && context->container->assContainer)
context->container->assContainer->Command(context, CONTAINER_INIT, NULL);
context->container->assContainer->Command(context,
CONTAINER_INIT,
NULL);
}
#endif
context->manager->subtitle->Command(context, MANAGER_GET, &trackid);
context->manager->subtitle->Command(context, MANAGER_GET,
&trackid);
/* konfetti: I make this hack a little bit nicer,
* but its still a hack in my opinion ;)
*/
if (context->container && context->container->assContainer)
context->container->assContainer->Command(context, CONTAINER_SWITCH_SUBTITLE, &trackid);
context->container->assContainer->Command(context,
CONTAINER_SWITCH_SUBTITLE,
&trackid);
if (trackid >= TEXTSRTOFFSET)
{
if (context->container && context->container->textSrtContainer)
context->container->textSrtContainer->Command(context, CONTAINER_SWITCH_SUBTITLE, &trackid);
if (trackid >= TEXTSRTOFFSET) {
if (context->container
&& context->container->textSrtContainer)
context->container->textSrtContainer->Command(context,
CONTAINER_SWITCH_SUBTITLE,
&trackid);
}
if (trackid >= TEXTSSAOFFSET)
{
if (context->container && context->container->textSsaContainer)
context->container->textSsaContainer->Command(context, CONTAINER_SWITCH_SUBTITLE, &trackid);
if (trackid >= TEXTSSAOFFSET) {
if (context->container
&& context->container->textSsaContainer)
context->container->textSsaContainer->Command(context,
CONTAINER_SWITCH_SUBTITLE,
&trackid);
}
} else
{
} else {
ret = cERR_PLAYBACK_ERROR;
playback_err("no subtitle\n");
}
} else
{
} else {
playback_err("not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -808,13 +888,16 @@ static int PlaybackSwitchSubtitle(Context_t *context, int* track) {
return ret;
}
static int PlaybackSwitchDVBSubtitle(Context_t *context, int* pid) {
static int PlaybackSwitchDVBSubtitle(Context_t * context, int *pid)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "Track: %d\n", *pid);
if (context && context->manager && context->manager->dvbsubtitle) {
if (context->manager->dvbsubtitle->Command(context, *pid < 0 ? MANAGER_DEL : MANAGER_SET, pid) < 0) {
if (context->manager->dvbsubtitle->
Command(context, *pid < 0 ? MANAGER_DEL : MANAGER_SET,
pid) < 0) {
playback_err("dvbsub manager set track failed\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -829,13 +912,15 @@ static int PlaybackSwitchDVBSubtitle(Context_t *context, int* pid) {
return ret;
}
static int PlaybackSwitchTeletext(Context_t *context, int* pid) {
static int PlaybackSwitchTeletext(Context_t * context, int *pid)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "Track: %d\n", *pid);
if (context && context->manager && context->manager->teletext) {
if (context->manager->teletext->Command(context, *pid < 0 ? MANAGER_DEL : MANAGER_SET, pid)) {
if (context->manager->teletext->
Command(context, *pid < 0 ? MANAGER_DEL : MANAGER_SET, pid)) {
playback_err("ttxsub manager set track failed\n");
ret = cERR_PLAYBACK_ERROR;
}
@@ -850,7 +935,8 @@ static int PlaybackSwitchTeletext(Context_t *context, int* pid) {
return ret;
}
static int PlaybackInfo(Context_t *context, char** infoString) {
static int PlaybackInfo(Context_t * context, char **infoString)
{
int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
@@ -862,14 +948,17 @@ static int PlaybackInfo(Context_t *context, char** infoString) {
*/
if (context->container && context->container->selectedContainer)
context->container->selectedContainer->Command(context, CONTAINER_INFO, infoString);
context->container->selectedContainer->Command(context,
CONTAINER_INFO,
infoString);
playback_printf(10, "exiting with value %d\n", ret);
return ret;
}
static int Command(void* _context, PlaybackCmd_t command, void * argument) {
static int Command(void *_context, PlaybackCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context; /* to satisfy compiler */
int ret = cERR_PLAYBACK_NO_ERROR;
@@ -918,7 +1007,8 @@ static int Command(void* _context, PlaybackCmd_t command, void * argument) {
break;
}
case PLAYBACK_PTS:{ // 10
ret = PlaybackPts(context, (unsigned long long int*)argument);
ret =
PlaybackPts(context, (unsigned long long int *) argument);
break;
}
case PLAYBACK_LENGTH:{ // 11
@@ -945,8 +1035,11 @@ static int Command(void* _context, PlaybackCmd_t command, void * argument) {
ret = PlaybackFastBackward(context, (int *) argument);
break;
}
case PLAYBACK_GET_FRAME_COUNT: { // 10
ret = PlaybackGetFrameCount(context, (unsigned long long int*)argument);
case PLAYBACK_GET_FRAME_COUNT:{
// 10
ret =
PlaybackGetFrameCount(context,
(unsigned long long int *) argument);
break;
}
case PLAYBACK_SWITCH_DVBSUBTITLE:{

View File

@@ -49,7 +49,8 @@ static int xRes = 0;
static int yRes = 0;
static int bpp = 0;
int kbhit(void) {
int kbhit(void)
{
struct timeval tv;
fd_set read_fd;
@@ -74,14 +75,12 @@ void framebuffer_init()
fd = open("/dev/fb0", O_RDWR);
if (fd < 0)
{
if (fd < 0) {
perror("/dev/fb0");
return;
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo) < 0)
{
if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo) < 0) {
perror("FBIOGET_VSCREENINFO");
return;
}
@@ -90,10 +89,10 @@ void framebuffer_init()
ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo);
printf("mode %d, %d, %d\n", screeninfo.xres, screeninfo.yres, screeninfo.bits_per_pixel);
printf("mode %d, %d, %d\n", screeninfo.xres, screeninfo.yres,
screeninfo.bits_per_pixel);
if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0)
{
if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0) {
perror("FBIOGET_FSCREENINFO");
printf("fb failed\n");
}
@@ -109,10 +108,11 @@ void framebuffer_init()
printf("%dk video mem\n", available / 1024);
lfb = (unsigned char*) mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
lfb =
(unsigned char *) mmap(0, available, PROT_WRITE | PROT_READ,
MAP_SHARED, fd, 0);
if (lfb == NULL)
{
if (lfb == NULL) {
perror("mmap");
return;
}
@@ -121,29 +121,27 @@ void framebuffer_init()
}
int main(int argc,char* argv[]) {
int main(int argc, char *argv[])
{
SubtitleOutputDef_t out;
int showInfos = 0, noinput = 0;
char file[255] = { "" };
int speed = 0, speedmap = 0;
printf("%s >\n", __FILE__);
if (argc < 2)
{
if (argc < 2) {
printf("give me a filename please\n");
exit(1);
}
if (strstr(argv[1], "://") == NULL)
{
if (strstr(argv[1], "://") == NULL) {
strcpy(file, "file://");
}
strcat(file, argv[1]);
/* debug helper */
if(argc == 3 && !strcmp(argv[2], "-d"))
{
if (argc == 3 && !strcmp(argv[2], "-d")) {
showInfos = 1;
}
@@ -172,7 +170,10 @@ int main(int argc,char* argv[]) {
out.destination = (uint32_t *) lfb;
out.destStride = stride;
player->output->subtitle->Command(player, (OutputCmd_t)OUTPUT_SET_SUBTITLE_OUTPUT, (void*) &out);
player->output->subtitle->Command(player,
(OutputCmd_t)
OUTPUT_SET_SUBTITLE_OUTPUT,
(void *) &out);
if (player->playback->Command(player, PLAYBACK_OPEN, file) < 0)
return 10;
@@ -203,7 +204,8 @@ int main(int argc,char* argv[]) {
free(TrackList);
}
player->manager->subtitle->Command(player, MANAGER_LIST, &TrackList);
player->manager->subtitle->Command(player, MANAGER_LIST,
&TrackList);
if (TrackList != NULL) {
printf("SubtitleTrack List\n");
int i = 0;
@@ -219,28 +221,40 @@ int main(int argc,char* argv[]) {
int AudioTrackId = -1;
char *AudioTrackEncoding = NULL;
char *AudioTrackName = NULL;
player->manager->audio->Command(player, MANAGER_GET, &AudioTrackId);
player->manager->audio->Command(player, MANAGER_GETENCODING, &AudioTrackEncoding);
player->manager->audio->Command(player, MANAGER_GETNAME, &AudioTrackName);
printf("Current Audio Track : %d %s %s\n", AudioTrackId, AudioTrackEncoding, AudioTrackName);
player->manager->audio->Command(player, MANAGER_GET,
&AudioTrackId);
player->manager->audio->Command(player, MANAGER_GETENCODING,
&AudioTrackEncoding);
player->manager->audio->Command(player, MANAGER_GETNAME,
&AudioTrackName);
printf("Current Audio Track : %d %s %s\n", AudioTrackId,
AudioTrackEncoding, AudioTrackName);
free(AudioTrackEncoding);
free(AudioTrackName);
AudioTrackEncoding = NULL;
AudioTrackName = NULL;
player->manager->video->Command(player, MANAGER_GET, &AudioTrackId);
player->manager->video->Command(player, MANAGER_GETENCODING, &AudioTrackEncoding);
player->manager->video->Command(player, MANAGER_GETNAME, &AudioTrackName);
printf("Current Video Track : %d %s %s\n", AudioTrackId, AudioTrackEncoding, AudioTrackName);
player->manager->video->Command(player, MANAGER_GET,
&AudioTrackId);
player->manager->video->Command(player, MANAGER_GETENCODING,
&AudioTrackEncoding);
player->manager->video->Command(player, MANAGER_GETNAME,
&AudioTrackName);
printf("Current Video Track : %d %s %s\n", AudioTrackId,
AudioTrackEncoding, AudioTrackName);
free(AudioTrackEncoding);
free(AudioTrackName);
AudioTrackEncoding = NULL;
AudioTrackName = NULL;
player->manager->subtitle->Command(player, MANAGER_GET, &AudioTrackId);
player->manager->subtitle->Command(player, MANAGER_GETENCODING, &AudioTrackEncoding);
player->manager->subtitle->Command(player, MANAGER_GETNAME, &AudioTrackName);
printf("Current Subtitle Track : %d %s %s\n", AudioTrackId, AudioTrackEncoding, AudioTrackName);
player->manager->subtitle->Command(player, MANAGER_GET,
&AudioTrackId);
player->manager->subtitle->Command(player, MANAGER_GETENCODING,
&AudioTrackEncoding);
player->manager->subtitle->Command(player, MANAGER_GETNAME,
&AudioTrackName);
printf("Current Subtitle Track : %d %s %s\n", AudioTrackId,
AudioTrackEncoding, AudioTrackName);
free(AudioTrackEncoding);
free(AudioTrackName);
AudioTrackEncoding = NULL;
@@ -256,10 +270,8 @@ int main(int argc,char* argv[]) {
{
player->output->Command(player, OUTPUT_OPEN, NULL);
if (showInfos == 1)
{
char *tags[] =
{
if (showInfos == 1) {
char *tags[] = {
"Title",
"Artist",
"Album",
@@ -272,8 +284,7 @@ int main(int argc,char* argv[]) {
NULL
};
int i = 0;
while (tags[i] != NULL)
{
while (tags[i] != NULL) {
char *tag = tags[i];
player->playback->Command(player, PLAYBACK_INFO, &tag);
#if !defined(VDR1722)
@@ -316,12 +327,15 @@ int main(int argc,char* argv[]) {
switch (Key2) {
case 'l':{
char **TrackList = NULL;
player->manager->audio->Command(player, MANAGER_LIST, &TrackList);
player->manager->audio->Command(player,
MANAGER_LIST,
&TrackList);
if (TrackList != NULL) {
printf("AudioTrack List\n");
int i = 0;
for (i = 0; TrackList[i] != NULL; i += 2) {
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
printf("\t%s - %s\n", TrackList[i],
TrackList[i + 1]);
free(TrackList[i]);
free(TrackList[i + 1]);
}
@@ -333,10 +347,18 @@ int main(int argc,char* argv[]) {
int AudioTrackId = -1;
char *AudioTrackEncoding = NULL;
char *AudioTrackName = NULL;
player->manager->audio->Command(player, MANAGER_GET, &AudioTrackId);
player->manager->audio->Command(player, MANAGER_GETENCODING, &AudioTrackEncoding);
player->manager->audio->Command(player, MANAGER_GETNAME, &AudioTrackName);
printf("Current Audio Track : %d %s %s\n", AudioTrackId, AudioTrackEncoding, AudioTrackName);
player->manager->audio->Command(player,
MANAGER_GET,
&AudioTrackId);
player->manager->audio->Command(player,
MANAGER_GETENCODING,
&AudioTrackEncoding);
player->manager->audio->Command(player,
MANAGER_GETNAME,
&AudioTrackName);
printf("Current Audio Track : %d %s %s\n",
AudioTrackId, AudioTrackEncoding,
AudioTrackName);
free(AudioTrackEncoding);
free(AudioTrackName);
AudioTrackEncoding = NULL;
@@ -347,7 +369,9 @@ int main(int argc,char* argv[]) {
default:{
Key2 -= 0x30;
if (Key2 >= 0 && Key2 <= 9) {
player->playback->Command(player, PLAYBACK_SWITCH_AUDIO, (void*)&Key2);
player->playback->Command(player,
PLAYBACK_SWITCH_AUDIO,
(void *) &Key2);
}
}
@@ -360,12 +384,15 @@ int main(int argc,char* argv[]) {
switch (Key2) {
case 'l':{
char **TrackList = NULL;
player->manager->subtitle->Command(player, MANAGER_LIST, &TrackList);
player->manager->subtitle->Command(player,
MANAGER_LIST,
&TrackList);
if (TrackList != NULL) {
printf("SubtitleTrack List\n");
int i = 0;
for (i = 0; TrackList[i] != NULL; i += 2) {
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
printf("\t%s - %s\n", TrackList[i],
TrackList[i + 1]);
free(TrackList[i]);
free(TrackList[i + 1]);
}
@@ -377,10 +404,18 @@ int main(int argc,char* argv[]) {
int SubtitleTrackId = -1;
char *SubtitleTrackEncoding = NULL;
char *SubtitleTrackName = NULL;
player->manager->subtitle->Command(player, MANAGER_GET, &SubtitleTrackId);
player->manager->subtitle->Command(player, MANAGER_GETENCODING, &SubtitleTrackEncoding);
player->manager->subtitle->Command(player, MANAGER_GETNAME, &SubtitleTrackName);
printf("Current Subtitle Track : %d %s %s\n", SubtitleTrackId, SubtitleTrackEncoding, SubtitleTrackName);
player->manager->subtitle->Command(player,
MANAGER_GET,
&SubtitleTrackId);
player->manager->subtitle->Command(player,
MANAGER_GETENCODING,
&SubtitleTrackEncoding);
player->manager->subtitle->Command(player,
MANAGER_GETNAME,
&SubtitleTrackName);
printf("Current Subtitle Track : %d %s %s\n",
SubtitleTrackId, SubtitleTrackEncoding,
SubtitleTrackName);
free(SubtitleTrackEncoding);
free(SubtitleTrackName);
SubtitleTrackEncoding = NULL;
@@ -391,7 +426,9 @@ int main(int argc,char* argv[]) {
default:{
Key2 -= 0x30;
if (Key2 >= 0 && Key2 <= 9) {
player->playback->Command(player, PLAYBACK_SWITCH_SUBTITLE, (void*)&Key2);
player->playback->Command(player,
PLAYBACK_SWITCH_SUBTITLE,
(void *) &Key2);
}
}
@@ -422,18 +459,32 @@ int main(int argc,char* argv[]) {
if (speed > 7)
speed = 1;
switch(speed)
{
case 1: speedmap = 1; break;
case 2: speedmap = 3; break;
case 3: speedmap = 7; break;
case 4: speedmap = 15; break;
case 5: speedmap = 31; break;
case 6: speedmap = 63; break;
case 7: speedmap = 127; break;
switch (speed) {
case 1:
speedmap = 1;
break;
case 2:
speedmap = 3;
break;
case 3:
speedmap = 7;
break;
case 4:
speedmap = 15;
break;
case 5:
speedmap = 31;
break;
case 6:
speedmap = 63;
break;
case 7:
speedmap = 127;
break;
}
player->playback->Command(player, PLAYBACK_FASTFORWARD, &speedmap);
player->playback->Command(player, PLAYBACK_FASTFORWARD,
&speedmap);
break;
}
@@ -446,18 +497,33 @@ int main(int argc,char* argv[]) {
if (speed < -7)
speed = -1;
switch(speed)
{
case -1: speedmap = -5; break;
case -2: speedmap = -10; break;
case -3: speedmap = -20; break;
case -4: speedmap = -40; break;
case -5: speedmap = -80; break;
case -6: speedmap = -160; break;
case -7: speedmap = -320; break;
switch (speed) {
case -1:
speedmap = -5;
break;
case -2:
speedmap = -10;
break;
case -3:
speedmap = -20;
break;
case -4:
speedmap = -40;
break;
case -5:
speedmap = -80;
break;
case -6:
speedmap = -160;
break;
case -7:
speedmap = -320;
break;
}
player->playback->Command(player, PLAYBACK_FASTBACKWARD, &speedmap);
player->playback->Command(player,
PLAYBACK_FASTBACKWARD,
&speedmap);
break;
}
#if defined(VDR1722)
@@ -470,8 +536,10 @@ int main(int argc,char* argv[]) {
float sec;
printf("gotoPos %i\n", gotoPos);
if (player->container && player->container->selectedContainer)
player->container->selectedContainer->Command(player, CONTAINER_LENGTH, &length);
if (player->container
&& player->container->selectedContainer)
player->container->selectedContainer->
Command(player, CONTAINER_LENGTH, &length);
if (gotoPos <= 0) {
printf("kleiner als erlaubt\n");
@@ -484,7 +552,8 @@ int main(int argc,char* argv[]) {
sec = gotoPos;
}
player->playback->Command(player, PLAYBACK_SEEK, (void*)&sec);
player->playback->Command(player, PLAYBACK_SEEK,
(void *) &sec);
printf("goto postion (%i sec)\n", sec);
break;
}
@@ -495,12 +564,24 @@ int main(int argc,char* argv[]) {
float sec = 0.0;
printf("seconds %d \n", Key2);
switch (Key2) {
case 1: sec=-15.0;break;
case 4: sec=-60.0;break;
case 7: sec=-300.0;break;
case 3: sec= 15.0;break;
case 6: sec= 60.0;break;
case 9: sec= 300.0;break;
case 1:
sec = -15.0;
break;
case 4:
sec = -60.0;
break;
case 7:
sec = -300.0;
break;
case 3:
sec = 15.0;
break;
case 6:
sec = 60.0;
break;
case 9:
sec = 300.0;
break;
}
#else
char seek[256];
@@ -510,17 +591,24 @@ int main(int argc,char* argv[]) {
float sec;
unsigned long long int CurrentPTS = 0;
player->playback->Command(player, PLAYBACK_PTS, &CurrentPTS);
if (player->container && player->container->selectedContainer)
player->container->selectedContainer->Command(player, CONTAINER_LENGTH, &length);
player->playback->Command(player, PLAYBACK_PTS,
&CurrentPTS);
if (player->container
&& player->container->selectedContainer)
player->container->selectedContainer->
Command(player, CONTAINER_LENGTH, &length);
int CurrentSec = CurrentPTS / 90000;
printf("CurrentSec = %i, seekTo = %i, abs(seekTo) = %i seekTo + CurrentSec %i\n", CurrentSec, seekTo, abs(seekTo), (seekTo + CurrentSec));
printf
("CurrentSec = %i, seekTo = %i, abs(seekTo) = %i seekTo + CurrentSec %i\n",
CurrentSec, seekTo, abs(seekTo),
(seekTo + CurrentSec));
int ergSec = CurrentSec + seekTo;
if (ergSec < 0) {
printf("kleiner als erlaubt\n");
sec = 0.0;
}else if((CurrentSec + seekTo) >= ((int)length - 10)){
} else if ((CurrentSec + seekTo) >=
((int) length - 10)) {
printf("laenger als erlaubt\n");
sec = (int) length - 10;
} else {
@@ -530,29 +618,36 @@ int main(int argc,char* argv[]) {
printf("springe %i \n", (int) sec);
#endif
player->playback->Command(player, PLAYBACK_SEEK, (void*)&sec);
player->playback->Command(player, PLAYBACK_SEEK,
(void *) &sec);
break;
}
case 'l':{
double length = 0;
if (player->container && player->container->selectedContainer)
player->container->selectedContainer->Command(player, CONTAINER_LENGTH, &length);
printf("Length = %02d:%02d:%02d (%.4f sec)\n", (int)((length/60)/60)%60, (int)(length/60)%60, (int)length%60, length);
if (player->container
&& player->container->selectedContainer)
player->container->selectedContainer->
Command(player, CONTAINER_LENGTH, &length);
printf("Length = %02d:%02d:%02d (%.4f sec)\n",
(int) ((length / 60) / 60) % 60,
(int) (length / 60) % 60, (int) length % 60,
length);
break;
}
case 'j':{
unsigned long long int pts = 0;
player->playback->Command(player, PLAYBACK_PTS, &pts);
unsigned long long int sec = pts / 90000;
printf("Pts = %02d:%02d:%02d (%llu.0000 sec)\n", (int)((sec/60)/60)%60, (int)(sec/60)%60, (int)sec%60, sec);
printf("Pts = %02d:%02d:%02d (%llu.0000 sec)\n",
(int) ((sec / 60) / 60) % 60,
(int) (sec / 60) % 60, (int) sec % 60, sec);
break;
}
case 'i':
{
char *tags[] =
{
char *tags[] = {
"Title",
"Artist",
"Album",
@@ -565,10 +660,10 @@ int main(int argc,char* argv[]) {
NULL
};
int i = 0;
while (tags[i] != NULL)
{
while (tags[i] != NULL) {
char *tag = tags[i];
player->playback->Command(player, PLAYBACK_INFO, &tag);
player->playback->Command(player, PLAYBACK_INFO,
&tag);
if (tag != NULL)
printf("\t%s:\t%s\n", tags[i], tag);
@@ -589,8 +684,10 @@ int main(int argc,char* argv[]) {
printf("q: Stop\n");
printf("c: Continue\n");
printf("p: Pause\n");
printf("f: Increase speed (Fast forward) (stepwise)\n");
printf("b: Decrease speed (Fast reverse) (stepwise)\n");
printf
("f: Increase speed (Fast forward) (stepwise)\n");
printf
("b: Decrease speed (Fast reverse) (stepwise)\n");
printf("l: Print duration\n");
printf("j: Print current PTS\n");
printf("k[1,4,7]: Jump back [15,60,300] seconds\n");

View File

@@ -17,7 +17,9 @@ static AVFormatContext* avContext = NULL;
void dump_metadata()
{
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(avContext->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
while ((tag =
av_dict_get(avContext->metadata, "", tag,
AV_DICT_IGNORE_SUFFIX)))
printf("%s: %s\n", tag->key, tag->value);
}
@@ -28,14 +30,12 @@ int main(int argc,char* argv[])
unsigned int i;
int err;
if (argc < 2)
{
if (argc < 2) {
printf("give me a filename please\n");
return -1;
}
if (strstr(argv[1], "://") == NULL)
{
if (strstr(argv[1], "://") == NULL) {
strcpy(file, "file://");
}
@@ -53,8 +53,7 @@ int main(int argc,char* argv[])
return -1;
}
if (avformat_find_stream_info(avContext, NULL) < 0)
{
if (avformat_find_stream_info(avContext, NULL) < 0) {
printf("Error avformat_find_stream_info\n");
}
@@ -62,15 +61,15 @@ int main(int argc,char* argv[])
dump_metadata();
printf("\nstream specific metadata:\n");
for (i = 0; i < avContext->nb_streams; i++)
{
for (i = 0; i < avContext->nb_streams; i++) {
AVStream *stream = avContext->streams[i];
if (stream)
{
if (stream) {
AVDictionaryEntry *tag = NULL;
if (stream->metadata != NULL)
while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
while ((tag =
av_dict_get(stream->metadata, "", tag,
AV_DICT_IGNORE_SUFFIX)))
printf("%s: %s\n", tag->key, tag->value);
}
}