mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
lib cleanup and sync for mips vu support
This commit is contained in:
380
libeplayer3/manager/audio.c
Normal file
380
libeplayer3/manager/audio.c
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* audio manager handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
#include "manager.h"
|
||||
#include "common.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define TRACKWRAP 20
|
||||
|
||||
/* Error Constants */
|
||||
#define cERR_AUDIO_MGR_NO_ERROR 0
|
||||
#define cERR_AUDIO_MGR_ERROR -1
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
static Track_t *Tracks = NULL;
|
||||
static int TrackCount = 0;
|
||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int ManagerAdd(Context_t *context, Track_t track)
|
||||
{
|
||||
audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", __FILE__, __FUNCTION__, track.Name, track.Encoding, track.Id);
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
Tracks[i].Id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
|
||||
return cERR_AUDIO_MGR_ERROR;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
if (Tracks[i].Id == track.Id)
|
||||
{
|
||||
Tracks[i].pending = 0;
|
||||
if(track.aacbuf){
|
||||
free(track.aacbuf);
|
||||
track.aacbuf = NULL;
|
||||
}
|
||||
return cERR_AUDIO_MGR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TrackCount < TRACKWRAP)
|
||||
{
|
||||
copyTrack(&Tracks[TrackCount], &track);
|
||||
TrackCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
audio_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
|
||||
return cERR_AUDIO_MGR_ERROR;
|
||||
}
|
||||
|
||||
if (TrackCount > 0)
|
||||
{
|
||||
context->playback->isAudio = 1;
|
||||
}
|
||||
|
||||
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
return cERR_AUDIO_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static char **ManagerList(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
char **tracklist = NULL;
|
||||
|
||||
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
||||
|
||||
if (tracklist == NULL)
|
||||
{
|
||||
audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
|
||||
{
|
||||
if (Tracks[i].pending)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t len = strlen(Tracks[i].Name) + 20;
|
||||
char tmp[len];
|
||||
snprintf(tmp, len, "%d %s", Tracks[i].Id, Tracks[i].Name);
|
||||
tracklist[j] = strdup(tmp);
|
||||
tracklist[j + 1] = strdup(Tracks[i].Encoding);
|
||||
}
|
||||
tracklist[j] = NULL;
|
||||
}
|
||||
|
||||
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
|
||||
|
||||
return tracklist;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static TrackDescription_t *ManagerList(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0;
|
||||
TrackDescription_t *tracklist = NULL;
|
||||
|
||||
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
tracklist = malloc(sizeof(TrackDescription_t) * ((TrackCount) + 1));
|
||||
|
||||
if (tracklist == NULL)
|
||||
{
|
||||
audio_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (i = 0; i < TrackCount; ++i)
|
||||
{
|
||||
if (Tracks[i].pending || Tracks[i].Id < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
tracklist[j].Id = Tracks[i].Id;
|
||||
tracklist[j].Name = strdup(Tracks[i].Name);
|
||||
tracklist[j].Encoding = strdup(Tracks[i].Encoding);
|
||||
++j;
|
||||
}
|
||||
|
||||
tracklist[j].Id = -1;
|
||||
}
|
||||
//audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
|
||||
|
||||
return tracklist;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ManagerDel(Context_t *context)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
freeTrack(&Tracks[i]);
|
||||
}
|
||||
|
||||
free(Tracks);
|
||||
Tracks = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
audio_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
|
||||
return cERR_AUDIO_MGR_ERROR;
|
||||
}
|
||||
|
||||
TrackCount = 0;
|
||||
CurrentTrack = 0;
|
||||
context->playback->isAudio = 0;
|
||||
|
||||
audio_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
|
||||
|
||||
return cERR_AUDIO_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||
{
|
||||
int ret = cERR_AUDIO_MGR_NO_ERROR;
|
||||
|
||||
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case MANAGER_ADD:
|
||||
{
|
||||
Track_t *track = argument;
|
||||
ret = ManagerAdd(context, *track);
|
||||
break;
|
||||
}
|
||||
case MANAGER_LIST:
|
||||
{
|
||||
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
|
||||
// *((TrackDescription_t **)argument) = ManagerList(context);
|
||||
*((char ***)argument) = (char **)ManagerList(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_REF_LIST:
|
||||
{
|
||||
*((Track_t **)argument) = Tracks;
|
||||
break;
|
||||
}
|
||||
case MANAGER_REF_LIST_SIZE:
|
||||
{
|
||||
*((int *)argument) = TrackCount;
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET:
|
||||
{
|
||||
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((int *)argument) = (int)Tracks[CurrentTrack].Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((int *)argument) = (int) -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK_DESC:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
TrackDescription_t *track = malloc(sizeof(TrackDescription_t));
|
||||
*((TrackDescription_t **)argument) = track;
|
||||
if (track)
|
||||
{
|
||||
memset(track, 0, sizeof(TrackDescription_t));
|
||||
track->Id = Tracks[CurrentTrack].Id;
|
||||
track->Name = strdup(Tracks[CurrentTrack].Name);
|
||||
track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*((TrackDescription_t **)argument) = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK:
|
||||
{
|
||||
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((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);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((char **)argument) = (char *)strdup("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GETNAME:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((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", __FILE__, __FUNCTION__, *((int *)argument));
|
||||
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
if (Tracks[i].Id == *((int *)argument))
|
||||
{
|
||||
CurrentTrack = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == TrackCount)
|
||||
{
|
||||
audio_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
|
||||
ret = cERR_AUDIO_MGR_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_DEL:
|
||||
{
|
||||
ret = ManagerDel(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_INIT_UPDATE:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
Tracks[i].pending = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", __FILE__, __FUNCTION__, command);
|
||||
ret = cERR_AUDIO_MGR_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
audio_mgr_printf(10, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
struct Manager_s AudioManager =
|
||||
{
|
||||
"Audio",
|
||||
&Command,
|
||||
NULL
|
||||
};
|
237
libeplayer3/manager/chapter.c
Normal file
237
libeplayer3/manager/chapter.c
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* chapter manager handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "manager.h"
|
||||
#include "common.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
#define TRACKWRAP 64
|
||||
|
||||
#define CHAPTER_MGR_DEBUG
|
||||
|
||||
#ifdef CHAPTER_MGR_DEBUG
|
||||
|
||||
static short debug_level = 0;
|
||||
|
||||
#define chapter_mgr_printf(level, x...) do { \
|
||||
if (debug_level >= level) printf(x); } while (0)
|
||||
#else
|
||||
#define chapter_mgr_printf(level, x...)
|
||||
#endif
|
||||
|
||||
#ifndef CHAPTER_MGR_SILENT
|
||||
#define chapter_mgr_err(x...) do { printf(x); } while (0)
|
||||
#else
|
||||
#define chapter_mgr_err(x...)
|
||||
#endif
|
||||
|
||||
/* Error Constants */
|
||||
#define cERR_CHAPTER_MGR_NO_ERROR 0
|
||||
#define cERR_CHAPTER_MGR_ERROR -1
|
||||
|
||||
static const char FILENAME[] = __FILE__;
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
static Track_t *Tracks = NULL;
|
||||
static int TrackCount = 0;
|
||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track)
|
||||
{
|
||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
Tracks[i].Id = -1;
|
||||
}
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
chapter_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
|
||||
return cERR_CHAPTER_MGR_ERROR;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
if (Tracks[i].Id == track.Id)
|
||||
{
|
||||
Tracks[i].pending = 0;
|
||||
return cERR_CHAPTER_MGR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TrackCount < TRACKWRAP)
|
||||
{
|
||||
copyTrack(&Tracks[TrackCount], &track);
|
||||
|
||||
TrackCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
chapter_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
|
||||
return cERR_CHAPTER_MGR_ERROR;
|
||||
}
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
return cERR_CHAPTER_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static char **ManagerList(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
char **tracklist = NULL;
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
|
||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
||||
|
||||
if (tracklist == NULL)
|
||||
{
|
||||
chapter_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
|
||||
{
|
||||
if (Tracks[i].pending)
|
||||
continue;
|
||||
char tmp[20];
|
||||
snprintf(tmp, sizeof(tmp), "%d", (int)Tracks[i].chapter_start);
|
||||
tracklist[j] = strdup(tmp);
|
||||
tracklist[j + 1] = strdup(Tracks[i].Name);
|
||||
}
|
||||
tracklist[j] = NULL;
|
||||
}
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
||||
__FUNCTION__, tracklist, j, TrackCount);
|
||||
|
||||
return tracklist;
|
||||
}
|
||||
|
||||
static int ManagerDel(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
freeTrack(&Tracks[i]);
|
||||
}
|
||||
free(Tracks);
|
||||
Tracks = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
chapter_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
|
||||
return cERR_CHAPTER_MGR_ERROR;
|
||||
}
|
||||
|
||||
TrackCount = 0;
|
||||
CurrentTrack = 0;
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
|
||||
|
||||
return cERR_CHAPTER_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||
{
|
||||
int ret = cERR_CHAPTER_MGR_NO_ERROR;
|
||||
|
||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case MANAGER_ADD:
|
||||
{
|
||||
Track_t *track = argument;
|
||||
ret = ManagerAdd(context, *track);
|
||||
break;
|
||||
}
|
||||
case MANAGER_LIST:
|
||||
{
|
||||
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
|
||||
*((char ***) argument) = (char **) ManagerList(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_DEL:
|
||||
{
|
||||
ret = ManagerDel(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_INIT_UPDATE:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
Tracks[i].pending = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
chapter_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||
ret = cERR_CHAPTER_MGR_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
chapter_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct Manager_s ChapterManager =
|
||||
{
|
||||
"Chapter",
|
||||
&Command,
|
||||
NULL
|
||||
};
|
124
libeplayer3/manager/manager.c
Normal file
124
libeplayer3/manager/manager.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* manager handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "manager.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
extern Manager_t AudioManager;
|
||||
extern Manager_t VideoManager;
|
||||
extern Manager_t SubtitleManager;
|
||||
extern Manager_t ChapterManager;
|
||||
|
||||
ManagerHandler_t ManagerHandler =
|
||||
{
|
||||
"ManagerHandler",
|
||||
&AudioManager,
|
||||
&VideoManager,
|
||||
&SubtitleManager,
|
||||
&ChapterManager
|
||||
};
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
void copyTrack(Track_t *to, Track_t *from)
|
||||
{
|
||||
if (NULL != to && NULL != from)
|
||||
{
|
||||
*to = *from;
|
||||
if (from->Name != NULL)
|
||||
{
|
||||
to->Name = strdup(from->Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
to->Name = strdup("Unknown");
|
||||
}
|
||||
|
||||
if (from->Encoding != NULL)
|
||||
{
|
||||
to->Encoding = strdup(from->Encoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
to->Encoding = strdup("Unknown");
|
||||
}
|
||||
|
||||
if (from->language != NULL)
|
||||
{
|
||||
to->language = strdup(from->language);
|
||||
}
|
||||
else
|
||||
{
|
||||
to->language = strdup("Unknown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void freeTrack(Track_t *track)
|
||||
{
|
||||
if (NULL != track)
|
||||
{
|
||||
if (track->Name != NULL)
|
||||
{
|
||||
free(track->Name);
|
||||
track->Name = NULL;
|
||||
}
|
||||
|
||||
if (track->Encoding != NULL)
|
||||
{
|
||||
free(track->Encoding);
|
||||
track->Encoding = NULL;
|
||||
}
|
||||
|
||||
if (track->language != NULL)
|
||||
{
|
||||
free(track->language);
|
||||
track->language = NULL;
|
||||
}
|
||||
|
||||
if (track->aacbuf != NULL)
|
||||
{
|
||||
free(track->aacbuf);
|
||||
track->aacbuf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
331
libeplayer3/manager/subtitle.c
Normal file
331
libeplayer3/manager/subtitle.c
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* subtitle manager handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "manager.h"
|
||||
#include "common.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define TRACKWRAP 20
|
||||
|
||||
/* Error Constants */
|
||||
#define cERR_SUBTITLE_MGR_NO_ERROR 0
|
||||
#define cERR_SUBTITLE_MGR_ERROR -1
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
static Track_t *Tracks = NULL;
|
||||
static int TrackCount = 0;
|
||||
static int CurrentTrack = -1; //no as default.
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track)
|
||||
{
|
||||
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", __FILE__, __FUNCTION__, track.Name, track.Encoding, track.Id);
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
Tracks[i].Id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
|
||||
return cERR_SUBTITLE_MGR_ERROR;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
if (Tracks[i].Id == track.Id)
|
||||
{
|
||||
Tracks[i].pending = 0;
|
||||
return cERR_SUBTITLE_MGR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TrackCount < TRACKWRAP)
|
||||
{
|
||||
copyTrack(&Tracks[TrackCount], &track);
|
||||
TrackCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitle_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
|
||||
return cERR_SUBTITLE_MGR_ERROR;
|
||||
}
|
||||
|
||||
if (TrackCount > 0)
|
||||
{
|
||||
// context->playback->isSubtitle = 1;
|
||||
}
|
||||
|
||||
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
return cERR_SUBTITLE_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static char **ManagerList(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
char **tracklist = NULL;
|
||||
|
||||
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
||||
|
||||
if (tracklist == NULL)
|
||||
{
|
||||
subtitle_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
|
||||
{
|
||||
if (Tracks[i].pending)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t len = strlen(Tracks[i].Name) + 20;
|
||||
char tmp[len];
|
||||
snprintf(tmp, len, "%d %s", Tracks[i].Id, Tracks[i].Name);
|
||||
tracklist[j] = strdup(tmp);
|
||||
tracklist[j + 1] = strdup(Tracks[i].Encoding);
|
||||
}
|
||||
tracklist[j] = NULL;
|
||||
}
|
||||
|
||||
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
|
||||
|
||||
return tracklist;
|
||||
}
|
||||
|
||||
static int ManagerDel(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
freeTrack(&Tracks[i]);
|
||||
}
|
||||
|
||||
free(Tracks);
|
||||
Tracks = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitle_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
|
||||
return cERR_SUBTITLE_MGR_ERROR;
|
||||
}
|
||||
|
||||
TrackCount = 0;
|
||||
CurrentTrack = -1;
|
||||
// context->playback->isSubtitle = 0;
|
||||
|
||||
subtitle_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
|
||||
|
||||
return cERR_SUBTITLE_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||
{
|
||||
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
|
||||
|
||||
subtitle_mgr_printf(50, "%s::%s %d\n", __FILE__, __FUNCTION__, command);
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case MANAGER_ADD:
|
||||
{
|
||||
Track_t *track = argument;
|
||||
ret = ManagerAdd(context, *track);
|
||||
break;
|
||||
}
|
||||
case MANAGER_LIST:
|
||||
{
|
||||
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
|
||||
*((char ***)argument) = (char **)ManagerList(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET:
|
||||
{
|
||||
subtitle_mgr_printf(20, "%s::%s MANAGER_GET\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if (TrackCount > 0 && CurrentTrack >= 0)
|
||||
{
|
||||
*((int *)argument) = (int)Tracks[CurrentTrack].Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((int *)argument) = (int) -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK_DESC:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
TrackDescription_t *track = malloc(sizeof(TrackDescription_t));
|
||||
*((TrackDescription_t **)argument) = track;
|
||||
if (track)
|
||||
{
|
||||
memset(track, 0, sizeof(TrackDescription_t));
|
||||
track->Id = Tracks[CurrentTrack].Id;
|
||||
track->Name = strdup(Tracks[CurrentTrack].Name);
|
||||
track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*((TrackDescription_t **)argument) = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK:
|
||||
{
|
||||
subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
|
||||
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((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);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((char **)argument) = (char *)strdup("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GETNAME:
|
||||
{
|
||||
if (TrackCount > 0 && CurrentTrack >= 0)
|
||||
{
|
||||
*((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", __FILE__, __FUNCTION__, *((int *)argument));
|
||||
|
||||
if (*((int *)argument) < 0)
|
||||
{
|
||||
CurrentTrack = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
if (Tracks[i].Id == *((int *)argument))
|
||||
{
|
||||
CurrentTrack = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == TrackCount)
|
||||
{
|
||||
subtitle_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
|
||||
ret = cERR_SUBTITLE_MGR_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_DEL:
|
||||
{
|
||||
ret = ManagerDel(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_INIT_UPDATE:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
Tracks[i].pending = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
subtitle_mgr_err("%s::%s ContainerCmd not supported!", __FILE__, __FUNCTION__);
|
||||
ret = cERR_SUBTITLE_MGR_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
subtitle_mgr_printf(50, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct Manager_s SubtitleManager =
|
||||
{
|
||||
"Subtitle",
|
||||
&Command,
|
||||
NULL
|
||||
};
|
336
libeplayer3/manager/video.c
Normal file
336
libeplayer3/manager/video.c
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* video manager handling.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* ***************************** */
|
||||
/* Includes */
|
||||
/* ***************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "manager.h"
|
||||
#include "common.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define TRACKWRAP 4
|
||||
|
||||
/* Error Constants */
|
||||
#define cERR_VIDEO_MGR_NO_ERROR 0
|
||||
#define cERR_VIDEO_MGR_ERROR -1
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
static Track_t *Tracks = NULL;
|
||||
static int TrackCount = 0;
|
||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
||||
|
||||
static void (* updatedTrackInfoFnc)(void) = NULL;
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int ManagerAdd(Context_t *context, Track_t track)
|
||||
{
|
||||
video_mgr_printf(10, "\n");
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
Tracks[i].Id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tracks == NULL)
|
||||
{
|
||||
video_mgr_err("malloc failed\n");
|
||||
return cERR_VIDEO_MGR_ERROR;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++)
|
||||
{
|
||||
if (Tracks[i].Id == track.Id)
|
||||
{
|
||||
Tracks[i].pending = 0;
|
||||
return cERR_VIDEO_MGR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TrackCount < TRACKWRAP)
|
||||
{
|
||||
copyTrack(&Tracks[TrackCount], &track);
|
||||
TrackCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
video_mgr_err("TrackCount out if range %d - %d\n", TrackCount, TRACKWRAP);
|
||||
return cERR_VIDEO_MGR_ERROR;
|
||||
}
|
||||
|
||||
if (TrackCount > 0)
|
||||
{
|
||||
context->playback->isVideo = 1;
|
||||
}
|
||||
|
||||
video_mgr_printf(10, "\n");
|
||||
|
||||
return cERR_VIDEO_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static char **ManagerList(Context_t *context __attribute__((unused)))
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
char **tracklist = NULL;
|
||||
|
||||
video_mgr_printf(10, "\n");
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
||||
|
||||
if (tracklist == NULL)
|
||||
{
|
||||
video_mgr_err("malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
|
||||
{
|
||||
if (Tracks[i].pending)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
size_t len = strlen(Tracks[i].Name) + 20;
|
||||
char tmp[len];
|
||||
snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name);
|
||||
tracklist[j] = strdup(tmp);
|
||||
tracklist[j + 1] = strdup(Tracks[i].Encoding);
|
||||
}
|
||||
tracklist[j] = NULL;
|
||||
}
|
||||
|
||||
video_mgr_printf(10, "return %p (%d - %d)\n", tracklist, j, TrackCount);
|
||||
|
||||
return tracklist;
|
||||
}
|
||||
|
||||
static int ManagerDel(Context_t *context)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
video_mgr_printf(10, "\n");
|
||||
|
||||
if (Tracks != NULL)
|
||||
{
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
freeTrack(&Tracks[i]);
|
||||
}
|
||||
free(Tracks);
|
||||
Tracks = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
video_mgr_err("nothing to delete!\n");
|
||||
return cERR_VIDEO_MGR_ERROR;
|
||||
}
|
||||
|
||||
TrackCount = 0;
|
||||
CurrentTrack = 0;
|
||||
context->playback->isVideo = 0;
|
||||
|
||||
video_mgr_printf(10, "return no error\n");
|
||||
return cERR_VIDEO_MGR_NO_ERROR;
|
||||
}
|
||||
|
||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||
{
|
||||
int ret = cERR_VIDEO_MGR_NO_ERROR;
|
||||
|
||||
video_mgr_printf(10, "\n");
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case MANAGER_ADD:
|
||||
{
|
||||
Track_t *track = argument;
|
||||
ret = ManagerAdd(context, *track);
|
||||
break;
|
||||
}
|
||||
case MANAGER_LIST:
|
||||
{
|
||||
container_ffmpeg_update_tracks(context, context->playback->uri, 0);
|
||||
*((char ***)argument) = (char **)ManagerList(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((int *)argument) = (int)Tracks[CurrentTrack].Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((int *)argument) = (int) -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK_DESC:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
TrackDescription_t *track = malloc(sizeof(TrackDescription_t));
|
||||
*((TrackDescription_t **)argument) = track;
|
||||
if (track)
|
||||
{
|
||||
memset(track, 0, sizeof(TrackDescription_t));
|
||||
track->Id = Tracks[CurrentTrack].Id;
|
||||
track->Name = strdup(Tracks[CurrentTrack].Name);
|
||||
track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
|
||||
track->frame_rate = Tracks[CurrentTrack].frame_rate;
|
||||
track->width = Tracks[CurrentTrack].width;
|
||||
track->height = Tracks[CurrentTrack].height;
|
||||
track->aspect_ratio_num = Tracks[CurrentTrack].aspect_ratio_num;
|
||||
track->aspect_ratio_den = Tracks[CurrentTrack].aspect_ratio_den;
|
||||
context->output->video->Command(context, OUTPUT_GET_PROGRESSIVE, &(track->progressive));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*((TrackDescription_t **)argument) = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GET_TRACK:
|
||||
{
|
||||
video_mgr_printf(20, "MANAGER_GET_TRACK\n");
|
||||
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((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);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((char **)argument) = (char *)strdup("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_GETNAME:
|
||||
{
|
||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
||||
{
|
||||
*((char **)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((char **)argument) = (char *)strdup("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_SET:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
if (Tracks[i].Id == *((int *)argument))
|
||||
{
|
||||
CurrentTrack = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == TrackCount)
|
||||
{
|
||||
video_mgr_err("track id %d unknown\n", *((int *)argument));
|
||||
ret = cERR_VIDEO_MGR_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_DEL:
|
||||
{
|
||||
ret = ManagerDel(context);
|
||||
break;
|
||||
}
|
||||
case MANAGER_INIT_UPDATE:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < TrackCount; i++)
|
||||
{
|
||||
Tracks[i].pending = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MANAGER_UPDATED_TRACK_INFO:
|
||||
{
|
||||
if (updatedTrackInfoFnc != NULL)
|
||||
updatedTrackInfoFnc();
|
||||
break;
|
||||
}
|
||||
case MANAGER_REGISTER_UPDATED_TRACK_INFO:
|
||||
{
|
||||
updatedTrackInfoFnc = (void (*)(void))argument;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
video_mgr_err("ContainerCmd %d not supported!\n", command);
|
||||
ret = cERR_VIDEO_MGR_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
video_mgr_printf(10, "returning %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
struct Manager_s VideoManager =
|
||||
{
|
||||
"Video",
|
||||
&Command,
|
||||
NULL
|
||||
};
|
Reference in New Issue
Block a user