mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 15:33:00 +02:00
libeplayer3: implement multi-program support
This commit is contained in:
@@ -80,10 +80,27 @@ bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, in
|
||||
videoDecoder->Stop(false);
|
||||
audioDecoder->Stop();
|
||||
} else {
|
||||
std::vector<std::string> keys, values;
|
||||
int selected_program = 0;
|
||||
if (GetPrograms(keys, values) && (keys.size() > 1) && ProgramSelectionCallback) {
|
||||
const char *key = ProgramSelectionCallback(ProgramSelectionCallbackData, keys, values);
|
||||
if (!key) {
|
||||
player->Close();
|
||||
return false;
|
||||
}
|
||||
selected_program = atoi(key);
|
||||
|
||||
} else if (keys.size() > 0)
|
||||
selected_program = atoi(keys[0].c_str());
|
||||
|
||||
if (!keys.size() || !player->SelectProgram(selected_program)) {
|
||||
if (apid)
|
||||
SetAPid(apid);
|
||||
if (vpid)
|
||||
SetVPid(vpid);
|
||||
}
|
||||
playing = true;
|
||||
player->output.Open();
|
||||
if (apid)
|
||||
SetAPid(apid, 0);
|
||||
ret = player->Play();
|
||||
if (ret && !isHTTP)
|
||||
playing = ret = player->Pause();
|
||||
@@ -109,6 +126,11 @@ bool cPlayback::SetAPid(int pid, bool /* ac3 */)
|
||||
return player->SwitchAudio(pid);
|
||||
}
|
||||
|
||||
bool cPlayback::SetVPid(int pid)
|
||||
{
|
||||
return player->SwitchVideo(pid);
|
||||
}
|
||||
|
||||
bool cPlayback::SetSubtitlePid(int pid)
|
||||
{
|
||||
return player->SwitchSubtitle(pid);
|
||||
@@ -321,6 +343,9 @@ cPlayback::cPlayback(int num __attribute__((unused)))
|
||||
{
|
||||
playing = false;
|
||||
decoders_closed = false;
|
||||
ProgramSelectionCallback = NULL;
|
||||
ProgramSelectionCallbackData = NULL;
|
||||
|
||||
player = new Player();
|
||||
}
|
||||
|
||||
@@ -368,6 +393,24 @@ AVFormatContext *cPlayback::GetAVFormatContext()
|
||||
return player ? player->GetAVFormatContext() : NULL;
|
||||
}
|
||||
|
||||
void cPlayback::ReleaseAVFormatContext() { if (player)
|
||||
player->ReleaseAVFormatContext();
|
||||
void cPlayback::ReleaseAVFormatContext()
|
||||
{
|
||||
if (player)
|
||||
player->ReleaseAVFormatContext();
|
||||
}
|
||||
|
||||
bool cPlayback::GetPrograms(std::vector<std::string> &keys, std::vector<std::string> &values)
|
||||
{
|
||||
return player->GetPrograms(keys, values);
|
||||
}
|
||||
|
||||
bool cPlayback::SelectProgram(std::string &key)
|
||||
{
|
||||
return player->SelectProgram(key);
|
||||
}
|
||||
|
||||
void cPlayback::SetProgramSelectionCallback(const char *(*fun)(void *, std::vector<std::string> &keys, std::vector<std::string> &values), void *opaque)
|
||||
{
|
||||
ProgramSelectionCallback = fun;
|
||||
ProgramSelectionCallbackData = opaque;
|
||||
}
|
||||
|
@@ -29,6 +29,11 @@ class cPlayback
|
||||
off_t last_size;
|
||||
int init_jump;
|
||||
Player *player;
|
||||
const char *(*ProgramSelectionCallback)(void *, std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
void *ProgramSelectionCallbackData;
|
||||
|
||||
bool GetPrograms(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
bool SelectProgram(std::string &key);
|
||||
public:
|
||||
cPlayback(int num = 0);
|
||||
~cPlayback();
|
||||
@@ -36,7 +41,8 @@ class cPlayback
|
||||
bool Open(playmode_t PlayMode);
|
||||
void Close(void);
|
||||
bool Start(char *filename, int vpid, int vtype, int apid, int ac3, int duration);
|
||||
bool SetAPid(int pid, bool ac3);
|
||||
bool SetAPid(int pid, bool ac3 = false);
|
||||
bool SetVPid(int pid);
|
||||
bool SetSubtitlePid(int pid);
|
||||
bool SetTeletextPid(int pid);
|
||||
int GetAPid(void);
|
||||
@@ -55,16 +61,18 @@ class cPlayback
|
||||
void RequestAbort(void);
|
||||
bool IsPlaying(void);
|
||||
uint64_t GetReadCount(void);
|
||||
#if 0
|
||||
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language);
|
||||
bool SelectSubtitles(int pid);
|
||||
#endif
|
||||
|
||||
void GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
|
||||
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
|
||||
void SetProgramSelectionCallback(const char *(*fun)(void *, std::vector<std::string> &keys, std::vector<std::string> &values), void *opaque);
|
||||
|
||||
AVFormatContext *GetAVFormatContext();
|
||||
void ReleaseAVFormatContext();
|
||||
#if 0
|
||||
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language);
|
||||
bool SelectSubtitles(int pid);
|
||||
|
||||
// Functions that are not used by movieplayer.cpp:
|
||||
bool GetOffset(off64_t &offset);
|
||||
bool IsPlaying(void) const;
|
||||
|
Reference in New Issue
Block a user