all: clean up cPlayback header, hide private stuff

compile tested only ;)
This commit is contained in:
Stefan Seyfried
2013-11-02 23:39:31 +01:00
parent d94e47c757
commit e746daaf5a
14 changed files with 376 additions and 548 deletions

View File

@@ -1,126 +0,0 @@
#ifndef __PLAYBACK_TD_H
#define __PLAYBACK_TD_H
#include <inttypes.h>
#include <string>
#include <map>
#include <vector>
/* almost 256kB */
#define INBUF_SIZE (1394 * 188)
#define PESBUF_SIZE (128 * 1024)
typedef enum {
PLAYMODE_TS = 0,
PLAYMODE_FILE,
} playmode_t;
typedef enum {
FILETYPE_UNKNOWN,
FILETYPE_TS,
FILETYPE_MPG,
FILETYPE_VDR
} filetype_t;
typedef enum {
STATE_STOP,
STATE_PLAY,
STATE_PAUSE,
STATE_FF,
STATE_REW,
STATE_INIT
} playstate_t;
typedef struct {
std::string Name;
off_t Size;
} filelist_t;
class cPlayback
{
private:
uint8_t *inbuf;
ssize_t inbuf_pos;
ssize_t inbuf_sync;
uint8_t *pesbuf;
ssize_t pesbuf_pos;
ssize_t inbuf_read(void);
ssize_t read_ts(void);
ssize_t read_mpeg(void);
uint8_t cc[256];
int in_fd;
int video_type;
int playback_speed;
int mSpeed;
playmode_t playMode;
std::vector<filelist_t> filelist; /* for multi-file playback */
bool filelist_auto_add(void);
int mf_open(int fileno);
int mf_close(void);
off_t mf_lseek(off_t pos);
off_t mf_getsize(void);
int curr_fileno;
off_t curr_pos;
off_t last_size;
off_t bytes_per_second;
uint16_t vpid;
uint16_t apid;
bool ac3;
struct AStream {
// uint16_t pid;
bool ac3;
std::string lang; /* not yet really used */
};
std::map<uint16_t, AStream> astreams; /* stores AStream sorted by pid */
int64_t pts_start;
int64_t pts_end;
int64_t _pts_end; /* last good endpts */
int64_t pts_curr;
int64_t get_pts(uint8_t *p, bool pes, int bufsize);
filetype_t filetype;
playstate_t playstate;
off_t seek_to_pts(int64_t pts);
off_t mp_seekSync(off_t pos);
int64_t get_PES_PTS(uint8_t *buf, int len, bool until_eof);
pthread_t thread;
bool thread_started;
public:
cPlayback(int num = 0);
~cPlayback();
void playthread();
bool Open(playmode_t PlayMode);
void Close(void);
bool Start(char *filename, unsigned short vpid, int vtype, unsigned short apid,
int ac3, unsigned int duration);
bool SetAPid(unsigned short pid, int ac3);
bool SetSpeed(int speed);
bool GetSpeed(int &speed) const;
bool GetPosition(int &position, int &duration); /* pos: current time in ms, dur: file length in ms */
bool SetPosition(int position, bool absolute = false); /* position: jump in ms */
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language);
void RequestAbort();
#if 0
// Functions that are not used by movieplayer.cpp:
bool Stop(void);
bool GetOffset(off64_t &offset);
bool IsPlaying(void) const { return playing; }
bool IsEnabled(void) const { return enabled; }
void * GetHandle(void);
void * GetDmHandle(void);
int GetCurrPlaybackSpeed(void) const { return nPlaybackSpeed; }
void PlaybackNotify (int Event, void *pData, void *pTag);
void DMNotify(int Event, void *pTsBuf, void *Tag);
#endif
};
#endif

View File

