mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
all: clean up cPlayback header, hide private stuff
compile tested only ;)
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
#define IN_FILE "/tmp/rmfp.in2"
|
||||
#define OUT_FILE "/tmp/rmfp.out2"
|
||||
|
||||
#include "playback.h"
|
||||
#include "playback_hal.h"
|
||||
|
||||
extern "C"{
|
||||
#include "e2mruainclude.h"
|
||||
@@ -73,8 +73,38 @@ static time_t monotonic_ms(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
class PBPrivate
|
||||
{
|
||||
public:
|
||||
bool rmfp_command(int cmd, int param, bool has_param, char *buf, int buflen);
|
||||
void run_rmfp(void);
|
||||
PBPrivate(void) {
|
||||
playing = 0;
|
||||
thread_started = false;
|
||||
eof = false;
|
||||
open_success = false;
|
||||
pthread_mutex_init(&rmfp_cmd_mutex, NULL);
|
||||
};
|
||||
~PBPrivate(void) {
|
||||
pthread_mutex_destroy(&rmfp_cmd_mutex);
|
||||
};
|
||||
|
||||
int duration;
|
||||
int playing;
|
||||
int speed;
|
||||
playmode_t pmode;
|
||||
uint16_t apid;
|
||||
uint16_t subpid;
|
||||
bool eof;
|
||||
bool open_success;
|
||||
bool thread_started;
|
||||
pthread_t thread;
|
||||
pthread_mutex_t rmfp_cmd_mutex;
|
||||
char *fname;
|
||||
};
|
||||
|
||||
/* the mutex makes sure that commands are not interspersed */
|
||||
bool cPlayback::rmfp_command(int cmd, int param, bool has_param, char *buf, int buflen)
|
||||
bool PBPrivate::rmfp_command(int cmd, int param, bool has_param, char *buf, int buflen)
|
||||
{
|
||||
lt_info("%s: %d %d %d %d\n", __func__, cmd, param, has_param, buflen);
|
||||
bool ret = true;
|
||||
@@ -141,21 +171,21 @@ bool cPlayback::rmfp_command(int cmd, int param, bool has_param, char *buf, int
|
||||
* the output will be buffered after starting up and we will only
|
||||
* see "Playback has started..." after the player exits
|
||||
*/
|
||||
void cPlayback::run_rmfp()
|
||||
void PBPrivate::run_rmfp()
|
||||
{
|
||||
lt_debug("%s: starting\n", __func__);
|
||||
thread_started = true;
|
||||
//Watch for the space at the end
|
||||
std::string base = "rmfp_player -dram 1 -ve 1 -waitexit ";
|
||||
std::string filename(mfilename);
|
||||
std::string filename(fname);
|
||||
std::string file = '"' + filename + '"';
|
||||
std::string final = base + file;
|
||||
|
||||
if (playMode == PLAYMODE_TS && mduration != 0)
|
||||
if (pmode == PLAYMODE_TS && duration != 0)
|
||||
{
|
||||
std::stringstream duration;
|
||||
duration << (mduration /** 60000LL*/);
|
||||
final = base + "-duration " + duration.str() + " " + file;
|
||||
std::stringstream du;
|
||||
du << (duration /** 60000LL*/);
|
||||
final = base + "-duration " + du.str() + " " + file;
|
||||
}
|
||||
|
||||
pid_t pid = 0;
|
||||
@@ -190,7 +220,7 @@ void cPlayback::run_rmfp()
|
||||
else if (strstr(output, "End of file..."))
|
||||
{
|
||||
playing = 1; /* this can happen without "Playback has started..." */
|
||||
eof_reached = true;
|
||||
eof = true;
|
||||
lt_info("%s: ===================> eof_reached = true\n", __func__);
|
||||
}
|
||||
}
|
||||
@@ -206,14 +236,14 @@ void cPlayback::run_rmfp()
|
||||
playing = 2;
|
||||
else
|
||||
playing = 0;
|
||||
eof_reached = true;
|
||||
eof = true;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
/* helper function to call the cpp thread loop */
|
||||
void *execute_rua_thread(void *c)
|
||||
{
|
||||
cPlayback *obj = (cPlayback *)c;
|
||||
PBPrivate *obj = (PBPrivate *)c;
|
||||
lt_info_c("%s\n", __func__);
|
||||
obj->run_rmfp();
|
||||
/* free(obj); // this is most likely wrong */
|
||||
@@ -228,11 +258,11 @@ bool cPlayback::Open(playmode_t PlayMode)
|
||||
"PLAYMODE_TS",
|
||||
"PLAYMODE_FILE"
|
||||
};
|
||||
playMode = PlayMode;
|
||||
if (playMode > 1)
|
||||
pd->pmode = PlayMode;
|
||||
if (pd->pmode > 1)
|
||||
{
|
||||
lt_info("%s: PlayMode %d out of range!\n", __func__, PlayMode);
|
||||
playMode = PLAYMODE_FILE;
|
||||
pd->pmode = PLAYMODE_FILE;
|
||||
}
|
||||
|
||||
lt_info("%s: mode %d (%s)\n", __func__, PlayMode, aPLAYMODE[PlayMode]);
|
||||
@@ -253,7 +283,7 @@ bool cPlayback::Open(playmode_t PlayMode)
|
||||
if (i > 10)
|
||||
{
|
||||
lt_info("%s: ERROR - player is not idle after 10 seconds!\n", __func__);
|
||||
open_success = false;
|
||||
pd->open_success = false;
|
||||
return false;
|
||||
}
|
||||
sleep(1);
|
||||
@@ -266,7 +296,7 @@ bool cPlayback::Open(playmode_t PlayMode)
|
||||
unlink(IN_FILE);
|
||||
unlink(OUT_FILE);
|
||||
|
||||
open_success = true;
|
||||
pd->open_success = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -278,49 +308,49 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
|
||||
|
||||
lt_info("%s: filename=%s\n", __func__, filename);
|
||||
lt_info("%s: vpid=%u vtype=%d apid=%u ac3=%d duration=%i open_success=%d\n",
|
||||
__func__, vpid, vtype, _apid, ac3, duration, open_success);
|
||||
__func__, vpid, vtype, _apid, ac3, duration, pd->open_success);
|
||||
|
||||
if (!open_success)
|
||||
if (!pd->open_success)
|
||||
return false;
|
||||
|
||||
eof_reached = false;
|
||||
pd->eof = false;
|
||||
//create playback path
|
||||
apid = 0;
|
||||
subpid = 0;
|
||||
mfilename = filename;
|
||||
mduration = duration;
|
||||
if (pthread_create(&thread, 0, execute_rua_thread, this) != 0)
|
||||
pd->apid = 0;
|
||||
pd->subpid = 0;
|
||||
pd->fname = filename;
|
||||
pd->duration = duration;
|
||||
if (pthread_create(&pd->thread, 0, execute_rua_thread, pd) != 0)
|
||||
{
|
||||
lt_info("%s: error creating rmfp_player thread! (out of memory?)\n", __func__);
|
||||
ret = false;
|
||||
}
|
||||
while (! playing)
|
||||
while (! pd->playing)
|
||||
sleep(1);
|
||||
if (playing == 2)
|
||||
playing = 0;
|
||||
if (pd->playing == 2)
|
||||
pd->playing = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cPlayback::Close(void)
|
||||
{
|
||||
lt_info("%s: playing %d thread_started %d\n", __func__, playing, thread_started);
|
||||
lt_info("%s: playing %d thread_started %d\n", __func__, pd->playing, pd->thread_started);
|
||||
|
||||
if (thread_started)
|
||||
if (pd->thread_started)
|
||||
{
|
||||
rmfp_command(KEY_COMMAND_QUIT_ALL, 0, false, NULL, 0);
|
||||
pd->rmfp_command(KEY_COMMAND_QUIT_ALL, 0, false, NULL, 0);
|
||||
|
||||
if (pthread_join(thread, NULL))
|
||||
if (pthread_join(pd->thread, NULL))
|
||||
lt_info("%s: error joining rmfp thread (%m)\n", __func__);
|
||||
playing = 0;
|
||||
thread_started = false;
|
||||
pd->playing = 0;
|
||||
pd->thread_started = false;
|
||||
}
|
||||
else
|
||||
lt_info("%s: Warning: thread_started == false!\n", __func__);
|
||||
|
||||
if (open_success)
|
||||
if (pd->open_success)
|
||||
{
|
||||
proc_put("/proc/player", "1", 2);
|
||||
open_success = false;
|
||||
pd->open_success = false;
|
||||
lt_info("%s: /proc/player switched to '1'\n", __func__);
|
||||
usleep(1000000);
|
||||
}
|
||||
@@ -329,9 +359,9 @@ void cPlayback::Close(void)
|
||||
bool cPlayback::SetAPid(unsigned short pid, int /*ac3*/)
|
||||
{
|
||||
lt_info("%s: pid %i\n", __func__, pid);
|
||||
if (pid != apid) {
|
||||
rmfp_command(KEY_COMMAND_SWITCH_AUDIO, pid, true, NULL, 0);
|
||||
apid = pid;
|
||||
if (pid != pd->apid) {
|
||||
pd->rmfp_command(KEY_COMMAND_SWITCH_AUDIO, pid, true, NULL, 0);
|
||||
pd->apid = pid;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -339,29 +369,29 @@ bool cPlayback::SetAPid(unsigned short pid, int /*ac3*/)
|
||||
bool cPlayback::SelectSubtitles(int pid)
|
||||
{
|
||||
lt_info("%s: pid %i\n", __func__, pid);
|
||||
if (pid != subpid)
|
||||
if (pid != pd->subpid)
|
||||
{
|
||||
rmfp_command(KEY_COMMAND_SWITCH_SUBS, pid, true, NULL, 0);
|
||||
subpid = pid;
|
||||
pd->rmfp_command(KEY_COMMAND_SWITCH_SUBS, pid, true, NULL, 0);
|
||||
pd->subpid = pid;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cPlayback::SetSpeed(int speed)
|
||||
{
|
||||
lt_info("%s: playing %d speed %d\n", __func__, playing, speed);
|
||||
lt_info("%s: playing %d speed %d\n", __func__, pd->playing, speed);
|
||||
|
||||
if (!playing)
|
||||
if (!pd->playing)
|
||||
return false;
|
||||
|
||||
playback_speed = speed;
|
||||
pd->speed = speed;
|
||||
|
||||
if (speed > 1 || speed < 0)
|
||||
rmfp_command(CUSTOM_COMMAND_TRICK_SEEK, speed, true, NULL, 0);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_TRICK_SEEK, speed, true, NULL, 0);
|
||||
else if (speed == 0)
|
||||
rmfp_command(KEY_COMMAND_PAUSE, 0, false, NULL, 0);
|
||||
pd->rmfp_command(KEY_COMMAND_PAUSE, 0, false, NULL, 0);
|
||||
else
|
||||
rmfp_command(KEY_COMMAND_PLAY, 0, false, NULL, 0);
|
||||
pd->rmfp_command(KEY_COMMAND_PLAY, 0, false, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -378,22 +408,22 @@ bool cPlayback::GetSpeed(int &/*speed*/) const
|
||||
// in milliseconds
|
||||
bool cPlayback::GetPosition(int &position, int &duration)
|
||||
{
|
||||
lt_debug("%s: playing %d\n", __func__, playing);
|
||||
lt_debug("%s: playing %d\n", __func__, pd->playing);
|
||||
|
||||
if (eof_reached)
|
||||
if (pd->eof)
|
||||
{
|
||||
position = mduration;
|
||||
duration = mduration;
|
||||
position = pd->duration;
|
||||
duration = pd->duration;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!playing)
|
||||
if (!pd->playing)
|
||||
return false;
|
||||
|
||||
char buf[32];
|
||||
/* custom command 222 returns "12345\n1234\n",
|
||||
* first line is duration, second line is position */
|
||||
if (! rmfp_command(222, 0, false, buf, 32))
|
||||
if (! pd->rmfp_command(222, 0, false, buf, 32))
|
||||
return false;
|
||||
duration = atoi(buf);
|
||||
char *p = strchr(buf, '\n');
|
||||
@@ -404,11 +434,11 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
||||
if (duration == 0)
|
||||
duration = position + 1000;
|
||||
|
||||
if (playMode == PLAYMODE_TS)
|
||||
if (pd->pmode == PLAYMODE_TS)
|
||||
{
|
||||
if (position > mduration)
|
||||
mduration = position + 1000;
|
||||
duration = mduration;
|
||||
if (position > pd->duration)
|
||||
pd->duration = position + 1000;
|
||||
duration = pd->duration;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -416,23 +446,23 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
||||
|
||||
bool cPlayback::SetPosition(int position, bool absolute)
|
||||
{
|
||||
lt_info("%s: pos %d abs %d playing %d\n", __func__, position, absolute, playing);
|
||||
lt_info("%s: pos %d abs %d playing %d\n", __func__, position, absolute, pd->playing);
|
||||
|
||||
if (!playing)
|
||||
if (!pd->playing)
|
||||
return false;
|
||||
|
||||
int seconds = position / 1000;;
|
||||
|
||||
if (absolute)
|
||||
{
|
||||
rmfp_command(KEY_COMMAND_SEEK_TO_TIME, seconds, true, NULL, 0);
|
||||
pd->rmfp_command(KEY_COMMAND_SEEK_TO_TIME, seconds, true, NULL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (position > 0)
|
||||
rmfp_command(CUSTOM_COMMAND_SEEK_RELATIVE_FWD, seconds, true, NULL, 0);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_SEEK_RELATIVE_FWD, seconds, true, NULL, 0);
|
||||
else if (position < 0)
|
||||
rmfp_command(CUSTOM_COMMAND_SEEK_RELATIVE_BWD, seconds, true, NULL, 0);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_SEEK_RELATIVE_BWD, seconds, true, NULL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -440,7 +470,7 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t
|
||||
{
|
||||
lt_info("%s\n", __func__);
|
||||
char buf[32];
|
||||
rmfp_command(CUSTOM_COMMAND_AUDIO_COUNT, 0, false, buf, 3);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_AUDIO_COUNT, 0, false, buf, 3);
|
||||
unsigned int audio_count = atoi(buf);
|
||||
|
||||
*numpida = audio_count;
|
||||
@@ -451,7 +481,7 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t
|
||||
char streamidstring[11];
|
||||
char audio_lang[21];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
rmfp_command(CUSTOM_COMMAND_GET_AUDIO_BY_ID, aid, true, buf, 32);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_GET_AUDIO_BY_ID, aid, true, buf, 32);
|
||||
memcpy(streamidstring, buf, 10);
|
||||
streamidstring[10] = '\0';
|
||||
memcpy(audio_lang, buf + 10, 20);
|
||||
@@ -469,7 +499,7 @@ void cPlayback::FindAllSubs(uint16_t *spids, unsigned short *supported, uint16_t
|
||||
lt_info("%s\n", __func__);
|
||||
char buf[32];
|
||||
|
||||
rmfp_command(CUSTOM_COMMAND_SUBS_COUNT, 0, false, buf, 3);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_SUBS_COUNT, 0, false, buf, 3);
|
||||
unsigned int spu_count = atoi(buf);
|
||||
*numpids = spu_count;
|
||||
|
||||
@@ -480,7 +510,7 @@ void cPlayback::FindAllSubs(uint16_t *spids, unsigned short *supported, uint16_t
|
||||
char streamidstring[11];
|
||||
char spu_lang[21];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
rmfp_command(CUSTOM_COMMAND_GET_SUB_BY_ID, sid, true, buf, 32);
|
||||
pd->rmfp_command(CUSTOM_COMMAND_GET_SUB_BY_ID, sid, true, buf, 32);
|
||||
memcpy(streamidstring, buf, 10);
|
||||
streamidstring[10] = '\0';
|
||||
memcpy(spu_lang, buf + 10, 20);
|
||||
@@ -511,15 +541,12 @@ void cPlayback::RequestAbort(void)
|
||||
cPlayback::cPlayback(int /*num*/)
|
||||
{
|
||||
lt_info("%s: constructor\n", __func__);
|
||||
playing = 0;
|
||||
thread_started = false;
|
||||
eof_reached = false;
|
||||
open_success = false;
|
||||
pthread_mutex_init(&rmfp_cmd_mutex, NULL);
|
||||
pd = new PBPrivate();
|
||||
}
|
||||
|
||||
cPlayback::~cPlayback()
|
||||
{
|
||||
lt_info("%s\n", __func__);
|
||||
pthread_mutex_destroy(&rmfp_cmd_mutex);
|
||||
delete pd;
|
||||
pd = NULL;
|
||||
}
|
||||
|
@@ -1,63 +0,0 @@
|
||||
#ifndef __PLAYBACK_H
|
||||
#define __PLAYBACK_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
typedef enum {
|
||||
PLAYMODE_TS = 0,
|
||||
PLAYMODE_FILE,
|
||||
} playmode_t;
|
||||
|
||||
class cPlayback
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t rmfp_cmd_mutex;
|
||||
int playing;
|
||||
bool eof_reached;
|
||||
int playback_speed;
|
||||
playmode_t playMode;
|
||||
bool open_success;
|
||||
uint16_t apid;
|
||||
uint16_t subpid;
|
||||
char *mfilename;
|
||||
int mduration;
|
||||
pthread_t thread;
|
||||
bool thread_started;
|
||||
/* private functions */
|
||||
bool rmfp_command(int cmd, int param, bool has_param, char *buf, int buflen);
|
||||
public:
|
||||
cPlayback(int num = 0);
|
||||
~cPlayback();
|
||||
|
||||
void run_rmfp();
|
||||
|
||||
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 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 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
|
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "playback.h"
|
||||
#include "playback_hal.h"
|
||||
|
||||
static const char * FILENAME = "playback-dummy";
|
||||
|
||||
@@ -13,14 +13,14 @@ void cPlayback::Close(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool cPlayback::Start(char * filename, unsigned short vpid, int vtype, unsigned short apid, bool ac3, int duration)
|
||||
bool cPlayback::Start(char * filename, unsigned short vpid, int vtype, unsigned short apid, int ac3, unsigned int duration)
|
||||
{
|
||||
printf("%s:%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d duration=%i\n",
|
||||
FILENAME, __func__, filename, vpid, vtype, apid, ac3, duration);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cPlayback::SetAPid(unsigned short pid, bool /*ac3*/)
|
||||
bool cPlayback::SetAPid(unsigned short pid, int /*ac3*/)
|
||||
{
|
||||
printf("%s:%s pid %i\n", FILENAME, __func__, pid);
|
||||
return true;
|
||||
|
@@ -1,37 +0,0 @@
|
||||
#ifndef __PLAYBACK_H
|
||||
#define __PLAYBACK_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
typedef enum {
|
||||
PLAYMODE_TS = 0,
|
||||
PLAYMODE_FILE,
|
||||
} playmode_t;
|
||||
|
||||
class cPlayback
|
||||
{
|
||||
public:
|
||||
bool Open(playmode_t PlayMode);
|
||||
void Close(void);
|
||||
bool Start(char * filename, unsigned short vpid, int vtype, unsigned short apid, bool ac3, int duration);
|
||||
bool Stop(void);
|
||||
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();
|
||||
//
|
||||
cPlayback(int num = 0);
|
||||
~cPlayback();
|
||||
private:
|
||||
void *pdata; /* not yet used */
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,3 +1 @@
|
||||
/* playback_*.cpp uses off_t */
|
||||
#include <config.h>
|
||||
#include "playback_td.h"
|
||||
#include "playback_hal.h"
|
||||
|
55
include/playback_hal.h
Normal file
55
include/playback_hal.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* (C) 2010-2013 Stefan Seyfried
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __playback_hal__
|
||||
#define __playback_hal__
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
typedef enum {
|
||||
PLAYMODE_TS = 0,
|
||||
PLAYMODE_FILE,
|
||||
} playmode_t;
|
||||
|
||||
class PBPrivate;
|
||||
class cPlayback
|
||||
{
|
||||
public:
|
||||
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 Stop(void);
|
||||
bool SetAPid(unsigned short pid, int audio_flag);
|
||||
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 *pids, unsigned short *aud_flags, uint16_t *num, std::string *language);
|
||||
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *num, std::string *language);
|
||||
bool SelectSubtitles(int pid);
|
||||
void GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
|
||||
void RequestAbort();
|
||||
//
|
||||
cPlayback(int num = 0);
|
||||
~cPlayback();
|
||||
private:
|
||||
PBPrivate *pd;
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,16 +0,0 @@
|
||||
#include <config.h>
|
||||
#if HAVE_TRIPLEDRAGON
|
||||
#include "../libtriple/playback_td.h"
|
||||
#elif HAVE_SPARK_HARDWARE
|
||||
#include "../libspark/playback_libeplayer3.h"
|
||||
#elif HAVE_AZBOX_HARDWARE
|
||||
#include "../azbox/playback.h"
|
||||
#elif HAVE_GENERIC_HARDWARE
|
||||
#if BOXMODEL_RASPI
|
||||
#include "../raspi/playback.h"
|
||||
#else
|
||||
#include "../generic-pc/playback.h"
|
||||
#endif
|
||||
#else
|
||||
#error neither HAVE_TRIPLEDRAGON nor HAVE_SPARK_HARDWARE defined
|
||||
#endif
|
@@ -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
|
@@ -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
|
||||
|
@@ -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
|
@@ -1 +0,0 @@
|
||||
#include "playback_td.h"
|
@@ -9,7 +9,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include "playback_td.h"
|
||||
#include <map>
|
||||
|
||||
#include "playback_hal.h"
|
||||
#include "dmx_hal.h"
|
||||
#include "audio_td.h"
|
||||
#include "video_hal.h"
|
||||
@@ -51,9 +53,117 @@ static const char *FILETYPE[] = {
|
||||
"FILETYPE_VDR"
|
||||
};
|
||||
|
||||
/* almost 256kB */
|
||||
#define INBUF_SIZE (1394 * 188)
|
||||
#define PESBUF_SIZE (128 * 1024)
|
||||
|
||||
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 PBPrivate
|
||||
{
|
||||
public:
|
||||
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 *audio_fd;
|
||||
VDec *vdec;
|
||||
|
||||
int playback_speed;
|
||||
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;
|
||||
|
||||
PBPrivate(VDec *v);
|
||||
~PBPrivate();
|
||||
|
||||
void playthread();
|
||||
|
||||
bool Open(playmode_t PlayMode);
|
||||
void Close(void);
|
||||
bool Start(char *filename, unsigned short vpid, int vtype, unsigned short apid, int ac3, int *afd);
|
||||
bool SetAPid(unsigned short pid, int ac3);
|
||||
bool SetSpeed(int speed);
|
||||
bool GetPosition(int &position, int &duration); /* pos: current time in ms, dur: file length in ms */
|
||||
bool SetPosition(int position, bool absolute); /* position: jump in ms */
|
||||
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language);
|
||||
};
|
||||
|
||||
cPlayback::cPlayback(int)
|
||||
{
|
||||
lt_debug("%s\n", __FUNCTION__);
|
||||
pd = new PBPrivate(videoDecoder->vdec);
|
||||
}
|
||||
|
||||
cPlayback::~cPlayback()
|
||||
{
|
||||
delete pd;
|
||||
pd = NULL;
|
||||
}
|
||||
|
||||
PBPrivate::PBPrivate(VDec *v)
|
||||
{
|
||||
thread_started = false;
|
||||
inbuf = NULL;
|
||||
pesbuf = NULL;
|
||||
@@ -61,9 +171,10 @@ cPlayback::cPlayback(int)
|
||||
curr_fileno = -1;
|
||||
in_fd = -1;
|
||||
streamtype = 0;
|
||||
vdec = v;
|
||||
}
|
||||
|
||||
cPlayback::~cPlayback()
|
||||
PBPrivate::~PBPrivate()
|
||||
{
|
||||
lt_debug("%s\n", __FUNCTION__);
|
||||
Close();
|
||||
@@ -71,6 +182,11 @@ cPlayback::~cPlayback()
|
||||
|
||||
|
||||
bool cPlayback::Open(playmode_t mode)
|
||||
{
|
||||
return pd->Open(mode);
|
||||
}
|
||||
|
||||
bool PBPrivate::Open(playmode_t mode)
|
||||
{
|
||||
static const char *PMODE[] = {
|
||||
"PLAYMODE_TS",
|
||||
@@ -79,7 +195,6 @@ bool cPlayback::Open(playmode_t mode)
|
||||
|
||||
lt_debug("%s: PlayMode = %s\n", __FUNCTION__, PMODE[mode]);
|
||||
thread_started = false;
|
||||
playMode = mode;
|
||||
filetype = FILETYPE_TS;
|
||||
playback_speed = 0;
|
||||
last_size = 0;
|
||||
@@ -91,6 +206,11 @@ bool cPlayback::Open(playmode_t mode)
|
||||
|
||||
//Used by Fileplay
|
||||
void cPlayback::Close(void)
|
||||
{
|
||||
pd->Close();
|
||||
}
|
||||
|
||||
void PBPrivate::Close(void)
|
||||
{
|
||||
lt_info("%s\n", __FUNCTION__);
|
||||
playstate = STATE_STOP;
|
||||
@@ -116,13 +236,19 @@ void cPlayback::Close(void)
|
||||
audioDecoder->SetMute(was_muted);
|
||||
}
|
||||
|
||||
bool cPlayback::Start(char *filename, unsigned short vp, int vtype, unsigned short ap, int _ac3, unsigned int)
|
||||
bool cPlayback::Start(char *filename, unsigned short vp, int vtype, unsigned short ap, int ac3, unsigned int)
|
||||
{
|
||||
return pd->Start(filename, vp, vtype, ap, ac3, &audioDemux->fd);
|
||||
}
|
||||
|
||||
bool PBPrivate::Start(char *filename, unsigned short vp, int vtype, unsigned short ap, int _ac3, int *audiofd)
|
||||
{
|
||||
struct stat s;
|
||||
off_t r;
|
||||
vpid = vp;
|
||||
apid = ap;
|
||||
ac3 = _ac3;
|
||||
audio_fd = audiofd;
|
||||
lt_info("%s name = '%s' vpid 0x%04hx vtype %d apid 0x%04hx ac3 %d filelist.size: %u\n",
|
||||
__FUNCTION__, filename, vpid, vtype, apid, ac3, filelist.size());
|
||||
if (!filelist.empty())
|
||||
@@ -255,12 +381,12 @@ bool cPlayback::Start(char *filename, unsigned short vp, int vtype, unsigned sho
|
||||
|
||||
static void *start_playthread(void *c)
|
||||
{
|
||||
cPlayback *obj = (cPlayback *)c;
|
||||
PBPrivate *obj = (PBPrivate *)c;
|
||||
obj->playthread();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cPlayback::playthread(void)
|
||||
void PBPrivate::playthread(void)
|
||||
{
|
||||
thread_started = true;
|
||||
int ret, towrite;
|
||||
@@ -272,9 +398,9 @@ void cPlayback::playthread(void)
|
||||
}
|
||||
fcntl(dvrfd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
pthread_cleanup_push(playthread_cleanup_handler, (void *)audioDemux->fd);
|
||||
pthread_cleanup_push(playthread_cleanup_handler, (void *)audio_fd);
|
||||
|
||||
ioctl(audioDemux->fd, DEMUX_SELECT_SOURCE, INPUT_FROM_PVR);
|
||||
ioctl(*audio_fd, DEMUX_SELECT_SOURCE, INPUT_FROM_PVR);
|
||||
if (ac3)
|
||||
audioDecoder->SetStreamType(AUDIO_FMT_DOLBY_DIGITAL);
|
||||
else
|
||||
@@ -369,7 +495,7 @@ void cPlayback::playthread(void)
|
||||
static void playthread_cleanup_handler(void *arg)
|
||||
{
|
||||
lt_info_c("%s\n", __FUNCTION__);
|
||||
int admx_fd = (int)arg;
|
||||
int admx_fd = *((int *)arg);
|
||||
ioctl(admx_fd, DEMUX_SELECT_SOURCE, INPUT_FROM_CHANNEL0);
|
||||
audioDemux->Stop();
|
||||
videoDemux->Stop();
|
||||
@@ -379,7 +505,12 @@ static void playthread_cleanup_handler(void *arg)
|
||||
dvrfd = -1;
|
||||
}
|
||||
|
||||
bool cPlayback::SetAPid(unsigned short pid, int _ac3)
|
||||
bool cPlayback::SetAPid(unsigned short pid, int ac3)
|
||||
{
|
||||
return pd->SetAPid(pid, ac3);
|
||||
}
|
||||
|
||||
bool PBPrivate::SetAPid(unsigned short pid, int _ac3)
|
||||
{
|
||||
lt_info("%s pid: 0x%04hx ac3: %d\n", __FUNCTION__, pid, _ac3);
|
||||
apid = pid;
|
||||
@@ -409,6 +540,11 @@ bool cPlayback::SetAPid(unsigned short pid, int _ac3)
|
||||
}
|
||||
|
||||
bool cPlayback::SetSpeed(int speed)
|
||||
{
|
||||
return pd->SetSpeed(speed);
|
||||
}
|
||||
|
||||
bool PBPrivate::SetSpeed(int speed)
|
||||
{
|
||||
lt_info("%s speed = %d\n", __FUNCTION__, speed);
|
||||
if (speed < 0)
|
||||
@@ -435,7 +571,7 @@ bool cPlayback::SetSpeed(int speed)
|
||||
{
|
||||
was_muted = audioDecoder->getMuteStatus();
|
||||
audioDecoder->mute();
|
||||
videoDecoder->vdec->FastForwardMode();
|
||||
vdec->FastForwardMode();
|
||||
}
|
||||
playback_speed = speed;
|
||||
if (playback_speed == 0)
|
||||
@@ -450,12 +586,17 @@ bool cPlayback::SetSpeed(int speed)
|
||||
bool cPlayback::GetSpeed(int &speed) const
|
||||
{
|
||||
lt_debug("%s\n", __FUNCTION__);
|
||||
speed = playback_speed;
|
||||
speed = pd->playback_speed;
|
||||
return true;
|
||||
}
|
||||
|
||||
// in milliseconds
|
||||
bool cPlayback::GetPosition(int &position, int &duration)
|
||||
{
|
||||
return pd->GetPosition(position, duration);
|
||||
}
|
||||
|
||||
bool PBPrivate::GetPosition(int &position, int &duration)
|
||||
{
|
||||
int64_t tmppts;
|
||||
lt_debug("%s\n", __FUNCTION__);
|
||||
@@ -532,6 +673,11 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
||||
}
|
||||
|
||||
bool cPlayback::SetPosition(int position, bool absolute)
|
||||
{
|
||||
return pd->SetPosition(position, absolute);
|
||||
}
|
||||
|
||||
bool PBPrivate::SetPosition(int position, bool absolute)
|
||||
{
|
||||
lt_info("%s pos = %d abs = %d\n", __FUNCTION__, position, absolute);
|
||||
int currpos, target, duration, oldspeed;
|
||||
@@ -568,6 +714,11 @@ bool cPlayback::SetPosition(int position, bool absolute)
|
||||
}
|
||||
|
||||
void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language)
|
||||
{
|
||||
pd->FindAllPids(apids, ac3flags, numpida, language);
|
||||
}
|
||||
|
||||
void PBPrivate::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language)
|
||||
{
|
||||
lt_info("%s\n", __FUNCTION__);
|
||||
int i = 0;
|
||||
@@ -605,7 +756,7 @@ void cPlayback::RequestAbort(void)
|
||||
{
|
||||
}
|
||||
|
||||
off_t cPlayback::seek_to_pts(int64_t pts)
|
||||
off_t PBPrivate::seek_to_pts(int64_t pts)
|
||||
{
|
||||
off_t newpos = curr_pos;
|
||||
int64_t tmppts, ptsdiff;
|
||||
@@ -657,7 +808,7 @@ off_t cPlayback::seek_to_pts(int64_t pts)
|
||||
return newpos;
|
||||
}
|
||||
|
||||
bool cPlayback::filelist_auto_add()
|
||||
bool PBPrivate::filelist_auto_add()
|
||||
{
|
||||
if (filelist.size() != 1)
|
||||
return false;
|
||||
@@ -695,7 +846,7 @@ bool cPlayback::filelist_auto_add()
|
||||
}
|
||||
|
||||
/* the mf_* functions are wrappers for multiple-file I/O */
|
||||
int cPlayback::mf_open(int fileno)
|
||||
int PBPrivate::mf_open(int fileno)
|
||||
{
|
||||
if (filelist.empty())
|
||||
return -1;
|
||||
@@ -713,7 +864,7 @@ int cPlayback::mf_open(int fileno)
|
||||
return in_fd;
|
||||
}
|
||||
|
||||
int cPlayback::mf_close(void)
|
||||
int PBPrivate::mf_close(void)
|
||||
{
|
||||
int ret = 0;
|
||||
lt_info("%s in_fd = %d curr_fileno = %d\n", __FUNCTION__, in_fd, curr_fileno);
|
||||
@@ -724,7 +875,7 @@ int cPlayback::mf_close(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t cPlayback::mf_getsize(void)
|
||||
off_t PBPrivate::mf_getsize(void)
|
||||
{
|
||||
off_t ret = 0;
|
||||
if (filelist.size() == 1 && in_fd != -1)
|
||||
@@ -740,7 +891,7 @@ off_t cPlayback::mf_getsize(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t cPlayback::mf_lseek(off_t pos)
|
||||
off_t PBPrivate::mf_lseek(off_t pos)
|
||||
{
|
||||
off_t offset = 0, lpos = pos, ret;
|
||||
unsigned int fileno;
|
||||
@@ -786,7 +937,7 @@ off_t cPlayback::mf_lseek(off_t pos)
|
||||
|
||||
/* gets the PTS at a specific file position from a PES
|
||||
ATTENTION! resets buf! */
|
||||
int64_t cPlayback::get_PES_PTS(uint8_t *buf, int len, bool last)
|
||||
int64_t PBPrivate::get_PES_PTS(uint8_t *buf, int len, bool last)
|
||||
{
|
||||
int64_t pts = -1;
|
||||
int off, plen;
|
||||
@@ -832,7 +983,7 @@ int64_t cPlayback::get_PES_PTS(uint8_t *buf, int len, bool last)
|
||||
}
|
||||
|
||||
/* needs to be called with inbufpos_mutex locked! */
|
||||
ssize_t cPlayback::inbuf_read()
|
||||
ssize_t PBPrivate::inbuf_read()
|
||||
{
|
||||
if (filetype == FILETYPE_UNKNOWN)
|
||||
return -1;
|
||||
@@ -842,7 +993,7 @@ ssize_t cPlayback::inbuf_read()
|
||||
return read_mpeg();
|
||||
}
|
||||
|
||||
ssize_t cPlayback::read_ts()
|
||||
ssize_t PBPrivate::read_ts()
|
||||
{
|
||||
ssize_t toread, ret = 0, sync, off;
|
||||
toread = INBUF_SIZE - inbuf_pos;
|
||||
@@ -1057,7 +1208,7 @@ ssize_t cPlayback::read_ts()
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t cPlayback::read_mpeg()
|
||||
ssize_t PBPrivate::read_mpeg()
|
||||
{
|
||||
ssize_t toread, ret, sync;
|
||||
//toread = PESBUF_SIZE - pesbuf_pos;
|
||||
@@ -1276,7 +1427,7 @@ ssize_t cPlayback::read_mpeg()
|
||||
//== returns offset to start of TS packet or actual ==
|
||||
//== pos on failure. ==
|
||||
//====================================================
|
||||
off_t cPlayback::mp_seekSync(off_t pos)
|
||||
off_t PBPrivate::mp_seekSync(off_t pos)
|
||||
{
|
||||
off_t npos = pos;
|
||||
off_t ret;
|
||||
@@ -1399,7 +1550,7 @@ static int sync_ts(uint8_t *p, int len)
|
||||
|
||||
/* get the pts value from a TS or PES packet
|
||||
pes == true selects PES mode. */
|
||||
int64_t cPlayback::get_pts(uint8_t *p, bool pes, int bufsize)
|
||||
int64_t PBPrivate::get_pts(uint8_t *p, bool pes, int bufsize)
|
||||
{
|
||||
const uint8_t *end = p + bufsize; /* check for overflow */
|
||||
if (bufsize < 14)
|
||||
|
@@ -1,129 +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 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 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
|
@@ -1 +0,0 @@
|
||||
../generic-pc/playback.h
|
Reference in New Issue
Block a user