mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3: extend API
This commit is contained in:
@@ -4,8 +4,8 @@ AM_CPPFLAGS = -I$(srcdir)/include
|
||||
AM_CPPFLAGS += -Wall
|
||||
AM_CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||
AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
|
||||
AM_CPPFLAGS += -fno-rtti
|
||||
#AM_CPPFLAGS += -ggdb
|
||||
#AM_CPPFLAGS += -fno-rtti
|
||||
AM_CPPFLAGS += -ggdb
|
||||
|
||||
libeplayer3_la_SOURCES = \
|
||||
input.cpp output.cpp manager.cpp player.cpp \
|
||||
|
@@ -56,7 +56,6 @@ class Input
|
||||
float seek_sec_abs;
|
||||
float seek_sec_rel;
|
||||
bool isContainerRunning;
|
||||
bool terminating;
|
||||
bool abortPlayback;
|
||||
|
||||
Player *player;
|
||||
|
@@ -90,6 +90,11 @@ class Player {
|
||||
bool SwitchTeletext(int pid);
|
||||
bool SwitchSubtitle(int pid);
|
||||
|
||||
int GetAudioPid();
|
||||
int GetVideoPid();
|
||||
int GetSubtitlePid();
|
||||
int GetTeletextPid();
|
||||
|
||||
bool GetPts(int64_t &pts);
|
||||
bool GetFrameCount(int64_t &framecount);
|
||||
bool GetDuration(double &duration);
|
||||
@@ -98,6 +103,7 @@ class Player {
|
||||
bool SlowMotion(int repeats);
|
||||
bool FastBackward(int speed);
|
||||
bool FastForward(int speed);
|
||||
|
||||
bool Open(const char *Url, bool noprobe = false);
|
||||
bool Close();
|
||||
bool Play();
|
||||
|
@@ -49,7 +49,7 @@ Input::Input()
|
||||
hasPlayThreadStarted = 0;
|
||||
seek_sec_abs = -1.0;
|
||||
seek_sec_rel = 0.0;
|
||||
terminating = false;
|
||||
abortPlayback = false;
|
||||
}
|
||||
|
||||
Input::~Input()
|
||||
@@ -377,8 +377,6 @@ bool Input::Init(const char *filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
terminating = false;
|
||||
|
||||
bool res = UpdateTracks();
|
||||
|
||||
if (!videoTrack && !audioTrack) {
|
||||
@@ -398,19 +396,15 @@ bool Input::Init(const char *filename)
|
||||
|
||||
bool Input::UpdateTracks()
|
||||
{
|
||||
if (terminating)
|
||||
if (abortPlayback)
|
||||
return true;
|
||||
|
||||
std::vector<Chapter> chapters;
|
||||
for (unsigned int i = 0; i < avfc->nb_chapters; i++) {
|
||||
AVDictionaryEntry *title = av_dict_get(avfc->metadata, "title", NULL, 0);
|
||||
if (!title)
|
||||
continue;
|
||||
AVChapter *ch = avfc->chapters[i];
|
||||
if (!ch)
|
||||
continue;
|
||||
AVDictionaryEntry* title = av_dict_get(ch->metadata, "title", NULL, 0);
|
||||
Chapter chapter;
|
||||
chapter.title = title ? title->value : "?";
|
||||
chapter.title = title ? title->value : "";
|
||||
chapter.start = (double) ch->start * av_q2d(ch->time_base) * 1000.0;
|
||||
chapter.end = (double) ch->end * av_q2d(ch->time_base) * 1000.0;
|
||||
chapters.push_back(chapter);
|
||||
@@ -496,11 +490,12 @@ bool Input::UpdateTracks()
|
||||
stream->codec->codec = avcodec_find_decoder(stream->codec->codec_id);
|
||||
if (!stream->codec->codec)
|
||||
fprintf(stderr, "avcodec_find_decoder failed for subtitle track %d\n", n);
|
||||
else if (avcodec_open2(stream->codec, stream->codec->codec, NULL)) {
|
||||
fprintf(stderr, "avcodec_open2 failed for subtitle track %d\n", n);
|
||||
stream->codec->codec = NULL;
|
||||
else {
|
||||
int err = avcodec_open2(stream->codec, stream->codec->codec, NULL);
|
||||
if (averror(err, avcodec_open2))
|
||||
stream->codec->codec = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stream->codec->codec)
|
||||
player->manager.addSubtitleTrack(track);
|
||||
}
|
||||
@@ -522,8 +517,6 @@ bool Input::Stop()
|
||||
while (hasPlayThreadStarted != 0)
|
||||
usleep(100000);
|
||||
|
||||
terminating = true;
|
||||
|
||||
if (avfc)
|
||||
avformat_close_input(&avfc);
|
||||
|
||||
|
@@ -156,5 +156,5 @@ void Manager::clearTracks()
|
||||
|
||||
Manager::~Manager()
|
||||
{
|
||||
clearTracks();
|
||||
clearTracks();
|
||||
}
|
||||
|
@@ -38,6 +38,13 @@ Player::Player()
|
||||
output.player = this;
|
||||
manager.player = this;
|
||||
hasThreadStarted = false;
|
||||
|
||||
isPaused = false;
|
||||
isPlaying = false;
|
||||
isForwarding = false;
|
||||
isBackWard = false;
|
||||
isSlowMotion = false;
|
||||
Speed = 0;
|
||||
}
|
||||
|
||||
void *Player::playthread(void *arg)
|
||||
@@ -337,25 +344,25 @@ bool Player::GetDuration(double &duration)
|
||||
bool Player::SwitchVideo(int pid)
|
||||
{
|
||||
Track *track = manager.getVideoTrack(pid);
|
||||
return track && input.SwitchVideo(track);
|
||||
return input.SwitchVideo(track);
|
||||
}
|
||||
|
||||
bool Player::SwitchAudio(int pid)
|
||||
{
|
||||
Track *track = manager.getAudioTrack(pid);
|
||||
return track && input.SwitchAudio(track);
|
||||
return input.SwitchAudio(track);
|
||||
}
|
||||
|
||||
bool Player::SwitchSubtitle(int pid)
|
||||
{
|
||||
Track *track = manager.getSubtitleTrack(pid);
|
||||
return track && input.SwitchSubtitle(track);
|
||||
return input.SwitchSubtitle(track);
|
||||
}
|
||||
|
||||
bool Player::SwitchTeletext(int pid)
|
||||
{
|
||||
Track *track = manager.getTeletextTrack(pid);
|
||||
return track && input.SwitchTeletext(track);
|
||||
return input.SwitchTeletext(track);
|
||||
}
|
||||
|
||||
bool Player::GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values)
|
||||
@@ -386,3 +393,35 @@ void Player::RequestAbort()
|
||||
{
|
||||
abortRequested = true;
|
||||
}
|
||||
|
||||
int Player::GetVideoPid()
|
||||
{
|
||||
Track *track = input.videoTrack;
|
||||
if (track)
|
||||
return track->pid;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Player::GetAudioPid()
|
||||
{
|
||||
Track *track = input.audioTrack;
|
||||
if (track)
|
||||
return track->pid;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Player::GetSubtitlePid()
|
||||
{
|
||||
Track *track = input.subtitleTrack;
|
||||
if (track)
|
||||
return track->pid;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Player::GetTeletextPid()
|
||||
{
|
||||
Track *track = input.teletextTrack;
|
||||
if (track)
|
||||
return track->pid;
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user