mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
azbox: split up cVideo::ShowPicture
create a new show_iframe function which just gets the still-mpeg data passed from ShowPicture
This commit is contained in:
@@ -62,6 +62,8 @@ int system_rev = 0;
|
|||||||
|
|
||||||
static bool hdmi_enabled = true;
|
static bool hdmi_enabled = true;
|
||||||
static bool stillpicture = false;
|
static bool stillpicture = false;
|
||||||
|
/* prototype */
|
||||||
|
static void show_iframe(int fd, unsigned char *iframe, size_t st_size);
|
||||||
|
|
||||||
#define VIDEO_STREAMTYPE_MPEG2 0
|
#define VIDEO_STREAMTYPE_MPEG2 0
|
||||||
#define VIDEO_STREAMTYPE_MPEG4_H264 1
|
#define VIDEO_STREAMTYPE_MPEG4_H264 1
|
||||||
@@ -294,12 +296,11 @@ void cVideo::SetVideoMode(analog_mode_t mode)
|
|||||||
void cVideo::ShowPicture(const char * fname)
|
void cVideo::ShowPicture(const char * fname)
|
||||||
{
|
{
|
||||||
lt_debug("%s(%s)\n", __func__, fname);
|
lt_debug("%s(%s)\n", __func__, fname);
|
||||||
static const unsigned char pes_header[] = { 0, 0, 1, 0xE0, 0, 0, 0x80, 0x80, 5, 0x21, 0, 1, 0, 1};
|
|
||||||
static const unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 };
|
|
||||||
char destname[512];
|
char destname[512];
|
||||||
char cmd[512];
|
char cmd[512];
|
||||||
char *p;
|
char *p;
|
||||||
int mfd;
|
int mfd;
|
||||||
|
unsigned char *iframe;
|
||||||
struct stat st, st2;
|
struct stat st, st2;
|
||||||
if (video_standby)
|
if (video_standby)
|
||||||
{
|
{
|
||||||
@@ -307,6 +308,11 @@ void cVideo::ShowPicture(const char * fname)
|
|||||||
lt_info("%s: video_standby == true\n", __func__);
|
lt_info("%s: video_standby == true\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
lt_info("%s: decoder not opened?\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
strcpy(destname, "/var/cache");
|
strcpy(destname, "/var/cache");
|
||||||
if (stat(fname, &st2))
|
if (stat(fname, &st2))
|
||||||
{
|
{
|
||||||
@@ -343,52 +349,17 @@ void cVideo::ShowPicture(const char * fname)
|
|||||||
}
|
}
|
||||||
fstat(mfd, &st);
|
fstat(mfd, &st);
|
||||||
|
|
||||||
closeDevice();
|
|
||||||
openDevice();
|
|
||||||
|
|
||||||
if (fd >= 0)
|
|
||||||
{
|
|
||||||
stillpicture = true;
|
stillpicture = true;
|
||||||
|
|
||||||
if (ioctl(fd, VIDEO_SET_FORMAT, VIDEO_FORMAT_16_9) < 0)
|
iframe = (unsigned char *)malloc(st.st_size);
|
||||||
lt_info("%s: VIDEO_SET_FORMAT failed (%m)\n", __func__);
|
|
||||||
bool seq_end_avail = false;
|
|
||||||
size_t pos=0;
|
|
||||||
int count = 7;
|
|
||||||
unsigned char *iframe = (unsigned char *)malloc((st.st_size < 8192) ? 8192 : st.st_size);
|
|
||||||
if (! iframe)
|
if (! iframe)
|
||||||
{
|
{
|
||||||
lt_info("%s: malloc failed (%m)\n", __func__);
|
lt_info("%s: malloc failed (%m)\n", __func__);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
read(mfd, iframe, st.st_size);
|
read(mfd, iframe, st.st_size);
|
||||||
ioctl(fd, VIDEO_SET_STREAMTYPE, VIDEO_FORMAT_MPEG2);
|
show_iframe(fd, iframe, st.st_size);
|
||||||
ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY);
|
|
||||||
ioctl(fd, VIDEO_PLAY);
|
|
||||||
ioctl(fd, VIDEO_CONTINUE);
|
|
||||||
ioctl(fd, VIDEO_CLEAR_BUFFER);
|
|
||||||
while (pos <= (st.st_size-4) && !(seq_end_avail = (!iframe[pos] && !iframe[pos+1] && iframe[pos+2] == 1 && iframe[pos+3] == 0xB7)))
|
|
||||||
++pos;
|
|
||||||
while (count--)
|
|
||||||
{
|
|
||||||
if ((iframe[3] >> 4) != 0xE) // no pes header
|
|
||||||
{
|
|
||||||
write(fd, pes_header, sizeof(pes_header));
|
|
||||||
usleep(8000);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
iframe[4] = iframe[5] = 0x00;
|
|
||||||
write(fd, iframe, st.st_size);
|
|
||||||
usleep(8000);
|
|
||||||
}
|
|
||||||
if (!seq_end_avail)
|
|
||||||
write(fd, seq_end, sizeof(seq_end));
|
|
||||||
memset(iframe, 0, 8192);
|
|
||||||
write(fd, iframe, 8192);
|
|
||||||
ioctl(fd, VIDEO_STOP, 0);
|
|
||||||
ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
|
|
||||||
free(iframe);
|
free(iframe);
|
||||||
}
|
|
||||||
out:
|
out:
|
||||||
close(mfd);
|
close(mfd);
|
||||||
return;
|
return;
|
||||||
@@ -596,3 +567,39 @@ int64_t cVideo::GetPTS(void)
|
|||||||
lt_info("%s: GET_PTS failed (%m)\n", __func__);
|
lt_info("%s: GET_PTS failed (%m)\n", __func__);
|
||||||
return pts;
|
return pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void show_iframe(int fd, unsigned char *iframe, size_t st_size)
|
||||||
|
{
|
||||||
|
static const unsigned char pes_header[] = { 0, 0, 1, 0xE0, 0, 0, 0x80, 0x80, 5, 0x21, 0, 1, 0, 1};
|
||||||
|
static const unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 };
|
||||||
|
unsigned char stuffing[128];
|
||||||
|
bool seq_end_avail = false;
|
||||||
|
size_t pos = 0;
|
||||||
|
int count = 7;
|
||||||
|
if (ioctl(fd, VIDEO_SET_FORMAT, VIDEO_FORMAT_16_9) < 0)
|
||||||
|
lt_info_c("%s: VIDEO_SET_FORMAT failed (%m)\n", __func__);
|
||||||
|
ioctl(fd, VIDEO_SET_STREAMTYPE, VIDEO_FORMAT_MPEG2);
|
||||||
|
ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY);
|
||||||
|
ioctl(fd, VIDEO_PLAY);
|
||||||
|
ioctl(fd, VIDEO_CONTINUE);
|
||||||
|
ioctl(fd, VIDEO_CLEAR_BUFFER);
|
||||||
|
while (pos <= (st_size-4) && !(seq_end_avail = (!iframe[pos] && !iframe[pos+1] && iframe[pos+2] == 1 && iframe[pos+3] == 0xB7)))
|
||||||
|
++pos;
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
if ((iframe[3] >> 4) != 0xE) // no pes header
|
||||||
|
write(fd, pes_header, sizeof(pes_header));
|
||||||
|
else
|
||||||
|
iframe[4] = iframe[5] = 0x00;
|
||||||
|
write(fd, iframe, st_size);
|
||||||
|
usleep(8000);
|
||||||
|
}
|
||||||
|
if (!seq_end_avail)
|
||||||
|
write(fd, seq_end, sizeof(seq_end));
|
||||||
|
|
||||||
|
memset(stuffing, 0, sizeof(stuffing));
|
||||||
|
for (count = 0; count < 8192 / (int)sizeof(stuffing); count++)
|
||||||
|
write(fd, stuffing, sizeof(stuffing));
|
||||||
|
ioctl(fd, VIDEO_STOP, 0);
|
||||||
|
ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user