libeplayer3: implement Manager class

This commit is contained in:
martii
2014-04-06 21:12:56 +02:00
parent 2067355059
commit 1112111e2d
11 changed files with 298 additions and 1195 deletions

View File

@@ -1,186 +0,0 @@
/*
* 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 <map>
#include "manager.h"
#include "player.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define AUDIO_MGR_DEBUG
#ifdef AUDIO_MGR_DEBUG
static short debug_level = 0;
#define audio_mgr_printf(level, x...) do { \
if (debug_level >= level) printf(x); } while (0)
#else
#define audio_mgr_printf(level, x...)
#endif
#ifndef AUDIO_MGR_SILENT
#define audio_mgr_err(x...) do { printf(x); } while (0)
#else
#define audio_mgr_err(x...)
#endif
/* Error Constants */
#define cERR_AUDIO_MGR_NO_ERROR 0
#define cERR_AUDIO_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static std::map<int,Track_t> Tracks;
static int CurrentPid = -1;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
static int ManagerAdd(Player * context, Track_t track)
{
Tracks[track.pid] = track;
context->playback->isAudio = 1;
if (CurrentPid < 0)
CurrentPid = track.pid;
return cERR_AUDIO_MGR_NO_ERROR;
}
static char **ManagerList(Player * context __attribute__ ((unused)))
{
int j = 0;
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
{
size_t len = it->second.Name.length() + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", it->second.pid, it->second.Name.c_str());
tracklist[j] = strdup(tmp);
snprintf(tmp, len, "%d\n", it->second.ac3flags);
tracklist[j + 1] = strdup(tmp);
j += 2;
}
tracklist[j] = NULL;
return tracklist;
}
static int ManagerDel(Player * context)
{
Tracks.clear();
CurrentPid = -1;
context->playback->isAudio = 0;
return cERR_AUDIO_MGR_NO_ERROR;
}
static int Command(Player *context, ManagerCmd_t command, void *argument)
{
int ret = cERR_AUDIO_MGR_NO_ERROR;
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
switch (command) {
case MANAGER_ADD:{
Track_t *track = (Track_t *) argument;
ret = ManagerAdd(context, *track);
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
*((int *) argument) = (int) CurrentPid;
break;
}
case MANAGER_GET_TRACK:{
if (CurrentPid > -1)
*((Track_t **) argument) = &Tracks[CurrentPid];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETNAME:{
if (CurrentPid > -1)
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
else
*((char **) argument) = strdup("");
break;
}
case MANAGER_SET:{
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
if (it != Tracks.end())
CurrentPid = *((int *) argument);
else
ret = cERR_AUDIO_MGR_ERROR;
break;
}
case MANAGER_DEL:{
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE:{
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
it->second.pending = 1;
break;
}
default:
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);
return ret;
}
struct Manager_s AudioManager = {
"Audio",
&Command,
NULL
};

View File

@@ -1,152 +0,0 @@
/*
* 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 <map>
#include "manager.h"
#include "player.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#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 */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static std::map<int,Track_t> Tracks;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
static int ManagerAdd(Player * context __attribute__((unused)), Track_t track)
{
Tracks[track.pid] = track;
return cERR_CHAPTER_MGR_NO_ERROR;
}
static char **ManagerList(Player * context __attribute__ ((unused)))
{
int j = 0;
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
{
size_t len = it->second.Name.length() + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", it->second.pid, it->second.Name.c_str());
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup("");
j += 2;
}
tracklist[j] = NULL;
return tracklist;
}
static int ManagerDel(Player * context __attribute__((unused)))
{
Tracks.clear();
return cERR_CHAPTER_MGR_NO_ERROR;
}
static int Command(Player *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 = (Track_t *) argument;
ret = ManagerAdd(context, *track);
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_DEL:{
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE:{
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
it->second.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
};

View File

@@ -25,52 +25,159 @@
#include <string.h>
#include "manager.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
extern Manager_t AudioManager;
extern Manager_t VideoManager;
extern Manager_t SubtitleManager;
extern Manager_t TeletextManager;
extern Manager_t ChapterManager;
ManagerHandler_t ManagerHandler = {
"ManagerHandler",
&AudioManager,
&VideoManager,
&SubtitleManager,
&TeletextManager,
&ChapterManager
};
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
void copyTrack(Track_t * to, Track_t * from)
void Manager::addVideoTrack(Track &track)
{
*to = *from;
if (from->language != NULL)
to->language = strdup(from->language);
else
to->language = strdup("Unknown");
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
Track *t = new Track;
*t = track;
videoTracks[track.pid] = t;
}
void freeTrack(Track_t * track)
void Manager::addAudioTrack(Track &track)
{
if (track->language != NULL)
free(track->language);
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
Track *t = new Track;
*t = track;
audioTracks[track.pid] = t;
}
void Manager::addSubtitleTrack(Track &track)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
Track *t = new Track;
*t = track;
subtitleTracks[track.pid] = t;
}
void Manager::addTeletextTrack(Track &track)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
Track *t = new Track;
*t = track;
teletextTracks[track.pid] = t;
}
std::vector<Track> Manager::getVideoTracks()
{
// input.UpdateTracks();
std::vector<Track> res;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for(std::map<int,Track*>::iterator it = videoTracks.begin(); it != videoTracks.end(); ++it)
if (!it->second->inactive)
res.push_back(*it->second);
return res;
}
std::vector<Track> Manager::getAudioTracks()
{
// input.UpdateTracks();
std::vector<Track> res;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for(std::map<int,Track*>::iterator it = audioTracks.begin(); it != audioTracks.end(); ++it)
if (!it->second->inactive)
res.push_back(*it->second);
return res;
}
std::vector<Track> Manager::getSubtitleTracks()
{
// input.UpdateTracks();
std::vector<Track> res;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for(std::map<int,Track*>::iterator it = subtitleTracks.begin(); it != subtitleTracks.end(); ++it)
if (!it->second->inactive)
res.push_back(*it->second);
return res;
}
std::vector<Track> Manager::getTeletextTracks()
{
// input.UpdateTracks();
std::vector<Track> res;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for(std::map<int,Track*>::iterator it = teletextTracks.begin(); it != teletextTracks.end(); ++it)
if (!it->second->inactive)
res.push_back(*it->second);
return res;
}
Track *Manager::getVideoTrack(int pid)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::map<int,Track*>::iterator it = videoTracks.find(pid);
if (it != videoTracks.end() && !it->second->inactive)
return it->second;
return NULL;
}
Track *Manager::getAudioTrack(int pid)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::map<int,Track*>::iterator it = audioTracks.find(pid);
if (it != audioTracks.end() && !it->second->inactive)
return it->second;
return NULL;
}
Track *Manager::getSubtitleTrack(int pid)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::map<int,Track*>::iterator it = subtitleTracks.find(pid);
if (it != subtitleTracks.end() && !it->second->inactive)
return it->second;
return NULL;
}
Track *Manager::getTeletextTrack(int pid)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::map<int,Track*>::iterator it = teletextTracks.find(pid);
if (it != teletextTracks.end() && !it->second->inactive)
return it->second;
return NULL;
}
bool Manager::initTrackUpdate()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for (std::map<int,Track*>::iterator it = audioTracks.begin(); it != audioTracks.end(); ++it)
it->second->inactive = !it->second->is_static;
for (std::map<int, Track*>::iterator it = videoTracks.begin(); it != videoTracks.end(); ++it)
it->second->inactive = !it->second->is_static;
for (std::map<int,Track*>::iterator it = subtitleTracks.begin(); it != subtitleTracks.end(); ++it)
it->second->inactive = !it->second->is_static;
for (std::map<int,Track*>::iterator it = teletextTracks.begin(); it != teletextTracks.end(); ++it)
it->second->inactive = !it->second->is_static;
return true;
}
void Manager::clearTracks()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
for (std::map<int,Track*>::iterator it = audioTracks.begin(); it != audioTracks.end(); ++it)
delete it->second;
audioTracks.clear();
for (std::map<int, Track*>::iterator it = videoTracks.begin(); it != videoTracks.end(); ++it)
delete it->second;
videoTracks.clear();
for (std::map<int,Track*>::iterator it = subtitleTracks.begin(); it != subtitleTracks.end(); ++it)
delete it->second;
subtitleTracks.clear();
for (std::map<int,Track*>::iterator it = teletextTracks.begin(); it != teletextTracks.end(); ++it)
delete it->second;
teletextTracks.clear();
}
Manager::~Manager()
{
clearTracks();
}