@@ -12,7 +12,8 @@ extern PlaybackHandler_t PlaybackHandler;
extern ContainerHandler_t ContainerHandler;
extern ManagerHandler_t ManagerHandler;
#include "playback_libeplayer3.h"
//#include "playback_libeplayer3.h"
#include "playback_hal.h"
static Context_t *player;
@@ -27,6 +28,21 @@ static std::string fn_xml;
static off_t last_size;
static int init_jump;
class PBPrivate
{
public:
bool enabled;
bool playing;
int speed;
int astream;
PBPrivate() {
enabled = false;
playing = false;
speed = 0;
astream = -1;
};
};
//Used by Fileplay
bool cPlayback::Open(playmode_t PlayMode)
{
@@ -47,7 +63,7 @@ bool cPlayback::Open(playmode_t PlayMode)
fn_ts = "";
fn_xml = "";
last_size = 0;
nPlaybackSpeed = 0;
pd->speed = 0;
init_jump = -1;
player = (Context_t*) malloc(sizeof(Context_t));
@@ -97,7 +113,7 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
init_jump = -1;
//create playback path
mAudioStream=0;
pd->astream = 0;
char file[400] = {""};
if(!strncmp("http://", filename, 7))
@@ -181,9 +197,9 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
ret = false;
printf("failed to pause playback\n");
} else
playing = true;
pd->playing = true;
} else
playing = true;
pd->playing = true;
}
printf("%s:%s - return=%d\n", FILENAME, __FUNCTION__, ret);
@@ -210,8 +226,9 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
//Used by Fileplay
bool cPlayback::Stop(void)
{
printf("%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
if(playing==false) return false;
printf("%s:%s playing %d\n", FILENAME, __func__, pd->playing);
if (pd->playing == false)
return false;
if(player && player->playback && player->output) {
player->playback->Command(player, PLAYBACK_STOP, NULL);
@@ -231,25 +248,25 @@ bool cPlayback::Stop(void)
if(player != NULL)
player = NULL;
playing=false;
pd->playing = false;
return true;
}
bool cPlayback::SetAPid(unsigned short pid, bool /*ac3*/)
bool cPlayback::SetAPid(unsigned short pid, int /*ac3*/)
{
printf("%s:%s\n", FILENAME, __FUNCTION__);
int i=pid;
if(pid!=mAudioStream){
if (pid != pd->astream){
if(player && player->playback)
player->playback->Command(player, PLAYBACK_SWITCH_AUDIO, (void*)&i);
mAudioStream=pid;
player->playback->Command(player, PLAYBACK_SWITCH_AUDIO, (void*)&i);
pd->astream = pid;
}
return true;
}
bool cPlayback::SetSpeed(int speed)
{
printf("%s:%s playing %d speed %d\n", FILENAME, __FUNCTION__, playing, speed);
printf("%s:%s playing %d speed %d\n", FILENAME, __func__, pd->playing, speed);
if (! decoders_closed)
{
@@ -260,18 +277,18 @@ bool cPlayback::SetSpeed(int speed)
if (player && player->output && player->playback) {
player->output->Command(player, OUTPUT_OPEN, NULL);
if (player->playback->Command(player, PLAYBACK_PLAY, NULL) == 0) // playback.c uses "int = 0" for "true"
playing = true;
pd->playing = true;
}
}
if(playing==false)
return false;
if (!pd->playing)
return false;
if(player && player->playback)
{
int result = 0;
nPlaybackSpeed = speed;
pd->speed = speed;
if (speed > 1)
{
@@ -330,7 +347,7 @@ bool cPlayback::SetSpeed(int speed)
bool cPlayback::GetSpeed(int &speed) const
{
//printf("%s:%s\n", FILENAME, __FUNCTION__);
speed = nPlaybackSpeed;
speed = pd->speed;
return true;
}
@@ -347,14 +364,14 @@ bool cPlayback::GetPosition(int &position, int &duration)
struct stat s;
if (!stat(fn_ts.c_str(), &s))
{
if (! playing || last_size != s.st_size)
if (!pd->playing || last_size != s.st_size)
{
last_size = s.st_size;
time_t curr_time = s.st_mtime;
if (!stat(fn_xml.c_str(), &s))
{
duration = (curr_time - s.st_mtime) * 1000;
if (! playing)
if (!pd->playing)
return true;
got_duration = true;
}
@@ -362,7 +379,8 @@ bool cPlayback::GetPosition(int &position, int &duration)
}
}
if(playing==false) return false;
if (!pd->playing)
return false;
if (player && player->playback && !player->playback->isPlaying) {
printf("cPlayback::%s !!!!EOF!!!! < -1\n", __func__);
@@ -403,7 +421,7 @@ bool cPlayback::GetPosition(int &position, int &duration)
bool cPlayback::SetPosition(int position, bool /*absolute*/)
{
printf("%s:%s %d\n", FILENAME, __FUNCTION__,position);
if (playing == false)
if (!pd->playing)
{
/* the calling sequence is:
* Start() - paused
@@ -486,12 +504,14 @@ void cPlayback::RequestAbort(void)
cPlayback::cPlayback(int /*num*/)
{
printf("%s:%s\n", FILENAME, __FUNCTION__);
playing=false;
pd = new PBPrivate();
}
cPlayback::~cPlayback()
{
printf("%s:%s\n", FILENAME, __FUNCTION__);
delete pd;
pd = NULL;
}
#if 0

View File

@@ -1,50 +0,0 @@
#ifndef __HAL_PLAYBACK_H
#define __HAL_PLAYBACK_H
#include <string>
#include <vector>
typedef enum {
PLAYMODE_TS = 0,
PLAYMODE_FILE
} playmode_t;
class cPlayback
{
private:
bool enabled;
bool playing;
int nPlaybackSpeed;
int mAudioStream;
bool Stop(void);
public:
cPlayback(int num = 0);
~cPlayback();
bool Open(playmode_t PlayMode);
void Close(void);
bool Start(char *filename, unsigned short vpid, int vtype, unsigned short apid,
int ac3, unsigned int duration);
bool SetAPid(unsigned short pid, bool ac3);
bool SetSpeed(int speed);
bool GetSpeed(int &speed) const;
bool GetPosition(int &position, int &duration);
bool SetPosition(int position, bool absolute = false);
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language);
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language);
bool SelectSubtitles(int pid);
void GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
void RequestAbort();
#if 0
// Functions that are not used by movieplayer.cpp:
bool GetOffset(off64_t &offset);
bool IsPlaying(void) const;
bool IsEnabled(void) const;
void * GetHandle(void);
void * GetDmHandle(void);
int GetCurrPlaybackSpeed(void) const;
void PlaybackNotify (int Event, void *pData, void *pTag);
void DMNotify(int Event, void *pTsBuf, void *Tag);
#endif
};
#endif