Origin commit data
------------------
Branch: master
Commit: b4bf02c39c
Author: vanhofen <vanhofen@gmx.de>
Date: 2018-01-19 (Fri, 19 Jan 2018)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2018-01-19 08:44:03 +01:00
49 changed files with 772 additions and 520 deletions

View File

@@ -55,6 +55,7 @@ static ao_device *adevice = NULL;
static ao_sample_format sformat;
static AVCodecContext *c = NULL;
static AVCodecParameters *p = NULL;
cAudio::cAudio(void *, void *, void *)
{
@@ -356,28 +357,31 @@ void cAudio::run()
lt_info("%s: nb_streams: %d, should be 1!\n", __func__, avfc->nb_streams);
goto out;
}
if (avfc->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
lt_info("%s: stream 0 no audio codec? 0x%x\n", __func__, avfc->streams[0]->codec->codec_type);
p = avfc->streams[0]->codecpar;
if (p->codec_type != AVMEDIA_TYPE_AUDIO)
lt_info("%s: stream 0 no audio codec? 0x%x\n", __func__, p->codec_type);
c = avfc->streams[0]->codec;
codec = avcodec_find_decoder(c->codec_id);
codec = avcodec_find_decoder(p->codec_id);
if (!codec) {
lt_info("%s: Codec for %s not found\n", __func__, avcodec_get_name(c->codec_id));
lt_info("%s: Codec for %s not found\n", __func__, avcodec_get_name(p->codec_id));
goto out;
}
if (c)
av_free(c);
c = avcodec_alloc_context3(codec);
if (avcodec_open2(c, codec, NULL) < 0) {
lt_info("%s: avcodec_open2() failed\n", __func__);
goto out;
}
frame = av_frame_alloc();
if (!frame) {
lt_info("%s: avcodec_alloc_frame failed\n", __func__);
lt_info("%s: av_frame_alloc failed\n", __func__);
goto out2;
}
/* output sample rate, channels, layout could be set here if necessary */
o_ch = c->channels; /* 2 */
o_sr = c->sample_rate; /* 48000 */
o_layout = c->channel_layout; /* AV_CH_LAYOUT_STEREO */
o_ch = p->channels; /* 2 */
o_sr = p->sample_rate; /* 48000 */
o_layout = p->channel_layout; /* AV_CH_LAYOUT_STEREO */
if (sformat.channels != o_ch || sformat.rate != o_sr ||
sformat.byte_format != AO_FMT_NATIVE || sformat.bits != 16 || adevice == NULL)
{
@@ -405,10 +409,10 @@ void cAudio::run()
#endif
av_get_sample_fmt_string(tmp, sizeof(tmp), c->sample_fmt);
lt_info("decoding %s, sample_fmt %d (%s) sample_rate %d channels %d\n",
avcodec_get_name(c->codec_id), c->sample_fmt, tmp, c->sample_rate, c->channels);
avcodec_get_name(p->codec_id), c->sample_fmt, tmp, p->sample_rate, p->channels);
swr = swr_alloc_set_opts(swr,
o_layout, AV_SAMPLE_FMT_S16, o_sr, /* output */
c->channel_layout, c->sample_fmt, c->sample_rate, /* input */
p->channel_layout, c->sample_fmt, p->sample_rate, /* input */
0, NULL);
if (! swr) {
lt_info("could not alloc resample context\n");
@@ -422,15 +426,15 @@ void cAudio::run()
avcodec_decode_audio4(c, frame, &gotframe, &avpkt);
if (gotframe && thread_started) {
int out_linesize;
obuf_sz = av_rescale_rnd(swr_get_delay(swr, c->sample_rate) +
frame->nb_samples, o_sr, c->sample_rate, AV_ROUND_UP);
obuf_sz = av_rescale_rnd(swr_get_delay(swr, p->sample_rate) +
frame->nb_samples, o_sr, p->sample_rate, AV_ROUND_UP);
if (obuf_sz > obuf_sz_max) {
lt_info("obuf_sz: %d old: %d\n", obuf_sz, obuf_sz_max);
av_free(obuf);
if (av_samples_alloc(&obuf, &out_linesize, o_ch,
frame->nb_samples, AV_SAMPLE_FMT_S16, 1) < 0) {
lt_info("av_samples_alloc failed\n");
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
break; /* while (thread_started) */
}
obuf_sz_max = obuf_sz;
@@ -443,7 +447,7 @@ void cAudio::run()
obuf_sz, AV_SAMPLE_FMT_S16, 1);
ao_play(adevice, (char *)obuf, o_buf_sz);
}
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
}
// ao_close(adevice); /* can take long :-( */
av_free(obuf);
@@ -452,6 +456,7 @@ void cAudio::run()
av_frame_free(&frame);
out2:
avcodec_close(c);
av_free(c);
c = NULL;
out:
avformat_close_input(&avfc);

View File

@@ -30,6 +30,7 @@
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
}
@@ -79,10 +80,12 @@ cVideo::cVideo(int, void *, void *, unsigned int)
buf_in = 0;
buf_out = 0;
pig_x = pig_y = pig_w = pig_h = 0;
pig_changed = false;
display_aspect = DISPLAY_AR_16_9;
display_crop = DISPLAY_AR_MODE_LETTERBOX;
v_format = VIDEO_FORMAT_MPEG2;
output_h = 0;
stillpicture = false;
}
cVideo::~cVideo(void)
@@ -163,6 +166,18 @@ int cVideo::setBlank(int)
return 1;
}
int cVideo::GetVideoSystem()
{
int current_video_system = VIDEO_STD_1080I50;
if(dec_w < 720)
current_video_system = VIDEO_STD_PAL;
else if(dec_w > 720 && dec_w <= 1280)
current_video_system = VIDEO_STD_720P50;
return current_video_system;
}
int cVideo::SetVideoSystem(int system, bool)
{
int h;
@@ -196,25 +211,13 @@ int cVideo::SetVideoSystem(int system, bool)
lt_info("%s: unhandled value %d\n", __func__, system);
return 0;
}
v_std = (VIDEO_STD) system;
// v_std = (VIDEO_STD) system;
output_h = h;
if (display_aspect < DISPLAY_AR_RAW && output_h > 0) /* don't know what to do with this */
glfb->setOutputFormat(aspect_ratios[display_aspect], output_h, display_crop);
return 0;
}
int cVideo::GetVideoSystem()
{
int current_video_system = VIDEO_STD_1080I50;
if(dec_w < 720)
current_video_system = VIDEO_STD_PAL;
else if(dec_w > 720 && dec_w <= 1280)
current_video_system = VIDEO_STD_720P50;
return 0;
}
int cVideo::getPlayState(void)
{
return VIDEO_PLAYING;
@@ -224,11 +227,17 @@ void cVideo::SetVideoMode(analog_mode_t)
{
}
void cVideo::ShowPicture(const char *fname, const char *)
void cVideo::ShowPicture(const char *fname)
{
lt_info("%s(%s)\n", __func__, fname);
if (access(fname, R_OK))
return;
still_m.lock();
stillpicture = true;
buf_num = 0;
buf_in = 0;
buf_out = 0;
still_m.unlock();
unsigned int i;
int stream_id = -1;
@@ -236,6 +245,7 @@ void cVideo::ShowPicture(const char *fname, const char *)
int len;
AVFormatContext *avfc = NULL;
AVCodecContext *c = NULL;
AVCodecParameters *p = NULL;
AVCodec *codec;
AVFrame *frame, *rgbframe;
AVPacket avpkt;
@@ -250,17 +260,18 @@ void cVideo::ShowPicture(const char *fname, const char *)
goto out_close;
}
for (i = 0; i < avfc->nb_streams; i++) {
if (avfc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (avfc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
stream_id = i;
break;
}
}
if (stream_id < 0)
goto out_close;
c = avfc->streams[stream_id]->codec;
codec = avcodec_find_decoder(c->codec_id);
if (!avcodec_open2(c, codec, NULL) < 0) {
lt_info("%s: Could not find/open the codec, id 0x%x\n", __func__, c->codec_id);
p = avfc->streams[stream_id]->codecpar;
codec = avcodec_find_decoder(p->codec_id);
c = avcodec_alloc_context3(codec);
if (avcodec_open2(c, codec, NULL) < 0) {
lt_info("%s: Could not find/open the codec, id 0x%x\n", __func__, p->codec_id);
goto out_close;
}
frame = av_frame_alloc();
@@ -277,15 +288,15 @@ void cVideo::ShowPicture(const char *fname, const char *)
len = avcodec_decode_video2(c, frame, &got_frame, &avpkt);
if (len < 0) {
lt_info("%s: avcodec_decode_video2 %d\n", __func__, len);
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
goto out_free;
}
if (avpkt.size > len)
lt_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len);
if (got_frame) {
unsigned int need = avpicture_get_size(PIX_FMT_RGB32, c->width, c->height);
unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, c->width, c->height, 1);
struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt,
c->width, c->height, PIX_FMT_RGB32,
c->width, c->height, AV_PIX_FMT_RGB32,
SWS_BICUBIC, 0, 0, 0);
if (!convert)
lt_info("%s: ERROR setting up SWS context\n", __func__);
@@ -294,8 +305,8 @@ void cVideo::ShowPicture(const char *fname, const char *)
SWFramebuffer *f = &buffers[buf_in];
if (f->size() < need)
f->resize(need);
avpicture_fill((AVPicture *)rgbframe, &(*f)[0], PIX_FMT_RGB32,
c->width, c->height);
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], AV_PIX_FMT_RGB32,
c->width, c->height, 1);
sws_scale(convert, frame->data, frame->linesize, 0, c->height,
rgbframe->data, rgbframe->linesize);
sws_freeContext(convert);
@@ -308,7 +319,7 @@ void cVideo::ShowPicture(const char *fname, const char *)
buf_in %= VDEC_MAXBUFS;
buf_num++;
if (buf_num > (VDEC_MAXBUFS - 1)) {
lt_debug("%s: buf_num overflow\n", __func__);
lt_info("%s: buf_num overflow\n", __func__);
buf_out++;
buf_out %= VDEC_MAXBUFS;
buf_num--;
@@ -316,9 +327,10 @@ void cVideo::ShowPicture(const char *fname, const char *)
buf_m.unlock();
}
}
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
out_free:
avcodec_close(c);
av_free(c);
av_frame_free(&frame);
av_frame_free(&rgbframe);
out_close:
@@ -328,6 +340,10 @@ void cVideo::ShowPicture(const char *fname, const char *)
void cVideo::StopPicture()
{
lt_info("%s\n", __func__);
still_m.lock();
stillpicture = false;
still_m.unlock();
}
void cVideo::Standby(unsigned int)
@@ -351,7 +367,32 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
{
width = dec_w;
height = dec_h;
switch (dec_r) {
case 23://23.976fps
rate = VIDEO_FRAME_RATE_23_976;
break;
case 24:
rate = VIDEO_FRAME_RATE_24;
break;
case 25:
rate = VIDEO_FRAME_RATE_25;
break;
case 29://29,976fps
rate = VIDEO_FRAME_RATE_29_97;
break;
case 30:
rate = VIDEO_FRAME_RATE_30;
break;
case 50:
rate = VIDEO_FRAME_RATE_50;
break;
case 60:
rate = VIDEO_FRAME_RATE_60;
break;
default:
rate = dec_r;
break;
}
}
void cVideo::SetSyncMode(AVSYNC_TYPE)
@@ -407,6 +448,7 @@ void cVideo::run(void)
{
lt_info("====================== start decoder thread ================================\n");
AVCodec *codec;
AVCodecParameters *p = NULL;
AVCodecContext *c= NULL;
AVFormatContext *avfc = NULL;
AVInputFormat *inp;
@@ -447,20 +489,21 @@ void cVideo::run(void)
lt_info("%s: nb_streams %d, should be 1 => retry\n", __func__, avfc->nb_streams);
if (av_read_frame(avfc, &avpkt) < 0)
lt_info("%s: av_read_frame < 0\n", __func__);
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
if (! thread_running)
goto out;
}
if (avfc->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
lt_info("%s: no video codec? 0x%x\n", __func__, avfc->streams[0]->codec->codec_type);
p = avfc->streams[0]->codecpar;
if (p->codec_type != AVMEDIA_TYPE_VIDEO)
lt_info("%s: no video codec? 0x%x\n", __func__, p->codec_type);
c = avfc->streams[0]->codec;
codec = avcodec_find_decoder(c->codec_id);
codec = avcodec_find_decoder(p->codec_id);
if (!codec) {
lt_info("%s: Codec for %s not found\n", __func__, avcodec_get_name(c->codec_id));
lt_info("%s: Codec for %s not found\n", __func__, avcodec_get_name(p->codec_id));
goto out;
}
c = avcodec_alloc_context3(codec);
if (avcodec_open2(c, codec, NULL) < 0) {
lt_info("%s: Could not open codec\n", __func__);
goto out;
@@ -488,16 +531,17 @@ void cVideo::run(void)
lt_info("%s: avcodec_decode_video2 %d\n", __func__, len);
warn_d = time(NULL);
}
av_free_packet(&avpkt);
av_packet_unref(&avpkt);
continue;
}
if (avpkt.size > len)
lt_info("%s: WARN: pkt->size %d != len %d\n", __func__, avpkt.size, len);
if (got_frame) {
unsigned int need = avpicture_get_size(PIX_FMT_RGB32, c->width, c->height);
still_m.lock();
if (got_frame && ! stillpicture) {
unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, c->width, c->height, 1);
convert = sws_getCachedContext(convert,
c->width, c->height, c->pix_fmt,
c->width, c->height, PIX_FMT_RGB32,
c->width, c->height, AV_PIX_FMT_RGB32,
SWS_BICUBIC, 0, 0, 0);
if (!convert)
lt_info("%s: ERROR setting up SWS context\n", __func__);
@@ -506,8 +550,8 @@ void cVideo::run(void)
SWFramebuffer *f = &buffers[buf_in];
if (f->size() < need)
f->resize(need);
avpicture_fill((AVPicture *)rgbframe, &(*f)[0], PIX_FMT_RGB32,
c->width, c->height);
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], AV_PIX_FMT_RGB32,
c->width, c->height, 1);
sws_scale(convert, frame->data, frame->linesize, 0, c->height,
rgbframe->data, rgbframe->linesize);
if (dec_w != c->width || dec_h != c->height) {
@@ -521,6 +565,8 @@ void cVideo::run(void)
f->height(c->height);
int64_t vpts = av_frame_get_best_effort_timestamp(frame);
if (v_format == VIDEO_FORMAT_MPEG2)
vpts += 90000*4/10; /* 400ms */
else
vpts += 90000*3/10; /* 300ms */
f->pts(vpts);
AVRational a = av_guess_sample_aspect_ratio(avfc, avfc->streams[0], frame);
@@ -529,7 +575,7 @@ void cVideo::run(void)
buf_in %= VDEC_MAXBUFS;
buf_num++;
if (buf_num > (VDEC_MAXBUFS - 1)) {
lt_debug("%s: buf_num overflow\n", __func__);
lt_info("%s: buf_num overflow\n", __func__);
buf_out++;
buf_out %= VDEC_MAXBUFS;
buf_num--;
@@ -540,12 +586,15 @@ void cVideo::run(void)
lt_debug("%s: time_base: %d/%d, ticks: %d rate: %d pts 0x%" PRIx64 "\n", __func__,
c->time_base.num, c->time_base.den, c->ticks_per_frame, dec_r,
av_frame_get_best_effort_timestamp(frame));
}
av_free_packet(&avpkt);
} else
lt_info("%s: got_frame: %d stillpicture: %d\n", __func__, got_frame, stillpicture);
still_m.unlock();
av_packet_unref(&avpkt);
}
sws_freeContext(convert);
out2:
avcodec_close(c);
av_free(c);
av_frame_free(&frame);
av_frame_free(&rgbframe);
out:
@@ -554,35 +603,59 @@ void cVideo::run(void)
av_free(pIOCtx);
/* reset output buffers */
bufpos = 0;
still_m.lock();
if (!stillpicture) {
buf_num = 0;
buf_in = 0;
buf_out = 0;
}
still_m.unlock();
lt_info("======================== end decoder thread ================================\n");
}
static bool swscale(unsigned char *src, unsigned char *dst, int sw, int sh, int dw, int dh)
static bool swscale(unsigned char *src, unsigned char *dst, int sw, int sh, int dw, int dh, AVPixelFormat sfmt)
{
bool ret = false;
int len = 0;
struct SwsContext *scale = NULL;
AVFrame *sframe, *dframe;
scale = sws_getCachedContext(scale, sw, sh, PIX_FMT_RGB32, dw, dh, PIX_FMT_RGB32, SWS_BICUBIC, 0, 0, 0);
scale = sws_getCachedContext(scale, sw, sh, sfmt, dw, dh, AV_PIX_FMT_RGB32, SWS_BICUBIC, 0, 0, 0);
if (!scale) {
lt_info_c("%s: ERROR setting up SWS context\n", __func__);
return false;
return ret;
}
sframe = av_frame_alloc();
dframe = av_frame_alloc();
if (!sframe || !dframe) {
AVFrame *sframe = av_frame_alloc();
AVFrame *dframe = av_frame_alloc();
if (sframe && dframe) {
len = av_image_fill_arrays(sframe->data, sframe->linesize, &(src)[0], sfmt, sw, sh, 1);
if(len>-1)
ret = true;
if(ret && (len = av_image_fill_arrays(dframe->data, dframe->linesize, &(dst)[0], AV_PIX_FMT_RGB32, dw, dh, 1)<0))
ret = false;
if(ret && (len = sws_scale(scale, sframe->data, sframe->linesize, 0, sh, dframe->data, dframe->linesize)<0))
ret = false;
else
ret = true;
}else{
lt_info_c("%s: could not alloc sframe (%p) or dframe (%p)\n", __func__, sframe, dframe);
goto out;
ret = false;
}
avpicture_fill((AVPicture *)sframe, &(src[0]), PIX_FMT_RGB32, sw, sh);
avpicture_fill((AVPicture *)dframe, &(dst[0]), PIX_FMT_RGB32, dw, dh);
sws_scale(scale, sframe->data, sframe->linesize, 0, sh, dframe->data, dframe->linesize);
out:
if(sframe){
av_frame_free(&sframe);
sframe = NULL;
}
if(dframe){
av_frame_free(&dframe);
dframe = NULL;
}
if(scale){
sws_freeContext(scale);
scale = NULL;
}
lt_info_c("%s: %s scale %ix%i to %ix%i ,len %i\n",ret?" ":"ERROR",__func__, sw, sh, dw, dh,len);
return ret;
}
@@ -613,24 +686,40 @@ bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool ge
xres = vid_w * a.num / a.den;
}
}
if(video.empty()){
get_video=false;
xres = osd_w;
yres = osd_h;
}
if (get_osd)
osd = glfb->getOSDBuffer();
unsigned int need = avpicture_get_size(PIX_FMT_RGB32, xres, yres);
unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, xres, yres, 1);
data = (unsigned char *)realloc(data, need); /* will be freed by caller */
if (data == NULL) /* out of memory? */
return false;
if (get_video) {
if (vid_w != xres || vid_h != yres) /* scale video into data... */
swscale(&video[0], data, vid_w, vid_h, xres, yres);
else /* get_video and no fancy scaling needed */
//memcpy dont work with copy BGR24 to RGB32
if (vid_w != xres || vid_h != yres){ /* scale video into data... */
bool ret = swscale(&video[0], data, vid_w, vid_h, xres, yres, AV_PIX_FMT_RGB32);
if(!ret){
free(data);
return false;
}
//memcpy dont work with copy BGR24 to RGB32
} else { /* get_video and no fancy scaling needed */
memcpy(data, &video[0], xres * yres * sizeof(uint32_t));
}
}
if (get_osd && (osd_w != xres || osd_h != yres)) {
/* rescale osd */
s_osd.resize(need);
swscale(&(*osd)[0], &s_osd[0], osd_w, osd_h, xres, yres);
bool ret = swscale(&(*osd)[0], &s_osd[0], osd_w, osd_h, xres, yres,AV_PIX_FMT_RGB32);
if(!ret){
free(data);
return false;
}
osd = &s_osd;
}