View File

@@ -1,180 +0,0 @@
/*
* 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 <map>
#include "manager.h"
#include "player.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define SUBTITLE_MGR_DEBUG
#ifdef SUBTITLE_MGR_DEBUG
static short debug_level = 10;
#define subtitle_mgr_printf(level, x...) do { \
if (debug_level >= level) printf(x); } while (0)
#else
#define subtitle_mgr_printf(level, x...)
#endif
#ifndef SUBTITLE_MGR_SILENT
#define subtitle_mgr_err(x...) do { printf(x); } while (0)
#else
#define subtitle_mgr_err(x...)
#endif
/* Error Constants */
#define cERR_SUBTITLE_MGR_NO_ERROR 0
#define cERR_SUBTITLE_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static std::map<int,Track_t> Tracks;
static int CurrentPid = -1;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
static int ManagerAdd(Player * context __attribute__((unused)), Track_t track)
{
Tracks[track.pid] = track;
context->playback->isAudio = 1;
return cERR_SUBTITLE_MGR_NO_ERROR;
}
static char **ManagerList(Player * context __attribute__ ((unused)))
{
int j = 0;
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
{
size_t len = it->second.Name.length() + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", it->second.pid, it->second.Name.c_str());
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup("");
j += 2;
}
tracklist[j] = NULL;
return tracklist;
}
static int ManagerDel(Player * context __attribute__((unused)))
{
Tracks.clear();
CurrentPid = -1;
return cERR_SUBTITLE_MGR_NO_ERROR;
}
static int Command(Player *context, ManagerCmd_t command, void *argument)
{
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, command);
switch (command) {
case MANAGER_ADD:{
Track_t *track = (Track_t *) argument;
ret = ManagerAdd(context, *track);
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
*((int *) argument) = (int) CurrentPid;
break;
}
case MANAGER_GET_TRACK:{
if (CurrentPid > -1)
*((Track_t **) argument) = &Tracks[CurrentPid];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETNAME:{
if (CurrentPid > -1)
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
else
*((char **) argument) = strdup("");
break;
}
case MANAGER_SET:{
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
if (it != Tracks.end())
CurrentPid = *((int *) argument);
else
ret = cERR_SUBTITLE_MGR_ERROR;
break;
}
case MANAGER_DEL:{
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE:{
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
it->second.pending = 1;
break;
}
default:
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);
return ret;
}
struct Manager_s SubtitleManager = {
"Subtitle",
&Command,
NULL
};

View File

@@ -1,181 +0,0 @@
/*
* teletext 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 <map>
#include "manager.h"
#include "player.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define TELETEXT_MGR_DEBUG
#ifdef TELETEXT_MGR_DEBUG
static short debug_level = 0;
#define teletext_mgr_printf(level, x...) do { \
if (debug_level >= level) printf(x); } while (0)
#else
#define teletext_mgr_printf(level, x...)
#endif
#ifndef TELETEXT_MGR_SILENT
#define teletext_mgr_err(x...) do { printf(x); } while (0)
#else
#define teletext_mgr_err(x...)
#endif
/* Error Constants */
#define cERR_TELETEXT_MGR_NO_ERROR 0
#define cERR_TELETEXT_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static std::map<int,Track_t> Tracks;
static int CurrentPid = -1;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
static int ManagerAdd(Player * context __attribute__((unused)), Track_t track)
{
Tracks[track.pid] = track;
context->playback->isAudio = 1;
return cERR_TELETEXT_MGR_NO_ERROR;
}
static char **ManagerList(Player * context __attribute__ ((unused)))
{
int j = 0;
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
{
size_t len = it->second.Name.length() + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", it->second.pid, it->second.Name.c_str());
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup("");
j += 2;
}
tracklist[j] = NULL;
return tracklist;
}
static int ManagerDel(Player * context __attribute__((unused)))
{
Tracks.clear();
CurrentPid = -1;
return cERR_TELETEXT_MGR_NO_ERROR;
}
static int Command(Player *context, ManagerCmd_t command, void *argument)
{
int ret = cERR_TELETEXT_MGR_NO_ERROR;
teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
switch (command) {
case MANAGER_ADD:{
Track_t *track = (Track_t *) argument;
ret = ManagerAdd(context, *track);
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
*((int *) argument) = (int) CurrentPid;
break;
}
case MANAGER_GET_TRACK:{
if (CurrentPid > -1)
*((Track_t **) argument) = &Tracks[CurrentPid];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETNAME:{
if (CurrentPid > -1)
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
else
*((char **) argument) = strdup("");
break;
}
case MANAGER_SET:{
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
if (it != Tracks.end())
CurrentPid = *((int *) argument);
else
ret = cERR_TELETEXT_MGR_ERROR;
break;
}
case MANAGER_DEL:{
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE:{
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
it->second.pending = 1;
break;
}
default:
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);
return ret;
}
struct Manager_s TeletextManager = {
"Teletext",
&Command,
NULL
};

View File

@@ -1,184 +0,0 @@
/*
* 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 <map>
#include "manager.h"
#include "player.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define VIDEO_MGR_DEBUG
#ifdef VIDEO_MGR_DEBUG
static short debug_level = 0;
#define video_mgr_printf(level, x...) do { \
if (debug_level >= level) printf(x); } while (0)
#else
#define video_mgr_printf(level, x...)
#endif
#ifndef VIDEO_MGR_SILENT
#define video_mgr_err(x...) do { printf(x); } while (0)
#else
#define video_mgr_err(x...)
#endif
/* Error Constants */
#define cERR_VIDEO_MGR_NO_ERROR 0
#define cERR_VIDEO_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static std::map<int,Track_t> Tracks;
static int CurrentPid = -1;
/* ***************************** */
/* Prototypes */
/* ***************************** */
/* ***************************** */
/* Functions */
/* ***************************** */
static int ManagerAdd(Player * context, Track_t track)
{
Tracks[track.pid] = track;
context->playback->isVideo = 1;
if (CurrentPid < 0)
CurrentPid = track.pid;
return cERR_VIDEO_MGR_NO_ERROR;
}
static char **ManagerList(Player * context __attribute__ ((unused)))
{
int j = 0;
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
{
size_t len = it->second.Name.length() + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", it->second.pid, it->second.Name.c_str());
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup("");
j += 2;
}
tracklist[j] = NULL;
return tracklist;
}
static int ManagerDel(Player * context)
{
Tracks.clear();
CurrentPid = -1;
context->playback->isAudio = 0;
return cERR_VIDEO_MGR_NO_ERROR;
}
static int Command(Player *context, ManagerCmd_t command, void *argument)
{
int ret = cERR_VIDEO_MGR_NO_ERROR;
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
switch (command) {
case MANAGER_ADD:{
Track_t *track = (Track_t *)argument;
ret = ManagerAdd(context, *track);
break;
}
case MANAGER_LIST:{
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
*((char ***) argument) = (char **) ManagerList(context);
break;
}
case MANAGER_GET:{
*((int *) argument) = (int) CurrentPid;
break;
}
case MANAGER_GET_TRACK:{
if (CurrentPid > -1)
*((Track_t **) argument) = &Tracks[CurrentPid];
else
*((Track_t **) argument) = NULL;
break;
}
case MANAGER_GETNAME:{
if (CurrentPid > -1)
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
else
*((char **) argument) = strdup("");
break;
}
case MANAGER_SET:{
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
if (it != Tracks.end())
CurrentPid = *((int *) argument);
else
ret = cERR_VIDEO_MGR_ERROR;
break;
}
case MANAGER_DEL:{
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE:{
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
it->second.pending = 1;
break;
}
default:
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);
return ret;
}
struct Manager_s VideoManager = {
"Video",
&Command,
NULL
};