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