View File

@@ -157,8 +157,8 @@ class cVideo : public Thread
/* aspect ratio */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int setAspectRatio(int aspect, int mode);
void getPictureInfo(int &width, int &height, int &rate);
/* cropping mode */
int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/);
@@ -170,20 +170,22 @@ class cVideo : public Thread
int getBlank(void);
int setBlank(int enable);
/* set video_system */
int SetVideoSystem(int video_system, bool remember = true);
int GetVideoSystem();
/* change video play state. Parameters are all unused. */
int Start(void *PcrChannel = NULL, unsigned short PcrPid = 0, unsigned short VideoPid = 0, void *x = NULL);
int Stop(bool blank = true);
bool Pause(void);
/* set video_system */
int SetVideoSystem(int video_system, bool remember = true);
int GetVideoSystem();
int SetStreamType(VIDEO_FORMAT type);
void ShowPicture(const char * fname);
void SetSyncMode(AVSYNC_TYPE mode);
bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; };
void SetCECAutoView(bool) { return; };
void SetCECAutoStandby(bool) { return; };
void ShowPicture(const char * fname, const char * destname = NULL);
void StopPicture();
void Standby(unsigned int bOn);
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600, int startx = 0, int starty = 0, int endx = 1279, int endy = 719);
@@ -218,6 +220,9 @@ class cVideo : public Thread
int pig_y;
int pig_w;
int pig_h;
bool pig_changed;
Mutex still_m;
bool stillpicture;
};
#endif

