libeplayer3/input: allow access to AVFormatContext

This commit is contained in:
martii
2014-05-29 21:57:38 +02:00
parent 9ac03e1046
commit 56ece5b5ea
6 changed files with 38 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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"

View File

@@ -362,3 +362,12 @@ int cPlayback::GetTeletextPid(void)
{
return player->GetTeletextPid();
}
AVFormatContext *cPlayback::GetAVFormatContext()
{
return player ? player->GetAVFormatContext() : NULL;
}
void cPlayback::ReleaseAVFormatContext() { if (player)
player->ReleaseAVFormatContext();
}

View File

@@ -10,9 +10,12 @@ typedef enum {
} playmode_t;
class Player;
struct AVFormatContext;
class cPlayback
{
friend class CStreamInfo2;
private:
bool enabled;
bool playing;
@@ -58,6 +61,9 @@ class cPlayback
#endif
void GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
AVFormatContext *GetAVFormatContext();
void ReleaseAVFormatContext();
#if 0
// Functions that are not used by movieplayer.cpp:
bool GetOffset(off64_t &offset);