libeplayer3-arm: cleanup types, use Context_t in commands

This commit is contained in:
max_10
2018-03-07 23:59:23 +01:00
committed by Thilo Graf
parent 71905680a6
commit cb275626b1
32 changed files with 195 additions and 183 deletions

View File

@@ -98,9 +98,8 @@ static int32_t selectContainer(Context_t *context, char *extension)
return ret; return ret;
} }
static int Command(void *_context, ContainerCmd_t command, void *argument) static int Command(Context_t *context, ContainerCmd_t command, void *argument __attribute__((unused)))
{ {
Context_t *context = (Context_t *) _context;
int ret = 0; int ret = 0;
container_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); container_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);

View File

@@ -42,12 +42,6 @@
#include <pthread.h> #include <pthread.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <libavutil/avutil.h>
#include <libavutil/time.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libavutil/opt.h>
#include <ffmpeg/mpeg4audio.h> #include <ffmpeg/mpeg4audio.h>
#include "common.h" #include "common.h"
@@ -56,10 +50,12 @@
#include "aac.h" #include "aac.h"
#include "pcm.h" #include "pcm.h"
#include "ffmpeg_metadata.h" #include "ffmpeg_metadata.h"
/* ***************************** */ /* ***************************** */
/* Makros/Constants */ /* Makros/Constants */
/* ***************************** */ /* ***************************** */
#if (LIBAVFORMAT_VERSION_MAJOR > 57)
#if (LIBAVFORMAT_VERSION_MAJOR > 56)
#define TS_BYTES_SEEKING 0 #define TS_BYTES_SEEKING 0
#else #else
#define TS_BYTES_SEEKING 1 #define TS_BYTES_SEEKING 1
@@ -1302,7 +1298,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int
void *opaque = NULL; void *opaque = NULL;
const char *protoName = NULL; const char *protoName = NULL;
uint8_t haveNativeProto = 0; uint8_t haveNativeProto = 0;
while (protoName = avio_enum_protocols(&opaque, 1)) while ((protoName = avio_enum_protocols(&opaque, 1)))
{ {
if (0 == strcmp("rtmp", protoName)) if (0 == strcmp("rtmp", protoName))
{ {
@@ -2581,12 +2577,14 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
size_t psize = 1; size_t psize = 1;
char **pp; char **pp;
if (!context) { if (!context)
{
fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__); fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__);
return cERR_CONTAINER_FFMPEG_ERR; return cERR_CONTAINER_FFMPEG_ERR;
} }
if (!p || *p) { if (!p || *p)
{
fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__); fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__);
return cERR_CONTAINER_FFMPEG_ERR; return cERR_CONTAINER_FFMPEG_ERR;
} }
@@ -2602,28 +2600,34 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata); psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata);
*p = malloc(sizeof(char *) * psize * 2); *p = 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;
} }
pp = *p; pp = *p;
if (avContextTab[0]->metadata) if (avContextTab[0]->metadata)
while ((tag = av_dict_get(avContextTab[0]->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { while ((tag = av_dict_get(avContextTab[0]->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
*pp++ = strdup(tag->key); *pp++ = strdup(tag->key);
*pp++ = strdup(tag->value); *pp++ = strdup(tag->value);
} }
if (videoTrack) { if (videoTrack)
{
tag = NULL; tag = NULL;
while ((tag = av_dict_get(((AVStream *)(videoTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { while ((tag = av_dict_get(((AVStream *)(videoTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
*pp++ = strdup(tag->key); *pp++ = strdup(tag->key);
*pp++ = strdup(tag->value); *pp++ = strdup(tag->value);
} }
} }
if (audioTrack) { if (audioTrack)
{
tag = NULL; tag = NULL;
while ((tag = av_dict_get(((AVStream *)(audioTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { while ((tag = av_dict_get(((AVStream *)(audioTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
*pp++ = strdup(tag->key); *pp++ = strdup(tag->key);
*pp++ = strdup(tag->value); *pp++ = strdup(tag->value);
} }
@@ -2634,9 +2638,8 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
return cERR_CONTAINER_FFMPEG_NO_ERROR; return cERR_CONTAINER_FFMPEG_NO_ERROR;
} }
static int32_t Command(void *_context, ContainerCmd_t command, void *argument) static int32_t Command(Context_t *context, ContainerCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_CONTAINER_FFMPEG_NO_ERROR; int ret = cERR_CONTAINER_FFMPEG_NO_ERROR;
ffmpeg_printf(50, "Command %d\n", command); ffmpeg_printf(50, "Command %d\n", command);
if (command != CONTAINER_SET_BUFFER_SEEK_TIME && if (command != CONTAINER_SET_BUFFER_SEEK_TIME &&

View File

@@ -28,10 +28,13 @@ typedef enum
CONTAINER_GET_METADATA CONTAINER_GET_METADATA
} ContainerCmd_t; } ContainerCmd_t;
struct Context_s;
typedef struct Context_s Context_t;
typedef struct Container_s typedef struct Container_s
{ {
char *Name; char *Name;
int (* Command)(/*Context_t*/void *, ContainerCmd_t, void *); int (* Command)(Context_t *, ContainerCmd_t, void *);
char **Capabilities; char **Capabilities;
} Container_t; } Container_t;
@@ -43,7 +46,7 @@ typedef struct ContainerHandler_s
char *Name; char *Name;
Container_t *selectedContainer; Container_t *selectedContainer;
int (* Command)(/*Context_t*/void *, ContainerCmd_t, void *); int (* Command)(Context_t *, ContainerCmd_t, void *);
} ContainerHandler_t; } ContainerHandler_t;
#endif #endif

View File

@@ -4,6 +4,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <libavutil/avutil.h>
#include <libavutil/time.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libavutil/opt.h>
typedef enum typedef enum
{ {
MANAGER_ADD, MANAGER_ADD,
@@ -54,11 +60,11 @@ typedef struct Track_s
int32_t aspect_ratio_den; int32_t aspect_ratio_den;
/* stream from ffmpeg */ /* stream from ffmpeg */
void *stream; AVStream *stream;
/* AVCodecContext for steam */ /* AVCodecContext for steam */
void *avCodecCtx; void *avCodecCtx;
/* codec extra data (header or some other stuff) */ /* codec extra data (header or some other stuff) */
void *extraData; uint8_t *extraData;
int extraSize; int extraSize;
uint8_t *aacbuf; uint8_t *aacbuf;
@@ -88,10 +94,13 @@ typedef struct TrackDescription_s
int progressive; int progressive;
} TrackDescription_t; } TrackDescription_t;
struct Context_s;
typedef struct Context_s Context_t;
typedef struct Manager_s typedef struct Manager_s
{ {
char *Name; char *Name;
int (* Command)(/*Context_t*/void *, ManagerCmd_t, void *); int (* Command)(Context_t *, ManagerCmd_t, void *);
char **Capabilities; char **Capabilities;
} Manager_t; } Manager_t;

View File

@@ -64,11 +64,14 @@ typedef struct
char *type; char *type;
} SubtitleOut_t; } SubtitleOut_t;
struct Context_s;
typedef struct Context_s Context_t;
typedef struct Output_s typedef struct Output_s
{ {
char *Name; char *Name;
int32_t (* Command)(/*Context_t*/void *, OutputCmd_t, void *); int32_t (* Command)(Context_t *, OutputCmd_t, void *);
int32_t (* Write)(/*Context_t*/void *, void *privateData); int32_t (* Write)(Context_t *, void *privateData);
char **Capabilities; char **Capabilities;
} Output_t; } Output_t;
@@ -81,7 +84,7 @@ typedef struct OutputHandler_s
Output_t *audio; Output_t *audio;
Output_t *video; Output_t *video;
Output_t *subtitle; Output_t *subtitle;
int32_t (* Command)(/*Context_t*/void *, OutputCmd_t, void *); int32_t (* Command)(Context_t *, OutputCmd_t, void *);
} OutputHandler_t; } OutputHandler_t;
#endif #endif

View File

@@ -26,6 +26,9 @@ typedef enum {
PLAYBACK_METADATA PLAYBACK_METADATA
} PlaybackCmd_t; } PlaybackCmd_t;
struct Context_s;
typedef struct Context_s Context_t;
typedef struct PlaybackHandler_s typedef struct PlaybackHandler_s
{ {
char *Name; char *Name;
@@ -51,7 +54,7 @@ typedef struct PlaybackHandler_s
uint8_t isSubtitle; uint8_t isSubtitle;
uint8_t abortRequested; uint8_t abortRequested;
int32_t (* Command)(/*Context_t*/void *, PlaybackCmd_t, void *); int32_t (* Command)(Context_t *, PlaybackCmd_t, void *);
char *uri; char *uri;
off_t size; off_t size;
uint8_t noprobe; /* hack: only minimal probing in av_find_stream_info */ uint8_t noprobe; /* hack: only minimal probing in av_find_stream_info */

View File

@@ -10,11 +10,11 @@ typedef enum { eNone, eAudio, eVideo} eWriterType_t;
typedef struct typedef struct
{ {
int fd; int fd;
unsigned char *data; uint8_t *data;
unsigned int len; unsigned int len;
unsigned long long int Pts; uint64_t Pts;
unsigned long long int Dts; unsigned long long int Dts;
unsigned char *private_data; uint8_t *private_data;
unsigned int private_size; unsigned int private_size;
unsigned int FrameRate; unsigned int FrameRate;
unsigned int FrameScale; unsigned int FrameScale;
@@ -38,7 +38,7 @@ typedef struct WriterCaps_s
typedef struct Writer_s typedef struct Writer_s
{ {
int (* reset)(); int (* reset)();
int (* writeData)(void *); int (* writeData)(WriterAVCallData_t *);
WriterCaps_t *caps; WriterCaps_t *caps;
} Writer_t; } Writer_t;

View File

@@ -71,7 +71,7 @@ if (debug_level >= level) printf("[%s:%s] \n" fmt, __FILE__, __FUNCTION__, ## x)
static Track_t *Tracks = NULL; static Track_t *Tracks = NULL;
static int TrackCount = 0; static int TrackCount = 0;
static int CurrentTrack = 0; //TRACK[0] as default. static int CurrentTrack = 0; //TRACK[0] as default.
/* ***************************** */ /* ***************************** */
/* Prototypes */ /* Prototypes */
@@ -212,9 +212,8 @@ static int ManagerDel(Context_t *context)
return cERR_AUDIO_MGR_NO_ERROR; return cERR_AUDIO_MGR_NO_ERROR;
} }
static int Command(void *_context, ManagerCmd_t command, void *argument) static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_AUDIO_MGR_NO_ERROR; int ret = cERR_AUDIO_MGR_NO_ERROR;
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
switch (command) switch (command)
@@ -228,7 +227,8 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
case MANAGER_LIST: case MANAGER_LIST:
{ {
container_ffmpeg_update_tracks(context, context->playback->uri, 0); container_ffmpeg_update_tracks(context, context->playback->uri, 0);
*((TrackDescription_t **)argument) = ManagerList(context); // *((TrackDescription_t **)argument) = ManagerList(context);
*((char ** *) argument) = (char **) ManagerList(context);
break; break;
} }
case MANAGER_GET: case MANAGER_GET:
@@ -269,7 +269,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__); audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0)) if ((TrackCount > 0) && (CurrentTrack >= 0))
{ {
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack]; *((Track_t **)argument) = (Track_t *) & Tracks[CurrentTrack];
} }
else else
{ {

View File

@@ -66,7 +66,7 @@ static const char FILENAME[] = __FILE__;
static Track_t *Tracks = NULL; static Track_t *Tracks = NULL;
static int TrackCount = 0; static int TrackCount = 0;
static int CurrentTrack = 0; //TRACK[0] as default. static int CurrentTrack = 0; //TRACK[0] as default.
/* ***************************** */ /* ***************************** */
/* Prototypes */ /* Prototypes */
@@ -76,7 +76,7 @@ static int CurrentTrack = 0; //TRACK[0] as default.
/* Functions */ /* Functions */
/* ***************************** */ /* ***************************** */
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__); chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
@@ -121,7 +121,7 @@ static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track
return cERR_CHAPTER_MGR_NO_ERROR; 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 i = 0, j = 0;
char **tracklist = NULL; char **tracklist = NULL;
@@ -157,7 +157,7 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
return tracklist; return tracklist;
} }
static int ManagerDel(Context_t * context __attribute__((unused))) static int ManagerDel(Context_t *context __attribute__((unused)))
{ {
int i = 0; int i = 0;

View File

@@ -69,7 +69,7 @@ if (debug_level >= level) printf(x); } while (0)
static Track_t *Tracks = NULL; static Track_t *Tracks = NULL;
static int TrackCount = 0; static int TrackCount = 0;
static int CurrentTrack = -1; //no as default. static int CurrentTrack = -1; //no as default.
/* ***************************** */ /* ***************************** */
/* Prototypes */ /* Prototypes */
@@ -256,7 +256,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
if ((TrackCount > 0) && (CurrentTrack >= 0)) if ((TrackCount > 0) && (CurrentTrack >= 0))
{ {
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack]; *((Track_t **)argument) = (Track_t *) & Tracks[CurrentTrack];
} }
else else
{ {

View File

@@ -69,7 +69,7 @@ if (debug_level >= level) printf(x); } while (0)
static Track_t *Tracks = NULL; static Track_t *Tracks = NULL;
static int TrackCount = 0; static int TrackCount = 0;
static int CurrentTrack = 0; //TRACK[0] as default. static int CurrentTrack = 0; //TRACK[0] as default.
static void (* updatedTrackInfoFnc)(void) = NULL; static void (* updatedTrackInfoFnc)(void) = NULL;
@@ -181,9 +181,8 @@ static int ManagerDel(Context_t *context)
return cERR_VIDEO_MGR_NO_ERROR; return cERR_VIDEO_MGR_NO_ERROR;
} }
static int Command(void *_context, ManagerCmd_t command, void *argument) static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_VIDEO_MGR_NO_ERROR; int ret = cERR_VIDEO_MGR_NO_ERROR;
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
switch (command) switch (command)
@@ -243,7 +242,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__); video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0)) if ((TrackCount > 0) && (CurrentTrack >= 0))
{ {
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack]; *((Track_t **)argument) = (Track_t *) & Tracks[CurrentTrack];
} }
else else
{ {

View File

@@ -228,9 +228,9 @@ int LinuxDvbPlay(Context_t *context, char *type)
/* /*
if (0 != ioctl(videofd, VIDEO_STOP)) if (0 != ioctl(videofd, VIDEO_STOP))
{ {
linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("ioctl failed with errno %d\n", errno);
linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno)); linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno));
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
*/ */
if (writer == NULL) if (writer == NULL)
@@ -276,9 +276,9 @@ int LinuxDvbPlay(Context_t *context, char *type)
/* /*
if (0 != ioctl(audiofd, AUDIO_STOP)) if (0 != ioctl(audiofd, AUDIO_STOP))
{ {
linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("ioctl failed with errno %d\n", errno);
linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno)); linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno));
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
*/ */
if (writer == NULL) if (writer == NULL)
@@ -347,11 +347,13 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type)
linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno)); linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno));
} }
/* set back to normal speed (end trickmodes) */ /* set back to normal speed (end trickmodes) */
// if (ioctl(audiofd, AUDIO_SET_SPEED, DVB_SPEED_NORMAL_PLAY) == -1) /*
// { if (ioctl(audiofd, AUDIO_SET_SPEED, DVB_SPEED_NORMAL_PLAY) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// } linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno));
}
*/
if (ioctl(audiofd, AUDIO_STOP) == -1) if (ioctl(audiofd, AUDIO_STOP) == -1)
{ {
linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("ioctl failed with errno %d\n", errno);
@@ -428,14 +430,16 @@ int LinuxDvbContinue(Context_t *context __attribute__((unused)), char *type)
int LinuxDvbReverseDiscontinuity(Context_t *context __attribute__((unused)), int *surplus __attribute__((unused))) int LinuxDvbReverseDiscontinuity(Context_t *context __attribute__((unused)), int *surplus __attribute__((unused)))
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
// int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus; /*
// linuxdvb_printf(50, "\n"); int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus;
// if (ioctl(videofd, VIDEO_DISCONTINUITY, (void*) dis_type) == -1) linuxdvb_printf(50, "\n");
// { if (ioctl(videofd, VIDEO_DISCONTINUITY, (void *) dis_type) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("VIDEO_DISCONTINUITY: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// } linuxdvb_err("VIDEO_DISCONTINUITY: %s\n", strerror(errno));
// linuxdvb_printf(50, "exiting\n"); }
linuxdvb_printf(50, "exiting\n");
*/
return ret; return ret;
} }
@@ -476,28 +480,33 @@ int LinuxDvbAudioMute(Context_t *context __attribute__((unused)), char *flag)
int LinuxDvbFlush(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) int LinuxDvbFlush(Context_t *context __attribute__((unused)), char *type __attribute__((unused)))
{ {
// unsigned char video = !strcmp("video", type); /*
// unsigned char audio = !strcmp("audio", type); unsigned char video = !strcmp("video", type);
// linuxdvb_printf(10, "v%d a%d\n", video, audio); unsigned char audio = !strcmp("audio", type);
// if ((video && videofd != -1) || (audio && audiofd != -1)) { linuxdvb_printf(10, "v%d a%d\n", video, audio);
// getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); if ((video && videofd != -1) || (audio && audiofd != -1))
// if (video && videofd != -1) { {
// if (ioctl(videofd, VIDEO_FLUSH, NULL) == -1) getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
// { if (video && videofd != -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("VIDEO_FLUSH: %s\n", strerror(errno)); if (ioctl(videofd, VIDEO_FLUSH, NULL) == -1)
// } {
// } linuxdvb_err("ioctl failed with errno %d\n", errno);
// if (audio && audiofd != -1) { linuxdvb_err("VIDEO_FLUSH: %s\n", strerror(errno));
// if (ioctl(audiofd, AUDIO_FLUSH, NULL) == -1) }
// { }
// linuxdvb_err("ioctl failed with errno %d\n", errno); if (audio && audiofd != -1)
// linuxdvb_err("AUDIO_FLUSH: %s\n", strerror(errno)); {
// } if (ioctl(audiofd, AUDIO_FLUSH, NULL) == -1)
// } {
// releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); linuxdvb_err("ioctl failed with errno %d\n", errno);
// } linuxdvb_err("AUDIO_FLUSH: %s\n", strerror(errno));
// linuxdvb_printf(10, "exiting\n"); }
}
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
}
linuxdvb_printf(10, "exiting\n");
*/
return cERR_LINUXDVB_NO_ERROR; return cERR_LINUXDVB_NO_ERROR;
} }
@@ -546,12 +555,14 @@ int LinuxDvbFastForward(Context_t *context, char *type)
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int));
linuxdvb_printf(1, "speedIndex %d\n", speedIndex); linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
// if (ioctl(videofd, VIDEO_SET_SPEED, SpeedList[speedIndex]) == -1) /*
// { if (ioctl(videofd, VIDEO_SET_SPEED, SpeedList[speedIndex]) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("VIDEO_SET_SPEED: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// ret = cERR_LINUXDVB_ERROR; linuxdvb_err("VIDEO_SET_SPEED: %s\n", strerror(errno));
// } ret = cERR_LINUXDVB_ERROR;
}
*/
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
} }
if (audio && audiofd != -1) if (audio && audiofd != -1)
@@ -559,12 +570,14 @@ int LinuxDvbFastForward(Context_t *context, char *type)
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int));
linuxdvb_printf(1, "speedIndex %d\n", speedIndex); linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
// if (ioctl(audiofd, AUDIO_SET_SPEED, SpeedList[speedIndex]) == -1) /*
// { if (ioctl(audiofd, AUDIO_SET_SPEED, SpeedList[speedIndex]) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// ret = cERR_LINUXDVB_ERROR; linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno));
// } ret = cERR_LINUXDVB_ERROR;
}
*/
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
} }
linuxdvb_printf(10, "exiting with value %d\n", ret); linuxdvb_printf(10, "exiting with value %d\n", ret);
@@ -728,11 +741,13 @@ int LinuxDvbSwitch(Context_t *context, char *type)
if (writer == NULL) if (writer == NULL)
{ {
linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding);
// if (ioctl(audiofd, AUDIO_SET_BYPASS_MODE, (void*) AUDIO_ENCODING_MP3) == -1) /*
// { if (ioctl(audiofd, AUDIO_SET_BYPASS_MODE, (void *) AUDIO_ENCODING_MP3) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// } linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno));
}
*/
} }
else else
{ {
@@ -776,11 +791,13 @@ int LinuxDvbSwitch(Context_t *context, char *type)
if (writer == NULL) if (writer == NULL)
{ {
linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding);
// if (ioctl(videofd, VIDEO_SET_STREAMTYPE, (void*) VIDEO_ENCODING_AUTO) == -1) /*
// { if (ioctl(videofd, VIDEO_SET_STREAMTYPE, (void *) VIDEO_ENCODING_AUTO) == -1)
// linuxdvb_err("ioctl failed with errno %d\n", errno); {
// linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno)); linuxdvb_err("ioctl failed with errno %d\n", errno);
// } linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno));
}
*/
} }
else else
{ {
@@ -812,15 +829,14 @@ int LinuxDvbSwitch(Context_t *context, char *type)
return cERR_LINUXDVB_NO_ERROR; return cERR_LINUXDVB_NO_ERROR;
} }
static int Write(void *_context, void *_out) static int Write(Context_t *context, void *_out)
{ {
Context_t *context = (Context_t *) _context; AudioVideoOut_t *out = (AudioVideoOut_t *) _out;
AudioVideoOut_t *out = (AudioVideoOut_t *) _out; int ret = cERR_LINUXDVB_NO_ERROR;
int ret = cERR_LINUXDVB_NO_ERROR; int res = 0;
int res = 0; unsigned char video = 0;
unsigned char video = 0; unsigned char audio = 0;
unsigned char audio = 0; Writer_t *writer;
Writer_t *writer;
WriterAVCallData_t call; WriterAVCallData_t call;
if (out == NULL) if (out == NULL)
{ {
@@ -905,7 +921,7 @@ static int Write(void *_context, void *_out)
call.Width = out->width; call.Width = out->width;
call.Height = out->height; call.Height = out->height;
call.InfoFlags = out->infoFlags; call.InfoFlags = out->infoFlags;
call.Version = 0; // is unsingned char call.Version = 0; // is unsingned char
if (writer->writeData) if (writer->writeData)
{ {
res = writer->writeData(&call); res = writer->writeData(&call);
@@ -947,7 +963,7 @@ static int Write(void *_context, void *_out)
call.FrameRate = out->frameRate; call.FrameRate = out->frameRate;
call.FrameScale = out->timeScale; call.FrameScale = out->timeScale;
call.InfoFlags = out->infoFlags; call.InfoFlags = out->infoFlags;
call.Version = 0; /* -1; unsigned char cannot be negative */ call.Version = 0; /* -1; unsigned char cannot be negative */
if (writer->writeData) if (writer->writeData)
{ {
res = writer->writeData(&call); res = writer->writeData(&call);
@@ -996,9 +1012,8 @@ static int reset(Context_t *context)
return ret; return ret;
} }
static int Command(void *_context, OutputCmd_t command, void *argument) static int Command(Context_t *context, OutputCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
linuxdvb_printf(50, "Command %d\n", command); linuxdvb_printf(50, "Command %d\n", command);
switch (command) switch (command)

View File

@@ -147,9 +147,8 @@ static void OutputDel(Context_t *context, char *port)
} }
} }
static int Command(void *_context, OutputCmd_t command, void *argument) static int Command(Context_t *context, OutputCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_OUTPUT_NO_ERROR; int ret = cERR_OUTPUT_NO_ERROR;
output_printf(10, "%s::%s Command %d\n", __FILE__, __FUNCTION__, command); output_printf(10, "%s::%s Command %d\n", __FILE__, __FUNCTION__, command);
switch (command) switch (command)

View File

@@ -188,9 +188,8 @@ static int Flush()
return cERR_SUBTITLE_NO_ERROR; return cERR_SUBTITLE_NO_ERROR;
} }
static int Write(void *_context, void *data) static int Write(Context_t *context, void *data)
{ {
Context_t *context = (Context_t *)_context;
char *Encoding = NULL; char *Encoding = NULL;
SubtitleOut_t *out = NULL; SubtitleOut_t *out = NULL;
int32_t curtrackid = -1; int32_t curtrackid = -1;
@@ -257,9 +256,8 @@ static int32_t subtitle_Close(Context_t *context __attribute__((unused)))
return cERR_SUBTITLE_NO_ERROR; return cERR_SUBTITLE_NO_ERROR;
} }
static int Command(void *_context, OutputCmd_t command, void *argument __attribute__((unused))) static int Command(Context_t *context, OutputCmd_t command, void *argument __attribute__((unused)))
{ {
Context_t *context = (Context_t *) _context;
int ret = cERR_SUBTITLE_NO_ERROR; int ret = cERR_SUBTITLE_NO_ERROR;
subtitle_printf(50, "%d\n", command); subtitle_printf(50, "%d\n", command);
switch (command) switch (command)

View File

@@ -156,9 +156,8 @@ static int reset()
return 0; return 0;
} }
static int _writeData(void *_call, int type) static int _writeData(WriterAVCallData_t *call, int type)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
aac_printf(10, "\n _writeData type[%d]\n", type); aac_printf(10, "\n _writeData type[%d]\n", type);
if (call == NULL) if (call == NULL)
{ {
@@ -199,9 +198,8 @@ static int _writeData(void *_call, int type)
return writev_with_retry(call->fd, iov, 2); return writev_with_retry(call->fd, iov, 2);
} }
static int writeDataADTS(void *_call) static int writeDataADTS(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
aac_printf(10, "\n"); aac_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {
@@ -221,7 +219,7 @@ static int writeDataADTS(void *_call)
if ((call->private_data && 0 == strncmp("ADTS", (const char *)call->private_data, call->private_size)) || if ((call->private_data && 0 == strncmp("ADTS", (const char *)call->private_data, call->private_size)) ||
HasADTSHeader(call->data, call->len)) HasADTSHeader(call->data, call->len))
{ {
return _writeData(_call, 0); return _writeData(call, 0);
} }
uint32_t PacketLength = call->len + AAC_HEADER_LENGTH; uint32_t PacketLength = call->len + AAC_HEADER_LENGTH;
uint8_t PesHeader[PES_MAX_HEADER_SIZE + AAC_HEADER_LENGTH]; uint8_t PesHeader[PES_MAX_HEADER_SIZE + AAC_HEADER_LENGTH];
@@ -258,9 +256,8 @@ static int writeDataADTS(void *_call)
return writev_with_retry(call->fd, iov, 2); return writev_with_retry(call->fd, iov, 2);
} }
static int writeDataLATM(void *_call) static int writeDataLATM(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
aac_printf(10, "\n"); aac_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {
@@ -274,7 +271,7 @@ static int writeDataLATM(void *_call)
} }
if (call->private_data && 0 == strncmp("LATM", (const char *)call->private_data, call->private_size)) if (call->private_data && 0 == strncmp("LATM", (const char *)call->private_data, call->private_size))
{ {
return _writeData(_call, 1); return _writeData(call, 1);
} }
aac_printf(10, "AudioPts %lld\n", call->Pts); aac_printf(10, "AudioPts %lld\n", call->Pts);
if (!pLATMCtx) if (!pLATMCtx)

View File

@@ -95,9 +95,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
ac3_printf(10, "\n"); ac3_printf(10, "\n");
unsigned char PesHeader[PES_MAX_HEADER_SIZE]; unsigned char PesHeader[PES_MAX_HEADER_SIZE];
if (call == NULL) if (call == NULL)

View File

@@ -96,10 +96,9 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call; unsigned char PesHeader[PES_MAX_HEADER_SIZE + 4 + 9];
unsigned char PesHeader[PES_MAX_HEADER_SIZE + 4 + 9];
amr_printf(10, "\n"); amr_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {

View File

@@ -113,12 +113,11 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call; unsigned char PesHeader[PES_MAX_HEADER_SIZE + 4];
unsigned char PesHeader[PES_MAX_HEADER_SIZE + 4]; // unsigned char Version = 5;
// unsigned char Version = 5; // unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
// unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
divx_printf(10, "\n"); divx_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {

View File

@@ -100,9 +100,8 @@ static int32_t reset()
return 0; return 0;
} }
static int32_t writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
uint8_t PesHeader[PES_AUDIO_HEADER_SIZE]; uint8_t PesHeader[PES_AUDIO_HEADER_SIZE];
dts_printf(10, "\n"); dts_printf(10, "\n");
if (call == NULL) if (call == NULL)

View File

@@ -91,9 +91,8 @@ static int32_t reset()
return 0; return 0;
} }
static int32_t writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
uint8_t PesHeader[PES_MAX_HEADER_SIZE]; uint8_t PesHeader[PES_MAX_HEADER_SIZE];
int32_t len = 0; int32_t len = 0;
h263_printf(10, "\n"); h263_printf(10, "\n");

