mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3: c++ adjustments
This commit is contained in:
@@ -2,21 +2,20 @@ noinst_LTLIBRARIES = libeplayer3.la
|
|||||||
|
|
||||||
CXXFLAGS = -Wall
|
CXXFLAGS = -Wall
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = -I$(srcdir)/include
|
||||||
-I$(srcdir)/include
|
AM_CPPFLAGS += -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||||
|
AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
|
||||||
|
|
||||||
libeplayer3_la_SOURCES = \
|
libeplayer3_la_SOURCES = \
|
||||||
container/container.c container/container_ffmpeg.c \
|
container/container.cpp container/container_ffmpeg.cpp \
|
||||||
manager/audio.c manager/manager.c manager/subtitle.c manager/video.c \
|
manager/audio.cpp manager/manager.cpp manager/subtitle.cpp manager/video.cpp \
|
||||||
manager/teletext.c manager/chapter.c \
|
manager/teletext.cpp manager/chapter.cpp \
|
||||||
output/linuxdvb.c output/output.c \
|
output/linuxdvb.cpp output/output.cpp \
|
||||||
playback/playback.c output/writer/writer.c output/writer/wmv.c \
|
playback/playback.cpp output/writer/writer.cpp output/writer/wmv.cpp \
|
||||||
output/writer/ac3.c output/writer/divx.c output/writer/pes.c \
|
output/writer/ac3.cpp output/writer/divx.cpp output/writer/pes.cpp \
|
||||||
output/writer/dts.c output/writer/mpeg2.c output/writer/mp3.c output/writer/misc.c \
|
output/writer/dts.cpp output/writer/mpeg2.cpp output/writer/mp3.cpp output/writer/misc.cpp \
|
||||||
output/writer/h264.c output/writer/h263.c output/writer/vc1.c \
|
output/writer/h264.cpp output/writer/h263.cpp output/writer/vc1.cpp \
|
||||||
output/writer/flac.c output/writer/pcm.c
|
output/writer/flac.cpp output/writer/pcm.cpp
|
||||||
|
|
||||||
AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
|
||||||
|
|
||||||
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ if (debug_level >= level) printf(x); } while (0)
|
|||||||
#define container_err(x...)
|
#define container_err(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int Command(Context_t *context, ContainerCmd_t command, void *argument __attribute__((unused)))
|
static int Command(Context_t *context, ContainerCmd_t command, const char *argument __attribute__((unused)))
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ static float seek_sec_abs = -1.0, seek_sec_rel = 0.0;
|
|||||||
/* MISC Functions */
|
/* MISC Functions */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static char *Codec2Encoding(AVCodecContext * codec)
|
static const char *Codec2Encoding(AVCodecContext * codec)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Codec ID: %ld (%.8lx)\n", (long) codec->codec_id, (long) codec->codec_id);
|
fprintf(stderr, "Codec ID: %ld (%.8lx)\n", (long) codec->codec_id, (long) codec->codec_id);
|
||||||
switch (codec->codec_id) {
|
switch (codec->codec_id) {
|
||||||
@@ -214,14 +214,15 @@ int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts)
|
|||||||
/* **************************** */
|
/* **************************** */
|
||||||
|
|
||||||
// from neutrino-mp/lib/libdvbsubtitle/dvbsub.cpp
|
// from neutrino-mp/lib/libdvbsubtitle/dvbsub.cpp
|
||||||
extern void dvbsub_write(AVSubtitle *, int64_t);
|
extern "C" void dvbsub_write(AVSubtitle *, int64_t);
|
||||||
extern void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid);
|
extern "C" void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid);
|
||||||
extern void dvbsub_ass_clear(void);
|
extern "C" void dvbsub_ass_clear(void);
|
||||||
// from neutrino-mp/lib/lib/libtuxtxt/tuxtxt_common.h
|
// from neutrino-mp/lib/lib/libtuxtxt/tuxtxt_common.h
|
||||||
extern void teletext_write(int pid, uint8_t *data, int size);
|
extern "C" void teletext_write(int pid, uint8_t *data, int size);
|
||||||
|
|
||||||
static void FFMPEGThread(Context_t * context)
|
static void *FFMPEGThread(void *arg)
|
||||||
{
|
{
|
||||||
|
Context_t *context = (Context_t *) arg;
|
||||||
char threadname[17];
|
char threadname[17];
|
||||||
strncpy(threadname, __func__, sizeof(threadname));
|
strncpy(threadname, __func__, sizeof(threadname));
|
||||||
threadname[16] = 0;
|
threadname[16] = 0;
|
||||||
@@ -443,6 +444,7 @@ static void FFMPEGThread(Context_t * context)
|
|||||||
hasPlayThreadStarted = 0;
|
hasPlayThreadStarted = 0;
|
||||||
|
|
||||||
ffmpeg_printf(10, "terminating\n");
|
ffmpeg_printf(10, "terminating\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **************************** */
|
/* **************************** */
|
||||||
@@ -463,10 +465,10 @@ static void log_callback(void *ptr __attribute__ ((unused)), int lvl __attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void container_ffmpeg_read_subtitle(Context_t * context, const char *filename, const char *format, int pid) {
|
static void container_ffmpeg_read_subtitle(Context_t * context, const char *filename, const char *format, int pid) {
|
||||||
char *lastDot = strrchr(filename, '.');
|
const char *lastDot = strrchr(filename, '.');
|
||||||
if (!lastDot)
|
if (!lastDot)
|
||||||
return;
|
return;
|
||||||
char *subfile = alloca(strlen(filename) + strlen(format));
|
char *subfile = (char *) alloca(strlen(filename) + strlen(format));
|
||||||
strcpy(subfile, filename);
|
strcpy(subfile, filename);
|
||||||
strcpy(subfile + (lastDot + 1 - filename), format);
|
strcpy(subfile + (lastDot + 1 - filename), format);
|
||||||
|
|
||||||
@@ -496,18 +498,6 @@ static void container_ffmpeg_read_subtitle(Context_t * context, const char *file
|
|||||||
}
|
}
|
||||||
AVPacket avpkt;
|
AVPacket avpkt;
|
||||||
av_init_packet(&avpkt);
|
av_init_packet(&avpkt);
|
||||||
#if 0
|
|
||||||
// FIXME, use custom values
|
|
||||||
if (c->subtitle_header && !strcmp(format, "srt")) {
|
|
||||||
av_freep(&c->subtitle_header);
|
|
||||||
|
|
||||||
#define ASS_DEFAULT_FONT "Arial"
|
|
||||||
#define ASS_DEFAULT_FONT_SIZE 16
|
|
||||||
#define ASS_DEFAULT_COLOR 0xffffff
|
|
||||||
|
|
||||||
ff_ass_subtitle_header(c, ASS_DEFAULT_FONT, ASS_DEFAULT_FONT_SIZE, ASS_DEFAULT_COLOR, 0, 0, 0, 0, 2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (c->subtitle_header)
|
if (c->subtitle_header)
|
||||||
fprintf(stderr, "%s\n", c->subtitle_header);
|
fprintf(stderr, "%s\n", c->subtitle_header);
|
||||||
@@ -525,8 +515,7 @@ static void container_ffmpeg_read_subtitle(Context_t * context, const char *file
|
|||||||
avformat_free_context(avfc);
|
avformat_free_context(avfc);
|
||||||
|
|
||||||
Track_t track;
|
Track_t track;
|
||||||
memset(&track, 0, sizeof(track));
|
track.Name = format;
|
||||||
track.Name = (char *) format;
|
|
||||||
track.is_static = 1;
|
track.is_static = 1;
|
||||||
track.Id = pid;
|
track.Id = pid;
|
||||||
track.Encoding = strcmp(format, "srt") ? "S_TEXT/ASS" : "S_TEXT/SRT";
|
track.Encoding = strcmp(format, "srt") ? "S_TEXT/ASS" : "S_TEXT/SRT";
|
||||||
@@ -542,7 +531,7 @@ static void container_ffmpeg_read_subtitles(Context_t * context, const char *fil
|
|||||||
container_ffmpeg_read_subtitle(context, filename, "ssa", 0xFFFD);
|
container_ffmpeg_read_subtitle(context, filename, "ssa", 0xFFFD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int container_ffmpeg_init(Context_t * context, char *filename)
|
int container_ffmpeg_init(Context_t * context, const char *filename)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -640,7 +629,7 @@ int container_ffmpeg_init(Context_t * context, char *filename)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
int container_ffmpeg_update_tracks(Context_t * context, const char *filename)
|
||||||
{
|
{
|
||||||
if (terminating)
|
if (terminating)
|
||||||
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
||||||
@@ -650,13 +639,12 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
|||||||
context->manager->video->Command(context, MANAGER_INIT_UPDATE, NULL);
|
context->manager->video->Command(context, MANAGER_INIT_UPDATE, NULL);
|
||||||
for (i = 0; i < avContext->nb_chapters; i++) {
|
for (i = 0; i < avContext->nb_chapters; i++) {
|
||||||
Track_t track;
|
Track_t track;
|
||||||
memset(&track, 0, sizeof(track));
|
|
||||||
track.Id = i;
|
track.Id = i;
|
||||||
AVDictionaryEntry *title;
|
AVDictionaryEntry *title;
|
||||||
AVChapter *ch = avContext->chapters[i];
|
AVChapter *ch = avContext->chapters[i];
|
||||||
title = av_dict_get(ch->metadata, "title", NULL, 0);
|
title = av_dict_get(ch->metadata, "title", NULL, 0);
|
||||||
track.Name = strdup(title ? title->value : "und");
|
track.Name = strdup(title ? title->value : "und");
|
||||||
ffmpeg_printf(10, "Chapter %s\n", track.Name);
|
ffmpeg_printf(10, "Chapter %s\n", track.Name.c_str());
|
||||||
track.chapter_start = (double) ch->start * av_q2d(ch->time_base) * 1000.0;
|
track.chapter_start = (double) ch->start * av_q2d(ch->time_base) * 1000.0;
|
||||||
track.chapter_end = (double) ch->end * av_q2d(ch->time_base) * 1000.0;
|
track.chapter_end = (double) ch->end * av_q2d(ch->time_base) * 1000.0;
|
||||||
context->manager->chapter->Command(context, MANAGER_ADD, &track);
|
context->manager->chapter->Command(context, MANAGER_ADD, &track);
|
||||||
@@ -683,18 +671,13 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
|||||||
Track_t track;
|
Track_t track;
|
||||||
AVStream *stream = avContext->streams[n];
|
AVStream *stream = avContext->streams[n];
|
||||||
|
|
||||||
char *encoding = Codec2Encoding(stream->codec);
|
const char *encoding = Codec2Encoding(stream->codec);
|
||||||
|
|
||||||
if (encoding != NULL)
|
if (encoding != NULL)
|
||||||
ffmpeg_printf(1, "%d. encoding = %s\n", n, encoding);
|
ffmpeg_printf(1, "%d. encoding = %s\n", n, encoding);
|
||||||
|
|
||||||
if (!stream->id)
|
if (!stream->id)
|
||||||
stream->id = n;
|
stream->id = n + 1;
|
||||||
|
|
||||||
/* some values in track are unset and therefor copyTrack segfaults.
|
|
||||||
* so set it by default to NULL!
|
|
||||||
*/
|
|
||||||
memset(&track, 0, sizeof(track));
|
|
||||||
|
|
||||||
track.avfc = avContext;
|
track.avfc = avContext;
|
||||||
track.stream = stream;
|
track.stream = stream;
|
||||||
@@ -736,7 +719,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
|||||||
|
|
||||||
track.Name = lang ? lang->value : "und";
|
track.Name = lang ? lang->value : "und";
|
||||||
|
|
||||||
ffmpeg_printf(10, "Language %s\n", track.Name);
|
ffmpeg_printf(10, "Language %s\n", track.Name.c_str());
|
||||||
|
|
||||||
track.Encoding = encoding;
|
track.Encoding = encoding;
|
||||||
track.Id = stream->id;
|
track.Id = stream->id;
|
||||||
@@ -770,7 +753,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
|||||||
|
|
||||||
track.Name = lang ? lang->value : "und";
|
track.Name = lang ? lang->value : "und";
|
||||||
|
|
||||||
ffmpeg_printf(10, "Language %s\n", track.Name);
|
ffmpeg_printf(10, "Language %s\n", track.Name.c_str());
|
||||||
|
|
||||||
track.Encoding = encoding;
|
track.Encoding = encoding;
|
||||||
track.Id = stream->id;
|
track.Id = stream->id;
|
||||||
@@ -786,7 +769,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename)
|
|||||||
ffmpeg_printf(10, "subtitle height %d\n", stream->codec->height);
|
ffmpeg_printf(10, "subtitle height %d\n", stream->codec->height);
|
||||||
ffmpeg_printf(10, "subtitle stream %p\n", stream);
|
ffmpeg_printf(10, "subtitle stream %p\n", stream);
|
||||||
|
|
||||||
ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name);
|
ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name.c_str());
|
||||||
|
|
||||||
if (stream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT && context->manager->teletext) {
|
if (stream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT && context->manager->teletext) {
|
||||||
ffmpeg_printf(10, "dvb_teletext\n");
|
ffmpeg_printf(10, "dvb_teletext\n");
|
||||||
@@ -853,7 +836,7 @@ static int container_ffmpeg_play(Context_t * context)
|
|||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
if ((error = pthread_create(&PlayThread, &attr, (void *) &FFMPEGThread, context)) != 0) {
|
if ((error = pthread_create(&PlayThread, &attr, FFMPEGThread, context)) != 0) {
|
||||||
ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error));
|
ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error));
|
||||||
ret = cERR_CONTAINER_FFMPEG_ERR;
|
ret = cERR_CONTAINER_FFMPEG_ERR;
|
||||||
} else {
|
} else {
|
||||||
@@ -997,7 +980,7 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
|
|||||||
if (audioTrack)
|
if (audioTrack)
|
||||||
psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata);
|
psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata);
|
||||||
|
|
||||||
*p = malloc(sizeof(char *) * psize * 2);
|
*p = (char **) malloc(sizeof(char *) * psize * 2);
|
||||||
if (!*p) {
|
if (!*p) {
|
||||||
fprintf(stderr, "MALLOC %s:%d\n", __func__, __LINE__);
|
fprintf(stderr, "MALLOC %s:%d\n", __func__, __LINE__);
|
||||||
return cERR_CONTAINER_FFMPEG_ERR;
|
return cERR_CONTAINER_FFMPEG_ERR;
|
||||||
@@ -1030,7 +1013,7 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
|
|||||||
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Command(Context_t *context, ContainerCmd_t command, void *argument)
|
static int Command(Context_t *context, ContainerCmd_t command, const char *argument)
|
||||||
{
|
{
|
||||||
int ret = cERR_CONTAINER_FFMPEG_NO_ERROR;
|
int ret = cERR_CONTAINER_FFMPEG_NO_ERROR;
|
||||||
|
|
||||||
@@ -1042,8 +1025,7 @@ static int Command(Context_t *context, ContainerCmd_t command, void *argument)
|
|||||||
return cERR_CONTAINER_FFMPEG_ERR;
|
return cERR_CONTAINER_FFMPEG_ERR;
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case CONTAINER_INIT:{
|
case CONTAINER_INIT:{
|
||||||
char *filename = (char *) argument;
|
ret = container_ffmpeg_init(context, argument);
|
||||||
ret = container_ffmpeg_init(context, filename);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONTAINER_PLAY:{
|
case CONTAINER_PLAY:{
|
||||||
@@ -1096,7 +1078,7 @@ static int Command(Context_t *context, ContainerCmd_t command, void *argument)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *FFMPEG_Capabilities[] = { "avi", "mkv", "mp4", "ts", "mov", "flv", "flac", "mp3", "mpg",
|
static const char *FFMPEG_Capabilities[] = { "avi", "mkv", "mp4", "ts", "mov", "flv", "flac", "mp3", "mpg",
|
||||||
"m2ts", "vob", "wmv", "wma", "asf", "mp2", "m4v", "m4a", "divx", "dat",
|
"m2ts", "vob", "wmv", "wma", "asf", "mp2", "m4v", "m4a", "divx", "dat",
|
||||||
"mpeg", "trp", "mts", "vdr", "ogg", "wav", "wtv", "ogm", "3gp", NULL
|
"mpeg", "trp", "mts", "vdr", "ogg", "wav", "wtv", "ogm", "3gp", NULL
|
||||||
};
|
};
|
||||||
|
@@ -16,5 +16,5 @@ typedef struct Context_s {
|
|||||||
int64_t *currentAudioPtsP;
|
int64_t *currentAudioPtsP;
|
||||||
} Context_t;
|
} Context_t;
|
||||||
|
|
||||||
int container_ffmpeg_update_tracks(Context_t * context, char *filename);
|
int container_ffmpeg_update_tracks(Context_t * context, const char *filename);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -22,19 +22,18 @@ struct Context_s;
|
|||||||
typedef struct Context_s Context_t;
|
typedef struct Context_s Context_t;
|
||||||
|
|
||||||
typedef struct Container_s {
|
typedef struct Container_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
int (*Command) (Context_t *, ContainerCmd_t, void *);
|
int (*Command) (Context_t *, ContainerCmd_t, const char *);
|
||||||
char **Capabilities;
|
const char **Capabilities;
|
||||||
|
|
||||||
} Container_t;
|
} Container_t;
|
||||||
|
|
||||||
|
|
||||||
extern Container_t FFMPEGContainer;
|
extern Container_t FFMPEGContainer;
|
||||||
|
|
||||||
typedef struct ContainerHandler_s {
|
typedef struct ContainerHandler_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
Container_t *selectedContainer;
|
Container_t *selectedContainer;
|
||||||
int (*Command) (Context_t *, ContainerCmd_t, void *);
|
int (*Command) (Context_t *, ContainerCmd_t, const char *);
|
||||||
} ContainerHandler_t;
|
} ContainerHandler_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include <libavutil/time.h>
|
#include <libavutil/time.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MANAGER_ADD,
|
MANAGER_ADD,
|
||||||
@@ -28,8 +31,8 @@ typedef enum {
|
|||||||
} eTrackTypeEplayer;
|
} eTrackTypeEplayer;
|
||||||
|
|
||||||
typedef struct Track_s {
|
typedef struct Track_s {
|
||||||
char *Name;
|
std::string Name;
|
||||||
char *Encoding;
|
const char *Encoding;
|
||||||
int Id;
|
int Id;
|
||||||
|
|
||||||
/* new field for ffmpeg - add at the end so no problem
|
/* new field for ffmpeg - add at the end so no problem
|
||||||
@@ -50,20 +53,21 @@ typedef struct Track_s {
|
|||||||
int is_static;
|
int is_static;
|
||||||
long long int chapter_start;
|
long long int chapter_start;
|
||||||
long long int chapter_end;
|
long long int chapter_end;
|
||||||
|
Track_s() : Encoding(NULL), Id(0), language(NULL), duration(-1), avfc(NULL), stream(NULL), pending(0), is_static(0), chapter_start(0), chapter_end(0) {}
|
||||||
} Track_t;
|
} Track_t;
|
||||||
|
|
||||||
struct Context_s;
|
struct Context_s;
|
||||||
typedef struct Context_s Context_t;
|
typedef struct Context_s Context_t;
|
||||||
|
|
||||||
typedef struct Manager_s {
|
typedef struct Manager_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
int (*Command) ( Context_t *, ManagerCmd_t, void *);
|
int (*Command) ( Context_t *, ManagerCmd_t, void *);
|
||||||
char **Capabilities;
|
const char **Capabilities;
|
||||||
|
|
||||||
} Manager_t;
|
} Manager_t;
|
||||||
|
|
||||||
typedef struct ManagerHandler_s {
|
typedef struct ManagerHandler_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
Manager_t *audio;
|
Manager_t *audio;
|
||||||
Manager_t *video;
|
Manager_t *video;
|
||||||
Manager_t *subtitle;
|
Manager_t *subtitle;
|
||||||
|
@@ -4,11 +4,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include <libavutil/time.h>
|
#include <libavutil/time.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OUTPUT_INIT,
|
OUTPUT_INIT,
|
||||||
@@ -46,7 +48,7 @@ typedef struct {
|
|||||||
|
|
||||||
int64_t pts;
|
int64_t pts;
|
||||||
|
|
||||||
char *type;
|
const char *type;
|
||||||
|
|
||||||
AVFormatContext *avfc;
|
AVFormatContext *avfc;
|
||||||
AVStream *stream;
|
AVStream *stream;
|
||||||
@@ -57,10 +59,10 @@ struct Context_s;
|
|||||||
typedef struct Context_s Context_t;
|
typedef struct Context_s Context_t;
|
||||||
|
|
||||||
typedef struct Output_s {
|
typedef struct Output_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
int (*Command) (Context_t *, OutputCmd_t, void *);
|
int (*Command) (Context_t *, OutputCmd_t, const char *);
|
||||||
int (*Write) (Context_t *, AudioVideoOut_t *privateData);
|
int (*Write) (Context_t *, AudioVideoOut_t *privateData);
|
||||||
char **Capabilities;
|
const char **Capabilities;
|
||||||
|
|
||||||
} Output_t;
|
} Output_t;
|
||||||
|
|
||||||
@@ -68,10 +70,10 @@ extern Output_t LinuxDvbOutput;
|
|||||||
extern Output_t SubtitleOutput;
|
extern Output_t SubtitleOutput;
|
||||||
|
|
||||||
typedef struct OutputHandler_s {
|
typedef struct OutputHandler_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
Output_t *audio;
|
Output_t *audio;
|
||||||
Output_t *video;
|
Output_t *video;
|
||||||
int (*Command) (Context_t *, OutputCmd_t, void *);
|
int (*Command) (Context_t *, OutputCmd_t, const char *);
|
||||||
} OutputHandler_t;
|
} OutputHandler_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef PLAYBACK_H_
|
#ifndef PLAYBACK_H_
|
||||||
#define PLAYBACK_H_
|
#define PLAYBACK_H_
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP,
|
typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP,
|
||||||
PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM,
|
PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM,
|
||||||
@@ -15,7 +16,7 @@ struct Context_s;
|
|||||||
typedef struct Context_s Context_t;
|
typedef struct Context_s Context_t;
|
||||||
|
|
||||||
typedef struct PlaybackHandler_s {
|
typedef struct PlaybackHandler_s {
|
||||||
char *Name;
|
const char *Name;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ typedef struct PlaybackHandler_s {
|
|||||||
unsigned char abortPlayback;
|
unsigned char abortPlayback;
|
||||||
|
|
||||||
int (*Command) ( Context_t *, PlaybackCmd_t, void *);
|
int (*Command) ( Context_t *, PlaybackCmd_t, void *);
|
||||||
char *uri;
|
std::string uri;
|
||||||
unsigned char noprobe; /* hack: only minimal probing in av_find_stream_info */
|
unsigned char noprobe; /* hack: only minimal probing in av_find_stream_info */
|
||||||
unsigned long long readCount;
|
unsigned long long readCount;
|
||||||
} PlaybackHandler_t;
|
} PlaybackHandler_t;
|
||||||
|
@@ -4,11 +4,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include <libavutil/time.h>
|
#include <libavutil/time.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum { eNone, eAudio, eVideo, eGfx } eWriterType_t;
|
typedef enum { eNone, eAudio, eVideo, eGfx } eWriterType_t;
|
||||||
|
|
||||||
@@ -32,9 +34,9 @@ typedef struct {
|
|||||||
} WriterAVCallData_t;
|
} WriterAVCallData_t;
|
||||||
|
|
||||||
typedef struct WriterCaps_s {
|
typedef struct WriterCaps_s {
|
||||||
char *name;
|
const char *name;
|
||||||
eWriterType_t type;
|
eWriterType_t type;
|
||||||
char *textEncoding;
|
const char *textEncoding;
|
||||||
/* fixme: revise if this is an enum! */
|
/* fixme: revise if this is an enum! */
|
||||||
int dvbEncoding;
|
int dvbEncoding;
|
||||||
} WriterCaps_t;
|
} WriterCaps_t;
|
||||||
|
@@ -23,15 +23,14 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Makros/Constants */
|
/* Makros/Constants */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
#define TRACKWRAP 20
|
|
||||||
|
|
||||||
#define AUDIO_MGR_DEBUG
|
#define AUDIO_MGR_DEBUG
|
||||||
|
|
||||||
@@ -65,9 +64,8 @@ static const char FILENAME[] = __FILE__;
|
|||||||
/* Varaibles */
|
/* Varaibles */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static Track_t *Tracks = NULL;
|
static std::map<int,Track_t> Tracks;
|
||||||
static int TrackCount = 0;
|
static int CurrentPid = -1;
|
||||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
@@ -79,109 +77,39 @@ static int CurrentTrack = 0; //TRACK[0] as default.
|
|||||||
|
|
||||||
static int ManagerAdd(Context_t * context, Track_t track)
|
static int ManagerAdd(Context_t * context, Track_t track)
|
||||||
{
|
{
|
||||||
|
Tracks[track.Id] = track;
|
||||||
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);
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < TRACKWRAP; i++)
|
|
||||||
Tracks[i].Id = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tracks == NULL) {
|
|
||||||
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
|
|
||||||
return cERR_AUDIO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < TRACKWRAP; i++) {
|
|
||||||
if (Tracks[i].Id == track.Id) {
|
|
||||||
Tracks[i].pending = 0;
|
|
||||||
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", FILENAME,
|
|
||||||
__FUNCTION__, TrackCount, TRACKWRAP);
|
|
||||||
return cERR_AUDIO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TrackCount > 0)
|
|
||||||
context->playback->isAudio = 1;
|
context->playback->isAudio = 1;
|
||||||
|
|
||||||
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
if (CurrentPid < 0)
|
||||||
|
CurrentPid = track.Id;
|
||||||
|
|
||||||
return cERR_AUDIO_MGR_NO_ERROR;
|
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;
|
int j = 0;
|
||||||
char **tracklist = NULL;
|
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
|
||||||
|
|
||||||
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
|
{
|
||||||
if (Tracks != NULL) {
|
size_t len = it->second.Name.length() + 20;
|
||||||
|
char tmp[len];
|
||||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str());
|
||||||
|
tracklist[j] = strdup(tmp);
|
||||||
if (tracklist == NULL) {
|
tracklist[j + 1] = strdup(it->second.Encoding);
|
||||||
audio_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;
|
|
||||||
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;
|
tracklist[j] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
return tracklist;
|
||||||
__FUNCTION__, tracklist, j, TrackCount);
|
|
||||||
|
|
||||||
return tracklist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ManagerDel(Context_t * context)
|
static int ManagerDel(Context_t * context)
|
||||||
{
|
{
|
||||||
|
Tracks.clear();
|
||||||
int i = 0;
|
CurrentPid = -1;
|
||||||
|
context->playback->isAudio = 0;
|
||||||
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
return cERR_AUDIO_MGR_NO_ERROR;
|
||||||
|
|
||||||
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", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
return cERR_AUDIO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackCount = 0;
|
|
||||||
CurrentTrack = 0;
|
|
||||||
context->playback->isAudio = 0;
|
|
||||||
|
|
||||||
audio_mgr_printf(10, "%s::%s return no error\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
|
|
||||||
return cERR_AUDIO_MGR_NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,90 +121,64 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MANAGER_ADD:{
|
case MANAGER_ADD:{
|
||||||
Track_t *track = argument;
|
Track_t *track = (Track_t *) argument;
|
||||||
|
|
||||||
ret = ManagerAdd(context, *track);
|
ret = ManagerAdd(context, *track);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_LIST:{
|
case MANAGER_LIST:{
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
*((char ***) argument) = (char **) ManagerList(context);
|
*((char ***) argument) = (char **) ManagerList(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET:{
|
case MANAGER_GET:{
|
||||||
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME,
|
*((int *) argument) = (int) CurrentPid;
|
||||||
__FUNCTION__);
|
break;
|
||||||
|
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
|
||||||
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
|
|
||||||
else
|
|
||||||
*((int *) argument) = (int) -1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_GET_TRACK:{
|
case MANAGER_GET_TRACK:{
|
||||||
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
|
if (CurrentPid > -1)
|
||||||
__FUNCTION__);
|
*((Track_t **) argument) = &Tracks[CurrentPid];
|
||||||
|
else
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
*((Track_t **) argument) = NULL;
|
||||||
*((Track_t **) argument) =
|
break;
|
||||||
(Track_t *) & Tracks[CurrentTrack];
|
|
||||||
else
|
|
||||||
*((Track_t **) argument) = NULL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_GETENCODING:{
|
case MANAGER_GETENCODING:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Encoding);
|
||||||
(char *) strdup(Tracks[CurrentTrack].Encoding);
|
else
|
||||||
else
|
*((char **) argument) = strdup("");
|
||||||
*((char **) argument) = (char *) strdup("");
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_GETNAME:{
|
case MANAGER_GETNAME:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
|
||||||
(char *) strdup(Tracks[CurrentTrack].Name);
|
else
|
||||||
else
|
*((char **) argument) = strdup("");
|
||||||
*((char **) argument) = (char *) strdup("");
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_SET:{
|
case MANAGER_SET:{
|
||||||
int i;
|
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
|
||||||
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
|
if (it != Tracks.end())
|
||||||
__FUNCTION__, *((int *) argument));
|
CurrentPid = *((int *) argument);
|
||||||
|
else
|
||||||
for (i = 0; i < TrackCount; i++)
|
ret = cERR_AUDIO_MGR_ERROR;
|
||||||
if (Tracks[i].Id == *((int *) argument)) {
|
break;
|
||||||
CurrentTrack = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == TrackCount) {
|
|
||||||
audio_mgr_err("%s::%s track id %d unknown\n", FILENAME,
|
|
||||||
__FUNCTION__, *((int *) argument));
|
|
||||||
ret = cERR_AUDIO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_DEL:{
|
case MANAGER_DEL:{
|
||||||
ret = ManagerDel(context);
|
ret = ManagerDel(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_INIT_UPDATE:{
|
case MANAGER_INIT_UPDATE:{
|
||||||
int i;
|
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
for (i = 0; i < TrackCount; i++)
|
it->second.pending = 1;
|
||||||
Tracks[i].pending = 1;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
|
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||||
__FUNCTION__, command);
|
ret = cERR_AUDIO_MGR_ERROR;
|
||||||
ret = cERR_AUDIO_MGR_ERROR;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,
|
audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
|
||||||
ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Makros/Constants */
|
/* Makros/Constants */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
#define TRACKWRAP 64
|
|
||||||
|
|
||||||
#define CHAPTER_MGR_DEBUG
|
#define CHAPTER_MGR_DEBUG
|
||||||
|
|
||||||
@@ -64,9 +64,7 @@ static const char FILENAME[] = __FILE__;
|
|||||||
/* Varaibles */
|
/* Varaibles */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static Track_t *Tracks = NULL;
|
static std::map<int,Track_t> Tracks;
|
||||||
static int TrackCount = 0;
|
|
||||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
@@ -78,101 +76,33 @@ static int CurrentTrack = 0; //TRACK[0] as default.
|
|||||||
|
|
||||||
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
||||||
{
|
{
|
||||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
Tracks[track.Id] = track;
|
||||||
|
|
||||||
if (Tracks == NULL) {
|
return cERR_CHAPTER_MGR_NO_ERROR;
|
||||||
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)))
|
static char **ManagerList(Context_t * context __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int i = 0, j = 0;
|
int j = 0;
|
||||||
char **tracklist = NULL;
|
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
|
||||||
|
|
||||||
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
|
{
|
||||||
if (Tracks != NULL) {
|
size_t len = it->second.Name.length() + 20;
|
||||||
|
char tmp[len];
|
||||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str());
|
||||||
|
tracklist[j] = strdup(tmp);
|
||||||
if (tracklist == NULL) {
|
tracklist[j + 1] = strdup(it->second.Encoding);
|
||||||
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;
|
tracklist[j] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
chapter_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
|
||||||
__FUNCTION__, tracklist, j, TrackCount);
|
|
||||||
|
|
||||||
return tracklist;
|
return tracklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ManagerDel(Context_t * context __attribute__((unused)))
|
static int ManagerDel(Context_t * context __attribute__((unused)))
|
||||||
{
|
{
|
||||||
int i = 0;
|
Tracks.clear();
|
||||||
|
return cERR_CHAPTER_MGR_NO_ERROR;
|
||||||
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)
|
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||||
@@ -183,12 +113,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MANAGER_ADD:{
|
case MANAGER_ADD:{
|
||||||
Track_t *track = argument;
|
Track_t *track = (Track_t *) argument;
|
||||||
ret = ManagerAdd(context, *track);
|
ret = ManagerAdd(context, *track);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_LIST:{
|
case MANAGER_LIST:{
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
*((char ***) argument) = (char **) ManagerList(context);
|
*((char ***) argument) = (char **) ManagerList(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -197,14 +127,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_INIT_UPDATE:{
|
case MANAGER_INIT_UPDATE:{
|
||||||
int i;
|
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
for (i = 0; i < TrackCount; i++)
|
it->second.pending = 1;
|
||||||
Tracks[i].pending = 1;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
chapter_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
|
chapter_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||||
__FUNCTION__, command);
|
|
||||||
ret = cERR_CHAPTER_MGR_ERROR;
|
ret = cERR_CHAPTER_MGR_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -63,16 +63,6 @@ void copyTrack(Track_t * to, Track_t * from)
|
|||||||
{
|
{
|
||||||
*to = *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)
|
if (from->language != NULL)
|
||||||
to->language = strdup(from->language);
|
to->language = strdup(from->language);
|
||||||
else
|
else
|
||||||
@@ -81,18 +71,6 @@ void copyTrack(Track_t * to, Track_t * from)
|
|||||||
|
|
||||||
void freeTrack(Track_t * track)
|
void freeTrack(Track_t * track)
|
||||||
{
|
{
|
||||||
if (track->Name != NULL)
|
|
||||||
free(track->Name);
|
|
||||||
|
|
||||||
if (track->Encoding != NULL)
|
|
||||||
free(track->Encoding);
|
|
||||||
|
|
||||||
if (track->language != NULL)
|
if (track->language != NULL)
|
||||||
free(track->language);
|
free(track->language);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (track->aacbuf != NULL)
|
|
||||||
free(track->aacbuf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Makros/Constants */
|
/* Makros/Constants */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
#define TRACKWRAP 20
|
|
||||||
|
|
||||||
#define SUBTITLE_MGR_DEBUG
|
#define SUBTITLE_MGR_DEBUG
|
||||||
|
|
||||||
@@ -64,9 +64,8 @@ static const char FILENAME[] = __FILE__;
|
|||||||
/* Varaibles */
|
/* Varaibles */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static Track_t *Tracks = NULL;
|
static std::map<int,Track_t> Tracks;
|
||||||
static int TrackCount = 0;
|
static int CurrentPid = -1;
|
||||||
static int CurrentTrack = -1; //no as default.
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
@@ -78,184 +77,85 @@ static int CurrentTrack = -1; //no as default.
|
|||||||
|
|
||||||
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
||||||
{
|
{
|
||||||
|
Tracks[track.Id] = track;
|
||||||
|
context->playback->isAudio = 1;
|
||||||
|
|
||||||
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__,
|
return cERR_SUBTITLE_MGR_NO_ERROR;
|
||||||
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", FILENAME, __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",
|
|
||||||
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
|
|
||||||
return cERR_SUBTITLE_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
|
||||||
|
|
||||||
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 j = 0;
|
||||||
int i = 0, j = 0;
|
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
|
||||||
|
|
||||||
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
|
{
|
||||||
if (Tracks != NULL) {
|
size_t len = it->second.Name.length() + 20;
|
||||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
char tmp[len];
|
||||||
|
snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str());
|
||||||
if (tracklist == NULL) {
|
tracklist[j] = strdup(tmp);
|
||||||
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME,
|
tracklist[j + 1] = strdup(it->second.Encoding);
|
||||||
__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\n", Tracks[i].Id, Tracks[i].Name);
|
|
||||||
tracklist[j] = strdup(tmp);
|
|
||||||
tracklist[j + 1] = strdup(Tracks[i].Encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
tracklist[j] = NULL;
|
tracklist[j] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
|
||||||
__FUNCTION__, tracklist, j, TrackCount);
|
|
||||||
|
|
||||||
return tracklist;
|
return tracklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ManagerDel(Context_t * context __attribute__((unused)))
|
static int ManagerDel(Context_t * context __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
Tracks.clear();
|
||||||
int i = 0;
|
CurrentPid = -1;
|
||||||
|
return cERR_SUBTITLE_MGR_NO_ERROR;
|
||||||
subtitle_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 {
|
|
||||||
subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
return cERR_SUBTITLE_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackCount = 0;
|
|
||||||
CurrentTrack = -1;
|
|
||||||
|
|
||||||
subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
|
|
||||||
return cERR_SUBTITLE_MGR_NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||||
{
|
{
|
||||||
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
|
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
|
||||||
|
|
||||||
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__,
|
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, command);
|
||||||
command);
|
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MANAGER_ADD:{
|
case MANAGER_ADD:{
|
||||||
Track_t *track = argument;
|
Track_t *track = (Track_t *) argument;
|
||||||
ret = ManagerAdd(context, *track);
|
ret = ManagerAdd(context, *track);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_LIST:{
|
case MANAGER_LIST:{
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
*((char ***) argument) = (char **) ManagerList(context);
|
*((char ***) argument) = (char **) ManagerList(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET:{
|
case MANAGER_GET:{
|
||||||
if (TrackCount > 0 && CurrentTrack >= 0)
|
*((int *) argument) = (int) CurrentPid;
|
||||||
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
|
|
||||||
else
|
|
||||||
*((int *) argument) = (int) -1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET_TRACK:{
|
case MANAGER_GET_TRACK:{
|
||||||
//subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
|
if (CurrentPid > -1)
|
||||||
|
*((Track_t **) argument) = &Tracks[CurrentPid];
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0)) {
|
else
|
||||||
subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack,
|
*((Track_t **) argument) = NULL;
|
||||||
&Tracks[CurrentTrack]);
|
|
||||||
*((Track_t **) argument) =
|
|
||||||
(Track_t *) & Tracks[CurrentTrack];
|
|
||||||
} else {
|
|
||||||
subtitle_mgr_printf(20, "return NULL\n");
|
|
||||||
*((Track_t **) argument) = NULL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GETENCODING:{
|
case MANAGER_GETENCODING:{
|
||||||
if (TrackCount > 0 && CurrentTrack >= 0)
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Encoding);
|
||||||
(char *) strdup(Tracks[CurrentTrack].Encoding);
|
else
|
||||||
else
|
*((char **) argument) = strdup("");
|
||||||
*((char **) argument) = (char *) strdup("");
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_GETNAME:{
|
case MANAGER_GETNAME:{
|
||||||
if (TrackCount > 0 && CurrentTrack >= 0)
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
|
||||||
(char *) strdup(Tracks[CurrentTrack].Name);
|
else
|
||||||
else
|
*((char **) argument) = strdup("");
|
||||||
*((char **) argument) = (char *) strdup("");
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_SET:{
|
case MANAGER_SET:{
|
||||||
int i;
|
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
|
||||||
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
|
if (it != Tracks.end())
|
||||||
__FUNCTION__, *((int *) argument));
|
CurrentPid = *((int *) argument);
|
||||||
|
else
|
||||||
if (*((int *) argument) < 0) {
|
ret = cERR_SUBTITLE_MGR_ERROR;
|
||||||
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", FILENAME,
|
|
||||||
__FUNCTION__, *((int *) argument));
|
|
||||||
ret = cERR_SUBTITLE_MGR_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_DEL:{
|
case MANAGER_DEL:{
|
||||||
@@ -263,21 +163,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_INIT_UPDATE:{
|
case MANAGER_INIT_UPDATE:{
|
||||||
int i;
|
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
for (i = 0; i < TrackCount; i++)
|
it->second.pending = 1;
|
||||||
if (!Tracks[i].is_static)
|
|
||||||
Tracks[i].pending = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME,
|
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, __FUNCTION__);
|
||||||
__FUNCTION__);
|
|
||||||
ret = cERR_SUBTITLE_MGR_ERROR;
|
ret = cERR_SUBTITLE_MGR_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME,
|
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
|
||||||
__FUNCTION__, ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -23,15 +23,14 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Makros/Constants */
|
/* Makros/Constants */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
#define TRACKWRAP 20
|
|
||||||
|
|
||||||
#define TELETEXT_MGR_DEBUG
|
#define TELETEXT_MGR_DEBUG
|
||||||
|
|
||||||
@@ -65,9 +64,8 @@ static const char FILENAME[] = __FILE__;
|
|||||||
/* Varaibles */
|
/* Varaibles */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static Track_t *Tracks = NULL;
|
static std::map<int,Track_t> Tracks;
|
||||||
static int TrackCount = 0;
|
static int CurrentPid = -1;
|
||||||
static int CurrentTrack = -1;
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
@@ -79,106 +77,35 @@ static int CurrentTrack = -1;
|
|||||||
|
|
||||||
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track)
|
||||||
{
|
{
|
||||||
|
Tracks[track.Id] = track;
|
||||||
|
context->playback->isAudio = 1;
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n",
|
return cERR_TELETEXT_MGR_NO_ERROR;
|
||||||
FILENAME, __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) {
|
|
||||||
teletext_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
|
|
||||||
return cERR_TELETEXT_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < TRACKWRAP; i++) {
|
|
||||||
if (Tracks[i].Id == track.Id) {
|
|
||||||
Tracks[i].pending = 0;
|
|
||||||
return cERR_TELETEXT_MGR_NO_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TrackCount < TRACKWRAP) {
|
|
||||||
copyTrack(&Tracks[TrackCount], &track);
|
|
||||||
TrackCount++;
|
|
||||||
} else {
|
|
||||||
teletext_mgr_err("%s:%s TrackCount out if range %d - %d\n",
|
|
||||||
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
|
|
||||||
return cERR_TELETEXT_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
|
||||||
|
|
||||||
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;
|
int j = 0;
|
||||||
char **tracklist = NULL;
|
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
|
{
|
||||||
if (Tracks != NULL) {
|
size_t len = it->second.Name.length() + 20;
|
||||||
|
char tmp[len];
|
||||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str());
|
||||||
|
tracklist[j] = strdup(tmp);
|
||||||
if (tracklist == NULL) {
|
tracklist[j + 1] = strdup(it->second.Encoding);
|
||||||
teletext_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;
|
|
||||||
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;
|
tracklist[j] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
|
||||||
__FUNCTION__, tracklist, j, TrackCount);
|
|
||||||
|
|
||||||
return tracklist;
|
return tracklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ManagerDel(Context_t * context __attribute__((unused)))
|
static int ManagerDel(Context_t * context __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
Tracks.clear();
|
||||||
int i = 0;
|
CurrentPid = -1;
|
||||||
|
return cERR_TELETEXT_MGR_NO_ERROR;
|
||||||
teletext_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 {
|
|
||||||
teletext_mgr_err("%s::%s nothing to delete!\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
return cERR_TELETEXT_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackCount = 0;
|
|
||||||
CurrentTrack = -1;
|
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s::%s return no error\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
|
|
||||||
return cERR_TELETEXT_MGR_NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -190,69 +117,46 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MANAGER_ADD:{
|
case MANAGER_ADD:{
|
||||||
Track_t *track = argument;
|
Track_t *track = (Track_t *) argument;
|
||||||
|
|
||||||
ret = ManagerAdd(context, *track);
|
ret = ManagerAdd(context, *track);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_LIST:{
|
case MANAGER_LIST:{
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
*((char ***) argument) = (char **) ManagerList(context);
|
*((char ***) argument) = (char **) ManagerList(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET:{
|
case MANAGER_GET:{
|
||||||
teletext_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME,
|
*((int *) argument) = (int) CurrentPid;
|
||||||
__FUNCTION__);
|
|
||||||
|
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
|
||||||
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
|
|
||||||
else
|
|
||||||
*((int *) argument) = (int) -1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET_TRACK:{
|
case MANAGER_GET_TRACK:{
|
||||||
teletext_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
|
if (CurrentPid > -1)
|
||||||
__FUNCTION__);
|
*((Track_t **) argument) = &Tracks[CurrentPid];
|
||||||
|
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
|
||||||
*((Track_t **) argument) =
|
|
||||||
(Track_t *) & Tracks[CurrentTrack];
|
|
||||||
else
|
else
|
||||||
*((Track_t **) argument) = NULL;
|
*((Track_t **) argument) = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GETENCODING:{
|
case MANAGER_GETENCODING:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Encoding);
|
||||||
(char *) strdup(Tracks[CurrentTrack].Encoding);
|
|
||||||
else
|
else
|
||||||
*((char **) argument) = (char *) strdup("");
|
*((char **) argument) = strdup("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GETNAME:{
|
case MANAGER_GETNAME:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
|
||||||
(char *) strdup(Tracks[CurrentTrack].Name);
|
else
|
||||||
else
|
*((char **) argument) = strdup("");
|
||||||
*((char **) argument) = (char *) strdup("");
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_SET:{
|
case MANAGER_SET:{
|
||||||
int i;
|
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
|
||||||
teletext_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
|
if (it != Tracks.end())
|
||||||
__FUNCTION__, *((int *) argument));
|
CurrentPid = *((int *) argument);
|
||||||
|
else
|
||||||
for (i = 0; i < TrackCount; i++)
|
|
||||||
if (Tracks[i].Id == *((int *) argument)) {
|
|
||||||
CurrentTrack = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == TrackCount) {
|
|
||||||
teletext_mgr_err("%s::%s track id %d unknown\n", FILENAME,
|
|
||||||
__FUNCTION__, *((int *) argument));
|
|
||||||
ret = cERR_TELETEXT_MGR_ERROR;
|
ret = cERR_TELETEXT_MGR_ERROR;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_DEL:{
|
case MANAGER_DEL:{
|
||||||
@@ -260,20 +164,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_INIT_UPDATE:{
|
case MANAGER_INIT_UPDATE:{
|
||||||
int i;
|
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
for (i = 0; i < TrackCount; i++)
|
it->second.pending = 1;
|
||||||
Tracks[i].pending = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n",
|
teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||||
FILENAME, __FUNCTION__, command);
|
|
||||||
ret = cERR_TELETEXT_MGR_ERROR;
|
ret = cERR_TELETEXT_MGR_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME,
|
teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
|
||||||
__FUNCTION__, ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Makros/Constants */
|
/* Makros/Constants */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
#define TRACKWRAP 4
|
|
||||||
|
|
||||||
#define VIDEO_MGR_DEBUG
|
#define VIDEO_MGR_DEBUG
|
||||||
|
|
||||||
@@ -64,9 +64,8 @@ static const char FILENAME[] = __FILE__;
|
|||||||
/* Varaibles */
|
/* Varaibles */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
|
|
||||||
static Track_t *Tracks = NULL;
|
static std::map<int,Track_t> Tracks;
|
||||||
static int TrackCount = 0;
|
static int CurrentPid = -1;
|
||||||
static int CurrentTrack = 0; //TRACK[0] as default.
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
@@ -78,106 +77,39 @@ static int CurrentTrack = 0; //TRACK[0] as default.
|
|||||||
|
|
||||||
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__);
|
Tracks[track.Id] = track;
|
||||||
|
|
||||||
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("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
|
|
||||||
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("%s:%s TrackCount out if range %d - %d\n", FILENAME,
|
|
||||||
__FUNCTION__, TrackCount, TRACKWRAP);
|
|
||||||
return cERR_VIDEO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TrackCount > 0)
|
|
||||||
context->playback->isVideo = 1;
|
context->playback->isVideo = 1;
|
||||||
|
|
||||||
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
if (CurrentPid < 0)
|
||||||
|
CurrentPid = track.Id;
|
||||||
|
|
||||||
return cERR_VIDEO_MGR_NO_ERROR;
|
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;
|
int j = 0;
|
||||||
char **tracklist = NULL;
|
char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1));
|
||||||
|
|
||||||
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
for(std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
|
{
|
||||||
if (Tracks != NULL) {
|
size_t len = it->second.Name.length() + 20;
|
||||||
|
char tmp[len];
|
||||||
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
|
snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str());
|
||||||
|
tracklist[j] = strdup(tmp);
|
||||||
if (tracklist == NULL) {
|
tracklist[j + 1] = strdup(it->second.Encoding);
|
||||||
video_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;
|
|
||||||
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;
|
tracklist[j] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
|
|
||||||
__FUNCTION__, tracklist, j, TrackCount);
|
|
||||||
|
|
||||||
return tracklist;
|
return tracklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ManagerDel(Context_t * context)
|
static int ManagerDel(Context_t * context)
|
||||||
{
|
{
|
||||||
int i = 0;
|
Tracks.clear();
|
||||||
|
CurrentPid = -1;
|
||||||
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
|
context->playback->isAudio = 0;
|
||||||
|
return cERR_VIDEO_MGR_NO_ERROR;
|
||||||
if (Tracks != NULL) {
|
|
||||||
for (i = 0; i < TrackCount; i++) {
|
|
||||||
freeTrack(&Tracks[i]);
|
|
||||||
}
|
|
||||||
free(Tracks);
|
|
||||||
Tracks = NULL;
|
|
||||||
} else {
|
|
||||||
video_mgr_err("%s::%s nothing to delete!\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
return cERR_VIDEO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackCount = 0;
|
|
||||||
CurrentTrack = 0;
|
|
||||||
context->playback->isVideo = 0;
|
|
||||||
|
|
||||||
video_mgr_printf(10, "%s::%s return no error\n", FILENAME,
|
|
||||||
__FUNCTION__);
|
|
||||||
|
|
||||||
return cERR_VIDEO_MGR_NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
||||||
@@ -188,63 +120,46 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MANAGER_ADD:{
|
case MANAGER_ADD:{
|
||||||
Track_t *track = argument;
|
Track_t *track = (Track_t *)argument;
|
||||||
ret = ManagerAdd(context, *track);
|
ret = ManagerAdd(context, *track);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_LIST:{
|
case MANAGER_LIST:{
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
*((char ***) argument) = (char **) ManagerList(context);
|
*((char ***) argument) = (char **) ManagerList(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GET:{
|
case MANAGER_GET:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
*((int *) argument) = (int) CurrentPid;
|
||||||
*((int *) argument) = (int) Tracks[CurrentTrack].Id;
|
break;
|
||||||
else
|
|
||||||
*((int *) argument) = (int) -1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case MANAGER_GET_TRACK:{
|
case MANAGER_GET_TRACK:{
|
||||||
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME,
|
if (CurrentPid > -1)
|
||||||
__FUNCTION__);
|
*((Track_t **) argument) = &Tracks[CurrentPid];
|
||||||
|
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
|
||||||
*((Track_t **) argument) =
|
|
||||||
(Track_t *) & Tracks[CurrentTrack];
|
|
||||||
else
|
else
|
||||||
*((Track_t **) argument) = NULL;
|
*((Track_t **) argument) = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GETENCODING:{
|
case MANAGER_GETENCODING:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Encoding);
|
||||||
(char *) strdup(Tracks[CurrentTrack].Encoding);
|
|
||||||
else
|
else
|
||||||
*((char **) argument) = (char *) strdup("");
|
*((char **) argument) = strdup("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_GETNAME:{
|
case MANAGER_GETNAME:{
|
||||||
if ((TrackCount > 0) && (CurrentTrack >= 0))
|
if (CurrentPid > -1)
|
||||||
*((char **) argument) =
|
*((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str());
|
||||||
(char *) strdup(Tracks[CurrentTrack].Name);
|
|
||||||
else
|
else
|
||||||
*((char **) argument) = (char *) strdup("");
|
*((char **) argument) = strdup("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_SET:{
|
case MANAGER_SET:{
|
||||||
int i;
|
std::map<int,Track_t>::iterator it = Tracks.find(*((int *) argument));
|
||||||
|
if (it != Tracks.end())
|
||||||
for (i = 0; i < TrackCount; i++)
|
CurrentPid = *((int *) argument);
|
||||||
if (Tracks[i].Id == *((int *) argument)) {
|
else
|
||||||
CurrentTrack = i;
|
ret = cERR_VIDEO_MGR_ERROR;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == TrackCount) {
|
|
||||||
video_mgr_err("%s::%s track id %d unknown\n", FILENAME,
|
|
||||||
__FUNCTION__, *((int *) argument));
|
|
||||||
ret = cERR_VIDEO_MGR_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_DEL:{
|
case MANAGER_DEL:{
|
||||||
@@ -252,20 +167,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MANAGER_INIT_UPDATE:{
|
case MANAGER_INIT_UPDATE:{
|
||||||
int i;
|
for (std::map<int,Track_t>::iterator it = Tracks.begin(); it != Tracks.end(); ++it)
|
||||||
for (i = 0; i < TrackCount; i++)
|
it->second.pending = 1;
|
||||||
Tracks[i].pending = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME,
|
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||||
__FUNCTION__, command);
|
|
||||||
ret = cERR_VIDEO_MGR_ERROR;
|
ret = cERR_VIDEO_MGR_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__,
|
video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
|
||||||
ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1040,7 +1040,7 @@ static int reset(Context_t * context)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
static int Command(Context_t *context, OutputCmd_t command, const char *argument)
|
||||||
{
|
{
|
||||||
int ret = cERR_LINUXDVB_NO_ERROR;
|
int ret = cERR_LINUXDVB_NO_ERROR;
|
||||||
|
|
||||||
@@ -1141,7 +1141,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *LinuxDvbCapabilities[] = { "audio", "video", NULL };
|
static const char *LinuxDvbCapabilities[] = { "audio", "video", NULL };
|
||||||
|
|
||||||
struct Output_s LinuxDvbOutput = {
|
struct Output_s LinuxDvbOutput = {
|
||||||
"LinuxDvb",
|
"LinuxDvb",
|
||||||
|
@@ -127,7 +127,7 @@ static void OutputDel(Context_t * context, char *port)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
static int Command(Context_t *context, OutputCmd_t command, const char *argument)
|
||||||
{
|
{
|
||||||
int ret = cERR_OUTPUT_NO_ERROR;
|
int ret = cERR_OUTPUT_NO_ERROR;
|
||||||
|
|
||||||
@@ -264,9 +264,9 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
|||||||
case OUTPUT_PTS:{
|
case OUTPUT_PTS:{
|
||||||
if (context && context->playback) {
|
if (context && context->playback) {
|
||||||
if (context->playback->isVideo)
|
if (context->playback->isVideo)
|
||||||
return context->output->video->Command(context, OUTPUT_PTS, argument);
|
return context->output->video->Command(context, OUTPUT_PTS, (const char *) argument);
|
||||||
if (context->playback->isAudio)
|
if (context->playback->isAudio)
|
||||||
return context->output->audio->Command(context, OUTPUT_PTS, argument);
|
return context->output->audio->Command(context, OUTPUT_PTS, (const char *) argument);
|
||||||
} else
|
} else
|
||||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -296,7 +296,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
|||||||
case OUTPUT_AUDIOMUTE:{
|
case OUTPUT_AUDIOMUTE:{
|
||||||
if (context && context->playback) {
|
if (context && context->playback) {
|
||||||
if (context->playback->isAudio)
|
if (context->playback->isAudio)
|
||||||
ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (char *) argument);
|
ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (const char *) argument);
|
||||||
} else
|
} else
|
||||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -304,7 +304,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
|||||||
case OUTPUT_DISCONTINUITY_REVERSE:{
|
case OUTPUT_DISCONTINUITY_REVERSE:{
|
||||||
if (context && context->playback) {
|
if (context && context->playback) {
|
||||||
if (context->playback->isVideo)
|
if (context->playback->isVideo)
|
||||||
ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (void *) argument);
|
ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (const char *) argument);
|
||||||
} else
|
} else
|
||||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -312,9 +312,9 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
|
|||||||
case OUTPUT_GET_FRAME_COUNT:{
|
case OUTPUT_GET_FRAME_COUNT:{
|
||||||
if (context && context->playback) {
|
if (context && context->playback) {
|
||||||
if (context->playback->isVideo)
|
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, (const char *)argument);
|
||||||
if (context->playback->isAudio)
|
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, (const char *)argument);
|
||||||
} else
|
} else
|
||||||
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
ret = cERR_OUTPUT_INTERNAL_ERROR;
|
||||||
break;
|
break;
|
||||||
|
@@ -163,7 +163,7 @@ static int writeData(WriterAVCallData_t *call)
|
|||||||
/*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
|
/*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
|
||||||
data is available. The content of this byte does not matter. It will be ignored
|
data is available. The content of this byte does not matter. It will be ignored
|
||||||
by the player */
|
by the player */
|
||||||
iov[ic].iov_base = "";
|
iov[ic].iov_base = (char *) "";
|
||||||
iov[ic++].iov_len = 1;
|
iov[ic++].iov_len = 1;
|
||||||
iov[0].iov_len =
|
iov[0].iov_len =
|
||||||
InsertPesHeader(PesHeader, PacketLength,
|
InsertPesHeader(PesHeader, PacketLength,
|
||||||
|
@@ -243,7 +243,7 @@ static int writeData(WriterAVCallData_t *call)
|
|||||||
insertSampleHeader = 0;
|
insertSampleHeader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketStart = malloc(call->len + HeaderLength);
|
PacketStart = (unsigned char *) malloc(call->len + HeaderLength);
|
||||||
memcpy(PacketStart, PesHeader, HeaderLength);
|
memcpy(PacketStart, PesHeader, HeaderLength);
|
||||||
memcpy(PacketStart + HeaderLength, call->data + Position,
|
memcpy(PacketStart + HeaderLength, call->data + Position,
|
||||||
PacketLength);
|
PacketLength);
|
||||||
|
@@ -71,8 +71,9 @@ static int PlaybackTerminate(Context_t * context);
|
|||||||
/* Supervisor Thread */
|
/* Supervisor Thread */
|
||||||
/* **************************** */
|
/* **************************** */
|
||||||
|
|
||||||
static void SupervisorThread(Context_t * context)
|
static void *SupervisorThread(void *arg)
|
||||||
{
|
{
|
||||||
|
Context_t *context = (Context_t *) arg;
|
||||||
hasThreadStarted = 1;
|
hasThreadStarted = 1;
|
||||||
|
|
||||||
playback_printf(10, ">\n");
|
playback_printf(10, ">\n");
|
||||||
@@ -88,6 +89,7 @@ static void SupervisorThread(Context_t * context)
|
|||||||
|
|
||||||
playback_printf(0, "terminating\n");
|
playback_printf(0, "terminating\n");
|
||||||
hasThreadStarted = 0;
|
hasThreadStarted = 0;
|
||||||
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
@@ -108,44 +110,32 @@ static int PlaybackOpen(Context_t * context, char *uri)
|
|||||||
return cERR_PLAYBACK_ERROR;
|
return cERR_PLAYBACK_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *extension = NULL;
|
|
||||||
|
|
||||||
context->playback->uri = strdup(uri);
|
|
||||||
|
|
||||||
context->playback->isHttp = 0;
|
context->playback->isHttp = 0;
|
||||||
|
|
||||||
if (!strncmp("file://", uri, 7) || !strncmp("myts://", uri, 7)) {
|
if (!strncmp("file://", uri, 7) || !strncmp("myts://", uri, 7)) {
|
||||||
if (!strncmp("myts://", uri, 7)) {
|
if (!strncmp("myts://", uri, 7)) {
|
||||||
memcpy(context->playback->uri, "file", 4);
|
context->playback->uri = "file";
|
||||||
|
context->playback->uri += (uri + 4);
|
||||||
context->playback->noprobe = 1;
|
context->playback->noprobe = 1;
|
||||||
} else
|
} else {
|
||||||
context->playback->noprobe = 0;
|
context->playback->noprobe = 0;
|
||||||
|
context->playback->uri = uri;
|
||||||
extension = getExtension(context->playback->uri + 7);
|
}
|
||||||
if (!extension)
|
|
||||||
return cERR_PLAYBACK_ERROR;
|
|
||||||
} else if (strstr(uri, "://")) {
|
} else if (strstr(uri, "://")) {
|
||||||
context->playback->isHttp = 1;
|
context->playback->isHttp = 1;
|
||||||
extension = "mp3";
|
|
||||||
if (!strncmp("mms://", uri, 6)) {
|
if (!strncmp("mms://", uri, 6)) {
|
||||||
// mms is in reality called rtsp, and ffmpeg expects this
|
context->playback->uri = "mmst";
|
||||||
char *tUri = (char *) malloc(strlen(uri) + 2);
|
context->playback->uri += (uri + 3);
|
||||||
strncpy(tUri + 1, uri, strlen(uri) + 1);
|
} else
|
||||||
strncpy(tUri, "mmst", 4);
|
context->playback->uri = uri;
|
||||||
free(context->playback->uri);
|
|
||||||
context->playback->uri = tUri;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
playback_err("Unknown stream (%s)\n", uri);
|
playback_err("Unknown stream (%s)\n", uri);
|
||||||
return cERR_PLAYBACK_ERROR;
|
return cERR_PLAYBACK_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((context->container->Command(context, CONTAINER_ADD, extension) <
|
if ((context->container->Command(context, CONTAINER_ADD, NULL) < 0)
|
||||||
0)
|
|
||||||
|| (!context->container->selectedContainer)
|
|| (!context->container->selectedContainer)
|
||||||
|| (context->container->
|
|| (context->container->selectedContainer->Command(context, CONTAINER_INIT, context->playback->uri.c_str()) < 0))
|
||||||
selectedContainer->Command(context, CONTAINER_INIT,
|
|
||||||
context->playback->uri) < 0))
|
|
||||||
return cERR_PLAYBACK_ERROR;
|
return cERR_PLAYBACK_ERROR;
|
||||||
|
|
||||||
playback_printf(10, "exiting with value 0\n");
|
playback_printf(10, "exiting with value 0\n");
|
||||||
@@ -175,10 +165,7 @@ static int PlaybackClose(Context_t * context)
|
|||||||
context->playback->BackWard = 0;
|
context->playback->BackWard = 0;
|
||||||
context->playback->SlowMotion = 0;
|
context->playback->SlowMotion = 0;
|
||||||
context->playback->Speed = 0;
|
context->playback->Speed = 0;
|
||||||
if (context->playback->uri) {
|
context->playback->uri.clear();
|
||||||
free(context->playback->uri);
|
|
||||||
context->playback->uri = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
playback_printf(10, "exiting with value %d\n", ret);
|
playback_printf(10, "exiting with value %d\n", ret);
|
||||||
|
|
||||||
@@ -222,9 +209,7 @@ static int PlaybackPlay(Context_t * context)
|
|||||||
PTHREAD_CREATE_DETACHED);
|
PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
if ((error =
|
if ((error =
|
||||||
pthread_create(&supervisorThread, &attr,
|
pthread_create(&supervisorThread, &attr, SupervisorThread, context)) != 0) {
|
||||||
(void *) &SupervisorThread,
|
|
||||||
context)) != 0) {
|
|
||||||
playback_printf(10,
|
playback_printf(10,
|
||||||
"Error creating thread, error:%d:%s\n",
|
"Error creating thread, error:%d:%s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
@@ -557,9 +542,9 @@ static int PlaybackSeek(Context_t * context, float *pos, int absolute)
|
|||||||
context->output->Command(context, OUTPUT_CLEAR, NULL);
|
context->output->Command(context, OUTPUT_CLEAR, NULL);
|
||||||
|
|
||||||
if (absolute)
|
if (absolute)
|
||||||
context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, pos);
|
context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, (const char *)pos);
|
||||||
else
|
else
|
||||||
context->container->selectedContainer->Command(context, CONTAINER_SEEK, pos);
|
context->container->selectedContainer->Command(context, CONTAINER_SEEK, (const char *)pos);
|
||||||
|
|
||||||
playback_printf(10, "exiting with value %d\n", ret);
|
playback_printf(10, "exiting with value %d\n", ret);
|
||||||
|
|
||||||
@@ -575,7 +560,7 @@ static int PlaybackPts(Context_t * context, unsigned long long int *pts)
|
|||||||
*pts = 0;
|
*pts = 0;
|
||||||
|
|
||||||
if (context->playback->isPlaying) {
|
if (context->playback->isPlaying) {
|
||||||
ret = context->output->Command(context, OUTPUT_PTS, pts);
|
ret = context->output->Command(context, OUTPUT_PTS, (const char *)pts);
|
||||||
} else {
|
} else {
|
||||||
playback_err("not possible\n");
|
playback_err("not possible\n");
|
||||||
ret = cERR_PLAYBACK_ERROR;
|
ret = cERR_PLAYBACK_ERROR;
|
||||||
@@ -598,7 +583,7 @@ static int PlaybackGetFrameCount(Context_t * context,
|
|||||||
if (context->playback->isPlaying) {
|
if (context->playback->isPlaying) {
|
||||||
ret =
|
ret =
|
||||||
context->output->Command(context, OUTPUT_GET_FRAME_COUNT,
|
context->output->Command(context, OUTPUT_GET_FRAME_COUNT,
|
||||||
frameCount);
|
(const char *)frameCount);
|
||||||
} else {
|
} else {
|
||||||
playback_err("not possible\n");
|
playback_err("not possible\n");
|
||||||
ret = cERR_PLAYBACK_ERROR;
|
ret = cERR_PLAYBACK_ERROR;
|
||||||
@@ -621,7 +606,7 @@ static int PlaybackLength(Context_t * context, double *length)
|
|||||||
if (context->container && context->container->selectedContainer)
|
if (context->container && context->container->selectedContainer)
|
||||||
context->container->selectedContainer->Command(context,
|
context->container->selectedContainer->Command(context,
|
||||||
CONTAINER_LENGTH,
|
CONTAINER_LENGTH,
|
||||||
length);
|
(const char *)length);
|
||||||
} else {
|
} else {
|
||||||
playback_err("not possible\n");
|
playback_err("not possible\n");
|
||||||
ret = cERR_PLAYBACK_ERROR;
|
ret = cERR_PLAYBACK_ERROR;
|
||||||
@@ -654,14 +639,11 @@ static int PlaybackSwitchAudio(Context_t * context, int *track)
|
|||||||
//PlaybackPause(context);
|
//PlaybackPause(context);
|
||||||
|
|
||||||
if (context->output && context->output->audio)
|
if (context->output && context->output->audio)
|
||||||
context->output->audio->Command(context, OUTPUT_SWITCH,
|
context->output->audio->Command(context, OUTPUT_SWITCH, "audio");
|
||||||
(void *) "audio");
|
|
||||||
|
|
||||||
if (context->container
|
if (context->container
|
||||||
&& context->container->selectedContainer)
|
&& context->container->selectedContainer)
|
||||||
context->container->selectedContainer->Command(context,
|
context->container->selectedContainer->Command(context, CONTAINER_SWITCH_AUDIO, (const char *)&nextrackid);
|
||||||
CONTAINER_SWITCH_AUDIO,
|
|
||||||
&nextrackid);
|
|
||||||
|
|
||||||
//PlaybackContinue(context);
|
//PlaybackContinue(context);
|
||||||
}
|
}
|
||||||
@@ -722,7 +704,7 @@ static int PlaybackSwitchTeletext(Context_t * context, int *pid)
|
|||||||
playback_err("no ttxsubtitle\n");
|
playback_err("no ttxsubtitle\n");
|
||||||
|
|
||||||
if (*pid < 0)
|
if (*pid < 0)
|
||||||
container_ffmpeg_update_tracks(context, context->playback->uri);
|
container_ffmpeg_update_tracks(context, context->playback->uri.c_str());
|
||||||
|
|
||||||
playback_printf(10, "exiting with value %d\n", ret);
|
playback_printf(10, "exiting with value %d\n", ret);
|
||||||
|
|
||||||
@@ -736,7 +718,7 @@ static int PlaybackMetadata(Context_t * context, char ***metadata)
|
|||||||
if (context->container && context->container->selectedContainer)
|
if (context->container && context->container->selectedContainer)
|
||||||
context->container->selectedContainer->Command(context,
|
context->container->selectedContainer->Command(context,
|
||||||
CONTAINER_METADATA,
|
CONTAINER_METADATA,
|
||||||
metadata);
|
(const char *)metadata);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,8 +64,8 @@ bool cPlayback::Open(playmode_t PlayMode)
|
|||||||
|
|
||||||
//Registration of output devices
|
//Registration of output devices
|
||||||
if(player && player->output) {
|
if(player && player->output) {
|
||||||
player->output->Command(player,OUTPUT_ADD, (void*)"audio");
|
player->output->Command(player,OUTPUT_ADD, "audio");
|
||||||
player->output->Command(player,OUTPUT_ADD, (void*)"video");
|
player->output->Command(player,OUTPUT_ADD, "video");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -246,8 +246,8 @@ bool cPlayback::Stop(void)
|
|||||||
player->output->Command(player, OUTPUT_CLOSE, NULL);
|
player->output->Command(player, OUTPUT_CLOSE, NULL);
|
||||||
|
|
||||||
if(player && player->output) {
|
if(player && player->output) {
|
||||||
player->output->Command(player,OUTPUT_DEL, (void*)"audio");
|
player->output->Command(player,OUTPUT_DEL, "audio");
|
||||||
player->output->Command(player,OUTPUT_DEL, (void*)"video");
|
player->output->Command(player,OUTPUT_DEL, "video");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player && player->playback)
|
if(player && player->playback)
|
||||||
|
Reference in New Issue
Block a user