mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-27 07:22:44 +02:00
libeplayer3: cleanups
Origin commit data
------------------
Branch: master
Commit: 42efb5c739
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:
@@ -8,13 +8,10 @@ AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
|
|||||||
AM_CPPFLAGS += -ggdb
|
AM_CPPFLAGS += -ggdb
|
||||||
|
|
||||||
libeplayer3_la_SOURCES = \
|
libeplayer3_la_SOURCES = \
|
||||||
container/container_ffmpeg.cpp \
|
input.cpp output.cpp manager.cpp player.cpp \
|
||||||
manager/manager.cpp output/output.cpp \
|
writer/writer.cpp writer/wmv.cpp writer/ac3.cpp writer/divx.cpp writer/pes.cpp \
|
||||||
playback/playback.cpp output/writer/writer.cpp output/writer/wmv.cpp \
|
writer/dts.cpp writer/mpeg2.cpp writer/mp3.cpp writer/misc.cpp writer/h264.cpp \
|
||||||
output/writer/ac3.cpp output/writer/divx.cpp output/writer/pes.cpp \
|
writer/h263.cpp writer/vc1.cpp writer/flac.cpp writer/pcm.cpp
|
||||||
output/writer/dts.cpp output/writer/mpeg2.cpp output/writer/mp3.cpp output/writer/misc.cpp \
|
|
||||||
output/writer/h264.cpp output/writer/h263.cpp output/writer/vc1.cpp \
|
|
||||||
output/writer/flac.cpp output/writer/pcm.cpp
|
|
||||||
|
|
||||||
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
||||||
|
|
||||||
|
@@ -58,7 +58,6 @@ class Input
|
|||||||
bool SwitchVideo(Track *track);
|
bool SwitchVideo(Track *track);
|
||||||
bool GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
bool GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||||
bool GetReadCount(uint64_t &readcount);
|
bool GetReadCount(uint64_t &readcount);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#ifndef WRITER_H_
|
#ifndef __WRITER_H__
|
||||||
#define WRITER_H_
|
#define __WRITER_H__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Includes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -100,6 +96,7 @@ bool Input::Play()
|
|||||||
hasPlayThreadStarted = 1;
|
hasPlayThreadStarted = 1;
|
||||||
|
|
||||||
int64_t currentVideoPts = 0, currentAudioPts = 0, showtime = 0, bofcount = 0;
|
int64_t currentVideoPts = 0, currentAudioPts = 0, showtime = 0, bofcount = 0;
|
||||||
|
bool restart_audio_resampling = false;
|
||||||
|
|
||||||
while (player->isCreationPhase) {
|
while (player->isCreationPhase) {
|
||||||
fprintf(stderr, "Thread waiting for end of init phase...\n");
|
fprintf(stderr, "Thread waiting for end of init phase...\n");
|
||||||
@@ -107,14 +104,12 @@ bool Input::Play()
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "Running!\n");
|
fprintf(stderr, "Running!\n");
|
||||||
|
|
||||||
bool restart_audio_resampling = false;
|
|
||||||
|
|
||||||
while (player->isPlaying && !player->abortRequested) {
|
while (player->isPlaying && !player->abortRequested) {
|
||||||
|
|
||||||
//IF MOVIE IS PAUSED, WAIT
|
//IF MOVIE IS PAUSED, WAIT
|
||||||
if (player->isPaused) {
|
if (player->isPaused) {
|
||||||
fprintf(stderr, "paused\n");
|
fprintf(stderr, "paused\n");
|
||||||
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -200,7 +195,7 @@ bool Input::Play()
|
|||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
break; // while
|
break; // while
|
||||||
}
|
}
|
||||||
long long int pts;
|
int64_t pts;
|
||||||
|
|
||||||
player->readCount += packet.size;
|
player->readCount += packet.size;
|
||||||
|
|
||||||
@@ -217,7 +212,7 @@ Track *_teletextTrack = teletextTrack;
|
|||||||
currentVideoPts = pts = calcPts(avfc, _videoTrack->stream, packet.pts);
|
currentVideoPts = pts = calcPts(avfc, _videoTrack->stream, packet.pts);
|
||||||
|
|
||||||
if (!player->output.Write(avfc, _videoTrack->stream, &packet, currentVideoPts))
|
if (!player->output.Write(avfc, _videoTrack->stream, &packet, currentVideoPts))
|
||||||
;//fprintf(stderr, "writing data to video device failed\n");
|
fprintf(stderr, "writing data to video device failed\n");
|
||||||
} else if (_audioTrack && (_audioTrack->pid == pid)) {
|
} else if (_audioTrack && (_audioTrack->pid == pid)) {
|
||||||
if (restart_audio_resampling) {
|
if (restart_audio_resampling) {
|
||||||
restart_audio_resampling = false;
|
restart_audio_resampling = false;
|
||||||
@@ -226,7 +221,7 @@ Track *_teletextTrack = teletextTrack;
|
|||||||
if (!player->isBackWard) {
|
if (!player->isBackWard) {
|
||||||
currentAudioPts = pts = calcPts(avfc, _audioTrack->stream, packet.pts);
|
currentAudioPts = pts = calcPts(avfc, _audioTrack->stream, packet.pts);
|
||||||
if (!player->output.Write(avfc, _audioTrack->stream, &packet, currentAudioPts))
|
if (!player->output.Write(avfc, _audioTrack->stream, &packet, currentAudioPts))
|
||||||
;//fprintf(stderr, "writing data to audio device failed\n");
|
fprintf(stderr, "writing data to audio device failed\n");
|
||||||
}
|
}
|
||||||
} else if (_subtitleTrack && (_subtitleTrack->pid == pid)) {
|
} else if (_subtitleTrack && (_subtitleTrack->pid == pid)) {
|
||||||
float duration = 3.0;
|
float duration = 3.0;
|
||||||
@@ -271,17 +266,12 @@ Track *_teletextTrack = teletextTrack;
|
|||||||
player->output.Clear();
|
player->output.Clear();
|
||||||
|
|
||||||
dvbsub_ass_clear();
|
dvbsub_ass_clear();
|
||||||
|
|
||||||
player->abortPlayback = 1;
|
player->abortPlayback = 1;
|
||||||
hasPlayThreadStarted = 0;
|
hasPlayThreadStarted = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **************************** */
|
|
||||||
/* Container part for ffmpeg */
|
|
||||||
/* **************************** */
|
|
||||||
|
|
||||||
/*static*/ int interrupt_cb(void *arg)
|
/*static*/ int interrupt_cb(void *arg)
|
||||||
{
|
{
|
||||||
Player *player = (Player *) arg;
|
Player *player = (Player *) arg;
|
||||||
@@ -372,7 +362,6 @@ bool Input::Init(const char *filename)
|
|||||||
|
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
fprintf(stderr, "filename NULL\n");
|
fprintf(stderr, "filename NULL\n");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +419,8 @@ bool Input::Init(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
terminating = false;
|
terminating = false;
|
||||||
int res = UpdateTracks();
|
|
||||||
|
bool res = UpdateTracks();
|
||||||
|
|
||||||
if (!videoTrack && !audioTrack) {
|
if (!videoTrack && !audioTrack) {
|
||||||
avformat_close_input(&avfc);
|
avformat_close_input(&avfc);
|
||||||
@@ -462,7 +452,7 @@ bool Input::UpdateTracks()
|
|||||||
if (!ch)
|
if (!ch)
|
||||||
continue;
|
continue;
|
||||||
Chapter chapter;
|
Chapter chapter;
|
||||||
chapter.title = title ? title->value : "unknown";
|
chapter.title = title ? title->value : "?";
|
||||||
chapter.start = (double) ch->start * av_q2d(ch->time_base) * 1000.0;
|
chapter.start = (double) ch->start * av_q2d(ch->time_base) * 1000.0;
|
||||||
chapter.end = (double) ch->end * av_q2d(ch->time_base) * 1000.0;
|
chapter.end = (double) ch->end * av_q2d(ch->time_base) * 1000.0;
|
||||||
chapters.push_back(chapter);
|
chapters.push_back(chapter);
|
||||||
@@ -473,50 +463,32 @@ bool Input::UpdateTracks()
|
|||||||
|
|
||||||
av_dump_format(avfc, 0, player->url.c_str(), 0);
|
av_dump_format(avfc, 0, player->url.c_str(), 0);
|
||||||
|
|
||||||
unsigned int n;
|
for (unsigned int n = 0; n < avfc->nb_streams; n++) {
|
||||||
|
|
||||||
for (n = 0; n < avfc->nb_streams; n++) {
|
|
||||||
Track track;
|
|
||||||
AVStream *stream = avfc->streams[n];
|
AVStream *stream = avfc->streams[n];
|
||||||
|
|
||||||
if (!stream->id)
|
if (!stream->id)
|
||||||
stream->id = n + 1;
|
stream->id = n + 1;
|
||||||
|
|
||||||
|
Track track;
|
||||||
track.avfc = avfc;
|
track.avfc = avfc;
|
||||||
track.stream = stream;
|
track.stream = stream;
|
||||||
|
AVDictionaryEntry *lang = av_dict_get(stream->metadata, "language", NULL, 0);
|
||||||
|
track.Name = lang ? lang->value : "?";
|
||||||
|
track.pid = stream->id;
|
||||||
|
if (stream->duration == AV_NOPTS_VALUE)
|
||||||
|
track.duration = (double) avfc->duration / 1000.0;
|
||||||
|
else
|
||||||
|
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
|
||||||
|
|
||||||
|
|
||||||
switch (stream->codec->codec_type) {
|
switch (stream->codec->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO: {
|
||||||
track.Name = "und";
|
|
||||||
track.avfc = avfc;
|
|
||||||
track.pid = stream->id;
|
|
||||||
|
|
||||||
if (stream->duration == AV_NOPTS_VALUE) {
|
|
||||||
track.duration = (double) avfc->duration / 1000.0;
|
|
||||||
} else {
|
|
||||||
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
player->manager.addVideoTrack(track);
|
player->manager.addVideoTrack(track);
|
||||||
if (!videoTrack)
|
if (!videoTrack)
|
||||||
videoTrack = player->manager.getVideoTrack(track.pid);
|
videoTrack = player->manager.getVideoTrack(track.pid);
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
|
||||||
AVDictionaryEntry *lang;
|
|
||||||
|
|
||||||
lang = av_dict_get(stream->metadata, "language", NULL, 0);
|
|
||||||
|
|
||||||
track.Name = lang ? lang->value : "und";
|
|
||||||
|
|
||||||
track.pid = stream->id;
|
|
||||||
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
|
|
||||||
|
|
||||||
if (stream->duration == AV_NOPTS_VALUE) {
|
|
||||||
track.duration = (double) avfc->duration / 1000.0;
|
|
||||||
} else {
|
|
||||||
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
|
|
||||||
}
|
}
|
||||||
|
case AVMEDIA_TYPE_AUDIO: {
|
||||||
switch(stream->codec->codec_id) {
|
switch(stream->codec->codec_id) {
|
||||||
case AUDIO_ENCODING_MPEG2:
|
case AUDIO_ENCODING_MPEG2:
|
||||||
track.ac3flags = 9;
|
track.ac3flags = 9;
|
||||||
@@ -542,19 +514,9 @@ bool Input::UpdateTracks()
|
|||||||
player->manager.addAudioTrack(track);
|
player->manager.addAudioTrack(track);
|
||||||
if (!audioTrack)
|
if (!audioTrack)
|
||||||
audioTrack = player->manager.getAudioTrack(track.pid);
|
audioTrack = player->manager.getAudioTrack(track.pid);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
}
|
||||||
{
|
case AVMEDIA_TYPE_SUBTITLE: {
|
||||||
AVDictionaryEntry *lang;
|
|
||||||
|
|
||||||
lang = av_dict_get(stream->metadata, "language", NULL, 0);
|
|
||||||
|
|
||||||
track.Name = lang ? lang->value : "und";
|
|
||||||
|
|
||||||
track.pid = stream->id;
|
|
||||||
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
|
|
||||||
|
|
||||||
if (stream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
|
if (stream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
AVDictionaryEntry *t = NULL;
|
AVDictionaryEntry *t = NULL;
|
||||||
@@ -584,7 +546,6 @@ bool Input::UpdateTracks()
|
|||||||
if (stream->codec->codec)
|
if (stream->codec->codec)
|
||||||
player->manager.addSubtitleTrack(track);
|
player->manager.addSubtitleTrack(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -592,7 +553,7 @@ bool Input::UpdateTracks()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* for */
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Includes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Includes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -59,7 +55,6 @@
|
|||||||
|
|
||||||
Output::Output()
|
Output::Output()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
videofd = audiofd = -1;
|
videofd = audiofd = -1;
|
||||||
videoWriter = audioWriter = NULL;
|
videoWriter = audioWriter = NULL;
|
||||||
videoStream = audioStream = NULL;
|
videoStream = audioStream = NULL;
|
||||||
@@ -67,13 +62,11 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
Output::~Output()
|
Output::~Output()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Output::Open()
|
bool Output::Open()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
||||||
|
|
||||||
@@ -106,7 +99,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Close()
|
bool Output::Close()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -126,7 +118,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Play()
|
bool Output::Play()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -151,7 +142,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Stop()
|
bool Output::Stop()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -178,7 +168,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Pause()
|
bool Output::Pause()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -199,7 +188,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Continue()
|
bool Output::Continue()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -220,7 +208,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Mute(bool b)
|
bool Output::Mute(bool b)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
||||||
|
|
||||||
//AUDIO_SET_MUTE has no effect with new player
|
//AUDIO_SET_MUTE has no effect with new player
|
||||||
@@ -233,7 +220,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Flush()
|
bool Output::Flush()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
@@ -250,7 +236,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::FastForward(int speed)
|
bool Output::FastForward(int speed)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
|
|
||||||
if (videofd > -1 && dioctl(videofd, VIDEO_FAST_FORWARD, speed))
|
if (videofd > -1 && dioctl(videofd, VIDEO_FAST_FORWARD, speed))
|
||||||
@@ -261,7 +246,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::SlowMotion(int speed)
|
bool Output::SlowMotion(int speed)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
|
|
||||||
if (videofd > -1 && dioctl(videofd, VIDEO_SLOWMOTION, speed))
|
if (videofd > -1 && dioctl(videofd, VIDEO_SLOWMOTION, speed))
|
||||||
@@ -272,7 +256,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::AVSync(bool b)
|
bool Output::AVSync(bool b)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
||||||
if (audiofd > -1 && dioctl(audiofd, AUDIO_SET_AV_SYNC, b))
|
if (audiofd > -1 && dioctl(audiofd, AUDIO_SET_AV_SYNC, b))
|
||||||
return false;
|
return false;
|
||||||
@@ -282,7 +265,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::ClearAudio()
|
bool Output::ClearAudio()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
||||||
if (audiofd > -1 && dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL))
|
if (audiofd > -1 && dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL))
|
||||||
return false;
|
return false;
|
||||||
@@ -292,7 +274,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::ClearVideo()
|
bool Output::ClearVideo()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
if (videofd > -1 && dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL))
|
if (videofd > -1 && dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL))
|
||||||
return false;
|
return false;
|
||||||
@@ -302,7 +283,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Clear()
|
bool Output::Clear()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
bool aret = ClearAudio();
|
bool aret = ClearAudio();
|
||||||
bool vret = ClearVideo();
|
bool vret = ClearVideo();
|
||||||
return aret && vret;
|
return aret && vret;
|
||||||
@@ -310,7 +290,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::GetPts(int64_t &pts)
|
bool Output::GetPts(int64_t &pts)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
pts = 0;
|
pts = 0;
|
||||||
return ((videofd > -1 && !dioctl(videofd, VIDEO_GET_PTS, (void *) &pts)) ||
|
return ((videofd > -1 && !dioctl(videofd, VIDEO_GET_PTS, (void *) &pts)) ||
|
||||||
(audiofd > -1 && !dioctl(audiofd, AUDIO_GET_PTS, (void *) &pts)));
|
(audiofd > -1 && !dioctl(audiofd, AUDIO_GET_PTS, (void *) &pts)));
|
||||||
@@ -318,7 +297,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::GetFrameCount(int64_t &framecount)
|
bool Output::GetFrameCount(int64_t &framecount)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
dvb_play_info_t playInfo;
|
dvb_play_info_t playInfo;
|
||||||
|
|
||||||
if ((videofd > -1 && dioctl(videofd, VIDEO_GET_PLAY_INFO, (void *) &playInfo)) ||
|
if ((videofd > -1 && dioctl(videofd, VIDEO_GET_PLAY_INFO, (void *) &playInfo)) ||
|
||||||
@@ -331,7 +309,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::SwitchAudio(AVStream *stream)
|
bool Output::SwitchAudio(AVStream *stream)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
|
||||||
if (stream == audioStream)
|
if (stream == audioStream)
|
||||||
return true;
|
return true;
|
||||||
@@ -353,7 +330,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::SwitchVideo(AVStream *stream)
|
bool Output::SwitchVideo(AVStream *stream)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
if (stream == videoStream)
|
if (stream == videoStream)
|
||||||
return true;
|
return true;
|
||||||
@@ -375,7 +351,6 @@ fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|||||||
|
|
||||||
bool Output::Write(AVFormatContext *avfc, AVStream *stream, AVPacket *packet, int64_t &Pts)
|
bool Output::Write(AVFormatContext *avfc, AVStream *stream, AVPacket *packet, int64_t &Pts)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "%s %d %s\n", __FILE__,__LINE__,__func__);
|
|
||||||
switch (stream->codec->codec_type) {
|
switch (stream->codec->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO: {
|
case AVMEDIA_TYPE_VIDEO: {
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
|
||||||
|
@@ -3,10 +3,6 @@
|
|||||||
* duckbox 2010
|
* duckbox 2010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Includes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -196,8 +192,7 @@ bool Player::Continue()
|
|||||||
{
|
{
|
||||||
int ret = true;
|
int ret = true;
|
||||||
|
|
||||||
if (isPlaying && (isPaused || isForwarding
|
if (isPlaying && (isPaused || isForwarding || isBackWard || isSlowMotion)) {
|
||||||
|| isBackWard || isSlowMotion)) {
|
|
||||||
|
|
||||||
if (isSlowMotion)
|
if (isSlowMotion)
|
||||||
output.Clear();
|
output.Clear();
|
||||||
@@ -314,8 +309,7 @@ bool Player::FastForward(int speed)
|
|||||||
int ret = true;
|
int ret = true;
|
||||||
|
|
||||||
/* Audio only forwarding not supported */
|
/* Audio only forwarding not supported */
|
||||||
if (isVideo && !isHttp && !isBackWard
|
if (isVideo && !isHttp && !isBackWard && (!isPaused || isPlaying)) {
|
||||||
&& (!isPaused || isPlaying)) {
|
|
||||||
|
|
||||||
if ((speed <= 0) || (speed > cMaxSpeed_ff)) {
|
if ((speed <= 0) || (speed > cMaxSpeed_ff)) {
|
||||||
fprintf(stderr, "speed %d out of range (1 - %d) \n", speed, cMaxSpeed_ff);
|
fprintf(stderr, "speed %d out of range (1 - %d) \n", speed, cMaxSpeed_ff);
|
||||||
@@ -338,8 +332,7 @@ bool Player::FastBackward(int speed)
|
|||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
/* Audio only reverse play not supported */
|
/* Audio only reverse play not supported */
|
||||||
if (isVideo && !isForwarding
|
if (isVideo && !isForwarding && (!isPaused || isPlaying)) {
|
||||||
&& (!isPaused || isPlaying)) {
|
|
||||||
|
|
||||||
if ((speed > 0) || (speed < cMaxSpeed_fr)) {
|
if ((speed > 0) || (speed < cMaxSpeed_fr)) {
|
||||||
fprintf(stderr, "speed %d out of range (0 - %d) \n", speed, cMaxSpeed_fr);
|
fprintf(stderr, "speed %d out of range (0 - %d) \n", speed, cMaxSpeed_fr);
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Includes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -102,7 +98,6 @@ bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
if (initialHeader) {
|
if (initialHeader) {
|
||||||
iov[ic].iov_base = stream->codec->extradata;
|
iov[ic].iov_base = stream->codec->extradata;
|
||||||
iov[ic++].iov_len = stream->codec->extradata_size;
|
iov[ic++].iov_len = stream->codec->extradata_size;
|
||||||
|
|
||||||
initialHeader = false;
|
initialHeader = false;
|
||||||
}
|
}
|
||||||
iov[ic].iov_base = packet->data;
|
iov[ic].iov_base = packet->data;
|
||||||
|
@@ -35,13 +35,13 @@
|
|||||||
#define CONTAINER_PARAMETERS_VERSION 0x00
|
#define CONTAINER_PARAMETERS_VERSION 0x00
|
||||||
|
|
||||||
typedef struct avcC_s {
|
typedef struct avcC_s {
|
||||||
unsigned char Version; /* configurationVersion */
|
unsigned char Version; // configurationVersion
|
||||||
unsigned char Profile; /* AVCProfileIndication */
|
unsigned char Profile; // AVCProfileIndication
|
||||||
unsigned char Compatibility; /* profile_compatibility */
|
unsigned char Compatibility; // profile_compatibility
|
||||||
unsigned char Level; /* AVCLevelIndication */
|
unsigned char Level; // AVCLevelIndication
|
||||||
unsigned char NalLengthMinusOne; /* held in bottom two bits */
|
unsigned char NalLengthMinusOne; // held in bottom two bits
|
||||||
unsigned char NumParamSets; /* held in bottom 5 bits */
|
unsigned char NumParamSets; // held in bottom 5 bits
|
||||||
unsigned char Params[1]; /* {length,params}{length,params}...sequence then picture */
|
unsigned char Params[1]; // {length,params}{length,params}...sequence then picture
|
||||||
} avcC_t;
|
} avcC_t;
|
||||||
|
|
||||||
const unsigned char Head[] = { 0, 0, 0, 1 };
|
const unsigned char Head[] = { 0, 0, 0, 1 };
|
||||||
@@ -95,13 +95,12 @@ bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
iov[ic].iov_base = packet->data;
|
iov[ic].iov_base = packet->data;
|
||||||
iov[ic++].iov_len = packet->size;
|
iov[ic++].iov_len = packet->size;
|
||||||
PacketLength += packet->size;
|
PacketLength += packet->size;
|
||||||
/*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
|
// Hellmaster1024:
|
||||||
data is available. The content of this byte does not matter. It will be ignored
|
// some packets will only be accepted by the player if we send one byte more than data is available.
|
||||||
by the player */
|
// The content of this byte does not matter. It will be ignored by the player
|
||||||
iov[ic].iov_base = (void *) "";
|
iov[ic].iov_base = (void *) "";
|
||||||
iov[ic++].iov_len = 1;
|
iov[ic++].iov_len = 1;
|
||||||
iov[0].iov_len =
|
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, pts, FakeStartCode);
|
||||||
InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, pts, FakeStartCode);
|
|
||||||
return writev(fd, iov, ic) > -1;
|
return writev(fd, iov, ic) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +126,7 @@ bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
HeaderData[ParametersLength++] = 0x00; // Start code
|
HeaderData[ParametersLength++] = 0x00; // Start code
|
||||||
HeaderData[ParametersLength++] = 0x00;
|
HeaderData[ParametersLength++] = 0x00;
|
||||||
HeaderData[ParametersLength++] = 0x01;
|
HeaderData[ParametersLength++] = 0x01;
|
||||||
HeaderData[ParametersLength++] =
|
HeaderData[ParametersLength++] = NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
|
||||||
NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS;
|
|
||||||
// Container message version - changes when/if we vary the format of the message
|
// Container message version - changes when/if we vary the format of the message
|
||||||
HeaderData[ParametersLength++] = CONTAINER_PARAMETERS_VERSION;
|
HeaderData[ParametersLength++] = CONTAINER_PARAMETERS_VERSION;
|
||||||
HeaderData[ParametersLength++] = 0xff; // Field separator
|
HeaderData[ParametersLength++] = 0xff; // Field separator
|
||||||
@@ -253,9 +251,7 @@ bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, A
|
|||||||
iov[ic++].iov_len = NalLength;
|
iov[ic++].iov_len = NalLength;
|
||||||
VideoPosition += NalLength;
|
VideoPosition += NalLength;
|
||||||
|
|
||||||
iov[0].iov_len =
|
iov[0].iov_len = InsertPesHeader(PesHeader, NalLength, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
|
||||||
InsertPesHeader(PesHeader, NalLength,
|
|
||||||
MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
|
|
||||||
ssize_t l = writev(fd, iov, ic);
|
ssize_t l = writev(fd, iov, ic);
|
||||||
if (l < 0)
|
if (l < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@@ -159,8 +159,7 @@ int WriterPCM::writePCM(int fd, int64_t Pts, uint8_t *data, unsigned int size)
|
|||||||
//printf("PCM %s - Position=%d\n", __FUNCTION__, pos);
|
//printf("PCM %s - Position=%d\n", __FUNCTION__, pos);
|
||||||
if ((size - pos) < SubFrameLen) {
|
if ((size - pos) < SubFrameLen) {
|
||||||
breakBufferFillSize = size - pos;
|
breakBufferFillSize = size - pos;
|
||||||
memcpy(breakBuffer, &data[pos],
|
memcpy(breakBuffer, &data[pos], sizeof(unsigned char) * breakBufferFillSize);
|
||||||
sizeof(unsigned char) * breakBufferFillSize);
|
|
||||||
//printf("PCM %s - Unplayed=%d\n", __FUNCTION__, breakBufferFillSize);
|
//printf("PCM %s - Unplayed=%d\n", __FUNCTION__, breakBufferFillSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -237,7 +236,6 @@ bool WriterPCM::Write(int fd, AVFormatContext *avfc, AVStream *stream, AVPacket
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -246,18 +244,13 @@ fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|||||||
unsigned int packet_size = packet->size;
|
unsigned int packet_size = packet->size;
|
||||||
|
|
||||||
if (restart_audio_resampling) {
|
if (restart_audio_resampling) {
|
||||||
fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|
||||||
restart_audio_resampling = false;
|
restart_audio_resampling = false;
|
||||||
initialHeader = true;
|
initialHeader = true;
|
||||||
|
|
||||||
if (swr) {
|
if (swr)
|
||||||
swr_free(&swr);
|
swr_free(&swr);
|
||||||
swr = NULL; //FIXME: Needed?
|
if (decoded_frame)
|
||||||
}
|
|
||||||
if (decoded_frame) {
|
|
||||||
av_frame_free(&decoded_frame);
|
av_frame_free(&decoded_frame);
|
||||||
decoded_frame = NULL; //FIXME: Needed?
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec *codec = avcodec_find_decoder(c->codec_id);
|
AVCodec *codec = avcodec_find_decoder(c->codec_id);
|
||||||
|
|
||||||
@@ -276,7 +269,6 @@ fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|||||||
|
|
||||||
int len = avcodec_decode_audio4(c, decoded_frame, &got_frame, packet);
|
int len = avcodec_decode_audio4(c, decoded_frame, &got_frame, packet);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -317,12 +309,10 @@ fprintf(stderr, "%s %s %d\n", __FILE__, __func__, __LINE__);
|
|||||||
|
|
||||||
e = swr_init(swr);
|
e = swr_init(swr);
|
||||||
if (e < 0) {
|
if (e < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "swr_init: %d (icl=%d ocl=%d isr=%d osr=%d isf=%d osf=%d\n",
|
||||||
"swr_init: %d (icl=%d ocl=%d isr=%d osr=%d isf=%d osf=%d\n",
|
|
||||||
-e, (int) c->channel_layout,
|
-e, (int) c->channel_layout,
|
||||||
(int) out_channel_layout, c->sample_rate, out_sample_rate, c->sample_fmt, AV_SAMPLE_FMT_S16);
|
(int) out_channel_layout, c->sample_rate, out_sample_rate, c->sample_fmt, AV_SAMPLE_FMT_S16);
|
||||||
swr_free(&swr);
|
swr_free(&swr);
|
||||||
swr = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +355,7 @@ WriterPCM::WriterPCM()
|
|||||||
out_channel_layout = AV_CH_LAYOUT_STEREO;
|
out_channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
|
|
||||||
Register(this, AV_CODEC_ID_PCM_S16LE/*FIXME*/, AUDIO_ENCODING_LPCMA);
|
Register(this, AV_CODEC_ID_INJECTPCM, AUDIO_ENCODING_LPCMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WriterPCM writer_pcm __attribute__ ((init_priority (300)));
|
static WriterPCM writer_pcm __attribute__ ((init_priority (300)));
|
||||||
|
@@ -27,44 +27,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <linux/dvb/video.h>
|
|
||||||
#include <linux/dvb/audio.h>
|
|
||||||
#include <linux/dvb/stm_ioctls.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "player.h"
|
|
||||||
#include "output.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "pes.h"
|
#include "pes.h"
|
||||||
#include "writer.h"
|
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Makros/Constants */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Types */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Varaibles */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Prototypes */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
/* ***************************** */
|
|
||||||
/* Functions */
|
|
||||||
/* ***************************** */
|
|
||||||
|
|
||||||
int InsertVideoPrivateDataHeader(unsigned char *data, int payload_size)
|
int InsertVideoPrivateDataHeader(unsigned char *data, int payload_size)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user