mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
libeplayer3: work around duplicate ffmpeg stream ids by comparing stream addresses instead of pids (plus a couple of optimizations)
Origin commit data
------------------
Branch: master
Commit: 908ff30629
Author: martii <m4rtii@gmx.de>
Date: 2014-04-10 (Thu, 10 Apr 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -60,7 +60,7 @@ Input::~Input()
|
|||||||
int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts)
|
int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts)
|
||||||
{
|
{
|
||||||
if (!avfc || !stream) {
|
if (!avfc || !stream) {
|
||||||
fprintf(stderr, "player / stream null\n");
|
fprintf(stderr, "context / stream null\n");
|
||||||
return INVALID_PTS_VALUE;
|
return INVALID_PTS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +168,7 @@ bool Input::Play()
|
|||||||
for (i = 0; i < avfc->nb_streams; i++)
|
for (i = 0; i < avfc->nb_streams; i++)
|
||||||
if (avfc->streams[i]->codec && avfc->streams[i]->codec->codec)
|
if (avfc->streams[i]->codec && avfc->streams[i]->codec->codec)
|
||||||
avcodec_flush_buffers(avfc->streams[i]->codec);
|
avcodec_flush_buffers(avfc->streams[i]->codec);
|
||||||
|
player->output.ClearVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
@@ -183,14 +184,13 @@ bool Input::Play()
|
|||||||
|
|
||||||
player->readCount += packet.size;
|
player->readCount += packet.size;
|
||||||
|
|
||||||
int pid = avfc->streams[packet.stream_index]->id;
|
AVStream *stream = avfc->streams[packet.stream_index];
|
||||||
|
|
||||||
Track *_videoTrack = videoTrack;
|
Track *_videoTrack = videoTrack;
|
||||||
Track *_audioTrack = audioTrack;
|
Track *_audioTrack = audioTrack;
|
||||||
Track *_subtitleTrack = subtitleTrack;
|
Track *_subtitleTrack = subtitleTrack;
|
||||||
Track *_teletextTrack = teletextTrack;
|
Track *_teletextTrack = teletextTrack;
|
||||||
|
|
||||||
if (_videoTrack && (_videoTrack->pid == pid)) {
|
if (_videoTrack && (_videoTrack->stream == stream)) {
|
||||||
int64_t pts = calcPts(avfc, _videoTrack->stream, packet.pts);
|
int64_t pts = calcPts(avfc, _videoTrack->stream, packet.pts);
|
||||||
if (!player->output.Write(avfc, _videoTrack->stream, &packet, pts)) {
|
if (!player->output.Write(avfc, _videoTrack->stream, &packet, pts)) {
|
||||||
if (warnVideoWrite)
|
if (warnVideoWrite)
|
||||||
@@ -200,7 +200,7 @@ bool Input::Play()
|
|||||||
warnVideoWrite = 100;
|
warnVideoWrite = 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_audioTrack && (_audioTrack->pid == pid)) {
|
} else if (_audioTrack && (_audioTrack->stream == stream)) {
|
||||||
if (restart_audio_resampling) {
|
if (restart_audio_resampling) {
|
||||||
restart_audio_resampling = false;
|
restart_audio_resampling = false;
|
||||||
player->output.Write(avfc, _audioTrack->stream, NULL, 0);
|
player->output.Write(avfc, _audioTrack->stream, NULL, 0);
|
||||||
@@ -216,7 +216,7 @@ bool Input::Play()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_subtitleTrack && (_subtitleTrack->pid == pid)) {
|
} else if (_subtitleTrack && (_subtitleTrack->stream == stream)) {
|
||||||
if (((AVStream *) _subtitleTrack->stream)->codec->codec) {
|
if (((AVStream *) _subtitleTrack->stream)->codec->codec) {
|
||||||
AVSubtitle sub;
|
AVSubtitle sub;
|
||||||
memset(&sub, 0, sizeof(sub));
|
memset(&sub, 0, sizeof(sub));
|
||||||
@@ -229,7 +229,7 @@ bool Input::Play()
|
|||||||
switch (sub.rects[0]->type) {
|
switch (sub.rects[0]->type) {
|
||||||
case SUBTITLE_TEXT: // FIXME?
|
case SUBTITLE_TEXT: // FIXME?
|
||||||
case SUBTITLE_ASS:
|
case SUBTITLE_ASS:
|
||||||
dvbsub_ass_write(((AVStream *) _subtitleTrack->stream)->codec, &sub, pid);
|
dvbsub_ass_write(_subtitleTrack->stream->codec, &sub, _subtitleTrack->stream->id);
|
||||||
break;
|
break;
|
||||||
case SUBTITLE_BITMAP: {
|
case SUBTITLE_BITMAP: {
|
||||||
int64_t pts = calcPts(avfc, _subtitleTrack->stream, packet.pts);
|
int64_t pts = calcPts(avfc, _subtitleTrack->stream, packet.pts);
|
||||||
@@ -242,8 +242,8 @@ bool Input::Play()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_teletextTrack && (_teletextTrack->pid == pid)) {
|
} else if (_teletextTrack && (_teletextTrack->stream == stream)) {
|
||||||
teletext_write(pid, packet.data, packet.size);
|
teletext_write(_teletextTrack->stream->id, packet.data, packet.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
|
@@ -128,6 +128,7 @@ bool Output::Play()
|
|||||||
|
|
||||||
if (videoStream && videofd > -1) {
|
if (videoStream && videofd > -1) {
|
||||||
videoWriter = Writer::GetWriter(videoStream->codec->codec_id, videoStream->codec->codec_type);
|
videoWriter = Writer::GetWriter(videoStream->codec->codec_id, videoStream->codec->codec_type);
|
||||||
|
videoWriter->Init();
|
||||||
if (dioctl(videofd, VIDEO_SET_ENCODING, videoWriter->GetVideoEncoding(videoStream->codec->codec_id))
|
if (dioctl(videofd, VIDEO_SET_ENCODING, videoWriter->GetVideoEncoding(videoStream->codec->codec_id))
|
||||||
|| dioctl(videofd, VIDEO_PLAY, NULL))
|
|| dioctl(videofd, VIDEO_PLAY, NULL))
|
||||||
ret = false;
|
ret = false;
|
||||||
@@ -135,6 +136,7 @@ bool Output::Play()
|
|||||||
|
|
||||||
if (audioStream && audiofd > -1) {
|
if (audioStream && audiofd > -1) {
|
||||||
audioWriter = Writer::GetWriter(audioStream->codec->codec_id, audioStream->codec->codec_type);
|
audioWriter = Writer::GetWriter(audioStream->codec->codec_id, audioStream->codec->codec_type);
|
||||||
|
audioWriter->Init();
|
||||||
if (dioctl(audiofd, AUDIO_SET_ENCODING, audioWriter->GetAudioEncoding(audioStream->codec->codec_id))
|
if (dioctl(audiofd, AUDIO_SET_ENCODING, audioWriter->GetAudioEncoding(audioStream->codec->codec_id))
|
||||||
|| dioctl(audiofd, AUDIO_PLAY, NULL))
|
|| dioctl(audiofd, AUDIO_PLAY, NULL))
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@@ -72,10 +72,7 @@ bool Player::Open(const char *Url, bool _noprobe)
|
|||||||
|
|
||||||
manager.clearTracks();
|
manager.clearTracks();
|
||||||
|
|
||||||
if (*Url == '/') {
|
if (!strncmp("mms://", Url, 6)) {
|
||||||
url = "file://";
|
|
||||||
url += Url;
|
|
||||||
} else if (!strncmp("mms://", Url, 6)) {
|
|
||||||
url = "mmst";
|
url = "mmst";
|
||||||
url += Url + 3;
|
url += Url + 3;
|
||||||
isHttp = true;
|
isHttp = true;
|
||||||
@@ -207,7 +204,6 @@ bool Player::Stop()
|
|||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
|
|
||||||
isPaused = false;
|
isPaused = false;
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
isForwarding = false;
|
isForwarding = false;
|
||||||
|
@@ -54,16 +54,14 @@ bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
uint8_t FakeHeaders[64]; // 64bytes should be enough to make the fake headers
|
uint8_t FakeHeaders[64] = { 0 }; // 64bytes should be enough to make the fake headers
|
||||||
unsigned int FakeHeaderLength;
|
unsigned int FakeHeaderLength;
|
||||||
uint8_t Version = 5;
|
uint8_t Version = 5;
|
||||||
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
|
unsigned int FakeStartCode = (Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||||
unsigned int usecPerFrame = 41708; /* Hellmaster1024: default value */
|
unsigned int usecPerFrame = 41708; /* Hellmaster1024: default value */
|
||||||
BitPacker_t ld = { FakeHeaders, 0, 32 };
|
BitPacker_t ld = { FakeHeaders, 0, 32 };
|
||||||
|
|
||||||
usecPerFrame = 1000000 / av_q2d(stream->r_frame_rate);
|
usecPerFrame = 1000000.0 / av_q2d(stream->r_frame_rate);
|
||||||
|
|
||||||
memset(FakeHeaders, 0, sizeof(FakeHeaders));
|
|
||||||
|
|
||||||
/* Create info record for frame parser */
|
/* Create info record for frame parser */
|
||||||
/* divx4 & 5
|
/* divx4 & 5
|
||||||
@@ -75,11 +73,10 @@ bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
PutBits(&ld, 0, 8); // profile = reserved
|
PutBits(&ld, 0, 8); // profile = reserved
|
||||||
PutBits(&ld, 0x1b2, 32); // startcode (user data)
|
PutBits(&ld, 0x1b2, 32); // startcode (user data)
|
||||||
PutBits(&ld, 0x53545443, 32); // STTC - an embedded ST timecode from an avi file
|
PutBits(&ld, 0x53545443, 32); // STTC - an embedded ST timecode from an avi file
|
||||||
PutBits(&ld, usecPerFrame, 32);
|
PutBits(&ld, usecPerFrame, 32); // microseconds per frame
|
||||||
// microseconds per frame
|
|
||||||
FlushBits(&ld);
|
FlushBits(&ld);
|
||||||
|
|
||||||
FakeHeaderLength = (ld.Ptr - (FakeHeaders));
|
FakeHeaderLength = (ld.Ptr - FakeHeaders);
|
||||||
|
|
||||||
struct iovec iov[4];
|
struct iovec iov[4];
|
||||||
int ic = 0;
|
int ic = 0;
|
||||||
|
@@ -38,9 +38,9 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
|||||||
|
|
||||||
#ifdef DEBUG_PUTBITS
|
#ifdef DEBUG_PUTBITS
|
||||||
if (ld->debug)
|
if (ld->debug)
|
||||||
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n",
|
dprintf("code = %d, length = %d, bit_buf = 0x%x, bit_left = %d\n",
|
||||||
code, length, bit_buf, bit_left);
|
code, length, bit_buf, bit_left);
|
||||||
#endif /* DEBUG_PUTBITS */
|
#endif
|
||||||
|
|
||||||
if (length < bit_left) {
|
if (length < bit_left) {
|
||||||
/* fits into current buffer */
|
/* fits into current buffer */
|
||||||
@@ -50,10 +50,10 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
|||||||
/* doesn't fit */
|
/* doesn't fit */
|
||||||
bit_buf <<= bit_left;
|
bit_buf <<= bit_left;
|
||||||
bit_buf |= code >> (length - bit_left);
|
bit_buf |= code >> (length - bit_left);
|
||||||
ld->Ptr[0] = (char) (bit_buf >> 24);
|
ld->Ptr[0] = (uint8_t) (bit_buf >> 24);
|
||||||
ld->Ptr[1] = (char) (bit_buf >> 16);
|
ld->Ptr[1] = (uint8_t) (bit_buf >> 16);
|
||||||
ld->Ptr[2] = (char) (bit_buf >> 8);
|
ld->Ptr[2] = (uint8_t) (bit_buf >> 8);
|
||||||
ld->Ptr[3] = (char) bit_buf;
|
ld->Ptr[3] = (uint8_t) bit_buf;
|
||||||
ld->Ptr += 4;
|
ld->Ptr += 4;
|
||||||
length -= bit_left;
|
length -= bit_left;
|
||||||
bit_buf = code & ((1 << length) - 1);
|
bit_buf = code & ((1 << length) - 1);
|
||||||
@@ -64,7 +64,7 @@ void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length)
|
|||||||
#ifdef DEBUG_PUTBITS
|
#ifdef DEBUG_PUTBITS
|
||||||
if (ld->debug)
|
if (ld->debug)
|
||||||
dprintf("bit_left = %d, bit_buf = 0x%x\n", bit_left, bit_buf);
|
dprintf("bit_left = %d, bit_buf = 0x%x\n", bit_left, bit_buf);
|
||||||
#endif /* DEBUG_PUTBITS */
|
#endif
|
||||||
|
|
||||||
/* writeback */
|
/* writeback */
|
||||||
ld->BitBuffer = bit_buf;
|
ld->BitBuffer = bit_buf;
|
||||||
@@ -78,7 +78,7 @@ void FlushBits(BitPacker_t * ld)
|
|||||||
#ifdef DEBUG_PUTBITS
|
#ifdef DEBUG_PUTBITS
|
||||||
if (ld->debug)
|
if (ld->debug)
|
||||||
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);
|
dprintf("flushing 0x%2.2x\n", ld->BitBuffer >> 24);
|
||||||
#endif /* DEBUG_PUTBITS */
|
#endif
|
||||||
*ld->Ptr++ = ld->BitBuffer >> 24;
|
*ld->Ptr++ = ld->BitBuffer >> 24;
|
||||||
ld->BitBuffer <<= 8;
|
ld->BitBuffer <<= 8;
|
||||||
ld->Remaining += 8;
|
ld->Remaining += 8;
|
||||||
|
@@ -17,18 +17,12 @@ extern cVideo *videoDecoder;
|
|||||||
//Used by Fileplay
|
//Used by Fileplay
|
||||||
bool cPlayback::Open(playmode_t PlayMode)
|
bool cPlayback::Open(playmode_t PlayMode)
|
||||||
{
|
{
|
||||||
const char *aPLAYMODE[] = {
|
|
||||||
"PLAYMODE_TS",
|
|
||||||
"PLAYMODE_FILE"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (PlayMode != PLAYMODE_TS) {
|
if (PlayMode != PLAYMODE_TS) {
|
||||||
audioDecoder->closeDevice();
|
audioDecoder->closeDevice();
|
||||||
videoDecoder->closeDevice();
|
videoDecoder->closeDevice();
|
||||||
decoders_closed = true;
|
decoders_closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s:%s - PlayMode=%s\n", __FILE__, __func__, aPLAYMODE[PlayMode]);
|
|
||||||
pm = PlayMode;
|
pm = PlayMode;
|
||||||
fn_ts = "";
|
fn_ts = "";
|
||||||
fn_xml = "";
|
fn_xml = "";
|
||||||
@@ -39,95 +33,73 @@ bool cPlayback::Open(playmode_t PlayMode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used by Fileplay
|
|
||||||
void cPlayback::Close(void)
|
void cPlayback::Close(void)
|
||||||
{
|
{
|
||||||
printf("%s:%s\n", __FILE__, __func__);
|
printf("%s %s %d\n", __FILE__, __func__, __LINE__);
|
||||||
|
|
||||||
//Dagobert: movieplayer does not call stop, it calls close ;)
|
//Dagobert: movieplayer does not call stop, it calls close ;)
|
||||||
Stop();
|
Stop();
|
||||||
if (decoders_closed)
|
if (decoders_closed) {
|
||||||
{
|
|
||||||
audioDecoder->openDevice();
|
audioDecoder->openDevice();
|
||||||
videoDecoder->openDevice();
|
videoDecoder->openDevice();
|
||||||
decoders_closed = false;
|
decoders_closed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used by Fileplay
|
|
||||||
bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, unsigned int)
|
bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, unsigned int)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool isHTTP = false;
|
bool isHTTP = false;
|
||||||
no_probe = false;
|
no_probe = false;
|
||||||
|
|
||||||
printf("%s:%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d, no_probe=%d\n",
|
fprintf(stderr, "%s:%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d\n", __FILE__, __func__, filename, vpid, vtype, apid, ac3);
|
||||||
__FILE__, __func__, filename, vpid, vtype, apid, ac3, no_probe);
|
|
||||||
|
|
||||||
init_jump = -1;
|
init_jump = -1;
|
||||||
|
|
||||||
//try to open file
|
std::string file;
|
||||||
if(player && player->Open(filename, no_probe)) {
|
if (*filename == '/')
|
||||||
if (pm != PLAYMODE_TS) {
|
file = "file://";
|
||||||
player->output.Open();
|
file += filename;
|
||||||
|
|
||||||
SetAPid(apid, 0);
|
if (file.substr(0, 7) == "file://") {
|
||||||
ret = player->Play();
|
if (file.substr(file.length() - 3) == ".ts") {
|
||||||
|
fn_xml = file.substr(7, file.length() - 2);
|
||||||
|
fn_xml += "xml";
|
||||||
|
no_probe = true;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
isHTTP = true;
|
||||||
|
|
||||||
/* konfetti: in case of upnp playing mp4 often leads to a
|
if (player->Open(file.c_str(), no_probe)) {
|
||||||
* paused playback but data is already injected which leads
|
if (pm == PLAYMODE_TS) {
|
||||||
* to errors ...
|
struct stat s;
|
||||||
* and I don't see any sense of pausing direct after starting
|
if (!stat(file.c_str(), &s))
|
||||||
* with the exception of timeshift. but this should be handled
|
last_size = s.st_size;
|
||||||
* outside this lib or with another function!
|
|
||||||
*/
|
|
||||||
if (pm != PLAYMODE_TS) {
|
|
||||||
if ((ret) && (!isHTTP)) {
|
|
||||||
//pause playback in case of timeshift
|
|
||||||
//FIXME: no picture on tv
|
|
||||||
if (!player->Pause()) {
|
|
||||||
ret = false;
|
|
||||||
printf("failed to pause playback\n");
|
|
||||||
} else
|
|
||||||
playing = true;
|
|
||||||
} else
|
|
||||||
playing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%s:%s - return=%d\n", __FILE__, __func__, ret);
|
|
||||||
|
|
||||||
fn_ts = std::string(filename);
|
|
||||||
if (fn_ts.length() > 3 && fn_ts.rfind(".ts") == fn_ts.length() - 3) {
|
|
||||||
fn_xml = fn_ts.substr(0, fn_ts.length() - 3) + ".xml";
|
|
||||||
no_probe = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pm == PLAYMODE_TS) {
|
|
||||||
struct stat s;
|
|
||||||
if (!stat(filename, &s))
|
|
||||||
last_size = s.st_size;
|
|
||||||
if (player) {
|
|
||||||
ret = true;
|
ret = true;
|
||||||
videoDecoder->Stop(false);
|
videoDecoder->Stop(false);
|
||||||
audioDecoder->Stop();
|
audioDecoder->Stop();
|
||||||
|
} else {
|
||||||
|
playing = true;
|
||||||
|
player->output.Open();
|
||||||
|
if (apid)
|
||||||
|
SetAPid(apid, 0);
|
||||||
|
ret = player->Play();
|
||||||
|
if (ret && !isHTTP)
|
||||||
|
playing = ret = player->Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used by Fileplay
|
|
||||||
bool cPlayback::Stop(void)
|
bool cPlayback::Stop(void)
|
||||||
{
|
{
|
||||||
printf("%s:%s playing %d\n", __FILE__, __func__, playing);
|
printf("%s:%s playing %d\n", __FILE__, __func__, playing);
|
||||||
//if(playing==false) return false;
|
|
||||||
|
|
||||||
player->Stop();
|
player->Stop();
|
||||||
player->output.Close();
|
player->output.Close();
|
||||||
player->Close();
|
player->Close();
|
||||||
|
|
||||||
playing=false;
|
playing = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +122,7 @@ bool cPlayback::SetSpeed(int speed)
|
|||||||
{
|
{
|
||||||
printf("%s:%s playing %d speed %d\n", __FILE__, __func__, playing, speed);
|
printf("%s:%s playing %d speed %d\n", __FILE__, __func__, playing, speed);
|
||||||
|
|
||||||
if (! decoders_closed)
|
if (!decoders_closed) {
|
||||||
{
|
|
||||||
audioDecoder->closeDevice();
|
audioDecoder->closeDevice();
|
||||||
videoDecoder->closeDevice();
|
videoDecoder->closeDevice();
|
||||||
decoders_closed = true;
|
decoders_closed = true;
|
||||||
@@ -160,45 +131,38 @@ bool cPlayback::SetSpeed(int speed)
|
|||||||
playing = player->Play();
|
playing = player->Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playing==false)
|
if(!playing)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int result = 0;
|
bool res = true;
|
||||||
|
|
||||||
nPlaybackSpeed = speed;
|
nPlaybackSpeed = speed;
|
||||||
|
|
||||||
if (speed > 1) {
|
if (speed > 1) {
|
||||||
/* direction switch ? */
|
/* direction switch ? */
|
||||||
if (player->isBackWard) {
|
if (player->isBackWard)
|
||||||
result = player->FastBackward(0);
|
player->FastBackward(0);
|
||||||
}
|
res = player->FastForward(speed);
|
||||||
result = player->FastForward(speed);
|
|
||||||
} else if (speed < 0) {
|
} else if (speed < 0) {
|
||||||
/* direction switch ? */
|
/* direction switch ? */
|
||||||
if (player->isForwarding) {
|
if (player->isForwarding)
|
||||||
result = player->Continue();
|
player->Continue();
|
||||||
}
|
res = player->FastBackward(speed);
|
||||||
result = player->FastBackward(speed);
|
|
||||||
} else if (speed == 0) {
|
} else if (speed == 0) {
|
||||||
/* konfetti: hmmm accessing the member isn't very proper */
|
/* konfetti: hmmm accessing the member isn't very proper */
|
||||||
if ((player->isForwarding) || (!player->isBackWard))
|
if ((player->isForwarding) || (!player->isBackWard))
|
||||||
player->Pause();
|
/* res = */ player->Pause();
|
||||||
else {
|
else
|
||||||
player->FastForward(0);
|
/* res = */ player->FastForward(0);
|
||||||
}
|
} else /* speed == 1 */ {
|
||||||
} else {
|
res = player->Continue();
|
||||||
result = player->Continue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_jump > -1) {
|
if (init_jump > -1) {
|
||||||
SetPosition(init_jump);
|
SetPosition(init_jump);
|
||||||
init_jump = -1;
|
init_jump = -1;
|
||||||
}
|
}
|
||||||
if (!result) {
|
return res;
|
||||||
printf("returning false\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPlayback::GetSpeed(int &speed) const
|
bool cPlayback::GetSpeed(int &speed) const
|
||||||
@@ -221,16 +185,13 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
* by comparing the mtime with the mtime of the xml file */
|
* by comparing the mtime with the mtime of the xml file */
|
||||||
if (pm == PLAYMODE_TS) {
|
if (pm == PLAYMODE_TS) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (!stat(fn_ts.c_str(), &s))
|
if (!stat(fn_ts.c_str(), &s)) {
|
||||||
{
|
if (!playing || last_size != s.st_size) {
|
||||||
if (! playing || last_size != s.st_size)
|
|
||||||
{
|
|
||||||
last_size = s.st_size;
|
last_size = s.st_size;
|
||||||
time_t curr_time = s.st_mtime;
|
time_t curr_time = s.st_mtime;
|
||||||
if (!stat(fn_xml.c_str(), &s))
|
if (!stat(fn_xml.c_str(), &s)) {
|
||||||
{
|
|
||||||
duration = (curr_time - s.st_mtime) * 1000;
|
duration = (curr_time - s.st_mtime) * 1000;
|
||||||
if (! playing)
|
if (!playing)
|
||||||
return true;
|
return true;
|
||||||
got_duration = true;
|
got_duration = true;
|
||||||
}
|
}
|
||||||
@@ -238,7 +199,8 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playing==false) return false;
|
if (!playing)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!player->isPlaying) {
|
if (!player->isPlaying) {
|
||||||
printf("cPlayback::%s !!!!EOF!!!! < -1\n", __func__);
|
printf("cPlayback::%s !!!!EOF!!!! < -1\n", __func__);
|
||||||
@@ -263,19 +225,17 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
|
|
||||||
player->GetDuration(length);
|
player->GetDuration(length);
|
||||||
|
|
||||||
if(length <= 0) {
|
if(length <= 0)
|
||||||
duration = duration+1000;
|
duration = duration+1000;
|
||||||
} else {
|
else
|
||||||
duration = length*1000.0;
|
duration = length*1000.0;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPlayback::SetPosition(int position, bool absolute)
|
bool cPlayback::SetPosition(int position, bool absolute)
|
||||||
{
|
{
|
||||||
if (playing == false)
|
if (!playing) {
|
||||||
{
|
|
||||||
/* the calling sequence is:
|
/* the calling sequence is:
|
||||||
* Start() - paused
|
* Start() - paused
|
||||||
* SetPosition() - which fails if not running
|
* SetPosition() - which fails if not running
|
||||||
@@ -359,7 +319,7 @@ void cPlayback::GetMetadata(std::vector<std::string> &keys, std::vector<std::str
|
|||||||
|
|
||||||
cPlayback::cPlayback(int num __attribute__((unused)))
|
cPlayback::cPlayback(int num __attribute__((unused)))
|
||||||
{
|
{
|
||||||
playing=false;
|
playing = false;
|
||||||
decoders_closed = false;
|
decoders_closed = false;
|
||||||
player = new Player();
|
player = new Player();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user