mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 15:33:00 +02:00
libspark: allow to seek backwards from EOF in cPlayback
This commit is contained in:
@@ -47,12 +47,18 @@ public:
|
|||||||
bool playing;
|
bool playing;
|
||||||
int speed;
|
int speed;
|
||||||
int astream;
|
int astream;
|
||||||
|
bool eof;
|
||||||
|
int length;
|
||||||
|
std::string curfile;
|
||||||
Player *player;
|
Player *player;
|
||||||
PBPrivate() {
|
PBPrivate() {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
playing = false;
|
playing = false;
|
||||||
speed = 0;
|
speed = 0;
|
||||||
astream = -1;
|
astream = -1;
|
||||||
|
eof = false;
|
||||||
|
length = 0;
|
||||||
|
curfile = "";
|
||||||
player = new Player;
|
player = new Player;
|
||||||
};
|
};
|
||||||
~PBPrivate() {
|
~PBPrivate() {
|
||||||
@@ -115,6 +121,7 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
|
|||||||
if (*filename == '/')
|
if (*filename == '/')
|
||||||
file = "file://";
|
file = "file://";
|
||||||
file += filename;
|
file += filename;
|
||||||
|
pd->curfile = file;
|
||||||
|
|
||||||
if (file.substr(0, 7) == "file://") {
|
if (file.substr(0, 7) == "file://") {
|
||||||
if (file.substr(file.length() - 3) == ".ts") {
|
if (file.substr(file.length() - 3) == ".ts") {
|
||||||
@@ -306,6 +313,8 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
if (!player->isPlaying) {
|
if (!player->isPlaying) {
|
||||||
lt_info("%s !!!!EOF!!!! < -1\n", __func__);
|
lt_info("%s !!!!EOF!!!! < -1\n", __func__);
|
||||||
position = duration;
|
position = duration;
|
||||||
|
pd->eof = true;
|
||||||
|
pd->length = duration;
|
||||||
// duration = 0;
|
// duration = 0;
|
||||||
// this is stupid
|
// this is stupid
|
||||||
return true;
|
return true;
|
||||||
@@ -338,7 +347,15 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
|
|
||||||
bool cPlayback::SetPosition(int position, bool absolute)
|
bool cPlayback::SetPosition(int position, bool absolute)
|
||||||
{
|
{
|
||||||
lt_info("%s %d\n", __func__, position);
|
lt_info("%s %d %d\n", __func__, position, absolute);
|
||||||
|
if (pd->eof) {
|
||||||
|
Close();
|
||||||
|
pd->eof = false;
|
||||||
|
Start((char *)pd->curfile.c_str(), pd->player->GetVideoPid(), 0, pd->player->GetAudioPid(), 0, 0);
|
||||||
|
SetSpeed(pd->speed);
|
||||||
|
pd->player->Seek((int64_t)(pd->length - position) * (AV_TIME_BASE / 1000), false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!pd->playing)
|
if (!pd->playing)
|
||||||
{
|
{
|
||||||
/* the calling sequence is:
|
/* the calling sequence is:
|
||||||
|
Reference in New Issue
Block a user