View File

@@ -284,9 +284,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
unsigned char PesHeader[PES_MAX_HEADER_SIZE]; unsigned char PesHeader[PES_MAX_HEADER_SIZE];
unsigned long long int VideoPts; unsigned long long int VideoPts;
unsigned int TimeDelta; unsigned int TimeDelta;

View File

@@ -168,9 +168,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
unsigned char PesHeader[PES_MAX_HEADER_SIZE]; unsigned char PesHeader[PES_MAX_HEADER_SIZE];
unsigned long long int VideoPts; unsigned long long int VideoPts;
unsigned int TimeDelta; unsigned int TimeDelta;

View File

@@ -132,9 +132,8 @@ static int32_t reset()
return 0; return 0;
} }
static int32_t writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
lpcm_printf(10, "\n"); lpcm_printf(10, "\n");
if (!call) if (!call)
{ {

View File

@@ -91,10 +91,9 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call; unsigned char PesHeader[PES_MAX_HEADER_SIZE + 22];
unsigned char PesHeader[PES_MAX_HEADER_SIZE + 22];
mp3_printf(10, "\n"); mp3_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {

View File

@@ -92,10 +92,9 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call; unsigned char PesHeader[PES_MAX_HEADER_SIZE];
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
int len = 0; int len = 0;
unsigned int Position = 0; unsigned int Position = 0;
mpeg2_printf(10, "\n"); mpeg2_printf(10, "\n");

View File

@@ -100,10 +100,9 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call; unsigned char PesHeader[PES_MAX_HEADER_SIZE];
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
mpeg4_printf(10, "\n"); mpeg4_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {

View File

@@ -110,9 +110,8 @@ static int32_t reset()
return 0; return 0;
} }
static int32_t writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
pcm_printf(10, "\n"); pcm_printf(10, "\n");
if (!call) if (!call)
{ {

View File

@@ -107,9 +107,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
//int len = 0; //int len = 0;
vc1_printf(10, "\n"); vc1_printf(10, "\n");
if (call == NULL) if (call == NULL)

View File

@@ -98,9 +98,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call, int is_vp6) static int writeData(WriterAVCallData_t *call, int is_vp6)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
vp_printf(10, "\n"); vp_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {
@@ -142,14 +141,14 @@ static int writeData(void *_call, int is_vp6)
return writev_with_retry(call->fd, iov, 2); return writev_with_retry(call->fd, iov, 2);
} }
static int writeDataVP6(void *_call) static int writeDataVP6(WriterAVCallData_t *call)
{ {
return writeData(_call, 1); return writeData(call, 1);
} }
static int writeDataVP89(void *_call) static int writeDataVP89(WriterAVCallData_t *call)
{ {
return writeData(_call, 0); return writeData(call, 0);
} }
/* ***************************** */ /* ***************************** */

View File

@@ -103,9 +103,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
//int len = 0; //int len = 0;
wma_printf(10, "\n"); wma_printf(10, "\n");
if (call == NULL) if (call == NULL)

View File

@@ -105,9 +105,8 @@ static int reset()
return 0; return 0;
} }
static int writeData(void *_call) static int writeData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
wmv_printf(10, "\n"); wmv_printf(10, "\n");
if (call == NULL) if (call == NULL)
{ {

View File

@@ -27,6 +27,7 @@
/* ***************************** */ /* ***************************** */
/* Makros/Constants */ /* Makros/Constants */
/* ***************************** */ /* ***************************** */
// SULGE DEBUG // SULGE DEBUG
//#define SAM_WITH_DEBUG //#define SAM_WITH_DEBUG
@@ -53,7 +54,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#define cERR_PLAYBACK_NO_ERROR 0 #define cERR_PLAYBACK_NO_ERROR 0
#define cERR_PLAYBACK_ERROR -1 #define cERR_PLAYBACK_ERROR -1
#define cMaxSpeed_ff 128 /* fixme: revise */ #define cMaxSpeed_ff 128 /* fixme: revise */
#define cMaxSpeed_fr -320 /* fixme: revise */ #define cMaxSpeed_fr -320 /* fixme: revise */
/* ***************************** */ /* ***************************** */
@@ -706,9 +707,8 @@ static int PlaybackMetadata(Context_t *context, char ***metadata)
return ret; return ret;
} }
static int32_t Command(void *_context, PlaybackCmd_t command, void *argument) static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context; /* to satisfy compiler */
int32_t ret = cERR_PLAYBACK_NO_ERROR; int32_t ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(20, "Command %d\n", command); playback_printf(20, "Command %d\n", command);
switch (command) switch (command)