mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
libeplayer3: implement Playback and Input classes
Origin commit data
------------------
Branch: master
Commit: cba7a708be
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:
@@ -1,38 +0,0 @@
|
||||
#ifndef CONTAINER_H_
|
||||
#define CONTAINER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
CONTAINER_INIT,
|
||||
CONTAINER_ADD,
|
||||
CONTAINER_PLAY,
|
||||
CONTAINER_STOP,
|
||||
CONTAINER_SEEK,
|
||||
CONTAINER_SEEK_ABS,
|
||||
CONTAINER_LENGTH,
|
||||
CONTAINER_DEL,
|
||||
CONTAINER_SWITCH_AUDIO,
|
||||
CONTAINER_SWITCH_SUBTITLE,
|
||||
CONTAINER_SWITCH_TELETEXT,
|
||||
CONTAINER_METADATA,
|
||||
} ContainerCmd_t;
|
||||
|
||||
struct Player;
|
||||
|
||||
typedef struct Container_s {
|
||||
const char *Name;
|
||||
int (*Command) (Player *, ContainerCmd_t, const char *);
|
||||
const char **Capabilities;
|
||||
} Container_t;
|
||||
|
||||
|
||||
extern Container_t FFMPEGContainer;
|
||||
|
||||
typedef struct ContainerHandler_s {
|
||||
const char *Name;
|
||||
Container_t *selectedContainer;
|
||||
int (*Command) (Player *, ContainerCmd_t, const char *);
|
||||
} ContainerHandler_t;
|
||||
|
||||
#endif
|
64
libeplayer3/include/input.h
Normal file
64
libeplayer3/include/input.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef __INPUT_H__
|
||||
#define __INPUT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/Condition>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
class Player;
|
||||
class Track;
|
||||
|
||||
class Input
|
||||
{
|
||||
friend class Player;
|
||||
|
||||
private:
|
||||
Track *videoTrack;
|
||||
Track *audioTrack;
|
||||
Track *subtitleTrack;
|
||||
Track *teletextTrack;
|
||||
|
||||
int hasPlayThreadStarted;
|
||||
float seek_sec_abs;
|
||||
float seek_sec_rel;
|
||||
bool isContainerRunning;
|
||||
bool terminating;
|
||||
|
||||
Player *context;
|
||||
AVFormatContext *avfc;
|
||||
uint64_t readCount;
|
||||
public:
|
||||
Input();
|
||||
~Input();
|
||||
|
||||
bool ReadSubtitle(const char *filename, const char *format, int pid);
|
||||
bool ReadSubtitles(const char *filename);
|
||||
bool Init(const char *filename);
|
||||
bool UpdateTracks();
|
||||
bool Play();
|
||||
bool Stop();
|
||||
bool Seek(float sec, bool absolute);
|
||||
bool GetDuration(double &duration);
|
||||
bool SwitchAudio(Track *track);
|
||||
bool SwitchSubtitle(Track *track);
|
||||
bool SwitchTeletext(Track *track);
|
||||
bool SwitchVideo(Track *track);
|
||||
bool GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
bool GetReadCount(uint64_t &readcount);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,11 +1,10 @@
|
||||
#ifndef MANAGER_H_
|
||||
#define MANAGER_H_
|
||||
#ifndef __MANAGER_H__
|
||||
#define __MANAGER_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
@@ -19,16 +18,7 @@ extern "C" {
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
MANAGER_ADD,
|
||||
MANAGER_LIST,
|
||||
MANAGER_GET,
|
||||
MANAGER_GETNAME,
|
||||
MANAGER_SET,
|
||||
MANAGER_DEL,
|
||||
MANAGER_GET_TRACK,
|
||||
MANAGER_INIT_UPDATE
|
||||
} ManagerCmd_t;
|
||||
class Player;
|
||||
|
||||
struct Track
|
||||
{
|
||||
@@ -49,12 +39,15 @@ struct Track
|
||||
int ac3flags;
|
||||
int type, mag, page; // for teletext
|
||||
|
||||
Track() : pid(-1), duration(-1), avfc(NULL), stream(NULL), inactive(0), is_static(0), ac3flags(-1) {}
|
||||
Track() : pid(-1), duration(-1), avfc(NULL), stream(NULL), inactive(0), is_static(0), ac3flags(0) {}
|
||||
};
|
||||
|
||||
class Manager
|
||||
{
|
||||
friend class Player;
|
||||
|
||||
private:
|
||||
Player *context;
|
||||
OpenThreads::Mutex mutex;
|
||||
std::map<int,Track *> videoTracks, audioTracks, subtitleTracks, teletextTracks;
|
||||
public:
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#ifndef OUTPUT_H_
|
||||
#define OUTPUT_H_
|
||||
#ifndef __OUTPUT_H__
|
||||
#define __OUTPUT_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
@@ -19,14 +20,19 @@ extern "C" {
|
||||
|
||||
#include "writer.h"
|
||||
|
||||
class Player;
|
||||
|
||||
class Output
|
||||
{
|
||||
friend class Player;
|
||||
|
||||
private:
|
||||
int videofd;
|
||||
int audiofd;
|
||||
Writer *videoWriter, *audioWriter;
|
||||
OpenThreads::Mutex audioMutex, videoMutex;
|
||||
AVStream *audioStream, *videoStream;
|
||||
Player *context;
|
||||
public:
|
||||
Output();
|
||||
~Output();
|
||||
|
@@ -1,45 +1,82 @@
|
||||
#ifndef PLAYBACK_H_
|
||||
#define PLAYBACK_H_
|
||||
#include <sys/types.h>
|
||||
#ifndef __PLAYBACK_H__
|
||||
#define __PLAYBACK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP,
|
||||
PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM,
|
||||
PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS,
|
||||
PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO,
|
||||
PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_METADATA, PLAYBACK_SLOWMOTION,
|
||||
PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT,
|
||||
PLAYBACK_SWITCH_TELETEXT
|
||||
} PlaybackCmd_t;
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/Condition>
|
||||
|
||||
struct Player;
|
||||
extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
typedef struct PlaybackHandler_s {
|
||||
const char *Name;
|
||||
class Player;
|
||||
class Input;
|
||||
|
||||
int fd;
|
||||
class Playback {
|
||||
friend class Player;
|
||||
friend class Input;
|
||||
|
||||
unsigned char isHttp;
|
||||
private:
|
||||
Player *context;
|
||||
|
||||
unsigned char isPlaying;
|
||||
unsigned char isPaused;
|
||||
unsigned char isForwarding;
|
||||
unsigned char isCreationPhase;
|
||||
bool isHttp;
|
||||
bool isPaused;
|
||||
bool isCreationPhase;
|
||||
|
||||
int BackWard;
|
||||
int SlowMotion;
|
||||
int Speed;
|
||||
int AVSync;
|
||||
bool isSlowMotion;
|
||||
int Speed;
|
||||
int AVSync;
|
||||
|
||||
bool isVideo;
|
||||
bool isAudio;
|
||||
|
||||
std::string url;
|
||||
bool noprobe; /* hack: only minimal probing in av_find_stream_info */
|
||||
|
||||
int hasThreadStarted;
|
||||
|
||||
public:
|
||||
bool isForwarding;
|
||||
bool isBackWard;
|
||||
bool isPlaying;
|
||||
bool abortPlayback;
|
||||
bool abortRequested;
|
||||
uint64_t readCount;
|
||||
|
||||
bool SwitchAudio(int pid);
|
||||
bool SwitchVideo(int pid);
|
||||
bool SwitchTeletext(int pid);
|
||||
bool SwitchSubtitle(int pid);
|
||||
bool GetPts(int64_t &pts);
|
||||
bool GetFrameCount(int64_t &framecount);
|
||||
bool GetDuration(double &duration);
|
||||
bool GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||
bool SlowMotion(int repeats);
|
||||
bool FastBackward(int speed);
|
||||
bool FastForward(int speed);
|
||||
bool Open(const char *Url);
|
||||
bool Close();
|
||||
bool Play();
|
||||
bool Pause();
|
||||
bool Continue();
|
||||
bool Stop();
|
||||
bool Seek(float pos, bool absolute);
|
||||
bool Terminate();
|
||||
|
||||
static void* SupervisorThread(void*);
|
||||
|
||||
Playback();
|
||||
};
|
||||
|
||||
unsigned char isVideo;
|
||||
unsigned char isAudio;
|
||||
unsigned char abortRequested;
|
||||
unsigned char abortPlayback;
|
||||
|
||||
int (*Command) ( Player *, PlaybackCmd_t, void *);
|
||||
std::string uri;
|
||||
unsigned char noprobe; /* hack: only minimal probing in av_find_stream_info */
|
||||
unsigned long long readCount;
|
||||
} PlaybackHandler_t;
|
||||
|
||||
#endif
|
||||
|
@@ -1,25 +1,63 @@
|
||||
#ifndef COMMON_H_
|
||||
#define COMMON_H_
|
||||
#ifndef __PLAYER_H__
|
||||
#define __PLAYER_H__
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/Condition>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
#include "container.h"
|
||||
#include "output.h"
|
||||
#include "manager.h"
|
||||
#include "playback.h"
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class Player {
|
||||
public: //FIXME
|
||||
PlaybackHandler_t *playback;
|
||||
ContainerHandler_t *container;
|
||||
int64_t *currentAudioPtsP;
|
||||
public:
|
||||
Player();
|
||||
~Player();
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
Output output;
|
||||
Manager manager;
|
||||
#include "input.h"
|
||||
#include "output.h"
|
||||
#include "manager.h"
|
||||
#include "playback.h"
|
||||
#include "player.h"
|
||||
|
||||
struct Chapter
|
||||
{
|
||||
std::string title;
|
||||
double start;
|
||||
double end;
|
||||
};
|
||||
|
||||
int container_ffmpeg_update_tracks(Player * context, const char *filename);
|
||||
class Player {
|
||||
friend class Input;
|
||||
friend class Output;
|
||||
friend class Manager;
|
||||
friend class Playback;
|
||||
friend class cPlayback;
|
||||
private:
|
||||
Input input;
|
||||
Output output;
|
||||
Manager manager;
|
||||
Playback playback;
|
||||
OpenThreads::Mutex chapterMutex;
|
||||
std::vector<Chapter> chapters;
|
||||
public: //FIXME
|
||||
int64_t *currentAudioPtsP;
|
||||
public:
|
||||
Player()
|
||||
{
|
||||
input.context = this;
|
||||
output.context = this;
|
||||
playback.context = this;
|
||||
manager.context = this;
|
||||
}
|
||||
|
||||
bool GetChapters(std::vector<int> &positions, std::vector<std::string> &titles);
|
||||
void SetChapters(std::vector<Chapter> &Chapters);
|
||||
};
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user