mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
- libgeneric: some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -61,11 +61,11 @@ static AVCodecParameters *p = NULL;
|
|||||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100)
|
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100)
|
||||||
static void get_packet_defaults(AVPacket *pkt)
|
static void get_packet_defaults(AVPacket *pkt)
|
||||||
{
|
{
|
||||||
memset(pkt, 0, sizeof(*pkt));
|
memset(pkt, 0, sizeof(*pkt));
|
||||||
|
|
||||||
pkt->pts = AV_NOPTS_VALUE;
|
pkt->pts = AV_NOPTS_VALUE;
|
||||||
pkt->dts = AV_NOPTS_VALUE;
|
pkt->dts = AV_NOPTS_VALUE;
|
||||||
pkt->pos = -1;
|
pkt->pos = -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -160,8 +160,7 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int le)
|
|||||||
hal_debug("%s ch %d srate %d bits %d le %d adevice %p\n", __func__, ch, srate, bits, le, adevice);;
|
hal_debug("%s ch %d srate %d bits %d le %d adevice %p\n", __func__, ch, srate, bits, le, adevice);;
|
||||||
int driver;
|
int driver;
|
||||||
int byte_format = le ? AO_FMT_LITTLE : AO_FMT_BIG;
|
int byte_format = le ? AO_FMT_LITTLE : AO_FMT_BIG;
|
||||||
if (sformat.bits != bits || sformat.channels != ch || sformat.rate != srate ||
|
if (sformat.bits != bits || sformat.channels != ch || sformat.rate != srate || sformat.byte_format != byte_format || adevice == NULL)
|
||||||
sformat.byte_format != byte_format || adevice == NULL)
|
|
||||||
{
|
{
|
||||||
driver = ao_default_driver_id();
|
driver = ao_default_driver_id();
|
||||||
sformat.bits = bits;
|
sformat.bits = bits;
|
||||||
@@ -173,10 +172,8 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int le)
|
|||||||
ao_close(adevice);
|
ao_close(adevice);
|
||||||
adevice = ao_open_live(driver, &sformat, NULL);
|
adevice = ao_open_live(driver, &sformat, NULL);
|
||||||
ao_info *ai = ao_driver_info(driver);
|
ao_info *ai = ao_driver_info(driver);
|
||||||
hal_info("%s: changed params ch %d srate %d bits %d le %d adevice %p\n",
|
hal_info("%s: changed params ch %d srate %d bits %d le %d adevice %p\n", __func__, ch, srate, bits, le, adevice);;
|
||||||
__func__, ch, srate, bits, le, adevice);;
|
hal_info("libao driver: %d name '%s' short '%s' author '%s'\n", driver, ai->name, ai->short_name, ai->author);
|
||||||
hal_info("libao driver: %d name '%s' short '%s' author '%s'\n",
|
|
||||||
driver, ai->name, ai->short_name, ai->author);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
@@ -213,10 +210,10 @@ int cAudio::StopClip()
|
|||||||
void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode)
|
void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode)
|
||||||
{
|
{
|
||||||
type = 0;
|
type = 0;
|
||||||
layer = 0; /* not used */
|
layer = 0; /* not used */
|
||||||
freq = 0;
|
freq = 0;
|
||||||
bitrate = 0; /* not used, but easy to get :-) */
|
bitrate = 0; /* not used, but easy to get :-) */
|
||||||
mode = 0; /* default: stereo */
|
mode = 0; /* default: stereo */
|
||||||
printf("cAudio::getAudioInfo c %p\n", c);
|
printf("cAudio::getAudioInfo c %p\n", c);
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
@@ -256,37 +253,35 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m
|
|||||||
switch (c->channel_layout)
|
switch (c->channel_layout)
|
||||||
{
|
{
|
||||||
case AV_CH_LAYOUT_MONO:
|
case AV_CH_LAYOUT_MONO:
|
||||||
mode = 1; // "C"
|
mode = 1; // "C"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_STEREO:
|
case AV_CH_LAYOUT_STEREO:
|
||||||
mode = 2; // "L/R"
|
mode = 2; // "L/R"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_2_1:
|
case AV_CH_LAYOUT_2_1:
|
||||||
case AV_CH_LAYOUT_SURROUND:
|
case AV_CH_LAYOUT_SURROUND:
|
||||||
mode = 3; // "L/C/R"
|
mode = 3; // "L/C/R"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_2POINT1:
|
case AV_CH_LAYOUT_2POINT1:
|
||||||
mode = 4; // "L/R/S"
|
mode = 4; // "L/R/S"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_3POINT1:
|
case AV_CH_LAYOUT_3POINT1:
|
||||||
mode = 5; // "L/C/R/S"
|
mode = 5; // "L/C/R/S"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_2_2:
|
case AV_CH_LAYOUT_2_2:
|
||||||
case AV_CH_LAYOUT_QUAD:
|
case AV_CH_LAYOUT_QUAD:
|
||||||
mode = 6; // "L/R/SL/SR"
|
mode = 6; // "L/R/SL/SR"
|
||||||
break;
|
break;
|
||||||
case AV_CH_LAYOUT_5POINT0:
|
case AV_CH_LAYOUT_5POINT0:
|
||||||
case AV_CH_LAYOUT_5POINT1:
|
case AV_CH_LAYOUT_5POINT1:
|
||||||
mode = 7; // "L/C/R/SL/SR"
|
mode = 7; // "L/C/R/SL/SR"
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
hal_info("%s: unknown ch_layout 0x%" PRIx64 "\n",
|
hal_info("%s: unknown ch_layout 0x%" PRIx64 "\n", __func__, c->channel_layout);
|
||||||
__func__, c->channel_layout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hal_debug("%s t: %d l: %d f: %d b: %d m: %d codec_id: %x\n",
|
hal_debug("%s t: %d l: %d f: %d b: %d m: %d codec_id: %x\n", __func__, type, layer, freq, bitrate, mode, c ? c->codec_id : -1);
|
||||||
__func__, type, layer, freq, bitrate, mode, c ? c->codec_id : -1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int /*iq_level*/)
|
void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int /*iq_level*/)
|
||||||
@@ -329,7 +324,7 @@ int cAudio::my_read(uint8_t *buf, int buf_size)
|
|||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
if (audioDecoder && bufpos < DMX_BUF_SZ - 4096)
|
if (audioDecoder && bufpos < DMX_BUF_SZ - 4096)
|
||||||
{
|
{
|
||||||
while (bufpos < buf_size && ++tmp < 20) /* retry max 20 times */
|
while (bufpos < buf_size && ++tmp < 20) /* retry max 20 times */
|
||||||
{
|
{
|
||||||
int ret = audioDemux->Read(dmxbuf + bufpos, DMX_BUF_SZ - bufpos, 10);
|
int ret = audioDemux->Read(dmxbuf + bufpos, DMX_BUF_SZ - bufpos, 10);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
@@ -396,11 +391,11 @@ void cAudio::run()
|
|||||||
#endif
|
#endif
|
||||||
inp = av_find_input_format("mpegts");
|
inp = av_find_input_format("mpegts");
|
||||||
AVIOContext *pIOCtx = avio_alloc_context(inbuf, INBUF_SIZE, // internal Buffer and its size
|
AVIOContext *pIOCtx = avio_alloc_context(inbuf, INBUF_SIZE, // internal Buffer and its size
|
||||||
0, // bWriteable (1=true,0=false)
|
0, // bWriteable (1=true,0=false)
|
||||||
NULL, // user data; will be passed to our callback functions
|
NULL, // user data; will be passed to our callback functions
|
||||||
_my_read, // read callback
|
_my_read, // read callback
|
||||||
NULL, // write callback
|
NULL, // write callback
|
||||||
NULL); // seek callback
|
NULL); // seek callback
|
||||||
avfc = avformat_alloc_context();
|
avfc = avformat_alloc_context();
|
||||||
avfc->pb = pIOCtx;
|
avfc->pb = pIOCtx;
|
||||||
avfc->iformat = inp;
|
avfc->iformat = inp;
|
||||||
@@ -450,11 +445,10 @@ void cAudio::run()
|
|||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
/* output sample rate, channels, layout could be set here if necessary */
|
/* output sample rate, channels, layout could be set here if necessary */
|
||||||
o_ch = p->channels; /* 2 */
|
o_ch = p->channels; /* 2 */
|
||||||
o_sr = p->sample_rate; /* 48000 */
|
o_sr = p->sample_rate; /* 48000 */
|
||||||
o_layout = p->channel_layout; /* AV_CH_LAYOUT_STEREO */
|
o_layout = p->channel_layout; /* AV_CH_LAYOUT_STEREO */
|
||||||
if (sformat.channels != o_ch || sformat.rate != o_sr ||
|
if (sformat.channels != o_ch || sformat.rate != o_sr || sformat.byte_format != AO_FMT_NATIVE || sformat.bits != 16 || adevice == NULL)
|
||||||
sformat.byte_format != AO_FMT_NATIVE || sformat.bits != 16 || adevice == NULL)
|
|
||||||
{
|
{
|
||||||
driver = ao_default_driver_id();
|
driver = ao_default_driver_id();
|
||||||
sformat.bits = 16;
|
sformat.bits = 16;
|
||||||
@@ -466,11 +460,9 @@ void cAudio::run()
|
|||||||
ao_close(adevice);
|
ao_close(adevice);
|
||||||
adevice = ao_open_live(driver, &sformat, NULL);
|
adevice = ao_open_live(driver, &sformat, NULL);
|
||||||
ai = ao_driver_info(driver);
|
ai = ao_driver_info(driver);
|
||||||
hal_info("%s: changed params ch %d srate %d bits %d adevice %p\n",
|
hal_info("%s: changed params ch %d srate %d bits %d adevice %p\n", __func__, o_ch, o_sr, 16, adevice);
|
||||||
__func__, o_ch, o_sr, 16, adevice);
|
|
||||||
if (ai)
|
if (ai)
|
||||||
hal_info("libao driver: %d name '%s' short '%s' author '%s'\n",
|
hal_info("libao driver: %d name '%s' short '%s' author '%s'\n", driver, ai->name, ai->short_name, ai->author);
|
||||||
driver, ai->name, ai->short_name, ai->author);
|
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
hal_info(" driver options:");
|
hal_info(" driver options:");
|
||||||
@@ -479,12 +471,11 @@ void cAudio::run()
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
#endif
|
#endif
|
||||||
av_get_sample_fmt_string(tmp, sizeof(tmp), c->sample_fmt);
|
av_get_sample_fmt_string(tmp, sizeof(tmp), c->sample_fmt);
|
||||||
hal_info("decoding %s, sample_fmt %d (%s) sample_rate %d channels %d\n",
|
hal_info("decoding %s, sample_fmt %d (%s) sample_rate %d channels %d\n", avcodec_get_name(p->codec_id), c->sample_fmt, tmp, p->sample_rate, p->channels);
|
||||||
avcodec_get_name(p->codec_id), c->sample_fmt, tmp, p->sample_rate, p->channels);
|
|
||||||
swr = swr_alloc_set_opts(swr,
|
swr = swr_alloc_set_opts(swr,
|
||||||
o_layout, AV_SAMPLE_FMT_S16, o_sr, /* output */
|
o_layout, AV_SAMPLE_FMT_S16, o_sr, /* output */
|
||||||
p->channel_layout, c->sample_fmt, p->sample_rate, /* input */
|
p->channel_layout, c->sample_fmt, p->sample_rate, /* input */
|
||||||
0, NULL);
|
0, NULL);
|
||||||
if (! swr)
|
if (! swr)
|
||||||
{
|
{
|
||||||
hal_info("could not alloc resample context\n");
|
hal_info("could not alloc resample context\n");
|
||||||
@@ -526,8 +517,7 @@ void cAudio::run()
|
|||||||
{
|
{
|
||||||
hal_info("obuf_sz: %d old: %d\n", obuf_sz, obuf_sz_max);
|
hal_info("obuf_sz: %d old: %d\n", obuf_sz, obuf_sz_max);
|
||||||
av_free(obuf);
|
av_free(obuf);
|
||||||
if (av_samples_alloc(&obuf, &out_linesize, o_ch,
|
if (av_samples_alloc(&obuf, &out_linesize, o_ch, frame->nb_samples, AV_SAMPLE_FMT_S16, 1) < 0)
|
||||||
frame->nb_samples, AV_SAMPLE_FMT_S16, 1) < 0)
|
|
||||||
{
|
{
|
||||||
hal_info("av_samples_alloc failed\n");
|
hal_info("av_samples_alloc failed\n");
|
||||||
av_packet_unref(&avpkt);
|
av_packet_unref(&avpkt);
|
||||||
@@ -535,8 +525,7 @@ void cAudio::run()
|
|||||||
}
|
}
|
||||||
obuf_sz_max = obuf_sz;
|
obuf_sz_max = obuf_sz;
|
||||||
}
|
}
|
||||||
obuf_sz = swr_convert(swr, &obuf, obuf_sz,
|
obuf_sz = swr_convert(swr, &obuf, obuf_sz, (const uint8_t **)frame->extended_data, frame->nb_samples);
|
||||||
(const uint8_t **)frame->extended_data, frame->nb_samples);
|
|
||||||
#if (LIBAVUTIL_VERSION_MAJOR < 54)
|
#if (LIBAVUTIL_VERSION_MAJOR < 54)
|
||||||
curr_pts = av_frame_get_best_effort_timestamp(frame);
|
curr_pts = av_frame_get_best_effort_timestamp(frame);
|
||||||
#else
|
#else
|
||||||
|
@@ -42,16 +42,17 @@ typedef enum
|
|||||||
class cAudio : public OpenThreads::Thread
|
class cAudio : public OpenThreads::Thread
|
||||||
{
|
{
|
||||||
friend class cPlayback;
|
friend class cPlayback;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fd;
|
int fd;
|
||||||
bool Muted;
|
bool Muted;
|
||||||
|
|
||||||
int clipfd; /* for pcm playback */
|
int clipfd; /* for pcm playback */
|
||||||
int mixer_fd; /* if we are using the OSS mixer */
|
int mixer_fd; /* if we are using the OSS mixer */
|
||||||
int mixer_num; /* oss mixer to use, if any */
|
int mixer_num; /* oss mixer to use, if any */
|
||||||
|
|
||||||
int StreamType;
|
int StreamType;
|
||||||
AUDIO_SYNC_MODE SyncMode;
|
AUDIO_SYNC_MODE SyncMode;
|
||||||
bool started;
|
bool started;
|
||||||
bool thread_started;
|
bool thread_started;
|
||||||
|
|
||||||
@@ -69,51 +70,27 @@ class cAudio : public OpenThreads::Thread
|
|||||||
/* construct & destruct */
|
/* construct & destruct */
|
||||||
cAudio(void *, void *, void *);
|
cAudio(void *, void *, void *);
|
||||||
~cAudio(void);
|
~cAudio(void);
|
||||||
int64_t getPts()
|
int64_t getPts() { return curr_pts; }
|
||||||
{
|
|
||||||
return curr_pts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *GetHandle()
|
void *GetHandle() { return NULL; };
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
void setAVInput(int /*val*/)
|
void setAVInput(int /*val*/) { return; };
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* shut up */
|
/* shut up */
|
||||||
int mute(bool remember = true)
|
int mute(bool remember = true) { return do_mute(true, remember); };
|
||||||
{
|
int unmute(bool remember = true) { return do_mute(false, remember); };
|
||||||
return do_mute(true, remember);
|
|
||||||
};
|
|
||||||
int unmute(bool remember = true)
|
|
||||||
{
|
|
||||||
return do_mute(false, remember);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* volume, min = 0, max = 255 */
|
/* volume, min = 0, max = 255 */
|
||||||
int setVolume(unsigned int left, unsigned int right);
|
int setVolume(unsigned int left, unsigned int right);
|
||||||
int getVolume(void)
|
int getVolume(void) { return volume; }
|
||||||
{
|
bool getMuteStatus(void) { return Muted; };
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
bool getMuteStatus(void)
|
|
||||||
{
|
|
||||||
return Muted;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* start and stop audio */
|
/* start and stop audio */
|
||||||
int Start(void);
|
int Start(void);
|
||||||
int Stop(void);
|
int Stop(void);
|
||||||
bool Pause(bool Pcm = true);
|
bool Pause(bool Pcm = true);
|
||||||
void SetStreamType(int bypass);
|
void SetStreamType(int bypass);
|
||||||
int GetStreamType(void)
|
int GetStreamType(void) { return StreamType; }
|
||||||
{
|
|
||||||
return StreamType;
|
|
||||||
}
|
|
||||||
void SetSyncMode(AVSYNC_TYPE Mode);
|
void SetSyncMode(AVSYNC_TYPE Mode);
|
||||||
|
|
||||||
/* select channels */
|
/* select channels */
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
TODO: AV-Sync code is "experimental" at best
|
TODO: AV-Sync code is "experimental" at best
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -85,14 +85,14 @@ void GLFramebuffer::blit()
|
|||||||
GLFbPC::GLFbPC(int x, int y, std::vector<unsigned char> &buf): mReInit(true), mShutDown(false), mInitDone(false)
|
GLFbPC::GLFbPC(int x, int y, std::vector<unsigned char> &buf): mReInit(true), mShutDown(false), mInitDone(false)
|
||||||
{
|
{
|
||||||
osd_buf = &buf;
|
osd_buf = &buf;
|
||||||
mState.width = x;
|
mState.width = x;
|
||||||
mState.height = y;
|
mState.height = y;
|
||||||
mX = &_mX[0];
|
mX = &_mX[0];
|
||||||
mY = &_mY[0];
|
mY = &_mY[0];
|
||||||
*mX = x;
|
*mX = x;
|
||||||
*mY = y;
|
*mY = y;
|
||||||
av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX);
|
av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX);
|
||||||
mVA = mOA; /* initial aspect ratios are from the FB resolution, those */
|
mVA = mOA; /* initial aspect ratios are from the FB resolution, those */
|
||||||
_mVA = mVA; /* will be updated by the videoDecoder functions anyway */
|
_mVA = mVA; /* will be updated by the videoDecoder functions anyway */
|
||||||
mVAchanged = true;
|
mVAchanged = true;
|
||||||
mCrop = DISPLAY_AR_MODE_PANSCAN;
|
mCrop = DISPLAY_AR_MODE_PANSCAN;
|
||||||
@@ -142,10 +142,10 @@ void GLFbPC::initKeys()
|
|||||||
mKeyMap[CLUTTER_KEY_Left] = KEY_LEFT;
|
mKeyMap[CLUTTER_KEY_Left] = KEY_LEFT;
|
||||||
mKeyMap[CLUTTER_KEY_Right] = KEY_RIGHT;
|
mKeyMap[CLUTTER_KEY_Right] = KEY_RIGHT;
|
||||||
|
|
||||||
mKeyMap[CLUTTER_KEY_F1] = KEY_RED;
|
mKeyMap[CLUTTER_KEY_F1] = KEY_RED;
|
||||||
mKeyMap[CLUTTER_KEY_F2] = KEY_GREEN;
|
mKeyMap[CLUTTER_KEY_F2] = KEY_GREEN;
|
||||||
mKeyMap[CLUTTER_KEY_F3] = KEY_YELLOW;
|
mKeyMap[CLUTTER_KEY_F3] = KEY_YELLOW;
|
||||||
mKeyMap[CLUTTER_KEY_F4] = KEY_BLUE;
|
mKeyMap[CLUTTER_KEY_F4] = KEY_BLUE;
|
||||||
|
|
||||||
mKeyMap[CLUTTER_KEY_F5] = KEY_RECORD;
|
mKeyMap[CLUTTER_KEY_F5] = KEY_RECORD;
|
||||||
mKeyMap[CLUTTER_KEY_F6] = KEY_PLAY;
|
mKeyMap[CLUTTER_KEY_F6] = KEY_PLAY;
|
||||||
@@ -163,40 +163,40 @@ void GLFbPC::initKeys()
|
|||||||
mKeyMap[CLUTTER_KEY_Return] = KEY_OK;
|
mKeyMap[CLUTTER_KEY_Return] = KEY_OK;
|
||||||
mKeyMap[CLUTTER_KEY_Escape] = KEY_EXIT;
|
mKeyMap[CLUTTER_KEY_Escape] = KEY_EXIT;
|
||||||
|
|
||||||
mKeyMap['0'] = KEY_0;
|
mKeyMap['0'] = KEY_0;
|
||||||
mKeyMap['1'] = KEY_1;
|
mKeyMap['1'] = KEY_1;
|
||||||
mKeyMap['2'] = KEY_2;
|
mKeyMap['2'] = KEY_2;
|
||||||
mKeyMap['3'] = KEY_3;
|
mKeyMap['3'] = KEY_3;
|
||||||
mKeyMap['4'] = KEY_4;
|
mKeyMap['4'] = KEY_4;
|
||||||
mKeyMap['5'] = KEY_5;
|
mKeyMap['5'] = KEY_5;
|
||||||
mKeyMap['6'] = KEY_6;
|
mKeyMap['6'] = KEY_6;
|
||||||
mKeyMap['7'] = KEY_7;
|
mKeyMap['7'] = KEY_7;
|
||||||
mKeyMap['8'] = KEY_8;
|
mKeyMap['8'] = KEY_8;
|
||||||
mKeyMap['9'] = KEY_9;
|
mKeyMap['9'] = KEY_9;
|
||||||
|
|
||||||
mKeyMap['+'] = KEY_VOLUMEUP;
|
mKeyMap['+'] = KEY_VOLUMEUP;
|
||||||
mKeyMap['-'] = KEY_VOLUMEDOWN;
|
mKeyMap['-'] = KEY_VOLUMEDOWN;
|
||||||
mKeyMap['.'] = KEY_MUTE;
|
mKeyMap['.'] = KEY_MUTE;
|
||||||
mKeyMap['a'] = KEY_AUDIO;
|
mKeyMap['a'] = KEY_AUDIO;
|
||||||
mKeyMap['e'] = KEY_EPG;
|
mKeyMap['e'] = KEY_EPG;
|
||||||
// ['f'] is reserved to toggle fullscreen;
|
// ['f'] is reserved to toggle fullscreen;
|
||||||
mKeyMap['g'] = KEY_GAMES;
|
mKeyMap['g'] = KEY_GAMES;
|
||||||
mKeyMap['h'] = KEY_HELP;
|
mKeyMap['h'] = KEY_HELP;
|
||||||
mKeyMap['i'] = KEY_INFO;
|
mKeyMap['i'] = KEY_INFO;
|
||||||
mKeyMap['m'] = KEY_MENU;
|
mKeyMap['m'] = KEY_MENU;
|
||||||
mKeyMap['p'] = KEY_POWER;
|
mKeyMap['p'] = KEY_POWER;
|
||||||
mKeyMap['r'] = KEY_RADIO;
|
mKeyMap['r'] = KEY_RADIO;
|
||||||
mKeyMap['s'] = KEY_SUBTITLE;
|
mKeyMap['s'] = KEY_SUBTITLE;
|
||||||
mKeyMap['t'] = KEY_TV;
|
mKeyMap['t'] = KEY_TV;
|
||||||
mKeyMap['v'] = KEY_VIDEO;
|
mKeyMap['v'] = KEY_VIDEO;
|
||||||
mKeyMap['z'] = KEY_SLEEP;
|
mKeyMap['z'] = KEY_SLEEP;
|
||||||
|
|
||||||
/* shift keys */
|
/* shift keys */
|
||||||
mKeyMap['F'] = KEY_FAVORITES;
|
mKeyMap['F'] = KEY_FAVORITES;
|
||||||
mKeyMap['M'] = KEY_MODE;
|
mKeyMap['M'] = KEY_MODE;
|
||||||
mKeyMap['S'] = KEY_SAT;
|
mKeyMap['S'] = KEY_SAT;
|
||||||
mKeyMap['T'] = KEY_TEXT;
|
mKeyMap['T'] = KEY_TEXT;
|
||||||
mKeyMap['W'] = KEY_WWW;
|
mKeyMap['W'] = KEY_WWW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterActor *stage = NULL;
|
static ClutterActor *stage = NULL;
|
||||||
@@ -311,9 +311,9 @@ void GLFramebuffer::run()
|
|||||||
std::map<int, int>::const_iterator i = glfb_priv->mKeyMap.find(key);
|
std::map<int, int>::const_iterator i = glfb_priv->mKeyMap.find(key);
|
||||||
if (i == glfb_priv->mKeyMap.end())
|
if (i == glfb_priv->mKeyMap.end())
|
||||||
return true;
|
return true;
|
||||||
ev.code = i->second;
|
ev.code = i->second;
|
||||||
ev.value = keystate; /* key own */
|
ev.value = keystate; /* key own */
|
||||||
ev.type = EV_KEY;
|
ev.type = EV_KEY;
|
||||||
gettimeofday(&ev.time, NULL);
|
gettimeofday(&ev.time, NULL);
|
||||||
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
||||||
ssize_t w = write(glfb_priv->input_fd, &ev, sizeof(ev));
|
ssize_t w = write(glfb_priv->input_fd, &ev, sizeof(ev));
|
||||||
@@ -353,8 +353,7 @@ void GLFbPC::render()
|
|||||||
// *mX = *mY * mOA.num / mOA.den;
|
// *mX = *mY * mOA.num / mOA.den;
|
||||||
clutter_actor_set_size(stage, *mX, *mY);
|
clutter_actor_set_size(stage, *mX, *mY);
|
||||||
}
|
}
|
||||||
hal_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n",
|
hal_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n", __func__, *mX, *mY, xoff, yoff, mFullscreen);
|
||||||
__func__, *mX, *mY, xoff, yoff, mFullscreen);
|
|
||||||
}
|
}
|
||||||
mReInitLock.unlock();
|
mReInitLock.unlock();
|
||||||
|
|
||||||
@@ -378,11 +377,11 @@ void GLFbPC::render()
|
|||||||
switch (cmp)
|
switch (cmp)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case INT_MIN: /* invalid */
|
case INT_MIN: /* invalid */
|
||||||
case 0: /* identical */
|
case 0: /* identical */
|
||||||
hal_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__);
|
hal_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__);
|
||||||
break;
|
break;
|
||||||
case 1: /* mVA > mOA -- video is wider than display */
|
case 1: /* mVA > mOA -- video is wider than display */
|
||||||
hal_debug("%s: mVA > mOA\n", __func__);
|
hal_debug("%s: mVA > mOA\n", __func__);
|
||||||
switch (mCrop)
|
switch (mCrop)
|
||||||
{
|
{
|
||||||
@@ -402,7 +401,7 @@ void GLFbPC::render()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -1: /* mVA < mOA -- video is taller than display */
|
case -1: /* mVA < mOA -- video is taller than display */
|
||||||
hal_debug("%s: mVA < mOA\n", __func__);
|
hal_debug("%s: mVA < mOA\n", __func__);
|
||||||
switch (mCrop)
|
switch (mCrop)
|
||||||
{
|
{
|
||||||
@@ -518,5 +517,5 @@ void GLFbPC::bltDisplayBuffer()
|
|||||||
sleep_us = 1;
|
sleep_us = 1;
|
||||||
}
|
}
|
||||||
hal_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n",
|
hal_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n",
|
||||||
buf->pts(), apts, (buf->pts() - apts) / 90000.0, sleep_us, videoDecoder->buf_num);
|
buf->pts(), apts, (buf->pts() - apts) / 90000.0, sleep_us, videoDecoder->buf_num);
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ extern cVideo *videoDecoder;
|
|||||||
|
|
||||||
#define dmx_err(_errfmt, _errstr, _revents) do { \
|
#define dmx_err(_errfmt, _errstr, _revents) do { \
|
||||||
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
||||||
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
cDemux *videoDemux = NULL;
|
cDemux *videoDemux = NULL;
|
||||||
@@ -113,13 +113,13 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
|
|||||||
hal_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
hal_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hal_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
|
hal_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n",
|
||||||
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
__func__, num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
||||||
|
|
||||||
if (dmx_type == DMX_VIDEO_CHANNEL)
|
if (dmx_type == DMX_VIDEO_CHANNEL)
|
||||||
uBufferSize = 0x100000; /* 1MB */
|
uBufferSize = 0x100000; /* 1MB */
|
||||||
if (dmx_type == DMX_AUDIO_CHANNEL)
|
if (dmx_type == DMX_AUDIO_CHANNEL)
|
||||||
uBufferSize = 0x10000; /* 64k */
|
uBufferSize = 0x10000; /* 64k */
|
||||||
#if 0
|
#if 0
|
||||||
if (!pesfds.empty())
|
if (!pesfds.empty())
|
||||||
{
|
{
|
||||||
@@ -193,7 +193,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
|||||||
#if 0
|
#if 0
|
||||||
if (len != 4095 && timeout != 100)
|
if (len != 4095 && timeout != 100)
|
||||||
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
|
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
|
||||||
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
||||||
#endif
|
#endif
|
||||||
int rc;
|
int rc;
|
||||||
struct pollfd ufds;
|
struct pollfd ufds;
|
||||||
@@ -253,8 +253,8 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
|
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
|
||||||
const unsigned char *const mask, int len, int timeout,
|
const unsigned char *const mask, int len, int timeout,
|
||||||
const unsigned char *const negmask)
|
const unsigned char *const negmask)
|
||||||
{
|
{
|
||||||
struct dmx_sct_filter_params s_flt;
|
struct dmx_sct_filter_params s_flt;
|
||||||
memset(&s_flt, 0, sizeof(s_flt));
|
memset(&s_flt, 0, sizeof(s_flt));
|
||||||
@@ -269,7 +269,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
s_flt.timeout = timeout;
|
s_flt.timeout = timeout;
|
||||||
flt = filter[0];
|
flt = filter[0];
|
||||||
memcpy(s_flt.filter.filter, filter, len);
|
memcpy(s_flt.filter.filter, filter, len);
|
||||||
memcpy(s_flt.filter.mask, mask, len);
|
memcpy(s_flt.filter.mask, mask, len);
|
||||||
if (negmask != NULL)
|
if (negmask != NULL)
|
||||||
memcpy(s_flt.filter.mode, negmask, len);
|
memcpy(s_flt.filter.mode, negmask, len);
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
|
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
|
||||||
case 0x70: /* time_date_section */
|
case 0x70: /* time_date_section */
|
||||||
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
|
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
|
||||||
//s_flt.pid = 0x0014;
|
//s_flt.pid = 0x0014;
|
||||||
to = 30000;
|
to = 30000;
|
||||||
break;
|
break;
|
||||||
case 0x71: /* running_status_section */
|
case 0x71: /* running_status_section */
|
||||||
@@ -331,7 +331,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
to = 0;
|
to = 0;
|
||||||
break;
|
break;
|
||||||
case 0x73: /* time_offset_section */
|
case 0x73: /* time_offset_section */
|
||||||
//s_flt.pid = 0x0014;
|
//s_flt.pid = 0x0014;
|
||||||
to = 30000;
|
to = 30000;
|
||||||
break;
|
break;
|
||||||
case 0x74: /* application_information_section */
|
case 0x74: /* application_information_section */
|
||||||
@@ -359,8 +359,8 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
if (timeout == 0 && negmask == NULL)
|
if (timeout == 0 && negmask == NULL)
|
||||||
s_flt.timeout = to;
|
s_flt.timeout = to;
|
||||||
|
|
||||||
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n", __func__, num,
|
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n",
|
||||||
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
__func__, num, pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
||||||
|
|
||||||
if (debuglevel == 2)
|
if (debuglevel == 2)
|
||||||
{
|
{
|
||||||
@@ -368,10 +368,10 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "mask: ");
|
fprintf(stderr, "mask: ");
|
||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mask[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "mode: ");
|
fprintf(stderr, "mode: ");
|
||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mode[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
|||||||
* this check originally is from tuxbox cvs but I'm not sure
|
* this check originally is from tuxbox cvs but I'm not sure
|
||||||
* what it is good for...
|
* what it is good for...
|
||||||
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
|
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
|
||||||
return false;
|
return false;
|
||||||
*/
|
*/
|
||||||
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
|
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
|
||||||
return false;
|
return false;
|
||||||
@@ -401,7 +401,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
|||||||
memset(&p_flt, 0, sizeof(p_flt));
|
memset(&p_flt, 0, sizeof(p_flt));
|
||||||
p_flt.pid = pid;
|
p_flt.pid = pid;
|
||||||
p_flt.output = DMX_OUT_DECODER;
|
p_flt.output = DMX_OUT_DECODER;
|
||||||
p_flt.input = DMX_IN_FRONTEND;
|
p_flt.input = DMX_IN_FRONTEND;
|
||||||
|
|
||||||
switch (dmx_type)
|
switch (dmx_type)
|
||||||
{
|
{
|
||||||
@@ -412,23 +412,23 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
|||||||
break;
|
break;
|
||||||
case DMX_AUDIO_CHANNEL:
|
case DMX_AUDIO_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
if (HAL_nodec) /* no need to demux if we don't decode... */
|
if (HAL_nodec) /* no need to demux if we don't decode... */
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case DMX_VIDEO_CHANNEL:
|
case DMX_VIDEO_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
if (HAL_nodec)
|
if (HAL_nodec)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case DMX_PES_CHANNEL:
|
case DMX_PES_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TAP;
|
p_flt.output = DMX_OUT_TAP;
|
||||||
break;
|
break;
|
||||||
case DMX_TP_CHANNEL:
|
case DMX_TP_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
|
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
based on Carjay's neutrino-hd-dvbapi work, see
|
based on Carjay's neutrino-hd-dvbapi work, see
|
||||||
http://gitorious.org/neutrino-hd/neutrino-hd-dvbapi
|
http://gitorious.org/neutrino-hd/neutrino-hd-dvbapi
|
||||||
|
|
||||||
TODO: AV-Sync code is "experimental" at best
|
TODO: AV-Sync code is "experimental" at best
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -83,14 +83,14 @@ void GLFramebuffer::blit()
|
|||||||
GLFbPC::GLFbPC(int x, int y, std::vector<unsigned char> &buf): mReInit(true), mShutDown(false), mInitDone(false)
|
GLFbPC::GLFbPC(int x, int y, std::vector<unsigned char> &buf): mReInit(true), mShutDown(false), mInitDone(false)
|
||||||
{
|
{
|
||||||
osd_buf = &buf;
|
osd_buf = &buf;
|
||||||
mState.width = x;
|
mState.width = x;
|
||||||
mState.height = y;
|
mState.height = y;
|
||||||
mX = &_mX[0];
|
mX = &_mX[0];
|
||||||
mY = &_mY[0];
|
mY = &_mY[0];
|
||||||
*mX = x;
|
*mX = x;
|
||||||
*mY = y;
|
*mY = y;
|
||||||
av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX);
|
av_reduce(&mOA.num, &mOA.den, x, y, INT_MAX);
|
||||||
mVA = mOA; /* initial aspect ratios are from the FB resolution, those */
|
mVA = mOA; /* initial aspect ratios are from the FB resolution, those */
|
||||||
_mVA = mVA; /* will be updated by the videoDecoder functions anyway */
|
_mVA = mVA; /* will be updated by the videoDecoder functions anyway */
|
||||||
mVAchanged = true;
|
mVAchanged = true;
|
||||||
mCrop = DISPLAY_AR_MODE_PANSCAN;
|
mCrop = DISPLAY_AR_MODE_PANSCAN;
|
||||||
@@ -165,40 +165,40 @@ void GLFbPC::initKeys()
|
|||||||
mKeyMap[0x0d] = KEY_OK;
|
mKeyMap[0x0d] = KEY_OK;
|
||||||
mKeyMap[0x1b] = KEY_EXIT;
|
mKeyMap[0x1b] = KEY_EXIT;
|
||||||
|
|
||||||
mKeyMap['0'] = KEY_0;
|
mKeyMap['0'] = KEY_0;
|
||||||
mKeyMap['1'] = KEY_1;
|
mKeyMap['1'] = KEY_1;
|
||||||
mKeyMap['2'] = KEY_2;
|
mKeyMap['2'] = KEY_2;
|
||||||
mKeyMap['3'] = KEY_3;
|
mKeyMap['3'] = KEY_3;
|
||||||
mKeyMap['4'] = KEY_4;
|
mKeyMap['4'] = KEY_4;
|
||||||
mKeyMap['5'] = KEY_5;
|
mKeyMap['5'] = KEY_5;
|
||||||
mKeyMap['6'] = KEY_6;
|
mKeyMap['6'] = KEY_6;
|
||||||
mKeyMap['7'] = KEY_7;
|
mKeyMap['7'] = KEY_7;
|
||||||
mKeyMap['8'] = KEY_8;
|
mKeyMap['8'] = KEY_8;
|
||||||
mKeyMap['9'] = KEY_9;
|
mKeyMap['9'] = KEY_9;
|
||||||
|
|
||||||
mKeyMap['+'] = KEY_VOLUMEUP;
|
mKeyMap['+'] = KEY_VOLUMEUP;
|
||||||
mKeyMap['-'] = KEY_VOLUMEDOWN;
|
mKeyMap['-'] = KEY_VOLUMEDOWN;
|
||||||
mKeyMap['.'] = KEY_MUTE;
|
mKeyMap['.'] = KEY_MUTE;
|
||||||
mKeyMap['a'] = KEY_AUDIO;
|
mKeyMap['a'] = KEY_AUDIO;
|
||||||
mKeyMap['e'] = KEY_EPG;
|
mKeyMap['e'] = KEY_EPG;
|
||||||
// ['f'] is reserved to toggle fullscreen;
|
// ['f'] is reserved to toggle fullscreen;
|
||||||
mKeyMap['g'] = KEY_GAMES;
|
mKeyMap['g'] = KEY_GAMES;
|
||||||
mKeyMap['h'] = KEY_HELP;
|
mKeyMap['h'] = KEY_HELP;
|
||||||
mKeyMap['i'] = KEY_INFO;
|
mKeyMap['i'] = KEY_INFO;
|
||||||
mKeyMap['m'] = KEY_MENU;
|
mKeyMap['m'] = KEY_MENU;
|
||||||
mKeyMap['p'] = KEY_POWER;
|
mKeyMap['p'] = KEY_POWER;
|
||||||
mKeyMap['r'] = KEY_RADIO;
|
mKeyMap['r'] = KEY_RADIO;
|
||||||
mKeyMap['s'] = KEY_SUBTITLE;
|
mKeyMap['s'] = KEY_SUBTITLE;
|
||||||
mKeyMap['t'] = KEY_TV;
|
mKeyMap['t'] = KEY_TV;
|
||||||
mKeyMap['v'] = KEY_VIDEO;
|
mKeyMap['v'] = KEY_VIDEO;
|
||||||
mKeyMap['z'] = KEY_SLEEP;
|
mKeyMap['z'] = KEY_SLEEP;
|
||||||
|
|
||||||
/* shift keys */
|
/* shift keys */
|
||||||
mKeyMap['F'] = KEY_FAVORITES;
|
mKeyMap['F'] = KEY_FAVORITES;
|
||||||
mKeyMap['M'] = KEY_MODE;
|
mKeyMap['M'] = KEY_MODE;
|
||||||
mKeyMap['S'] = KEY_SAT;
|
mKeyMap['S'] = KEY_SAT;
|
||||||
mKeyMap['T'] = KEY_TEXT;
|
mKeyMap['T'] = KEY_TEXT;
|
||||||
mKeyMap['W'] = KEY_WWW;
|
mKeyMap['W'] = KEY_WWW;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLFramebuffer::run()
|
void GLFramebuffer::run()
|
||||||
@@ -226,7 +226,7 @@ void GLFramebuffer::run()
|
|||||||
if ((!GLEW_VERSION_1_5) || (!GLEW_EXT_pixel_buffer_object) || (!GLEW_ARB_texture_non_power_of_two))
|
if ((!GLEW_VERSION_1_5) || (!GLEW_EXT_pixel_buffer_object) || (!GLEW_ARB_texture_non_power_of_two))
|
||||||
{
|
{
|
||||||
hal_info("GLFB: Sorry, your graphics card is not supported. "
|
hal_info("GLFB: Sorry, your graphics card is not supported. "
|
||||||
"Needs at least OpenGL 1.5, pixel buffer objects and NPOT textures.\n");
|
"Needs at least OpenGL 1.5, pixel buffer objects and NPOT textures.\n");
|
||||||
hal_info("incompatible graphics card: %m");
|
hal_info("incompatible graphics card: %m");
|
||||||
_exit(1); /* Life is hard */
|
_exit(1); /* Life is hard */
|
||||||
}
|
}
|
||||||
@@ -334,9 +334,9 @@ void GLFbPC::releaseGLObjects()
|
|||||||
std::map<unsigned char, int>::const_iterator i = glfb_priv->mKeyMap.find(key);
|
std::map<unsigned char, int>::const_iterator i = glfb_priv->mKeyMap.find(key);
|
||||||
if (i == glfb_priv->mKeyMap.end())
|
if (i == glfb_priv->mKeyMap.end())
|
||||||
return;
|
return;
|
||||||
ev.code = i->second;
|
ev.code = i->second;
|
||||||
ev.value = 1; /* key own */
|
ev.value = 1; /* key own */
|
||||||
ev.type = EV_KEY;
|
ev.type = EV_KEY;
|
||||||
gettimeofday(&ev.time, NULL);
|
gettimeofday(&ev.time, NULL);
|
||||||
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
||||||
write(glfb_priv->input_fd, &ev, sizeof(ev));
|
write(glfb_priv->input_fd, &ev, sizeof(ev));
|
||||||
@@ -351,9 +351,9 @@ void GLFbPC::releaseGLObjects()
|
|||||||
std::map<int, int>::const_iterator i = glfb_priv->mSpecialMap.find(key);
|
std::map<int, int>::const_iterator i = glfb_priv->mSpecialMap.find(key);
|
||||||
if (i == glfb_priv->mSpecialMap.end())
|
if (i == glfb_priv->mSpecialMap.end())
|
||||||
return;
|
return;
|
||||||
ev.code = i->second;
|
ev.code = i->second;
|
||||||
ev.value = 1;
|
ev.value = 1;
|
||||||
ev.type = EV_KEY;
|
ev.type = EV_KEY;
|
||||||
gettimeofday(&ev.time, NULL);
|
gettimeofday(&ev.time, NULL);
|
||||||
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
hal_debug_c("GLFB::%s: pushing 0x%x\n", __func__, ev.code);
|
||||||
write(glfb_priv->input_fd, &ev, sizeof(ev));
|
write(glfb_priv->input_fd, &ev, sizeof(ev));
|
||||||
@@ -394,8 +394,7 @@ void GLFbPC::render()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
*mX = *mY * mOA.num / mOA.den;
|
*mX = *mY * mOA.num / mOA.den;
|
||||||
hal_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n",
|
hal_info("%s: reinit mX:%d mY:%d xoff:%d yoff:%d fs %d\n", __func__, *mX, *mY, xoff, yoff, mFullscreen);
|
||||||
__func__, *mX, *mY, xoff, yoff, mFullscreen);
|
|
||||||
glViewport(xoff, yoff, *mX, *mY);
|
glViewport(xoff, yoff, *mX, *mY);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -438,11 +437,11 @@ void GLFbPC::render()
|
|||||||
switch (cmp)
|
switch (cmp)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case INT_MIN: /* invalid */
|
case INT_MIN: /* invalid */
|
||||||
case 0: /* identical */
|
case 0: /* identical */
|
||||||
hal_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__);
|
hal_debug("%s: mVA == mOA (or fullscreen mode :-)\n", __func__);
|
||||||
break;
|
break;
|
||||||
case 1: /* mVA > mOA -- video is wider than display */
|
case 1: /* mVA > mOA -- video is wider than display */
|
||||||
hal_debug("%s: mVA > mOA\n", __func__);
|
hal_debug("%s: mVA > mOA\n", __func__);
|
||||||
xscale = av_q2d(mVA) / av_q2d(mOA);
|
xscale = av_q2d(mVA) / av_q2d(mOA);
|
||||||
switch (mCrop)
|
switch (mCrop)
|
||||||
@@ -459,7 +458,7 @@ void GLFbPC::render()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -1: /* mVA < mOA -- video is taller than display */
|
case -1: /* mVA < mOA -- video is taller than display */
|
||||||
hal_debug("%s: mVA < mOA\n", __func__);
|
hal_debug("%s: mVA < mOA\n", __func__);
|
||||||
xscale = av_q2d(mVA) / av_q2d(mOA);
|
xscale = av_q2d(mVA) / av_q2d(mOA);
|
||||||
switch (mCrop)
|
switch (mCrop)
|
||||||
@@ -531,10 +530,10 @@ void GLFbPC::drawSquare(float size, float x_factor)
|
|||||||
{
|
{
|
||||||
GLfloat vertices[] =
|
GLfloat vertices[] =
|
||||||
{
|
{
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
-1.0f, -1.0f,
|
-1.0f, -1.0f,
|
||||||
1.0f, -1.0f,
|
1.0f, -1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
GLubyte indices[] = { 0, 1, 2, 3 };
|
GLubyte indices[] = { 0, 1, 2, 3 };
|
||||||
@@ -546,11 +545,11 @@ void GLFbPC::drawSquare(float size, float x_factor)
|
|||||||
0.0, 1.0,
|
0.0, 1.0,
|
||||||
1.0, 1.0,
|
1.0, 1.0,
|
||||||
};
|
};
|
||||||
if (x_factor > -99.0) /* x_factor == -100 => OSD */
|
if (x_factor > -99.0) /* x_factor == -100 => OSD */
|
||||||
{
|
{
|
||||||
if (videoDecoder &&
|
if (videoDecoder &&
|
||||||
videoDecoder->pig_x > 0 && videoDecoder->pig_y > 0 &&
|
videoDecoder->pig_x > 0 && videoDecoder->pig_y > 0 &&
|
||||||
videoDecoder->pig_w > 0 && videoDecoder->pig_h > 0)
|
videoDecoder->pig_w > 0 && videoDecoder->pig_h > 0)
|
||||||
{
|
{
|
||||||
/* these calculations even consider cropping and panscan mode
|
/* these calculations even consider cropping and panscan mode
|
||||||
* maybe this could be done with some clever opengl tricks? */
|
* maybe this could be done with some clever opengl tricks? */
|
||||||
@@ -562,14 +561,14 @@ void GLFbPC::drawSquare(float size, float x_factor)
|
|||||||
double h = (double)videoDecoder->pig_h / h2;
|
double h = (double)videoDecoder->pig_h / h2;
|
||||||
x += ((1.0l - x_factor * size) / 2.0l) * w / x_factor / size;
|
x += ((1.0l - x_factor * size) / 2.0l) * w / x_factor / size;
|
||||||
y += ((size - 1.0l) / 2.0l) * h / size;
|
y += ((size - 1.0l) / 2.0l) * h / size;
|
||||||
vertices[0] = x + w; /* top right x */
|
vertices[0] = x + w; /* top right x */
|
||||||
vertices[1] = y; /* top right y */
|
vertices[1] = y; /* top right y */
|
||||||
vertices[2] = x; /* top left x */
|
vertices[2] = x; /* top left x */
|
||||||
vertices[3] = y; /* top left y */
|
vertices[3] = y; /* top left y */
|
||||||
vertices[4] = x; /* bottom left x */
|
vertices[4] = x; /* bottom left x */
|
||||||
vertices[5] = y - h; /* bottom left y */
|
vertices[5] = y - h; /* bottom left y */
|
||||||
vertices[6] = vertices[0]; /* bottom right x */
|
vertices[6] = vertices[0]; /* bottom right x */
|
||||||
vertices[7] = vertices[5]; /* bottom right y */
|
vertices[7] = vertices[5]; /* bottom right y */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -590,7 +589,7 @@ void GLFbPC::drawSquare(float size, float x_factor)
|
|||||||
|
|
||||||
void GLFbPC::bltOSDBuffer()
|
void GLFbPC::bltOSDBuffer()
|
||||||
{
|
{
|
||||||
/* FIXME: copy each time */
|
/* FIXME: copy each time */
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mState.pbo);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mState.pbo);
|
||||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, osd_buf->size(), osd_buf->data(), GL_STREAM_DRAW_ARB);
|
glBufferData(GL_PIXEL_UNPACK_BUFFER, osd_buf->size(), osd_buf->data(), GL_STREAM_DRAW_ARB);
|
||||||
|
|
||||||
@@ -662,5 +661,5 @@ void GLFbPC::bltDisplayBuffer()
|
|||||||
sleep_us = 1;
|
sleep_us = 1;
|
||||||
}
|
}
|
||||||
hal_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n",
|
hal_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n",
|
||||||
buf->pts(), apts, (buf->pts() - apts) / 90000.0, sleep_us, videoDecoder->buf_num);
|
buf->pts(), apts, (buf->pts() - apts) / 90000.0, sleep_us, videoDecoder->buf_num);
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ class GLFbPC
|
|||||||
~GLFbPC();
|
~GLFbPC();
|
||||||
std::vector<unsigned char> *getOSDBuffer()
|
std::vector<unsigned char> *getOSDBuffer()
|
||||||
{
|
{
|
||||||
return osd_buf; /* pointer to OSD bounce buffer */
|
return osd_buf; /* pointer to OSD bounce buffer */
|
||||||
}
|
}
|
||||||
int getOSDWidth()
|
int getOSDWidth()
|
||||||
{
|
{
|
||||||
@@ -77,23 +77,23 @@ class GLFbPC
|
|||||||
fb_var_screeninfo si;
|
fb_var_screeninfo si;
|
||||||
int *mX;
|
int *mX;
|
||||||
int *mY;
|
int *mY;
|
||||||
int _mX[2]; /* output window size */
|
int _mX[2]; /* output window size */
|
||||||
int _mY[2]; /* [0] = normal, [1] = fullscreen */
|
int _mY[2]; /* [0] = normal, [1] = fullscreen */
|
||||||
AVRational mOA; /* output window aspect ratio */
|
AVRational mOA; /* output window aspect ratio */
|
||||||
AVRational mVA; /* video aspect ratio */
|
AVRational mVA; /* video aspect ratio */
|
||||||
AVRational _mVA; /* for detecting changes in mVA */
|
AVRational _mVA; /* for detecting changes in mVA */
|
||||||
bool mVAchanged;
|
bool mVAchanged;
|
||||||
float zoom; /* for cropping */
|
float zoom; /* for cropping */
|
||||||
float xscale; /* and aspect ratio */
|
float xscale; /* and aspect ratio */
|
||||||
int mCrop; /* DISPLAY_AR_MODE */
|
int mCrop; /* DISPLAY_AR_MODE */
|
||||||
|
|
||||||
bool mFullscreen; /* fullscreen? */
|
bool mFullscreen; /* fullscreen? */
|
||||||
bool mReInit; /* setup things for GL */
|
bool mReInit; /* setup things for GL */
|
||||||
OpenThreads::Mutex mReInitLock;
|
OpenThreads::Mutex mReInitLock;
|
||||||
bool mShutDown; /* if set main loop is left */
|
bool mShutDown; /* if set main loop is left */
|
||||||
bool mInitDone; /* condition predicate */
|
bool mInitDone; /* condition predicate */
|
||||||
// OpenThreads::Condition mInitCond; /* condition variable for init */
|
// OpenThreads::Condition mInitCond; /* condition variable for init */
|
||||||
// mutable OpenThreads::Mutex mMutex; /* lock our data */
|
// mutable OpenThreads::Mutex mMutex; /* lock our data */
|
||||||
|
|
||||||
std::vector<unsigned char> *osd_buf; /* silly bounce buffer */
|
std::vector<unsigned char> *osd_buf; /* silly bounce buffer */
|
||||||
|
|
||||||
@@ -108,36 +108,36 @@ class GLFbPC
|
|||||||
int64_t last_apts;
|
int64_t last_apts;
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
static void rendercb(); /* callback for GLUT */
|
static void rendercb(); /* callback for GLUT */
|
||||||
void render(); /* actual render function */
|
void render(); /* actual render function */
|
||||||
#if USE_OPENGL
|
#if USE_OPENGL
|
||||||
static void keyboardcb(unsigned char key, int x, int y);
|
static void keyboardcb(unsigned char key, int x, int y);
|
||||||
static void specialcb(int key, int x, int y);
|
static void specialcb(int key, int x, int y);
|
||||||
static void resizecb(int w, int h);
|
static void resizecb(int w, int h);
|
||||||
void checkReinit(int w, int h); /* e.g. in case window was resized */
|
void checkReinit(int w, int h); /* e.g. in case window was resized */
|
||||||
void setupGLObjects(); /* PBOs, textures and stuff */
|
void setupGLObjects(); /* PBOs, textures and stuff */
|
||||||
void releaseGLObjects();
|
void releaseGLObjects();
|
||||||
void drawSquare(float size, float x_factor = 1); /* do not be square */
|
void drawSquare(float size, float x_factor = 1); /* do not be square */
|
||||||
#endif
|
#endif
|
||||||
#if USE_CLUTTER
|
#if USE_CLUTTER
|
||||||
static bool keyboardcb(ClutterActor *actor, ClutterEvent *event, gpointer user_data);
|
static bool keyboardcb(ClutterActor *actor, ClutterEvent *event, gpointer user_data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initKeys(); /* setup key bindings for window */
|
void initKeys(); /* setup key bindings for window */
|
||||||
#if 0
|
#if 0
|
||||||
void setupCtx(); /* create the window and make the context current */
|
void setupCtx(); /* create the window and make the context current */
|
||||||
void setupOSDBuffer(); /* create the OSD buffer */
|
void setupOSDBuffer(); /* create the OSD buffer */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int width; /* width and height, fixed for a framebuffer instance */
|
int width; /* width and height, fixed for a framebuffer instance */
|
||||||
int height;
|
int height;
|
||||||
bool blit;
|
bool blit;
|
||||||
#if USE_OPENGL
|
#if USE_OPENGL
|
||||||
GLuint osdtex; /* holds the OSD texture */
|
GLuint osdtex; /* holds the OSD texture */
|
||||||
GLuint pbo; /* PBO we use for transfer to texture */
|
GLuint pbo; /* PBO we use for transfer to texture */
|
||||||
GLuint displaytex; /* holds the display texture */
|
GLuint displaytex; /* holds the display texture */
|
||||||
GLuint displaypbo;
|
GLuint displaypbo;
|
||||||
#endif
|
#endif
|
||||||
} mState;
|
} mState;
|
||||||
|
@@ -31,7 +31,7 @@ hw_caps_t *get_hwcaps(void)
|
|||||||
caps.can_pip = 1;
|
caps.can_pip = 1;
|
||||||
|
|
||||||
caps.can_cpufreq = 0;
|
caps.can_cpufreq = 0;
|
||||||
caps.can_shutdown = 1; /* for testing */
|
caps.can_shutdown = 1; /* for testing */
|
||||||
caps.display_type = HW_DISPLAY_LINE_TEXT;
|
caps.display_type = HW_DISPLAY_LINE_TEXT;
|
||||||
caps.has_HDMI = 1;
|
caps.has_HDMI = 1;
|
||||||
caps.display_xres = 8;
|
caps.display_xres = 8;
|
||||||
|
@@ -21,7 +21,7 @@ bool cPlayback::Start(std::string filename, std::string headers)
|
|||||||
bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, int duration, std::string /*headers*/)
|
bool cPlayback::Start(char *filename, int vpid, int vtype, int apid, int ac3, int duration, std::string /*headers*/)
|
||||||
{
|
{
|
||||||
printf("%s:%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d duration=%i\n",
|
printf("%s:%s - filename=%s vpid=%u vtype=%d apid=%u ac3=%d duration=%i\n",
|
||||||
FILENAME, __func__, filename, vpid, vtype, apid, ac3, duration);
|
FILENAME, __func__, filename, vpid, vtype, apid, ac3, duration);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,18 +81,12 @@ class cPlayback
|
|||||||
int GetSubtitlePid(void);
|
int GetSubtitlePid(void);
|
||||||
bool SetPosition(int position, bool absolute = false);
|
bool SetPosition(int position, bool absolute = false);
|
||||||
void FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *numpida, std::string *language);
|
void FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *numpida, std::string *language);
|
||||||
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language)
|
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language) { FindAllPids((int *) apids, (unsigned int *) ac3flags, (unsigned int *) numpida, language); };
|
||||||
{
|
|
||||||
FindAllPids((int *) apids, (unsigned int *) ac3flags, (unsigned int *) numpida, language);
|
|
||||||
};
|
|
||||||
void FindAllSubtitlePids(int *pids, unsigned int *numpids, std::string *language);
|
void FindAllSubtitlePids(int *pids, unsigned int *numpids, std::string *language);
|
||||||
void FindAllTeletextsubtitlePids(int *pids, unsigned int *numpidt, std::string *tlanguage, int *mags, int *pages);
|
void FindAllTeletextsubtitlePids(int *pids, unsigned int *numpidt, std::string *tlanguage, int *mags, int *pages);
|
||||||
void RequestAbort(void);
|
void RequestAbort(void);
|
||||||
void FindAllSubs(int *pids, unsigned int *supported, unsigned int *numpida, std::string *language);
|
void FindAllSubs(int *pids, unsigned int *supported, unsigned int *numpida, std::string *language);
|
||||||
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language)
|
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language) { FindAllSubs((int *) pids, (unsigned int *) supported, (unsigned int *) numpida, language); };
|
||||||
{
|
|
||||||
FindAllSubs((int *) pids, (unsigned int *) supported, (unsigned int *) numpida, language);
|
|
||||||
};
|
|
||||||
bool SelectSubtitles(int pid, std::string charset = "");
|
bool SelectSubtitles(int pid, std::string charset = "");
|
||||||
void GetTitles(std::vector<int> &playlists, std::vector<std::string> &titles, int ¤t);
|
void GetTitles(std::vector<int> &playlists, std::vector<std::string> &titles, int ¤t);
|
||||||
void SetTitle(int title);
|
void SetTitle(int title);
|
||||||
|
@@ -110,14 +110,14 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
if (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND)
|
if (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND)
|
||||||
{
|
{
|
||||||
if (g_strrstr(sourceName, "videosink"))
|
if (g_strrstr(sourceName, "videosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_ERROR: videosink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_ERROR: videosink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
else if (g_strrstr(sourceName, "audiosink"))
|
else if (g_strrstr(sourceName, "audiosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_ERROR: audioSink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_ERROR: audioSink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
|
|
||||||
end_eof = 1; // NOTE: just to exit
|
end_eof = 1; // NOTE: just to exit
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
if (inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE)
|
if (inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE)
|
||||||
{
|
{
|
||||||
if (g_strrstr(sourceName, "videosink"))
|
if (g_strrstr(sourceName, "videosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
}
|
}
|
||||||
g_error_free(inf);
|
g_error_free(inf);
|
||||||
break;
|
break;
|
||||||
@@ -166,7 +166,7 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
//FIXME: how shall playback handle this event???
|
//FIXME: how shall playback handle this event???
|
||||||
}
|
}
|
||||||
gst_tag_list_free(tags);
|
gst_tag_list_free(tags);
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
{
|
{
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
{
|
{
|
||||||
GstIterator *children;
|
GstIterator *children;
|
||||||
@@ -212,10 +213,12 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
{
|
{
|
||||||
if (audioSink)
|
if (audioSink)
|
||||||
@@ -232,7 +235,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -279,8 +283,7 @@ cPlayback::cPlayback(int num)
|
|||||||
nano_str = "";
|
nano_str = "";
|
||||||
|
|
||||||
hal_info("%s:%s - This program is linked against GStreamer %d.%d.%d %s\n",
|
hal_info("%s:%s - This program is linked against GStreamer %d.%d.%d %s\n",
|
||||||
FILENAME, __FUNCTION__,
|
FILENAME, __FUNCTION__, major, minor, micro, nano_str);
|
||||||
major, minor, micro, nano_str);
|
|
||||||
|
|
||||||
mAudioStream = 0;
|
mAudioStream = 0;
|
||||||
mSpeed = 0;
|
mSpeed = 0;
|
||||||
@@ -621,7 +624,7 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
unsigned long long int sec = 0;
|
unsigned long long int sec = 0;
|
||||||
|
|
||||||
gst_element_query_position(m_gst_playbin, &fmt, &pts);
|
gst_element_query_position(m_gst_playbin, &fmt, &pts);
|
||||||
position = pts / 1000000.0;
|
position = pts / 1000000.0;
|
||||||
|
|
||||||
// duration
|
// duration
|
||||||
GstFormat fmt_d = GST_FORMAT_TIME; //Returns time in nanosecs
|
GstFormat fmt_d = GST_FORMAT_TIME; //Returns time in nanosecs
|
||||||
@@ -709,17 +712,17 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu
|
|||||||
switch (mpegversion)
|
switch (mpegversion)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
gst_structure_get_int (structure, "layer", &layer);
|
gst_structure_get_int (structure, "layer", &layer);
|
||||||
if ( layer == 3 )
|
if ( layer == 3 )
|
||||||
return atMP3;
|
return atMP3;
|
||||||
else
|
else
|
||||||
return atMPEG;
|
return atMPEG;
|
||||||
ac3flags[0] = 4;
|
ac3flags[0] = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
ac3flags[i] = 4;
|
ac3flags[i] = 4;
|
||||||
case 2:
|
case 2:
|
||||||
//return atAAC;
|
//return atAAC;
|
||||||
|
@@ -225,16 +225,16 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
if (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND)
|
if (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND)
|
||||||
{
|
{
|
||||||
if (g_strrstr(sourceName, "videosink"))
|
if (g_strrstr(sourceName, "videosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_ERROR: videosink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_ERROR: videosink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
else if (g_strrstr(sourceName, "audiosink"))
|
else if (g_strrstr(sourceName, "audiosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_ERROR: audioSink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_ERROR: audioSink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
if (sourceName)
|
if (sourceName)
|
||||||
g_free(sourceName);
|
g_free(sourceName);
|
||||||
|
|
||||||
end_eof = 1; // NOTE: just to exit
|
end_eof = 1; // NOTE: just to exit
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
{
|
{
|
||||||
gchar *sourceName = gst_object_get_name(source);
|
gchar *sourceName = gst_object_get_name(source);
|
||||||
if (g_strrstr(sourceName, "videosink"))
|
if (g_strrstr(sourceName, "videosink"))
|
||||||
hal_info_c("%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_info_c("%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
if (sourceName)
|
if (sourceName)
|
||||||
g_free(sourceName);
|
g_free(sourceName);
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
}
|
}
|
||||||
if (tags)
|
if (tags)
|
||||||
gst_tag_list_unref(tags);
|
gst_tag_list_unref(tags);
|
||||||
hal_debug_c("%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event???
|
hal_debug_c("%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); // FIXME: how shall playback handle this event???
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_MESSAGE_ELEMENT:
|
case GST_MESSAGE_ELEMENT:
|
||||||
@@ -357,7 +357,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
{
|
{
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
{
|
{
|
||||||
GstIterator *children;
|
GstIterator *children;
|
||||||
@@ -396,10 +397,12 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
{
|
{
|
||||||
if (audioSink)
|
if (audioSink)
|
||||||
@@ -416,7 +419,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
{
|
{
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -453,8 +457,7 @@ cPlayback::cPlayback(int num)
|
|||||||
nano_str = "";
|
nano_str = "";
|
||||||
|
|
||||||
hal_info("%s:%s - This program is linked against GStreamer %d.%d.%d %s\n",
|
hal_info("%s:%s - This program is linked against GStreamer %d.%d.%d %s\n",
|
||||||
FILENAME, __FUNCTION__,
|
FILENAME, __FUNCTION__, major, minor, micro, nano_str);
|
||||||
major, minor, micro, nano_str);
|
|
||||||
|
|
||||||
mAudioStream = 0;
|
mAudioStream = 0;
|
||||||
mSpeed = 0;
|
mSpeed = 0;
|
||||||
@@ -599,7 +602,7 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/,
|
|||||||
|
|
||||||
hal_info("%s:%s - filename=%s\n", FILENAME, __FUNCTION__, filename);
|
hal_info("%s:%s - filename=%s\n", FILENAME, __FUNCTION__, filename);
|
||||||
|
|
||||||
guint flags = GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_NATIVE_VIDEO;
|
guint flags = GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_NATIVE_VIDEO;
|
||||||
|
|
||||||
/* increase the default 2 second / 2 MB buffer limitations to 5s / 5MB */
|
/* increase the default 2 second / 2 MB buffer limitations to 5s / 5MB */
|
||||||
int m_buffer_size = 5 * 1024 * 1024;
|
int m_buffer_size = 5 * 1024 * 1024;
|
||||||
@@ -849,7 +852,7 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
hal_info("%s - %d failed\n", __FUNCTION__, __LINE__);
|
hal_info("%s - %d failed\n", __FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
position = pts / 1000000.0;
|
position = pts / 1000000.0;
|
||||||
// duration
|
// duration
|
||||||
GstFormat fmt_d = GST_FORMAT_TIME; //Returns time in nanosecs
|
GstFormat fmt_d = GST_FORMAT_TIME; //Returns time in nanosecs
|
||||||
double length = 0;
|
double length = 0;
|
||||||
@@ -978,7 +981,7 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu
|
|||||||
if (caps)
|
if (caps)
|
||||||
gst_caps_unref(caps);
|
gst_caps_unref(caps);
|
||||||
|
|
||||||
//(ac3flags[i] > 2) ? ac3flags[i] = 1 : ac3flags[i] = 0;
|
//(ac3flags[i] > 2) ? ac3flags[i] = 1 : ac3flags[i] = 0;
|
||||||
|
|
||||||
g_signal_emit_by_name(m_gst_playbin, "get-audio-tags", i, &tags);
|
g_signal_emit_by_name(m_gst_playbin, "get-audio-tags", i, &tags);
|
||||||
if (tags)
|
if (tags)
|
||||||
|
@@ -19,6 +19,7 @@ class cPlayback
|
|||||||
int mAudioStream;
|
int mAudioStream;
|
||||||
int mSubtitleStream;
|
int mSubtitleStream;
|
||||||
int mTeletextStream;
|
int mTeletextStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cPlayback(int);
|
cPlayback(int);
|
||||||
bool Open(playmode_t PlayMode);
|
bool Open(playmode_t PlayMode);
|
||||||
@@ -28,15 +29,9 @@ class cPlayback
|
|||||||
bool SetAPid(int pid, bool ac3);
|
bool SetAPid(int pid, bool ac3);
|
||||||
bool SetSubtitlePid(int pid);
|
bool SetSubtitlePid(int pid);
|
||||||
bool SetTeletextPid(int pid);
|
bool SetTeletextPid(int pid);
|
||||||
int GetAPid(void)
|
int GetAPid(void) { return mAudioStream; }
|
||||||
{
|
|
||||||
return mAudioStream;
|
|
||||||
}
|
|
||||||
int GetVPid(void);
|
int GetVPid(void);
|
||||||
int GetSubtitlePid(void)
|
int GetSubtitlePid(void) { return mSubtitleStream; }
|
||||||
{
|
|
||||||
return mSubtitleStream;
|
|
||||||
}
|
|
||||||
int GetTeletextPid(void);
|
int GetTeletextPid(void);
|
||||||
void SuspendSubtitle(bool);
|
void SuspendSubtitle(bool);
|
||||||
int GetFirstTeletextPid(void);
|
int GetFirstTeletextPid(void);
|
||||||
@@ -46,23 +41,14 @@ class cPlayback
|
|||||||
void GetPts(uint64_t &pts);
|
void GetPts(uint64_t &pts);
|
||||||
bool SetPosition(int position, bool absolute = false);
|
bool SetPosition(int position, bool absolute = false);
|
||||||
void FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *numpida, std::string *language);
|
void FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *numpida, std::string *language);
|
||||||
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language)
|
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language) { FindAllPids((int *) apids, (unsigned int *) ac3flags, (unsigned int *) numpida, language); };
|
||||||
{
|
|
||||||
FindAllPids((int *) apids, (unsigned int *) ac3flags, (unsigned int *) numpida, language);
|
|
||||||
};
|
|
||||||
void FindAllSubtitlePids(int *pids, unsigned int *numpids, std::string *language);
|
void FindAllSubtitlePids(int *pids, unsigned int *numpids, std::string *language);
|
||||||
void FindAllTeletextsubtitlePids(int *pids, unsigned int *numpidt, std::string *tlanguage, int *mags, int *pages);
|
void FindAllTeletextsubtitlePids(int *pids, unsigned int *numpidt, std::string *tlanguage, int *mags, int *pages);
|
||||||
void RequestAbort(void);
|
void RequestAbort(void);
|
||||||
bool IsPlaying(void)
|
bool IsPlaying(void) { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
uint64_t GetReadCount(void);
|
uint64_t GetReadCount(void);
|
||||||
void FindAllSubs(int *pids, unsigned int *supported, unsigned int *numpida, std::string *language);
|
void FindAllSubs(int *pids, unsigned int *supported, unsigned int *numpida, std::string *language);
|
||||||
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language)
|
void FindAllSubs(uint16_t *pids, unsigned short *supported, uint16_t *numpida, std::string *language) { FindAllSubs((int *) pids, (unsigned int *) supported, (unsigned int *) numpida, language); };
|
||||||
{
|
|
||||||
FindAllSubs((int *) pids, (unsigned int *) supported, (unsigned int *) numpida, language);
|
|
||||||
};
|
|
||||||
bool SelectSubtitles(int pid, std::string charset = "");
|
bool SelectSubtitles(int pid, std::string charset = "");
|
||||||
void GetTitles(std::vector<int> &playlists, std::vector<std::string> &titles, int ¤t);
|
void GetTitles(std::vector<int> &playlists, std::vector<std::string> &titles, int ¤t);
|
||||||
void SetTitle(int title);
|
void SetTitle(int title);
|
||||||
@@ -70,10 +56,7 @@ class cPlayback
|
|||||||
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||||
//
|
//
|
||||||
~cPlayback();
|
~cPlayback();
|
||||||
AVFormatContext *GetAVFormatContext()
|
AVFormatContext *GetAVFormatContext() { return NULL; }
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
void ReleaseAVFormatContext() {}
|
void ReleaseAVFormatContext() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -68,11 +68,11 @@ static int bufpos;
|
|||||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100)
|
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 133, 100)
|
||||||
static void get_packet_defaults(AVPacket *pkt)
|
static void get_packet_defaults(AVPacket *pkt)
|
||||||
{
|
{
|
||||||
memset(pkt, 0, sizeof(*pkt));
|
memset(pkt, 0, sizeof(*pkt));
|
||||||
|
|
||||||
pkt->pts = AV_NOPTS_VALUE;
|
pkt->pts = AV_NOPTS_VALUE;
|
||||||
pkt->dts = AV_NOPTS_VALUE;
|
pkt->dts = AV_NOPTS_VALUE;
|
||||||
pkt->pos = -1;
|
pkt->pos = -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -145,14 +145,14 @@ int cVideo::getAspectRatio(void)
|
|||||||
ar = w * 100 * a.num / h / a.den;
|
ar = w * 100 * a.num / h / a.den;
|
||||||
if (ar < 100 || ar > 225) /* < 4:3, > 20:9 */
|
if (ar < 100 || ar > 225) /* < 4:3, > 20:9 */
|
||||||
; /* ret = 0: N/A */
|
; /* ret = 0: N/A */
|
||||||
else if (ar < 140) /* 4:3 */
|
else if (ar < 140) /* 4:3 */
|
||||||
ret = 1;
|
ret = 1;
|
||||||
else if (ar < 165) /* 14:9 */
|
else if (ar < 165) /* 14:9 */
|
||||||
ret = 2;
|
ret = 2;
|
||||||
else if (ar < 200) /* 16:9 */
|
else if (ar < 200) /* 16:9 */
|
||||||
ret = 3;
|
ret = 3;
|
||||||
else
|
else
|
||||||
ret = 4; /* 20:9 */
|
ret = 4; /* 20:9 */
|
||||||
out:
|
out:
|
||||||
buf_m.unlock();
|
buf_m.unlock();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -349,8 +349,8 @@ bool cVideo::ShowPicture(const char *fname)
|
|||||||
{
|
{
|
||||||
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
||||||
struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt,
|
struct SwsContext *convert = sws_getContext(c->width, c->height, c->pix_fmt,
|
||||||
c->width, c->height, VDEC_PIXFMT,
|
c->width, c->height, VDEC_PIXFMT,
|
||||||
SWS_BICUBIC, 0, 0, 0);
|
SWS_BICUBIC, 0, 0, 0);
|
||||||
if (!convert)
|
if (!convert)
|
||||||
hal_info("%s: ERROR setting up SWS context\n", __func__);
|
hal_info("%s: ERROR setting up SWS context\n", __func__);
|
||||||
else
|
else
|
||||||
@@ -360,9 +360,9 @@ bool cVideo::ShowPicture(const char *fname)
|
|||||||
if (f->size() < need)
|
if (f->size() < need)
|
||||||
f->resize(need);
|
f->resize(need);
|
||||||
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT,
|
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT,
|
||||||
c->width, c->height, 1);
|
c->width, c->height, 1);
|
||||||
sws_scale(convert, frame->data, frame->linesize, 0, c->height,
|
sws_scale(convert, frame->data, frame->linesize, 0, c->height,
|
||||||
rgbframe->data, rgbframe->linesize);
|
rgbframe->data, rgbframe->linesize);
|
||||||
sws_freeContext(convert);
|
sws_freeContext(convert);
|
||||||
f->width(c->width);
|
f->width(c->width);
|
||||||
f->height(c->height);
|
f->height(c->height);
|
||||||
@@ -485,7 +485,7 @@ static int my_read(void *, uint8_t *buf, int buf_size)
|
|||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
if (videoDecoder && bufpos < DMX_BUF_SZ - 4096)
|
if (videoDecoder && bufpos < DMX_BUF_SZ - 4096)
|
||||||
{
|
{
|
||||||
while (bufpos < buf_size && ++tmp < 20) /* retry max 20 times */
|
while (bufpos < buf_size && ++tmp < 20) /* retry max 20 times */
|
||||||
{
|
{
|
||||||
int ret = videoDemux->Read(dmxbuf + bufpos, DMX_BUF_SZ - bufpos, 20);
|
int ret = videoDemux->Read(dmxbuf + bufpos, DMX_BUF_SZ - bufpos, 20);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
@@ -541,11 +541,11 @@ void cVideo::run(void)
|
|||||||
#endif
|
#endif
|
||||||
inp = av_find_input_format("mpegts");
|
inp = av_find_input_format("mpegts");
|
||||||
AVIOContext *pIOCtx = avio_alloc_context(inbuf, INBUF_SIZE, // internal Buffer and its size
|
AVIOContext *pIOCtx = avio_alloc_context(inbuf, INBUF_SIZE, // internal Buffer and its size
|
||||||
0, // bWriteable (1=true,0=false)
|
0, // bWriteable (1=true,0=false)
|
||||||
NULL, // user data; will be passed to our callback functions
|
NULL, // user data; will be passed to our callback functions
|
||||||
my_read, // read callback
|
my_read, // read callback
|
||||||
NULL, // write callback
|
NULL, // write callback
|
||||||
NULL); // seek callback
|
NULL); // seek callback
|
||||||
avfc = avformat_alloc_context();
|
avfc = avformat_alloc_context();
|
||||||
avfc->pb = pIOCtx;
|
avfc->pb = pIOCtx;
|
||||||
avfc->iformat = inp;
|
avfc->iformat = inp;
|
||||||
@@ -639,9 +639,9 @@ void cVideo::run(void)
|
|||||||
{
|
{
|
||||||
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
unsigned int need = av_image_get_buffer_size(VDEC_PIXFMT, c->width, c->height, 1);
|
||||||
convert = sws_getCachedContext(convert,
|
convert = sws_getCachedContext(convert,
|
||||||
c->width, c->height, c->pix_fmt,
|
c->width, c->height, c->pix_fmt,
|
||||||
c->width, c->height, VDEC_PIXFMT,
|
c->width, c->height, VDEC_PIXFMT,
|
||||||
SWS_BICUBIC, 0, 0, 0);
|
SWS_BICUBIC, 0, 0, 0);
|
||||||
if (!convert)
|
if (!convert)
|
||||||
hal_info("%s: ERROR setting up SWS context\n", __func__);
|
hal_info("%s: ERROR setting up SWS context\n", __func__);
|
||||||
else
|
else
|
||||||
@@ -650,14 +650,11 @@ void cVideo::run(void)
|
|||||||
SWFramebuffer *f = &buffers[buf_in];
|
SWFramebuffer *f = &buffers[buf_in];
|
||||||
if (f->size() < need)
|
if (f->size() < need)
|
||||||
f->resize(need);
|
f->resize(need);
|
||||||
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT,
|
av_image_fill_arrays(rgbframe->data, rgbframe->linesize, &(*f)[0], VDEC_PIXFMT, c->width, c->height, 1);
|
||||||
c->width, c->height, 1);
|
sws_scale(convert, frame->data, frame->linesize, 0, c->height, rgbframe->data, rgbframe->linesize);
|
||||||
sws_scale(convert, frame->data, frame->linesize, 0, c->height,
|
|
||||||
rgbframe->data, rgbframe->linesize);
|
|
||||||
if (dec_w != c->width || dec_h != c->height)
|
if (dec_w != c->width || dec_h != c->height)
|
||||||
{
|
{
|
||||||
hal_info("%s: pic changed %dx%d -> %dx%d\n", __func__,
|
hal_info("%s: pic changed %dx%d -> %dx%d\n", __func__, dec_w, dec_h, c->width, c->height);
|
||||||
dec_w, dec_h, c->width, c->height);
|
|
||||||
dec_w = c->width;
|
dec_w = c->width;
|
||||||
dec_h = c->height;
|
dec_h = c->height;
|
||||||
w_h_changed = true;
|
w_h_changed = true;
|
||||||
@@ -697,13 +694,14 @@ void cVideo::run(void)
|
|||||||
dec_r = c->time_base.den / (c->time_base.num * c->ticks_per_frame);
|
dec_r = c->time_base.den / (c->time_base.num * c->ticks_per_frame);
|
||||||
buf_m.unlock();
|
buf_m.unlock();
|
||||||
}
|
}
|
||||||
hal_debug("%s: time_base: %d/%d, ticks: %d rate: %d pts 0x%" PRIx64 "\n", __func__,
|
hal_debug("%s: time_base: %d/%d, ticks: %d rate: %d pts 0x%" PRIx64 "\n",
|
||||||
c->time_base.num, c->time_base.den, c->ticks_per_frame, dec_r,
|
__func__, c->time_base.num, c->time_base.den, c->ticks_per_frame, dec_r,
|
||||||
#if (LIBAVUTIL_VERSION_MAJOR < 54)
|
#if (LIBAVUTIL_VERSION_MAJOR < 54)
|
||||||
av_frame_get_best_effort_timestamp(frame));
|
av_frame_get_best_effort_timestamp(frame)
|
||||||
#else
|
#else
|
||||||
frame->best_effort_timestamp);
|
frame->best_effort_timestamp
|
||||||
#endif
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hal_debug("%s: got_frame: %d stillpicture: %d\n", __func__, got_frame, stillpicture);
|
hal_debug("%s: got_frame: %d stillpicture: %d\n", __func__, got_frame, stillpicture);
|
||||||
@@ -789,7 +787,7 @@ static bool swscale(unsigned char *src, unsigned char *dst, int sw, int sh, int
|
|||||||
bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video, bool get_osd, bool scale_to_video)
|
bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video, bool get_osd, bool scale_to_video)
|
||||||
{
|
{
|
||||||
hal_info("%s: data 0x%p xres %d yres %d vid %d osd %d scale %d\n",
|
hal_info("%s: data 0x%p xres %d yres %d vid %d osd %d scale %d\n",
|
||||||
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
|
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
|
||||||
SWFramebuffer video;
|
SWFramebuffer video;
|
||||||
std::vector<unsigned char> *osd = NULL;
|
std::vector<unsigned char> *osd = NULL;
|
||||||
std::vector<unsigned char> s_osd; /* scaled OSD */
|
std::vector<unsigned char> s_osd; /* scaled OSD */
|
||||||
@@ -825,13 +823,13 @@ bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get
|
|||||||
osd = glfb_priv->getOSDBuffer();
|
osd = glfb_priv->getOSDBuffer();
|
||||||
unsigned int need = av_image_get_buffer_size(AV_PIX_FMT_RGB32, xres, yres, 1);
|
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 */
|
data = (unsigned char *)realloc(data, need); /* will be freed by caller */
|
||||||
if (data == NULL) /* out of memory? */
|
if (data == NULL) /* out of memory? */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (get_video)
|
if (get_video)
|
||||||
{
|
{
|
||||||
#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32
|
#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32
|
||||||
if (vid_w != xres || vid_h != yres) /* scale video into data... */
|
if (vid_w != xres || vid_h != yres) /* scale video into data... */
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
bool ret = swscale(&video[0], data, vid_w, vid_h, xres, yres, VDEC_PIXFMT);
|
bool ret = swscale(&video[0], data, vid_w, vid_h, xres, yres, VDEC_PIXFMT);
|
||||||
@@ -842,7 +840,7 @@ bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get
|
|||||||
}
|
}
|
||||||
#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32
|
#if USE_OPENGL //memcpy dont work with copy BGR24 to RGB32
|
||||||
}
|
}
|
||||||
else /* get_video and no fancy scaling needed */
|
else /* get_video and no fancy scaling needed */
|
||||||
{
|
{
|
||||||
memcpy(data, &video[0], xres * yres * sizeof(uint32_t));
|
memcpy(data, &video[0], xres * yres * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
@@ -878,7 +876,7 @@ bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get
|
|||||||
{
|
{
|
||||||
uint8_t *in = (uint8_t *)(pixpos);
|
uint8_t *in = (uint8_t *)(pixpos);
|
||||||
uint8_t *out = (uint8_t *)d;
|
uint8_t *out = (uint8_t *)d;
|
||||||
int a = in[3]; /* TODO: big/little endian? */
|
int a = in[3]; /* TODO: big/little endian? */
|
||||||
*out = (*out + ((*in - *out) * a) / 256);
|
*out = (*out + ((*in - *out) * a) / 256);
|
||||||
in++;
|
in++;
|
||||||
out++;
|
out++;
|
||||||
|
@@ -107,7 +107,7 @@ typedef enum
|
|||||||
VIDEO_STD_1080P24,
|
VIDEO_STD_1080P24,
|
||||||
VIDEO_STD_1080P25,
|
VIDEO_STD_1080P25,
|
||||||
VIDEO_STD_AUTO,
|
VIDEO_STD_AUTO,
|
||||||
VIDEO_STD_1080P50, /* SPARK only */
|
VIDEO_STD_1080P50, /* SPARK only */
|
||||||
VIDEO_STD_1080P60,
|
VIDEO_STD_1080P60,
|
||||||
VIDEO_STD_1080P2397,
|
VIDEO_STD_1080P2397,
|
||||||
VIDEO_STD_1080P2997,
|
VIDEO_STD_1080P2997,
|
||||||
@@ -149,44 +149,21 @@ class cVideo : public OpenThreads::Thread
|
|||||||
{
|
{
|
||||||
friend class GLFbPC;
|
friend class GLFbPC;
|
||||||
friend class cDemux;
|
friend class cDemux;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* called from GL thread */
|
/* called from GL thread */
|
||||||
class SWFramebuffer : public std::vector<unsigned char>
|
class SWFramebuffer : public std::vector<unsigned char>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SWFramebuffer() : mWidth(0), mHeight(0) {}
|
SWFramebuffer() : mWidth(0), mHeight(0) {}
|
||||||
void width(int w)
|
void width(int w) { mWidth = w; }
|
||||||
{
|
void height(int h) { mHeight = h; }
|
||||||
mWidth = w;
|
void pts(uint64_t p) { mPts = p; }
|
||||||
}
|
void AR(AVRational a) { mAR = a; }
|
||||||
void height(int h)
|
int width() const { return mWidth; }
|
||||||
{
|
int height() const { return mHeight; }
|
||||||
mHeight = h;
|
int64_t pts() const { return mPts; }
|
||||||
}
|
AVRational AR() const { return mAR; }
|
||||||
void pts(uint64_t p)
|
|
||||||
{
|
|
||||||
mPts = p;
|
|
||||||
}
|
|
||||||
void AR(AVRational a)
|
|
||||||
{
|
|
||||||
mAR = a;
|
|
||||||
}
|
|
||||||
int width() const
|
|
||||||
{
|
|
||||||
return mWidth;
|
|
||||||
}
|
|
||||||
int height() const
|
|
||||||
{
|
|
||||||
return mHeight;
|
|
||||||
}
|
|
||||||
int64_t pts() const
|
|
||||||
{
|
|
||||||
return mPts;
|
|
||||||
}
|
|
||||||
AVRational AR() const
|
|
||||||
{
|
|
||||||
return mAR;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
@@ -195,23 +172,15 @@ class cVideo : public OpenThreads::Thread
|
|||||||
};
|
};
|
||||||
int buf_in, buf_out, buf_num;
|
int buf_in, buf_out, buf_num;
|
||||||
int64_t GetPTS(void);
|
int64_t GetPTS(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* constructor & destructor */
|
/* constructor & destructor */
|
||||||
cVideo(int mode, void *, void *, unsigned int unit = 0);
|
cVideo(int mode, void *, void *, unsigned int unit = 0);
|
||||||
~cVideo(void);
|
~cVideo(void);
|
||||||
|
|
||||||
void *GetTVEnc()
|
void *GetTVEnc() { return NULL; };
|
||||||
{
|
void *GetTVEncSD() { return NULL; };
|
||||||
return NULL;
|
void setAVInput(int /*val*/) { return; };
|
||||||
};
|
|
||||||
void *GetTVEncSD()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
void setAVInput(int /*val*/)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* aspect ratio */
|
/* aspect ratio */
|
||||||
int getAspectRatio(void);
|
int getAspectRatio(void);
|
||||||
@@ -241,66 +210,28 @@ class cVideo : public OpenThreads::Thread
|
|||||||
bool ShowPicture(const char *fname);
|
bool ShowPicture(const char *fname);
|
||||||
|
|
||||||
void SetSyncMode(AVSYNC_TYPE mode);
|
void SetSyncMode(AVSYNC_TYPE mode);
|
||||||
bool SetCECMode(VIDEO_HDMI_CEC_MODE)
|
bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; };
|
||||||
{
|
void SetCECAutoView(bool) { return; };
|
||||||
return true;
|
void SetCECAutoStandby(bool) { return; };
|
||||||
};
|
int GetAudioDestination() { return 0; };
|
||||||
void SetCECAutoView(bool)
|
void SetAudioDestination(int /*audio_dest*/) { return; };
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
void SetCECAutoStandby(bool)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
int GetAudioDestination()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
void SetAudioDestination(int /*audio_dest*/)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
void StopPicture();
|
void StopPicture();
|
||||||
void Standby(unsigned int bOn);
|
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);
|
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);
|
||||||
void SetControl(int, int)
|
void SetControl(int, int) { return; };
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
void setContrast(int val);
|
void setContrast(int val);
|
||||||
void SetVideoMode(analog_mode_t mode);
|
void SetVideoMode(analog_mode_t mode);
|
||||||
void SetDBDR(int)
|
void SetDBDR(int) { return; };
|
||||||
{
|
void SetAudioHandle(void *) { return; };
|
||||||
return;
|
void SetAutoModes(int [VIDEO_STD_MAX]) { return; };
|
||||||
};
|
int OpenVBI(int) { return 0; };
|
||||||
void SetAudioHandle(void *)
|
int CloseVBI(void) { return 0; };
|
||||||
{
|
int StartVBI(unsigned short) { return 0; };
|
||||||
return;
|
int StopVBI(void) { return 0; };
|
||||||
};
|
|
||||||
void SetAutoModes(int [VIDEO_STD_MAX])
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
int OpenVBI(int)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int CloseVBI(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int StartVBI(unsigned short)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int StopVBI(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
void SetDemux(cDemux *dmx);
|
void SetDemux(cDemux *dmx);
|
||||||
bool GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
|
bool GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
|
||||||
SWFramebuffer *getDecBuf(void);
|
SWFramebuffer *getDecBuf(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run();
|
void run();
|
||||||
SWFramebuffer buffers[VDEC_MAXBUFS];
|
SWFramebuffer buffers[VDEC_MAXBUFS];
|
||||||
|
Reference in New Issue
Block a user