View File

@@ -200,10 +200,11 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
const char *mix_dev = getenv("MIX_DEVICE");
lt_debug("%s ch %d srate %d bits %d le %d\n", __FUNCTION__, ch, srate, bits, little_endian);
if (clipfd > -1) {
lt_info("%s: clipfd already opened (%d)\n", __FUNCTION__, clipfd);
lt_info("%s: clipfd already opened (%d)\n", __func__, clipfd);
return -1;
}
mixer_num = -1;
mixer_fd = -1;
/* a different DSP device can be given with DSP_DEVICE and MIX_DEVICE
* if this device cannot be opened, we fall back to the internal OSS device
* Example:

View File

@@ -351,7 +351,7 @@ void cVideo::closeDevice(void)
{
lt_debug("%s\n", __func__);
/* looks like sometimes close is unhappy about non-empty buffers */
Start();
// Start();
if (fd >= 0)
close(fd);
fd = -1;
@@ -602,6 +602,8 @@ void cVideo::StopPicture()
lt_debug("%s\n", __func__);
stillpicture = false;
Stop(1);
closeDevice();
openDevice();
}
void cVideo::Standby(unsigned int bOn)

View File

@@ -103,8 +103,7 @@ static void update_finish_timeout()
/* On some STBs PTS readed from decoder is invalid after seek or at start
* this is the reason for additional validation when we what to close immediately
*/
if (!progressive_playback && 0 == ret && currPts >= maxInjectedPts &&
((currPts - maxInjectedPts) / 90000) < 2)
if (!progressive_playback && 0 == ret && currPts >= maxInjectedPts && ((currPts - maxInjectedPts) / 90000) < 2)
{
/* close immediately
*/

View File

@@ -1261,8 +1261,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int
avContextTab[AVIdx]->interrupt_callback.callback = interrupt_cb;
avContextTab[AVIdx]->interrupt_callback.opaque = context->playback;
#ifdef SAM_CUSTOM_IO
if (0 == strstr(filename, "://") ||
0 == strncmp(filename, "file://", 7))
if (0 == strstr(filename, "://") || 0 == strncmp(filename, "file://", 7))
{
AVIOContext *avio_ctx = container_ffmpeg_get_avio_context(filename, 4096);
if (avio_ctx)
@@ -1334,8 +1333,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int
* unless uri contain param wich can be understandable
* only by librtmp
*/
if (strstr(filename, " token=") ||
strstr(filename, " jtv="))
if (strstr(filename, " token=") || strstr(filename, " jtv="))
{
rtmpProtoImplType = RTMP_LIBRTMP;
}
@@ -1479,8 +1477,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int
}
}
}
else if (0 == strncmp(filename, "http://", 7) ||
0 == strncmp(filename, "https://", 8))
else if (0 == strncmp(filename, "http://", 7) || 0 == strncmp(filename, "https://", 8))
{
av_dict_set(&avio_opts, "timeout", "20000000", 0); //20sec
av_dict_set(&avio_opts, "reconnect", "1", 0);
@@ -1532,8 +1529,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int
if (avContextTab[AVIdx] != NULL && avContextTab[AVIdx]->pb != NULL && !context->playback->isTSLiveMode)
{
ffmpeg_real_read_org = avContextTab[AVIdx]->pb->read_packet;
if (0 == AVIdx && strstr(filename, "://") != 0 &&
strncmp(filename, "file://", 7) != 0)
if (0 == AVIdx && strstr(filename, "://") != 0 && strncmp(filename, "file://", 7) != 0)
{
if (ffmpeg_buf_size > 0 && ffmpeg_buf_size > FILLBUFDIFF + FILLBUFPAKET)
{
@@ -1961,10 +1957,10 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
}
*/
}
else if (get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAV1
|| get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAV2
|| get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAPRO
|| get_codecpar(stream)->codec_id == AV_CODEC_ID_WMALOSSLESS) //if (get_codecpar(stream)->extradata_size > 0)
else if (get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAV1 ||
get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAV2 ||
get_codecpar(stream)->codec_id == AV_CODEC_ID_WMAPRO ||
get_codecpar(stream)->codec_id == AV_CODEC_ID_WMALOSSLESS) //if (get_codecpar(stream)->extradata_size > 0)
{
ffmpeg_printf(10, "Create WMA ExtraData\n");
uint16_t channels = get_codecpar(stream)->channels;

View File

@@ -36,8 +36,7 @@ void avpriv_align_put_bits(PutBitContext *s)
put_bits(s, s->bit_left & 7, 0);
}
void avpriv_put_string(PutBitContext *pb, const char *string,
int terminate_string)
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
{
while (*string)
{

View File

@@ -86,7 +86,6 @@ typedef struct TrackDescription_s
int32_t aspect_ratio_num;
int32_t aspect_ratio_den;
int progressive;
} TrackDescription_t;
typedef struct Manager_s
@@ -94,7 +93,6 @@ typedef struct Manager_s
char *Name;
int (* Command)(/*Context_t*/void *, ManagerCmd_t, void *);
char **Capabilities;
} Manager_t;
typedef struct ManagerHandler_s

View File

@@ -2,6 +2,7 @@
#define OUTPUT_H_
#include <stdio.h>
#include <stdint.h>
typedef enum
{
@@ -69,7 +70,6 @@ typedef struct Output_s
int32_t (* Command)(/*Context_t*/void *, OutputCmd_t, void *);
int32_t (* Write)(/*Context_t*/void *, void *privateData);
char **Capabilities;
} Output_t;
extern Output_t LinuxDvbOutput;

View File

@@ -3,7 +3,28 @@
#include <sys/types.h>
#include <stdint.h>
typedef enum {PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS, PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO, PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION, PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT, PLAYBACK_METADATA} PlaybackCmd_t;
typedef enum {
PLAYBACK_OPEN,
PLAYBACK_CLOSE,
PLAYBACK_PLAY,
PLAYBACK_STOP,
PLAYBACK_PAUSE,
PLAYBACK_CONTINUE,
PLAYBACK_FLUSH,
PLAYBACK_TERM,
PLAYBACK_FASTFORWARD,
PLAYBACK_SEEK,
PLAYBACK_SEEK_ABS,
PLAYBACK_PTS,
PLAYBACK_LENGTH,
PLAYBACK_SWITCH_AUDIO,
PLAYBACK_SWITCH_SUBTITLE,
PLAYBACK_INFO,
PLAYBACK_SLOWMOTION,
PLAYBACK_FASTBACKWARD,
PLAYBACK_GET_FRAME_COUNT,
PLAYBACK_METADATA
} PlaybackCmd_t;
typedef struct PlaybackHandler_s
{

View File

@@ -119,8 +119,7 @@ static void *TermThreadFun(void *arg)
FD_SET(g_pfd[0], &readfds);
FD_SET(fd, &readfds);
nfds = fd > g_pfd[0] ? fd + 1 : g_pfd[0] + 1;
while (select(nfds, &readfds, NULL, NULL, NULL) == -1
&& errno == EINTR)
while (select(nfds, &readfds, NULL, NULL, NULL) == -1 && errno == EINTR)
{
/* Restart if interrupted by signal */
continue;
@@ -475,6 +474,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
return commandRetVal;
}
#endif
static void UpdateVideoTrack()
{
HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, "vc");

View File

@@ -61,8 +61,6 @@ if (debug_level >= level) printf("[%s:%s] \n" fmt, __FILE__, __FUNCTION__, ## x)
#define cERR_AUDIO_MGR_NO_ERROR 0
#define cERR_AUDIO_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
@@ -85,7 +83,7 @@ static int CurrentTrack = 0; //TRACK[0] as default.
static int ManagerAdd(Context_t *context, Track_t track)
{
audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", FILENAME, __FUNCTION__, track.Name, track.Encoding, track.Id);
audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", __FILE__, __FUNCTION__, track.Name, track.Encoding, track.Id);
if (Tracks == NULL)
{
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -97,7 +95,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
}
if (Tracks == NULL)
{
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return cERR_AUDIO_MGR_ERROR;
}
int i = 0;
@@ -116,14 +114,14 @@ static int ManagerAdd(Context_t *context, Track_t track)
}
else
{
audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_AUDIO_MGR_ERROR;
}
if (TrackCount > 0)
{
context->playback->isAudio = 1;
}
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_AUDIO_MGR_NO_ERROR;
}
@@ -131,13 +129,13 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return NULL;
}
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
@@ -146,13 +144,13 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
continue;
size_t len = strlen(Tracks[i].Name) + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name);
snprintf(tmp, len, "%d %s", Tracks[i].Id, Tracks[i].Name);
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup(Tracks[i].Encoding);
}
tracklist[j] = NULL;
}
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
@@ -161,13 +159,13 @@ static TrackDescription_t *ManagerList(Context_t *context __attribute__((unused
{
int i = 0;
TrackDescription_t *tracklist = NULL;
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
tracklist = malloc(sizeof(TrackDescription_t) * ((TrackCount) + 1));
if (tracklist == NULL)
{
audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
audio_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return NULL;
}
int j = 0;
@@ -184,7 +182,7 @@ static TrackDescription_t *ManagerList(Context_t *context __attribute__((unused
}
tracklist[j].Id = -1;
}
//audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
//audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
#endif
@@ -192,7 +190,7 @@ static TrackDescription_t *ManagerList(Context_t *context __attribute__((unused
static int ManagerDel(Context_t *context)
{
int i = 0;
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
for (i = 0; i < TrackCount; i++)
@@ -204,13 +202,13 @@ static int ManagerDel(Context_t *context)
}
else
{
audio_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
audio_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
return cERR_AUDIO_MGR_ERROR;
}
TrackCount = 0;
CurrentTrack = 0;
context->playback->isAudio = 0;
audio_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
return cERR_AUDIO_MGR_NO_ERROR;
}
@@ -218,7 +216,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_AUDIO_MGR_NO_ERROR;
audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
switch (command)
{
case MANAGER_ADD:
@@ -235,7 +233,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
}
case MANAGER_GET:
{
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, __FUNCTION__);
audio_mgr_printf(20, "%s::%s MANAGER_GET\n", __FILE__, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
*((int *)argument) = (int)Tracks[CurrentTrack].Id;
@@ -268,7 +266,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
}
case MANAGER_GET_TRACK:
{
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack];
@@ -306,7 +304,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
case MANAGER_SET:
{
int i;
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, *((int *)argument));
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", __FILE__, __FUNCTION__, *((int *)argument));
for (i = 0; i < TrackCount; i++)
{
if (Tracks[i].Id == *((int *)argument))
@@ -317,7 +315,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
}
if (i == TrackCount)
{
audio_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int *)argument));
audio_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
ret = cERR_AUDIO_MGR_ERROR;
}
break;
@@ -337,11 +335,11 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
break;
}
default:
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", __FILE__, __FUNCTION__, command);
ret = cERR_AUDIO_MGR_ERROR;
break;
}
audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
audio_mgr_printf(10, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret);
return ret;
}

View File

@@ -33,7 +33,6 @@
#define TRACKWRAP 20
//#define SAM_WITH_DEBUG
#ifdef SAM_WITH_DEBUG
#define SUBTITLE_MGR_DEBUG
#else
@@ -60,14 +59,12 @@ if (debug_level >= level) printf(x); } while (0)
#define cERR_SUBTITLE_MGR_NO_ERROR 0
#define cERR_SUBTITLE_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
/* ***************************** */
/* Varaibles */
/* Variables */
/* ***************************** */
static Track_t *Tracks = NULL;
@@ -84,21 +81,21 @@ static int CurrentTrack = -1; //no as default.
static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track)
{
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__,
track.Name, track.Encoding, track.Id);
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", __FILE__, __FUNCTION__, track.Name, track.Encoding, track.Id);
if (Tracks == NULL)
{
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
int i;
for (i = 0; i < TRACKWRAP; i++)
{
Tracks[i].Id = -1;
}
}
if (Tracks == NULL)
{
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR;
}
@@ -119,13 +116,16 @@ static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track
}
else
{
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n",
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_SUBTITLE_MGR_ERROR;
}
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
if (TrackCount > 0)
{
// context->playback->isSubtitle = 1;
}
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_NO_ERROR;
}
@@ -135,7 +135,7 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
char **tracklist = NULL;
int i = 0, j = 0;
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
@@ -143,18 +143,20 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
if (tracklist == NULL)
{
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME,
__FUNCTION__);
subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return NULL;
}
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
{
if (Tracks[i].pending)
{
continue;
}
size_t len = strlen(Tracks[i].Name) + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name);
snprintf(tmp, len, "%d %s", Tracks[i].Id, Tracks[i].Name);
tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup(Tracks[i].Encoding);
}
@@ -162,18 +164,16 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
tracklist[j] = NULL;
}
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME,
__FUNCTION__, tracklist, j, TrackCount);
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t *context __attribute__((unused)))
{
int i = 0;
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
@@ -187,16 +187,15 @@ static int ManagerDel(Context_t * context __attribute__((unused)))
}
else
{
subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME,
__FUNCTION__);
subtitle_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR;
}
TrackCount = 0;
CurrentTrack = -1;
// context->playback->isSubtitle = 0;
subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME,
__FUNCTION__);
subtitle_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_NO_ERROR;
}
@@ -205,8 +204,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{
int ret = cERR_SUBTITLE_MGR_NO_ERROR;
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__,
command);
subtitle_mgr_printf(50, "%s::%s %d\n", __FILE__, __FUNCTION__, command);
switch (command)
{
@@ -225,25 +223,43 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_GET:
{
if (TrackCount > 0 && CurrentTrack >= 0)
{
*((int *)argument) = (int)Tracks[CurrentTrack].Id;
}
else
{
*((int *)argument) = (int) - 1;
}
break;
}
case MANAGER_GET_TRACK_DESC:
{
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
TrackDescription_t *track = malloc(sizeof(TrackDescription_t));
*((TrackDescription_t **)argument) = track;
if (track)
{
memset(track, 0, sizeof(TrackDescription_t));
track->Id = Tracks[CurrentTrack].Id;
track->Name = strdup(Tracks[CurrentTrack].Name);
track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
}
}
else
{
*((TrackDescription_t **)argument) = NULL;
}
break;
}
case MANAGER_GET_TRACK:
{
//subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack,
&Tracks[CurrentTrack]);
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack];
}
else
{
subtitle_mgr_printf(20, "return NULL\n");
*((Track_t **)argument) = NULL;
}
break;
@@ -251,26 +267,31 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_GETENCODING:
{
if (TrackCount > 0 && CurrentTrack >= 0)
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Encoding);
{
*((char **)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
}
else
{
*((char **)argument) = (char *)strdup("");
}
break;
}
case MANAGER_GETNAME:
{
if (TrackCount > 0 && CurrentTrack >= 0)
*((char **) argument) =
(char *) strdup(Tracks[CurrentTrack].Name);
{
*((char **)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
}
else
{
*((char **)argument) = (char *)strdup("");
}
break;
}
case MANAGER_SET:
{
int i;
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME,
__FUNCTION__, *((int *) argument));
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", __FILE__, __FUNCTION__, *((int *)argument));
if (*((int *)argument) < 0)
{
@@ -279,15 +300,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
}
for (i = 0; i < TrackCount; i++)
{
if (Tracks[i].Id == *((int *)argument))
{
CurrentTrack = i;
break;
}
}
if (i == TrackCount)
{
subtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME,
__FUNCTION__, *((int *) argument));
subtitle_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
ret = cERR_SUBTITLE_MGR_ERROR;
}
break;
@@ -301,24 +324,22 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{
int i;
for (i = 0; i < TrackCount; i++)
//if (!Tracks[i].is_static)
{
Tracks[i].pending = 1;
}
break;
}
default:
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME,
__FUNCTION__);
subtitle_mgr_err("%s:%s: ContainerCmd not supported!", __FILE__, __FUNCTION__);
ret = cERR_SUBTITLE_MGR_ERROR;
break;
}
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME,
__FUNCTION__, ret);
subtitle_mgr_printf(50, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret);
return ret;
}
struct Manager_s SubtitleManager =
{
"Subtitle",

View File

@@ -59,8 +59,6 @@ if (debug_level >= level) printf(x); } while (0)
#define cERR_VIDEO_MGR_NO_ERROR 0
#define cERR_VIDEO_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */
/* Types */
/* ***************************** */
@@ -85,7 +83,7 @@ static void (* updatedTrackInfoFnc)(void) = NULL;
static int ManagerAdd(Context_t *context, Track_t track)
{
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks == NULL)
{
Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
@@ -97,7 +95,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
}
if (Tracks == NULL)
{
video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_ERROR;
}
int i;
@@ -116,14 +114,14 @@ static int ManagerAdd(Context_t *context, Track_t track)
}
else
{
video_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
video_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_VIDEO_MGR_ERROR;
}
if (TrackCount > 0)
{
context->playback->isVideo = 1;
}
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_NO_ERROR;
}
@@ -131,13 +129,13 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
{
int i = 0, j = 0;
char **tracklist = NULL;
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
if (tracklist == NULL)
{
video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__);
video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return NULL;
}
for (i = 0, j = 0; i < TrackCount; i++, j += 2)
@@ -154,14 +152,14 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
}
tracklist[j] = NULL;
}
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, __FUNCTION__, tracklist, j, TrackCount);
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist;
}
static int ManagerDel(Context_t *context)
{
int i = 0;
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL)
{
for (i = 0; i < TrackCount; i++)
@@ -173,13 +171,13 @@ static int ManagerDel(Context_t *context)
}
else
{
video_mgr_err("%s::%s nothing to delete!\n", FILENAME, __FUNCTION__);
video_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_ERROR;
}
TrackCount = 0;
CurrentTrack = 0;
context->playback->isVideo = 0;
video_mgr_printf(10, "%s::%s return no error\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_NO_ERROR;
}
@@ -187,7 +185,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_VIDEO_MGR_NO_ERROR;
video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
switch (command)
{
case MANAGER_ADD:
@@ -242,7 +240,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
}
case MANAGER_GET_TRACK:
{
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
*((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack];
@@ -290,7 +288,7 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
}
if (i == TrackCount)
{
video_mgr_err("%s::%s track id %d unknown\n", FILENAME, __FUNCTION__, *((int *)argument));
video_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
ret = cERR_VIDEO_MGR_ERROR;
}
break;
@@ -321,11 +319,11 @@ static int Command(void *_context, ManagerCmd_t command, void *argument)
break;
}
default:
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
video_mgr_err("%s::%s ContainerCmd %d not supported!\n", __FILE__, __FUNCTION__, command);
ret = cERR_VIDEO_MGR_ERROR;
break;
}
video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret);
video_mgr_printf(10, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret);
return ret;
}

