libeplayer3: eliminate intermediate output layer

This commit is contained in:
martii
2014-04-06 13:30:20 +02:00
parent e85f1dd4d1
commit 558b9410a8
7 changed files with 89 additions and 470 deletions

View File

@@ -11,7 +11,7 @@ libeplayer3_la_SOURCES = \
container/container.cpp container/container_ffmpeg.cpp \ container/container.cpp container/container_ffmpeg.cpp \
manager/audio.cpp manager/manager.cpp manager/subtitle.cpp manager/video.cpp \ manager/audio.cpp manager/manager.cpp manager/subtitle.cpp manager/video.cpp \
manager/teletext.cpp manager/chapter.cpp \ manager/teletext.cpp manager/chapter.cpp \
output/linuxdvb.cpp output/output.cpp \ output/linuxdvb.cpp player.cpp \
playback/playback.cpp output/writer/writer.cpp output/writer/wmv.cpp \ playback/playback.cpp output/writer/writer.cpp output/writer/wmv.cpp \
output/writer/ac3.cpp output/writer/divx.cpp output/writer/pes.cpp \ output/writer/ac3.cpp output/writer/divx.cpp output/writer/pes.cpp \
output/writer/dts.cpp output/writer/mpeg2.cpp output/writer/mp3.cpp output/writer/misc.cpp \ output/writer/dts.cpp output/writer/mpeg2.cpp output/writer/mp3.cpp output/writer/misc.cpp \

View File

