mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
libeplayer3: implement Writer class
Origin commit data
------------------
Branch: master
Commit: 889d68740c
Author: martii <m4rtii@gmx.de>
Date: 2014-04-06 (Sun, 06 Apr 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -19,7 +19,6 @@ typedef enum {
|
||||
MANAGER_GET,
|
||||
MANAGER_GETNAME,
|
||||
MANAGER_SET,
|
||||
MANAGER_GETENCODING,
|
||||
MANAGER_DEL,
|
||||
MANAGER_GET_TRACK,
|
||||
MANAGER_INIT_UPDATE
|
||||
@@ -32,7 +31,6 @@ typedef enum {
|
||||
|
||||
typedef struct Track_s {
|
||||
std::string Name;
|
||||
const char *Encoding;
|
||||
int Id;
|
||||
|
||||
/* new field for ffmpeg - add at the end so no problem
|
||||
@@ -52,7 +50,10 @@ typedef struct Track_s {
|
||||
int is_static;
|
||||
long long int chapter_start;
|
||||
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) {}
|
||||
|
||||
int ac3flags;
|
||||
|
||||
Track_s() : Id(-1), language(NULL), duration(-1), avfc(NULL), stream(NULL), pending(0), is_static(0), chapter_start(0), chapter_end(0), ac3flags(-1) {}
|
||||
} Track_t;
|
||||
|
||||
struct Context_s;
|
||||
|
@@ -1,44 +1,18 @@
|
||||
#ifndef misc_123
|
||||
#define misc_123
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
/* some useful things needed by many files ... */
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
#define INVALID_PTS_VALUE 0x200000000ll
|
||||
|
||||
typedef struct BitPacker_s {
|
||||
unsigned char *Ptr; /* write pointer */
|
||||
unsigned int BitBuffer; /* bitreader shifter */
|
||||
int Remaining; /* number of remaining in the shifter */
|
||||
} BitPacker_t;
|
||||
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define INVALID_PTS_VALUE 0x200000000ull
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
/* ***************************** */
|
||||
struct BitPacker_t
|
||||
{
|
||||
unsigned char *Ptr; /* write pointer */
|
||||
unsigned int BitBuffer; /* bitreader shifter */
|
||||
int Remaining; /* number of remaining in the shifter */
|
||||
};
|
||||
|
||||
void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length);
|
||||
void FlushBits(BitPacker_t * ld);
|
||||
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static inline char *getExtension(char *name)
|
||||
{
|
||||
if (name) {
|
||||
char *ext = strrchr(name, '.');
|
||||
if (ext)
|
||||
return ext + 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@@ -28,7 +28,6 @@ typedef enum {
|
||||
OUTPUT_AVSYNC,
|
||||
OUTPUT_CLEAR,
|
||||
OUTPUT_PTS,
|
||||
OUTPUT_SWITCH,
|
||||
OUTPUT_SLOWMOTION,
|
||||
OUTPUT_AUDIOMUTE,
|
||||
OUTPUT_REVERSE,
|
||||
@@ -54,7 +53,7 @@ typedef struct Context_s Context_t;
|
||||
typedef struct Output_s {
|
||||
const char *Name;
|
||||
int (*Command) (Context_t *, OutputCmd_t, const char *);
|
||||
int (*Write) (Context_t *, AudioVideoOut_t *privateData);
|
||||
bool (*Write) (AVFormatContext *avfc, AVStream *stream, AVPacket *packet, int64_t &Pts);
|
||||
const char **Capabilities;
|
||||
|
||||
} Output_t;
|
||||
|
@@ -1,30 +1,32 @@
|
||||
#ifndef pes_123
|
||||
#define pes_123
|
||||
|
||||
#define PES_MAX_HEADER_SIZE 64
|
||||
#define PES_PRIVATE_DATA_FLAG 0x80
|
||||
#define PES_PRIVATE_DATA_LENGTH 8
|
||||
#define PES_LENGTH_BYTE_0 5
|
||||
#define PES_LENGTH_BYTE_1 4
|
||||
#define PES_FLAGS_BYTE 7
|
||||
#define PES_EXTENSION_DATA_PRESENT 0x01
|
||||
#define PES_HEADER_DATA_LENGTH_BYTE 8
|
||||
#define PES_START_CODE_RESERVED_4 0xfd
|
||||
#define PES_VERSION_FAKE_START_CODE 0x31
|
||||
#include <stdint.h>
|
||||
|
||||
#define PES_MAX_HEADER_SIZE 64
|
||||
#define PES_PRIVATE_DATA_FLAG 0x80
|
||||
#define PES_PRIVATE_DATA_LENGTH 8
|
||||
#define PES_LENGTH_BYTE_0 5
|
||||
#define PES_LENGTH_BYTE_1 4
|
||||
#define PES_FLAGS_BYTE 7
|
||||
#define PES_EXTENSION_DATA_PRESENT 0x01
|
||||
#define PES_HEADER_DATA_LENGTH_BYTE 8
|
||||
#define PES_START_CODE_RESERVED_4 0xfd
|
||||
#define PES_VERSION_FAKE_START_CODE 0x31
|
||||
|
||||
|
||||
#define MAX_PES_PACKET_SIZE (65535)
|
||||
#define MAX_PES_PACKET_SIZE 65535
|
||||
|
||||
|
||||
/* start codes */
|
||||
#define PCM_PES_START_CODE 0xbd
|
||||
#define PRIVATE_STREAM_1_PES_START_CODE 0xbd
|
||||
#define PCM_PES_START_CODE 0xbd
|
||||
#define PRIVATE_STREAM_1_PES_START_CODE 0xbd
|
||||
#define H263_VIDEO_PES_START_CODE 0xfe
|
||||
#define H264_VIDEO_PES_START_CODE 0xe2
|
||||
#define MPEG_VIDEO_PES_START_CODE 0xe0
|
||||
#define MPEG_AUDIO_PES_START_CODE 0xc0
|
||||
#define VC1_VIDEO_PES_START_CODE 0xfd
|
||||
#define AAC_AUDIO_PES_START_CODE 0xcf
|
||||
#define H264_VIDEO_PES_START_CODE 0xe2
|
||||
#define MPEG_VIDEO_PES_START_CODE 0xe0
|
||||
#define MPEG_AUDIO_PES_START_CODE 0xc0
|
||||
#define VC1_VIDEO_PES_START_CODE 0xfd
|
||||
#define AAC_AUDIO_PES_START_CODE 0xcf
|
||||
|
||||
int InsertPesHeader(uint8_t *data, int size, unsigned char stream_id, unsigned long long int pts, int pic_start_code);
|
||||
int InsertVideoPrivateDataHeader(uint8_t *data, int payload_size);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
@@ -12,61 +13,23 @@ extern "C" {
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
typedef enum { eNone, eAudio, eVideo, eGfx } eWriterType_t;
|
||||
#include <linux/dvb/stm_ioctls.h>
|
||||
|
||||
struct Context_s;
|
||||
typedef struct Context_s Context_t;
|
||||
#define AV_CODEC_ID_INJECTPCM AV_CODEC_ID_PCM_S16LE
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
int64_t Pts;
|
||||
int restart_audio_resampling;
|
||||
AVFormatContext *avfc;
|
||||
AVStream *stream;
|
||||
AVPacket *packet;
|
||||
Context_t *context;
|
||||
} WriterAVCallData_t;
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
static void Register(Writer *w, enum AVCodecID id, video_encoding_t encoding);
|
||||
static void Register(Writer *w, enum AVCodecID id, audio_encoding_t encoding);
|
||||
static video_encoding_t GetVideoEncoding(enum AVCodecID id);
|
||||
static audio_encoding_t GetAudioEncoding(enum AVCodecID id);
|
||||
static Writer *GetWriter(enum AVCodecID id, enum AVMediaType codec_type);
|
||||
|
||||
typedef struct WriterCaps_s {
|
||||
const char *name;
|
||||
eWriterType_t type;
|
||||
const char *textEncoding;
|
||||
/* fixme: revise if this is an enum! */
|
||||
int dvbEncoding;
|
||||
} WriterCaps_t;
|
||||
|
||||
typedef struct Writer_s {
|
||||
int (*reset) ();
|
||||
int (*writeData) (WriterAVCallData_t *);
|
||||
WriterCaps_t *caps;
|
||||
} Writer_t;
|
||||
|
||||
extern Writer_t WriterAudioIPCM;
|
||||
extern Writer_t WriterAudioPCM;
|
||||
extern Writer_t WriterAudioMP3;
|
||||
extern Writer_t WriterAudioMPEGL3;
|
||||
extern Writer_t WriterAudioAC3;
|
||||
extern Writer_t WriterAudioEAC3;
|
||||
//extern Writer_t WriterAudioAAC;
|
||||
extern Writer_t WriterAudioDTS;
|
||||
//extern Writer_t WriterAudioWMA;
|
||||
extern Writer_t WriterAudioFLAC;
|
||||
extern Writer_t WriterAudioVORBIS;
|
||||
|
||||
extern Writer_t WriterVideoMPEG2;
|
||||
extern Writer_t WriterVideoMPEGH264;
|
||||
extern Writer_t WriterVideoH264;
|
||||
extern Writer_t WriterVideoWMV;
|
||||
extern Writer_t WriterVideoDIVX;
|
||||
extern Writer_t WriterVideoFOURCC;
|
||||
extern Writer_t WriterVideoMSCOMP;
|
||||
extern Writer_t WriterVideoH263;
|
||||
extern Writer_t WriterVideoFLV;
|
||||
extern Writer_t WriterVideoVC1;
|
||||
|
||||
Writer_t *getWriter(char *encoding);
|
||||
|
||||
Writer_t *getDefaultVideoWriter();
|
||||
Writer_t *getDefaultAudioWriter();
|
||||
virtual void Init(void) { }
|
||||
virtual bool Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket *packet, int64_t &pts);
|
||||
|
||||
Writer() { Init (); }
|
||||
~Writer() {}
|
||||
};
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user