mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
libeplayer3/input: allow access to AVFormatContext
This commit is contained in:
@@ -47,6 +47,8 @@ class Input
|
||||
friend int interrupt_cb(void *arg);
|
||||
|
||||
private:
|
||||
OpenThreads::Mutex mutex;
|
||||
|
||||
Track *videoTrack;
|
||||
Track *audioTrack;
|
||||
Track *subtitleTrack;
|
||||
@@ -81,6 +83,8 @@ class Input
|
||||
bool SwitchVideo(Track *track);
|
||||
bool GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
bool GetReadCount(uint64_t &readcount);
|
||||
AVFormatContext *GetAVFormatContext();
|
||||
void ReleaseAVFormatContext();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -114,6 +114,9 @@ class Player {
|
||||
void RequestAbort();
|
||||
bool GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
|
||||
|
||||
AVFormatContext *GetAVFormatContext() { return input.GetAVFormatContext(); }
|
||||
void ReleaseAVFormatContext() { input.ReleaseAVFormatContext(); }
|
||||
|
||||
Player();
|
||||
};
|
||||
#endif
|
||||
|
@@ -532,6 +532,7 @@ bool Input::Stop()
|
||||
usleep(100000);
|
||||
|
||||
if (avfc) {
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
|
||||
for (unsigned int i = 0; i < avfc->nb_streams; i++)
|
||||
avcodec_close(avfc->streams[i]->codec);
|
||||
avformat_close_input(&avfc);
|
||||
@@ -542,6 +543,21 @@ bool Input::Stop()
|
||||
return true;
|
||||
}
|
||||
|
||||
AVFormatContext *Input::GetAVFormatContext()
|
||||
{
|
||||
mutex.lock();
|
||||
if (avfc)
|
||||
return avfc;
|
||||
mutex.unlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Input::ReleaseAVFormatContext()
|
||||
{
|
||||
if (avfc)
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
bool Input::Seek(int64_t avts, bool absolute)
|
||||
{
|
||||
if (absolute)
|
||||
|
@@ -36,10 +36,6 @@
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/Condition>
|
||||
|
||||
#include "player.h"
|
||||
#include "output.h"
|
||||
#include "writer.h"
|
||||
|
Reference in New Issue
Block a user