View File

@@ -58,7 +58,7 @@
#define LINUXDVB_SILENT
#endif
static short debug_level = 20;
static unsigned short debug_level = 20;
static const char FILENAME[] = __FILE__;

View File

@@ -57,8 +57,6 @@ if (debug_level >= level) fprintf(stderr, x); } while (0)
#define cERR_OUTPUT_NO_ERROR 0
#define cERR_OUTPUT_INTERNAL_ERROR -1
static const char *FILENAME = "output.c";
/* ***************************** */
/* Types */
/* ***************************** */
@@ -85,7 +83,7 @@ static Output_t *AvailableOutput[] =
static void printOutputCapabilities()
{
int i, j;
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
output_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
output_printf(10, "Capabilities:\n");
for (i = 0; AvailableOutput[i] != NULL; i++)
{
@@ -105,7 +103,7 @@ static void printOutputCapabilities()
static void OutputAdd(Context_t *context, char *port)
{
int i, j;
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
output_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
for (i = 0; AvailableOutput[i] != NULL; i++)
{
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
@@ -134,7 +132,7 @@ static void OutputAdd(Context_t *context, char *port)
static void OutputDel(Context_t *context, char *port)
{
output_printf(10, "%s::%s\n", FILENAME, __FUNCTION__);
output_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (!strcmp("audio", port))
{
context->output->audio = NULL;
@@ -153,7 +151,7 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
{
Context_t *context = (Context_t *) _context;
int ret = cERR_OUTPUT_NO_ERROR;
output_printf(10, "%s::%s Command %d\n", FILENAME, __FUNCTION__, command);
output_printf(10, "%s::%s Command %d\n", __FILE__, __FUNCTION__, command);
switch (command)
{
case OUTPUT_OPEN:
@@ -542,11 +540,11 @@ static int Command(void *_context, OutputCmd_t command, void *argument)
}
}
default:
output_err("%s::%s OutputCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
output_err("%s::%s OutputCmd %d not supported!\n", __FILE__, __FUNCTION__, command);
ret = cERR_OUTPUT_INTERNAL_ERROR;
break;
}
output_printf(10, "%s::%s exiting with value %d\n", FILENAME, __FUNCTION__, ret);
output_printf(10, "%s::%s exiting with value %d\n", __FILE__, __FUNCTION__, ret);
return ret;
}

View File

@@ -68,8 +68,6 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#define cERR_SUBTITLE_NO_ERROR 0
#define cERR_SUBTITLE_ERROR -1
static const char FILENAME[] = __FILE__;
/*
Number, Style, Name,, MarginL, MarginR, MarginV, Effect,, Text

View File

@@ -106,6 +106,7 @@ static uint8_t brcm_divx311_sequence_header[] =
/* ***************************** */
/* MISC Functions */
/* ***************************** */
static int reset()
{
initialHeader = 1;

View File

@@ -69,6 +69,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#else
#define h263_err(fmt, x...)
#endif
/* ***************************** */
/* Types */
/* ***************************** */

View File

@@ -266,8 +266,7 @@ static int32_t writeData(void *_call)
iov[1].iov_len = fixed_buffersize;
writev_with_retry(call->fd, iov, 2);
fixed_buffertimestamp += fixed_bufferduration;
int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT |
O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
writev_with_retry(g_fd_dump, iov, 2);
close(g_fd_dump);
}

View File

@@ -100,6 +100,7 @@ static video_codec_data_t videocodecdata = {0, 0};
/* ***************************** */
/* MISC Functions */
/* ***************************** */
static int reset()
{
initialHeader = 1;
@@ -153,8 +154,8 @@ static int writeData(void *_call)
}
}
uint8_t needFrameStartCode = 0;
if (sizeof(Vc1FrameStartCode) >= call->len
|| memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
if (sizeof(Vc1FrameStartCode) >= call->len ||
memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
{
needFrameStartCode = 1;
PacketLength += sizeof(Vc1FrameStartCode);

View File

@@ -98,6 +98,7 @@ static video_codec_data_t videocodecdata = {0, 0};
/* ***************************** */
/* MISC Functions */
/* ***************************** */
static int reset()
{
initialHeader = 1;
@@ -159,8 +160,8 @@ static int writeData(void *_call)
}
}
uint8_t needFrameStartCode = 0;
if (sizeof(Vc1FrameStartCode) >= call->len
|| memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
if (sizeof(Vc1FrameStartCode) >= call->len ||
memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
{
needFrameStartCode = 1;
PacketLength += sizeof(Vc1FrameStartCode);

View File

@@ -99,6 +99,7 @@ static Writer_t *AvailableWriter[] =
/* ***************************** */
/* Functions */
/* ***************************** */
ssize_t write_with_retry(int fd, const void *buf, size_t size)
{
ssize_t ret;

View File

@@ -52,6 +52,7 @@
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#ifdef SAM_WITH_DEBUG
#define H264_DEBUG
#else

View File

@@ -103,7 +103,7 @@ static const unsigned char Metadata[] =
};
/* ***************************** */
/* Varaibles */
/* Variables */
/* ***************************** */
static int initialHeader = 1;

View File

@@ -207,8 +207,7 @@ static int writeData(void *_call)
{
unsigned int PesLength;
unsigned int PrivateHeaderLength;
PrivateHeaderLength = InsertVideoPrivateDataHeader(&PesHeader[HeaderLength],
call->len);
PrivateHeaderLength = InsertVideoPrivateDataHeader(&PesHeader[HeaderLength], call->len);
/* Update PesLength */
PesLength = PesHeader[PES_LENGTH_BYTE_0] +
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;

View File

@@ -175,9 +175,9 @@ static int PlaybackOpen(Context_t *context, PlayFiles_t *pFiles)
return cERR_PLAYBACK_ERROR;
}
pFiles->szFirstFile = context->playback->uri;
if ((context->container->Command(context, CONTAINER_ADD, extension) < 0)
|| (!context->container->selectedContainer)
|| (context->container->selectedContainer->Command(context, CONTAINER_INIT, pFiles) < 0))
if ((context->container->Command(context, CONTAINER_ADD, extension) < 0) ||
(!context->container->selectedContainer) ||
(context->container->selectedContainer->Command(context, CONTAINER_INIT, pFiles) < 0))
{
playback_err("CONTAINER_ADD failed\n");
return cERR_PLAYBACK_ERROR;
@@ -409,6 +409,111 @@ static int32_t PlaybackTerminate(Context_t *context)
return ret;
}
static int PlaybackFastForward(Context_t *context, int *speed)
{
int32_t ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "speed %d\n", *speed);
/* Audio only forwarding not supported */
if (context->playback->isVideo && !context->playback->isHttp && !context->playback->BackWard && (!context->playback->isPaused || context->playback->isPlaying))
{
if ((*speed <= 0) || (*speed > cMaxSpeed_ff))
{
playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff);
return cERR_PLAYBACK_ERROR;
}
context->playback->isForwarding = 1;
context->playback->Speed = *speed;
playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed);
context->output->Command(context, OUTPUT_FASTFORWARD, NULL);
}
else
{
playback_err("fast forward not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
playback_printf(10, "exiting with value %d\n", ret);
return ret;
}
static int PlaybackFastBackward(Context_t *context, int *speed)
{
int32_t ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "speed = %d\n", *speed);
/* Audio only reverse play not supported */
if (context->playback->isVideo && !context->playback->isForwarding &&
(!context->playback->isPaused || context->playback->isPlaying))
{
if ((*speed > 0) || (*speed < cMaxSpeed_fr))
{
playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr);
return cERR_PLAYBACK_ERROR;
}
if (*speed == 0)
{
context->playback->BackWard = 0;
context->playback->Speed = 0; /* reverse end */
}
else
{
context->playback->isSeeking = 1;
context->playback->Speed = *speed;
context->playback->BackWard = 2 ^ (*speed);
playback_printf(1, "S %d B %f\n", context->playback->Speed, context->playback->BackWard);
}
context->output->Command(context, OUTPUT_AUDIOMUTE, "1");
context->output->Command(context, OUTPUT_CLEAR, NULL);
if (context->output->Command(context, OUTPUT_REVERSE, NULL) < 0)
{
playback_err("OUTPUT_REVERSE failed\n");
context->playback->BackWard = 0;
context->playback->Speed = 1;
context->playback->isSeeking = 0;
ret = cERR_PLAYBACK_ERROR;
}
}
else
{
playback_err("fast backward not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
context->playback->isSeeking = 0;
playback_printf(10, "exiting with value %d\n", ret);
return ret;
}
static int32_t PlaybackSlowMotion(Context_t *context, int *speed)
{
int32_t ret = cERR_PLAYBACK_NO_ERROR;
playback_printf(10, "\n");
//Audio only forwarding not supported
if (context->playback->isVideo && !context->playback->isHttp && context->playback->isPlaying)
{
if (context->playback->isPaused)
PlaybackContinue(context);
switch (*speed)
{
case 2:
context->playback->SlowMotion = 2;
break;
case 4:
context->playback->SlowMotion = 4;
break;
case 8:
context->playback->SlowMotion = 8;
break;
}
playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion);
context->output->Command(context, OUTPUT_SLOWMOTION, NULL);
}
else
{
playback_err("slowmotion not possible\n");
ret = cERR_PLAYBACK_ERROR;
}
playback_printf(10, "exiting with value %d\n", ret);
return ret;
}
static int32_t PlaybackSeek(Context_t *context, int64_t *pos, uint8_t absolute)
{
int32_t ret = cERR_PLAYBACK_NO_ERROR;
@@ -678,6 +783,21 @@ static int32_t Command(void *_context, PlaybackCmd_t command, void *argument)
ret = PlaybackInfo(context, (char **)argument);
break;
}
case PLAYBACK_SLOWMOTION:
{
ret = PlaybackSlowMotion(context, (int *)argument);
break;
}
case PLAYBACK_FASTBACKWARD:
{
ret = PlaybackFastBackward(context, (int *)argument);
break;
}
case PLAYBACK_FASTFORWARD:
{
ret = PlaybackFastForward(context, (int *)argument);
break;
}
case PLAYBACK_GET_FRAME_COUNT:
{
ret = PlaybackGetFrameCount(context, (uint64_t *)argument);