libeplayer3: cleanup types

This commit is contained in:
martii
2014-04-05 10:01:52 +02:00
parent 10e201b279
commit e5237866c4
30 changed files with 68 additions and 91 deletions

View File

@@ -41,9 +41,8 @@ if (debug_level >= level) printf(x); } while (0)
#define container_err(x...) #define container_err(x...)
#endif #endif
static int Command(void *_context, ContainerCmd_t command, void *argument __attribute__((unused))) 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__, __func__); container_printf(10, "%s::%s\n", __FILE__, __func__);

View File

@@ -39,12 +39,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 "common.h" #include "common.h"
#include "misc.h" #include "misc.h"
#include "debug.h" #include "debug.h"
@@ -450,7 +444,7 @@ static void FFMPEGThread(Context_t * context)
while (packet_size > 0) { while (packet_size > 0) {
int got_frame = 0; int got_frame = 0;
if (!decoded_frame) { if (!decoded_frame) {
if (!(decoded_frame = avcodec_alloc_frame())) { if (!(decoded_frame = av_frame_alloc())) {
fprintf(stderr, "out of memory\n"); fprintf(stderr, "out of memory\n");
exit(1); exit(1);
} }
@@ -1430,9 +1424,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 int Command(void *_context, ContainerCmd_t command, void *argument) static int 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);

View File

@@ -18,9 +18,12 @@ typedef enum {
CONTAINER_METADATA, CONTAINER_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;
@@ -31,7 +34,7 @@ extern Container_t FFMPEGContainer;
typedef struct ContainerHandler_s { 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,
MANAGER_LIST, MANAGER_LIST,
@@ -44,14 +50,16 @@ typedef struct Track_s {
int height; int height;
/* stream from ffmpeg */ /* stream from ffmpeg */
void *stream; AVStream *stream;
/* 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;
#if 0
uint8_t *aacbuf; uint8_t *aacbuf;
unsigned int aacbuflen; unsigned int aacbuflen;
int have_aacheader; int have_aacheader;
#endif
/* If player2 or the elf do not support decoding of audio codec set this. /* If player2 or the elf do not support decoding of audio codec set this.
* AVCodec is than used for softdecoding and stream will be injected as PCM */ * AVCodec is than used for softdecoding and stream will be injected as PCM */
@@ -64,9 +72,12 @@ typedef struct Track_s {
long long int chapter_end; long long int chapter_end;
} Track_t; } Track_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

@@ -2,6 +2,7 @@
#define OUTPUT_H_ #define OUTPUT_H_
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
typedef enum { typedef enum {
OUTPUT_INIT, OUTPUT_INIT,
@@ -28,13 +29,13 @@ typedef enum {
} OutputCmd_t; } OutputCmd_t;
typedef struct { typedef struct {
unsigned char *data; uint8_t *data;
unsigned int len; unsigned int len;
unsigned char *extradata; uint8_t *extradata;
unsigned int extralen; unsigned int extralen;
unsigned long long int pts; uint64_t pts;
float frameRate; float frameRate;
unsigned int timeScale; unsigned int timeScale;
@@ -45,10 +46,13 @@ typedef struct {
char *type; char *type;
} AudioVideoOut_t; } AudioVideoOut_t;
struct Context_s;
typedef struct Context_s Context_t;
typedef struct Output_s { typedef struct Output_s {
char *Name; char *Name;
int (*Command) ( /*Context_t */ void *, OutputCmd_t, void *); int (*Command) (Context_t *, OutputCmd_t, void *);
int (*Write) ( /*Context_t */ void *, void *privateData); int (*Write) (Context_t *, AudioVideoOut_t *privateData);
char **Capabilities; char **Capabilities;
} Output_t; } Output_t;
@@ -60,7 +64,7 @@ typedef struct OutputHandler_s {
char *Name; char *Name;
Output_t *audio; Output_t *audio;
Output_t *video; Output_t *video;
int (*Command) ( /*Context_t */ void *, OutputCmd_t, void *); int (*Command) (Context_t *, OutputCmd_t, void *);
} OutputHandler_t; } OutputHandler_t;
#endif #endif

View File

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

View File

@@ -11,6 +11,9 @@ typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP,
PLAYBACK_SWITCH_TELETEXT PLAYBACK_SWITCH_TELETEXT
} 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;
@@ -33,7 +36,7 @@ typedef struct PlaybackHandler_s {
unsigned char abortRequested; unsigned char abortRequested;
unsigned char abortPlayback; unsigned char abortPlayback;
int (*Command) ( /*Context_t */ void *, PlaybackCmd_t, void *); int (*Command) ( Context_t *, PlaybackCmd_t, void *);
char *uri; char *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;

View File

@@ -8,10 +8,10 @@ typedef enum { eNone, eAudio, eVideo, eGfx } 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 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;
@@ -30,8 +30,8 @@ typedef struct WriterCaps_s {
typedef struct Writer_s { typedef struct Writer_s {
int (*reset) (); int (*reset) ();
int (*writeData) (void *); int (*writeData) (WriterAVCallData_t *);
int (*writeReverseData) (void *); int (*writeReverseData) (WriterAVCallData_t *);
WriterCaps_t *caps; WriterCaps_t *caps;
} Writer_t; } Writer_t;

View File

@@ -185,9 +185,8 @@ static int ManagerDel(Context_t * context)
} }
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", FILENAME, __FUNCTION__); audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);

View File

@@ -175,9 +175,8 @@ static int ManagerDel(Context_t * context __attribute__((unused)))
return cERR_CHAPTER_MGR_NO_ERROR; return cERR_CHAPTER_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_CHAPTER_MGR_NO_ERROR; int ret = cERR_CHAPTER_MGR_NO_ERROR;
chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);

View File

@@ -90,7 +90,9 @@ void freeTrack(Track_t * track)
if (track->language != NULL) if (track->language != NULL)
free(track->language); free(track->language);
#if 0
if (track->aacbuf != NULL) if (track->aacbuf != NULL)
free(track->aacbuf); free(track->aacbuf);
#endif
} }

View File

@@ -181,9 +181,8 @@ static int ManagerDel(Context_t * context __attribute__((unused)))
return cERR_SUBTITLE_MGR_NO_ERROR; return cERR_SUBTITLE_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_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__,

View File

@@ -182,9 +182,8 @@ static int ManagerDel(Context_t * context __attribute__((unused)))
} }
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_TELETEXT_MGR_NO_ERROR; int ret = cERR_TELETEXT_MGR_NO_ERROR;
teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);

