libeplayer3: implement Playback and Input classes

Origin commit data
------------------
Branch: master
Commit: a965fe4359
Author: martii <m4rtii@gmx.de>
Date: 2014-04-07 (Mon, 07 Apr 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2014-04-07 21:01:35 +02:00
parent dffff81e92
commit e02b7dd602

View File

@@ -7,9 +7,7 @@
#include <audio_lib.h> #include <audio_lib.h>
#include <video_lib.h> #include <video_lib.h>
#include <player.h> #include "player.h"
extern PlaybackHandler_t PlaybackHandler;
extern ContainerHandler_t ContainerHandler;
#include "playback_libeplayer3.h" #include "playback_libeplayer3.h"
@@ -51,11 +49,6 @@ bool cPlayback::Open(playmode_t PlayMode)
player = new Player(); player = new Player();
if(player) {
player->playback = &PlaybackHandler;
player->container = &ContainerHandler;
}
return 0; return 0;
} }
@@ -104,13 +97,12 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, un
strcat(file, filename); strcat(file, filename);
//try to open file //try to open file
if(player && player->playback && player->playback->Command(player, PLAYBACK_OPEN, file) >= 0) { if(player && player->playback.Open(file)) {
if (pm != PLAYMODE_TS && player && player->playback) { if (pm != PLAYMODE_TS) {
player->output.Open(); player->output.Open();
SetAPid(apid, 0); SetAPid(apid, 0);
if ( player->playback->Command(player, PLAYBACK_PLAY, NULL) == 0 ) // playback.c uses "int = 0" for "true" ret = player->playback.Play();
ret = true;
} }
} }
@@ -127,7 +119,7 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, un
{ {
//pause playback in case of timeshift //pause playback in case of timeshift
//FIXME: no picture on tv //FIXME: no picture on tv
if (!player || !player->playback || player->playback->Command(player, PLAYBACK_PAUSE, NULL) < 0) if (!player || !player->playback.Pause())
{ {
ret = false; ret = false;
printf("failed to pause playback\n"); printf("failed to pause playback\n");
@@ -148,7 +140,7 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, un
struct stat s; struct stat s;
if (!stat(filename, &s)) if (!stat(filename, &s))
last_size = s.st_size; last_size = s.st_size;
if (player && player->playback) if (player)
{ {
ret = true; ret = true;
videoDecoder->Stop(false); videoDecoder->Stop(false);
@@ -164,14 +156,14 @@ bool cPlayback::Stop(void)
printf("%s:%s playing %d\n", FILENAME, __FUNCTION__, playing); printf("%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
//if(playing==false) return false; //if(playing==false) return false;
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_STOP, NULL); player->playback.Stop();
if(player) if(player)
player->output.Close(); player->output.Close();
if(player && player->playback) if(player)
player->playback->Command(player,PLAYBACK_CLOSE, NULL); player->playback.Close();
if(player) { if(player) {
delete player; delete player;
player = NULL; player = NULL;
@@ -184,10 +176,9 @@ bool cPlayback::Stop(void)
bool cPlayback::SetAPid(int pid, bool ac3 __attribute__((unused))) bool cPlayback::SetAPid(int pid, bool ac3 __attribute__((unused)))
{ {
printf("%s:%s\n", FILENAME, __FUNCTION__); printf("%s:%s\n", FILENAME, __FUNCTION__);
int i=pid;
if(pid!=mAudioStream){ if(pid!=mAudioStream){
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_SWITCH_AUDIO, (void*)&i); player->playback.SwitchAudio(pid);
mAudioStream=pid; mAudioStream=pid;
} }
return true; return true;
@@ -196,10 +187,9 @@ bool cPlayback::SetAPid(int pid, bool ac3 __attribute__((unused)))
bool cPlayback::SetSubtitlePid(int pid) bool cPlayback::SetSubtitlePid(int pid)
{ {
printf("%s:%s\n", FILENAME, __FUNCTION__); printf("%s:%s\n", FILENAME, __FUNCTION__);
int i=pid;
if(pid!=mSubtitleStream){ if(pid!=mSubtitleStream){
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_SWITCH_SUBTITLE, (void*)&i); player->playback.SwitchSubtitle(pid);
mSubtitleStream = pid; mSubtitleStream = pid;
} }
return true; return true;
@@ -208,10 +198,9 @@ bool cPlayback::SetSubtitlePid(int pid)
bool cPlayback::SetTeletextPid(int pid) bool cPlayback::SetTeletextPid(int pid)
{ {
printf("%s:%s\n", FILENAME, __FUNCTION__); printf("%s:%s\n", FILENAME, __FUNCTION__);
int i=pid;
if(pid!=mTeletextStream){ if(pid!=mTeletextStream){
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_SWITCH_TELETEXT, (void*)&i); player->playback.SwitchTeletext(pid);
mTeletextStream=pid; mTeletextStream=pid;
} }
return true; return true;
@@ -227,17 +216,16 @@ bool cPlayback::SetSpeed(int speed)
videoDecoder->closeDevice(); videoDecoder->closeDevice();
decoders_closed = true; decoders_closed = true;
usleep(500000); usleep(500000);
if (player && player->playback) { if (player) {
player->output.Open(); player->output.Open();
if (player->playback->Command(player, PLAYBACK_PLAY, NULL) == 0) // playback.c uses "int = 0" for "true" playing = player->playback.Play();
playing = true;
} }
} }
if(playing==false) if(playing==false)
return false; return false;
if(player && player->playback) if(player)
{ {
int result = 0; int result = 0;
@@ -246,41 +234,39 @@ bool cPlayback::SetSpeed(int speed)
if (speed > 1) if (speed > 1)
{ {
/* direction switch ? */ /* direction switch ? */
if (player->playback->BackWard) if (player->playback.isBackWard)
{ {
int r = 0; result = player->playback.FastBackward(0);
result = player->playback->Command(player, PLAYBACK_FASTBACKWARD, (void*)&r);
printf("result = %d\n", result); printf("result = %d\n", result);
} }
result = player->playback->Command(player, PLAYBACK_FASTFORWARD, (void*)&speed); result = player->playback.FastForward(speed);
} else } else
if (speed < 0) if (speed < 0)
{ {
/* direction switch ? */ /* direction switch ? */
if (player->playback->isForwarding) if (player->playback.isForwarding)
{ {
result = player->playback->Command(player, PLAYBACK_CONTINUE, NULL); result = player->playback.Continue();
printf("result = %d\n", result); printf("result = %d\n", result);
} }
result = player->playback->Command(player, PLAYBACK_FASTBACKWARD, (void*)&speed); result = player->playback.FastBackward(speed);
} }
else else
if (speed == 0) if (speed == 0)
{ {
/* konfetti: hmmm accessing the member isn't very proper */ /* konfetti: hmmm accessing the member isn't very proper */
if ((player->playback->isForwarding) || (!player->playback->BackWard)) if ((player->playback.isForwarding) || (!player->playback.isBackWard))
player->playback->Command(player, PLAYBACK_PAUSE, NULL); player->playback.Pause();
else else
{ {
int _speed = 0; /* means end of reverse playback */ player->playback.FastForward(0);
player->playback->Command(player, PLAYBACK_FASTBACKWARD, (void*)&_speed);
} }
} else } else
{ {
result = player->playback->Command(player, PLAYBACK_CONTINUE, NULL); result = player->playback.Continue();
} }
if (init_jump > -1) if (init_jump > -1)
@@ -306,8 +292,8 @@ bool cPlayback::GetSpeed(int &speed) const
void cPlayback::GetPts(uint64_t &pts) void cPlayback::GetPts(uint64_t &pts)
{ {
if (player && player->playback) if (player)
player->playback->Command(player, PLAYBACK_PTS, (void*)&pts); player->playback.GetPts((int64_t &) pts);
} }
// in milliseconds // in milliseconds
@@ -339,15 +325,15 @@ bool cPlayback::GetPosition(int &position, int &duration)
if(playing==false) return false; if(playing==false) return false;
if (player && player->playback && !player->playback->isPlaying) { if (player && !player->playback.isPlaying) {
printf("cPlayback::%s !!!!EOF!!!! < -1\n", __func__); printf("cPlayback::%s !!!!EOF!!!! < -1\n", __func__);
position = duration + 1000; position = duration + 1000;
return false; return false;
} }
unsigned long long int vpts = 0; int64_t vpts = 0;
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_PTS, &vpts); player->playback.GetPts(vpts);
if(vpts <= 0) { if(vpts <= 0) {
//printf("ERROR: vpts==0"); //printf("ERROR: vpts==0");
@@ -361,8 +347,8 @@ bool cPlayback::GetPosition(int &position, int &duration)
double length = 0; double length = 0;
if(player && player->playback) if(player)
player->playback->Command(player, PLAYBACK_LENGTH, &length); player->playback.GetDuration(length);
if(length <= 0) { if(length <= 0) {
duration = duration+1000; duration = duration+1000;
@@ -388,8 +374,8 @@ bool cPlayback::SetPosition(int position, bool absolute)
return false; return false;
} }
float pos = (position/1000.0); float pos = (position/1000.0);
if(player && player->playback) if(player)
player->playback->Command(player, absolute ? PLAYBACK_SEEK_ABS : PLAYBACK_SEEK, (void*)&pos); player->playback.Seek(pos, absolute);
return true; return true;
} }
@@ -475,53 +461,17 @@ bool cPlayback::SelectSubtitles(int pid)
void cPlayback::GetChapters(std::vector<int> &positions, std::vector<std::string> &titles) void cPlayback::GetChapters(std::vector<int> &positions, std::vector<std::string> &titles)
{ {
positions.clear(); player->GetChapters(positions, titles);
titles.clear();
#if 0 // FIXME ... later
if(player && player->manager && player->manager->chapter) {
char ** TrackList = NULL;
player->manager->chapter->Command(player, MANAGER_LIST, &TrackList);
if (TrackList != NULL) {
printf("%s: Chapter List\n", __func__);
int i = 0;
for (i = 0; TrackList[i] != NULL; i+=2) {
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
int pos = atoi(TrackList[i]);
std::string title(TrackList[i + 1]);
positions.push_back(pos);
titles.push_back(title);
free(TrackList[i]);
free(TrackList[i+1]);
}
free(TrackList);
}
}
#endif
} }
void cPlayback::GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values) void cPlayback::GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values)
{ {
#if 0 // FIXME ... later printf("%s:%s\n", FILENAME, __FUNCTION__);
keys.clear(); if (!player)
values.clear(); return;
char **metadata = NULL; player->input.GetMetadata(keys, values);
if (player && player->playback) {
player->playback->Command(player, PLAYBACK_METADATA, &metadata);
if (metadata) {
for (char **m = metadata; *m;) {
keys.push_back(*m);
free(*m++);
values.push_back(*m);
free(*m++);
}
free(metadata);
}
}
#endif
} }
//
cPlayback::cPlayback(int num __attribute__((unused))) cPlayback::cPlayback(int num __attribute__((unused)))
{ {
printf("%s:%s\n", FILENAME, __FUNCTION__); printf("%s:%s\n", FILENAME, __FUNCTION__);
@@ -534,23 +484,22 @@ cPlayback::~cPlayback()
} }
void cPlayback::RequestAbort() { void cPlayback::RequestAbort() {
if (player && player->playback) { if (player) {
player->playback->abortRequested = 1; player->playback.abortRequested = 1;
while (player->playback->isPlaying) while (player->playback.isPlaying)
usleep(100000); usleep(100000);
} }
} }
bool cPlayback::IsPlaying() { bool cPlayback::IsPlaying() {
if (player && player->playback) if (player)
return player->playback->isPlaying; return player->playback.isPlaying;
return false; return false;
} }
unsigned long long cPlayback::GetReadCount() { unsigned long long cPlayback::GetReadCount() {
if (player && player->playback) { if (player)
return player->playback->readCount; return player->playback.readCount;
}
return 0; return 0;
} }