@@ -276,16 +276,16 @@ static void *FFMPEGThread(void *arg)
currentVideoPts = pts = calcPts(avContext, videoTrack->stream, packet.pts); currentVideoPts = pts = calcPts(avContext, videoTrack->stream, packet.pts);
ffmpeg_printf(200, "VideoTrack index = %d %lld\n", pid, currentVideoPts); ffmpeg_printf(200, "VideoTrack index = %d %lld\n", pid, currentVideoPts);
if (!context->output->video->Write(avContext, videoTrack->stream, &packet, currentVideoPts)) if (!context->output->Write(avContext, videoTrack->stream, &packet, currentVideoPts))
ffmpeg_err("writing data to video device failed\n"); ffmpeg_err("writing data to video device failed\n");
} else if (audioTrack && (audioTrack->Id == pid)) { } else if (audioTrack && (audioTrack->Id == pid)) {
if (restart_audio_resampling) { if (restart_audio_resampling) {
restart_audio_resampling = false; restart_audio_resampling = false;
context->output->audio->Write(avContext, audioTrack->stream, NULL, currentAudioPts); context->output->Write(avContext, audioTrack->stream, NULL, currentAudioPts);
} }
if (!context->playback->BackWard) { if (!context->playback->BackWard) {
currentAudioPts = pts = calcPts(avContext, audioTrack->stream, packet.pts); currentAudioPts = pts = calcPts(avContext, audioTrack->stream, packet.pts);
if (!context->output->audio->Write(avContext, audioTrack->stream, &packet, currentAudioPts)) if (!context->output->Write(avContext, audioTrack->stream, &packet, currentAudioPts))
ffmpeg_err("writing data to audio device failed\n"); ffmpeg_err("writing data to audio device failed\n");
} }
} else if (subtitleTrack && (subtitleTrack->Id == pid)) { } else if (subtitleTrack && (subtitleTrack->Id == pid)) {

View File

@@ -47,11 +47,4 @@ typedef struct Output_s {
extern Output_t LinuxDvbOutput; extern Output_t LinuxDvbOutput;
extern Output_t SubtitleOutput; extern Output_t SubtitleOutput;
typedef struct OutputHandler_s {
const char *Name;
Output_t *audio;
Output_t *video;
int (*Command) (Player *, OutputCmd_t, const char *);
} OutputHandler_t;
#endif #endif

View File

@@ -8,12 +8,16 @@
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
struct Player { class Player {
PlaybackHandler_t *playback; public: //FIXME
ContainerHandler_t *container; PlaybackHandler_t *playback;
OutputHandler_t *output; ContainerHandler_t *container;
ManagerHandler_t *manager; Output_t *output;
int64_t *currentAudioPtsP; ManagerHandler_t *manager;
int64_t *currentAudioPtsP;
public:
Player();
~Player();
}; };
int container_ffmpeg_update_tracks(Player * context, const char *filename); int container_ffmpeg_update_tracks(Player * context, const char *filename);

View File

@@ -53,23 +53,8 @@
#define LINUXDVB_DEBUG #define LINUXDVB_DEBUG
static short debug_level = 0;
static const char FILENAME[] = __FILE__; static const char FILENAME[] = __FILE__;
#ifdef LINUXDVB_DEBUG
#define linuxdvb_printf(level, fmt, x...) do { \
if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x ); } while (0)
#else
#define linuxdvb_printf(x...)
#endif
#ifndef LINUXDVB_SILENT
#define linuxdvb_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0)
#else
#define linuxdvb_err(x...)
#endif
#define cERR_LINUXDVB_NO_ERROR 0 #define cERR_LINUXDVB_NO_ERROR 0
#define cERR_LINUXDVB_ERROR -1 #define cERR_LINUXDVB_ERROR -1
@@ -100,7 +85,7 @@ pthread_mutex_t LinuxDVBmutex;
/* ***************************** */ /* ***************************** */
/* Prototypes */ /* Prototypes */
/* ***************************** */ /* ***************************** */
int LinuxDvbStop(Player * context, char *type); int LinuxDvbStop();
/* ***************************** */ /* ***************************** */
/* MISC Functions */ /* MISC Functions */
@@ -112,11 +97,9 @@ void getLinuxDVBMutex(const char *filename
__attribute__ ((unused))) __attribute__ ((unused)))
{ {
linuxdvb_printf(250, "requesting mutex\n");
pthread_mutex_lock(&LinuxDVBmutex); pthread_mutex_lock(&LinuxDVBmutex);
linuxdvb_printf(250, "received mutex\n");
} }
void releaseLinuxDVBMutex(const char *filename void releaseLinuxDVBMutex(const char *filename
@@ -126,24 +109,15 @@ void releaseLinuxDVBMutex(const char *filename
{ {
pthread_mutex_unlock(&LinuxDVBmutex); pthread_mutex_unlock(&LinuxDVBmutex);
linuxdvb_printf(250, "released mutex\n");
} }
int LinuxDvbOpen(Player * context __attribute__ ((unused)), char *type) int LinuxDvbOpen(Player * context __attribute__ ((unused)), char *)
{ {
unsigned char video = !strcmp("video", type); if (videofd < 0) {
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if (videoStream && videofd < 0) {
videofd = open(VIDEODEV, O_RDWR); videofd = open(VIDEODEV, O_RDWR);
if (videofd < 0) { if (videofd < 0) {
linuxdvb_err("failed to open %s - errno %d\n", VIDEODEV,
errno);
linuxdvb_err("%s\n", strerror(errno));
return cERR_LINUXDVB_ERROR; return cERR_LINUXDVB_ERROR;
} }
@@ -153,13 +127,10 @@ int LinuxDvbOpen(Player * context __attribute__ ((unused)), char *type)
dioctl(videofd, VIDEO_SET_SPEED, DVB_SPEED_NORMAL_PLAY); dioctl(videofd, VIDEO_SET_SPEED, DVB_SPEED_NORMAL_PLAY);
} }
if (audio && audiofd < 0) { if (audiofd < 0) {
audiofd = open(AUDIODEV, O_RDWR); audiofd = open(AUDIODEV, O_RDWR);
if (audiofd < 0) { if (audiofd < 0) {
linuxdvb_err("failed to open %s - errno %d\n", AUDIODEV,
errno);
linuxdvb_err("%s\n", strerror(errno));
if (videofd < 0) if (videofd < 0)
close(videofd); close(videofd);
@@ -174,26 +145,22 @@ int LinuxDvbOpen(Player * context __attribute__ ((unused)), char *type)
return cERR_LINUXDVB_NO_ERROR; return cERR_LINUXDVB_NO_ERROR;
} }
int LinuxDvbClose(Player * context, char *type) int LinuxDvbClose(Player * context, char *)
{ {
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
/* closing stand alone is not allowed, so prevent /* closing stand alone is not allowed, so prevent
* user from closing and dont call stop. stop will * user from closing and dont call stop. stop will
* set default values for us (speed and so on). * set default values for us (speed and so on).
*/ */
LinuxDvbStop(context, type); LinuxDvbStop();
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) { if (videofd > -1) {
close(videofd); close(videofd);
videofd = -1; videofd = -1;
} }
if (audio && audiofd != -1) { if (audiofd > -1) {
close(audiofd); close(audiofd);
audiofd = -1; audiofd = -1;
} }
@@ -202,15 +169,10 @@ int LinuxDvbClose(Player * context, char *type)
return cERR_LINUXDVB_NO_ERROR; return cERR_LINUXDVB_NO_ERROR;
} }
int LinuxDvbPlay(Player * context, char *type) int LinuxDvbPlay(Player * context, char *)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
AVStream *_videoStream = videoStream; AVStream *_videoStream = videoStream;
AVStream *_audioStream = audioStream; AVStream *_audioStream = audioStream;
if (_videoStream) if (_videoStream)
@@ -233,17 +195,13 @@ int LinuxDvbPlay(Player * context, char *type)
return ret; return ret;
} }
int LinuxDvbStop(Player * context __attribute__ ((unused)), char *type) int LinuxDvbStop()
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) { if (videofd > -1) {
dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL); dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL);
/* set back to normal speed (end trickmodes) */ /* set back to normal speed (end trickmodes) */
@@ -252,7 +210,7 @@ int LinuxDvbStop(Player * context __attribute__ ((unused)), char *type)
if (dioctl(videofd, VIDEO_STOP, NULL)) if (dioctl(videofd, VIDEO_STOP, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
if (audio && audiofd != -1) { if (audiofd > -1) {
dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL); dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL);
/* set back to normal speed (end trickmodes) */ /* set back to normal speed (end trickmodes) */
@@ -267,21 +225,18 @@ int LinuxDvbStop(Player * context __attribute__ ((unused)), char *type)
return ret; return ret;
} }
int LinuxDvbPause(Player * context __attribute__ ((unused)), char *type) int LinuxDvbPause(Player * context __attribute__ ((unused)), char *)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) { if (videofd > -1) {
if (dioctl(videofd, VIDEO_FREEZE, NULL)) if (dioctl(videofd, VIDEO_FREEZE, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
if (audio && audiofd != -1) { if (audiofd > -1) {
if (dioctl(audiofd, AUDIO_PAUSE, NULL)) if (dioctl(audiofd, AUDIO_PAUSE, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
@@ -291,25 +246,20 @@ int LinuxDvbPause(Player * context __attribute__ ((unused)), char *type)
return ret; return ret;
} }
int LinuxDvbContinue(Player * context int LinuxDvbContinue(Player * context __attribute__ ((unused)), char *)
__attribute__ ((unused)), char *type)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if (video && videofd != -1) { if (videofd > -1) {
if (dioctl(videofd, VIDEO_CONTINUE, NULL)) if (dioctl(videofd, VIDEO_CONTINUE, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
if (audio && audiofd != -1) { if (audiofd > -1) {
if (dioctl(audiofd, AUDIO_CONTINUE, NULL)) if (dioctl(audiofd, AUDIO_CONTINUE, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
linuxdvb_printf(10, "exiting\n");
return ret; return ret;
@@ -321,21 +271,17 @@ int LinuxDvbReverseDiscontinuity(Player * context
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus; int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus;
linuxdvb_printf(50, "\n");
dioctl(videofd, VIDEO_DISCONTINUITY, (void *) dis_type); dioctl(videofd, VIDEO_DISCONTINUITY, (void *) dis_type);
linuxdvb_printf(50, "exiting\n");
return ret; return ret;
} }
int LinuxDvbAudioMute(Player * context int LinuxDvbAudioMute(Player * context __attribute__ ((unused)), char *flag)
__attribute__ ((unused)), char *flag)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
linuxdvb_printf(10, "\n");
if (audiofd != -1) { if (audiofd != -1) {
if (*flag == '1') { if (*flag == '1') {
@@ -351,48 +297,34 @@ int LinuxDvbAudioMute(Player * context
} }
} }
linuxdvb_printf(10, "exiting\n");
return ret; return ret;
} }
int LinuxDvbFlush(Player * context __attribute__ ((unused)), char *type) int LinuxDvbFlush(Player * context __attribute__ ((unused)), char *)
{ {
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if ((video && videofd != -1) || (audio && audiofd != -1)) {
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) if (videofd > -1)
dioctl(videofd, VIDEO_FLUSH, NULL); dioctl(videofd, VIDEO_FLUSH, NULL);
if (audio && audiofd != -1) if (audiofd > -1)
dioctl(audiofd, AUDIO_FLUSH, NULL); dioctl(audiofd, AUDIO_FLUSH, NULL);
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
}
linuxdvb_printf(10, "exiting\n");
return cERR_LINUXDVB_NO_ERROR; return cERR_LINUXDVB_NO_ERROR;
} }
#ifndef use_set_speed_instead_ff #ifndef use_set_speed_instead_ff
int LinuxDvbFastForward(Player * context, char *type) int LinuxDvbFastForward(Player * context, char *)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type); if (videofd > -1) {
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d speed %d\n", video, audio,
context->playback->Speed);
if (video && videofd != -1) {
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
@@ -404,7 +336,6 @@ int LinuxDvbFastForward(Player * context, char *type)
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
} }
linuxdvb_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -419,7 +350,6 @@ int LinuxDvbFastForward(Player * context, char *type)
unsigned char video = !strcmp("video", type); unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type); unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if (video && videofd != -1) { if (video && videofd != -1) {
@@ -427,7 +357,6 @@ int LinuxDvbFastForward(Player * context, char *type)
speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int));
linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
if (dioctl(videofd, VIDEO_SET_SPEED, SpeedList[speedIndex])) if (dioctl(videofd, VIDEO_SET_SPEED, SpeedList[speedIndex]))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
@@ -442,7 +371,6 @@ int LinuxDvbFastForward(Player * context, char *type)
speedIndex = speedIndex =
context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); context->playback->Speed % (sizeof(SpeedList) / sizeof(int));
linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
if (dioctl(audiofd, AUDIO_SET_SPEED, SpeedList[speedIndex])) { if (dioctl(audiofd, AUDIO_SET_SPEED, SpeedList[speedIndex])) {
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
@@ -451,49 +379,31 @@ int LinuxDvbFastForward(Player * context, char *type)
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
} }
linuxdvb_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
#endif #endif
int LinuxDvbReverse(Player * context
__attribute__ ((unused)), char *type
__attribute__ ((unused)))
{
int ret = cERR_LINUXDVB_NO_ERROR;
return ret;
}
int LinuxDvbSlowMotion(Player * context, char *type) int LinuxDvbSlowMotion(Player * context, char *type)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if ((video && videofd != -1) || (audio && audiofd != -1)) {
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) { if (videofd > -1) {
if (dioctl (videofd, VIDEO_SLOWMOTION, context->playback->SlowMotion)) { if (dioctl (videofd, VIDEO_SLOWMOTION, context->playback->SlowMotion)) {
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
} }
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
}
linuxdvb_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
int LinuxDvbAVSync(Player * context, char *type int LinuxDvbAVSync(Player * context, char *type __attribute__ ((unused)))
__attribute__ ((unused)))
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
/* konfetti: this one is dedicated to audiofd so we /* konfetti: this one is dedicated to audiofd so we
@@ -502,7 +412,7 @@ int LinuxDvbAVSync(Player * context, char *type
* setOn or something like that instead, this would remove * setOn or something like that instead, this would remove
* using a variable inside the structure. * using a variable inside the structure.
*/ */
if (audiofd != -1) { if (audiofd > -1) {
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (dioctl(audiofd, AUDIO_SET_AV_SYNC, context->playback->AVSync)) if (dioctl(audiofd, AUDIO_SET_AV_SYNC, context->playback->AVSync))
@@ -514,31 +424,46 @@ int LinuxDvbAVSync(Player * context, char *type
return ret; return ret;
} }
int LinuxDvbClear(Player * context __attribute__ ((unused)), char *type) int LinuxDvbClearAudio()
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
unsigned char video = !strcmp("video", type);
unsigned char audio = !strcmp("audio", type);
linuxdvb_printf(10, "v%d a%d\n", video, audio);
if ((video && videofd != -1) || (audio && audiofd != -1)) {
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (video && videofd != -1) { if (audiofd > -1) {
if (dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL))
ret = cERR_LINUXDVB_ERROR;
}
if (audio && audiofd != -1) {
if (dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL)) if (dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} }
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
}
linuxdvb_printf(10, "exiting\n"); return ret;
}
int LinuxDvbClearVideo()
{
int ret = cERR_LINUXDVB_NO_ERROR;
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (videofd > -1) {
if (dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL))
ret = cERR_LINUXDVB_ERROR;
}
releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
return ret;
}
int LinuxDvbClear()
{
int ret = LinuxDvbClearAudio();
if (ret == cERR_LINUXDVB_NO_ERROR)
ret = LinuxDvbClearVideo();
else
LinuxDvbClearVideo();
return ret; return ret;
} }
@@ -547,7 +472,6 @@ int LinuxDvbPts(Player * context
{ {
int ret = cERR_LINUXDVB_ERROR; int ret = cERR_LINUXDVB_ERROR;
linuxdvb_printf(50, "\n");
// pts is a non writting requests and can be done in parallel to other requests // pts is a non writting requests and can be done in parallel to other requests
//getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); //getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
@@ -572,23 +496,17 @@ int LinuxDvbGetFrameCount(Player * context
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
dvb_play_info_t playInfo; dvb_play_info_t playInfo;
linuxdvb_printf(50, "\n");
getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
if (videofd != -1) { if (videofd > -1) {
if (dioctl(videofd, VIDEO_GET_PLAY_INFO, (void *) &playInfo)) { if (dioctl(videofd, VIDEO_GET_PLAY_INFO, (void *) &playInfo))
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} else } else if (audiofd > -1) {
linuxdvb_err("V: %llu\n", playInfo.frame_count); if (dioctl(audiofd, AUDIO_GET_PLAY_INFO, (void *) &playInfo))
} else if (audiofd != -1) {
if (dioctl(audiofd, AUDIO_GET_PLAY_INFO, (void *) &playInfo)) {
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
} else } else
linuxdvb_err("A: %llu\n", playInfo.frame_count);
} else {
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
}
if (ret == cERR_LINUXDVB_NO_ERROR) if (ret == cERR_LINUXDVB_NO_ERROR)
*((unsigned long long int *) frameCount) = playInfo.frame_count; *((unsigned long long int *) frameCount) = playInfo.frame_count;
@@ -655,7 +573,6 @@ static int Command(Player *context, OutputCmd_t command, const char *argument)
{ {
int ret = cERR_LINUXDVB_NO_ERROR; int ret = cERR_LINUXDVB_NO_ERROR;
linuxdvb_printf(50, "Command %d\n", command);
switch (command) { switch (command) {
case OUTPUT_OPEN:{ case OUTPUT_OPEN:{
@@ -675,7 +592,7 @@ static int Command(Player *context, OutputCmd_t command, const char *argument)
} }
case OUTPUT_STOP:{ case OUTPUT_STOP:{
reset(context); reset(context);
ret = LinuxDvbStop(context, (char *) argument); ret = LinuxDvbStop();
sCURRENT_PTS = 0; sCURRENT_PTS = 0;
break; break;
} }
@@ -697,16 +614,12 @@ static int Command(Player *context, OutputCmd_t command, const char *argument)
return LinuxDvbFastForward(context, (char *) argument); return LinuxDvbFastForward(context, (char *) argument);
break; break;
} }
case OUTPUT_REVERSE:{
return LinuxDvbReverse(context, (char *) argument);
break;
}
case OUTPUT_AVSYNC:{ case OUTPUT_AVSYNC:{
ret = LinuxDvbAVSync(context, (char *) argument); ret = LinuxDvbAVSync(context, (char *) argument);
break; break;
} }
case OUTPUT_CLEAR:{ case OUTPUT_CLEAR:{
ret = LinuxDvbClear(context, (char *) argument); ret = LinuxDvbClear();
reset(context); reset(context);
sCURRENT_PTS = 0; sCURRENT_PTS = 0;
break; break;
@@ -738,12 +651,10 @@ static int Command(Player *context, OutputCmd_t command, const char *argument)
break; break;
} }
default: default:
linuxdvb_err("ContainerCmd %d not supported!\n", command);
ret = cERR_LINUXDVB_ERROR; ret = cERR_LINUXDVB_ERROR;
break; break;
} }
linuxdvb_printf(50, "exiting with value %d\n", ret);
return ret; return ret;
} }

View File

@@ -1,302 +0,0 @@
/*
* Output handling.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* ***************************** */
/* Includes */
/* ***************************** */
#include <stdio.h>
#include <string.h>
#include "player.h"
#include "output.h"
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
static short debug_level = 0;
#define output_printf(level, x...) do { \
if (debug_level >= level) fprintf(stderr, x); } while (0)
#else
#define output_printf(level, x...)
#endif
#ifndef OUTPUT_SILENT
#define output_err(x...) do { printf(x); } while (0)
#else
#define output_err(x...)
#endif
/* Error Constants */
#define cERR_OUTPUT_NO_ERROR 0
#define cERR_OUTPUT_INTERNAL_ERROR -1
static const char *FILENAME = "output.c";
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* ***************************** */
static Output_t *AvailableOutput[] = {
&LinuxDvbOutput,
NULL
};
/* ***************************** */
/* Output Functions */
/* ***************************** */
static void OutputAdd(Player * context, char *port)
{
int i, j;
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
for (i = 0; AvailableOutput[i] != NULL; i++)
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
if (!strcmp(AvailableOutput[i]->Capabilities[j], port)) {
if (!strcmp("audio", port)) {
context->output->audio = AvailableOutput[i];
return;
}
if (!strcmp("video", port)) {
context->output->video = AvailableOutput[i];
return;
}
}
}
static void OutputDel(Player * context, char *port)
{
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
if (!strcmp("audio", port))
context->output->audio = NULL;
else if (!strcmp("video", port))
context->output->video = NULL;
}
static int Command(Player *context, OutputCmd_t command, const char *argument)
{
int ret = cERR_OUTPUT_NO_ERROR;
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__,
command);
switch (command) {
case OUTPUT_OPEN:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_OPEN, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_OPEN, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_CLOSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_CLOSE, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_CLOSE, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_ADD:{
OutputAdd(context, (char *) argument);
break;
}
case OUTPUT_DEL:{
OutputDel(context, (char *) argument);
break;
}
case OUTPUT_PLAY:{ // 4
if (context && context->playback) {
if (context->playback->isVideo)
ret = context->output->video->Command(context, OUTPUT_PLAY, "video");
if (!ret) { // success or not executed, dunn care
if (context->playback->isAudio)
ret = context->output->audio->Command(context, OUTPUT_PLAY, "audio");
}
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_STOP:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |=
context->output->video->Command(context, OUTPUT_STOP, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_STOP, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_FLUSH:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_FLUSH, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_FLUSH, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_PAUSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_PAUSE, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_PAUSE, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_FASTFORWARD:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_FASTFORWARD, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_FASTFORWARD, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_REVERSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_REVERSE, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_REVERSE, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_CONTINUE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_CONTINUE, "video");
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_CONTINUE, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_AVSYNC:{
if (context && context->playback) {
if (context->playback->isVideo && context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_AVSYNC, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_CLEAR:{
if (context && context->playback) {
if (context->playback->isVideo
&& (argument == NULL || *(char *) argument == 'v'))
ret |= context->output->video->Command(context, OUTPUT_CLEAR, "video");
if (context->playback->isAudio
&& (argument == NULL || *(char *) argument == 'a'))
ret |= context->output->audio->Command(context, OUTPUT_CLEAR, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_PTS:{
if (context && context->playback) {
if (context->playback->isVideo)
return context->output->video->Command(context, OUTPUT_PTS, (const char *) argument);
if (context->playback->isAudio)
return context->output->audio->Command(context, OUTPUT_PTS, (const char *) argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_SLOWMOTION:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |=
context->output->video->Command(context, OUTPUT_SLOWMOTION, "video");
if (context->playback->isAudio)
ret |=
context->output->audio->Command(context, OUTPUT_SLOWMOTION, "audio");
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_AUDIOMUTE:{
if (context && context->playback) {
if (context->playback->isAudio)
ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (const char *) argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_DISCONTINUITY_REVERSE:{
if (context && context->playback) {
if (context->playback->isVideo)
ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (const char *) argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
case OUTPUT_GET_FRAME_COUNT:{
if (context && context->playback) {
if (context->playback->isVideo)
return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, (const char *)argument);
if (context->playback->isAudio)
return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, (const char *)argument);
} else
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
default:
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME,
__FUNCTION__, command);
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
output_printf(10, "%s::%s exiting with value %d\n", FILENAME,
__FUNCTION__, ret);
return ret;
}
OutputHandler_t OutputHandler = {
"Output",
NULL,
NULL,
&Command
};

13
libeplayer3/player.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "player.h"
#include <string>
extern Output_t LinuxDvbOutput;
Player::Player()
{
output = &LinuxDvbOutput;
}
Player::~Player()
{
}