View File

@@ -180,9 +180,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", FILENAME, __FUNCTION__); video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);

View File

@@ -894,10 +894,8 @@ 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, AudioVideoOut_t *out)
{ {
Context_t *context = (Context_t *) _context;
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;
@@ -1045,9 +1043,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);

View File

@@ -127,9 +127,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", FILENAME, __FUNCTION__, output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__,

View File

@@ -212,10 +212,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 char ExtraData[AAC_HEADER_LENGTH]; unsigned char ExtraData[AAC_HEADER_LENGTH];
unsigned int PacketLength; unsigned int PacketLength;

View File

@@ -91,10 +91,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];

View File

@@ -91,10 +91,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 char FakeHeaders[64]; // 64bytes should be enough to make the fake headers unsigned char FakeHeaders[64]; // 64bytes should be enough to make the fake headers
unsigned int FakeHeaderLength; unsigned int FakeHeaderLength;

View File

@@ -93,10 +93,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_AUDIO_HEADER_SIZE]; unsigned char PesHeader[PES_AUDIO_HEADER_SIZE];
dts_printf(10, "\n"); dts_printf(10, "\n");

View File

@@ -89,10 +89,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];
flac_printf(10, "\n"); flac_printf(10, "\n");

View File

@@ -89,10 +89,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];
int len = 0; int len = 0;

View File

@@ -108,10 +108,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;
@@ -385,10 +383,8 @@ static int writeData(void *_call)
return len; return len;
} }
static int writeReverseData(void *_call) static int writeReverseData(WriterAVCallData_t *call)
{ {
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
h264_printf(10, "\n"); h264_printf(10, "\n");
if (call == NULL) { if (call == NULL) {

View File

@@ -89,10 +89,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];
mp3_printf(10, "\n"); mp3_printf(10, "\n");

View File

@@ -90,10 +90,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];
int len = 0; int len = 0;
unsigned int Position = 0; unsigned int Position = 0;

View File

@@ -184,10 +184,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];
pcm_printf(10, "\n"); pcm_printf(10, "\n");

View File

@@ -121,10 +121,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");

View File

@@ -93,10 +93,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");

View File

@@ -118,10 +118,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;
awmv_t private_data; awmv_t private_data;
int len = 0; int len = 0;

View File

@@ -740,9 +740,8 @@ static int PlaybackMetadata(Context_t * context, char ***metadata)
return ret; return ret;
} }
static int Command(void *_context, PlaybackCmd_t command, void *argument) static int Command(Context_t *context, PlaybackCmd_t command, void *argument)
{ {
Context_t *context = (Context_t *) _context; /* to satisfy compiler */
int ret = cERR_PLAYBACK_NO_ERROR; int ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(20, "Command %d\n", command); playback_printf(20, "Command %d\n", command);