Add mapping of a stream type and bypass mode and try to set alternative one if main fail

This commit is contained in:
samsamsam
2019-02-03 12:45:03 +01:00
committed by Thilo Graf
parent cb7c9874e8
commit 77cac9222f
3 changed files with 68 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ typedef enum
AUDIOTYPE_WMA_PRO = 0x21,
AUDIOTYPE_AC3_PLUS = 0x22,
AUDIOTYPE_AMR = 0x23,
AUDIOTYPE_RAW = 0xf
AUDIOTYPE_RAW = 0x30
} audio_stream_type_t;

View File

@@ -698,7 +698,7 @@ int main(int argc, char *argv[])
memset(argvBuff, '\0', sizeof(argvBuff));
int commandRetVal = -1;
/* inform client that we can handle additional commands */
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 54);
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 55);
PlayFiles_t playbackFiles;
memset(&playbackFiles, 0x00, sizeof(playbackFiles));

View File

@@ -96,15 +96,65 @@ int LinuxDvbStop(Context_t *context, char *type);
#define getLinuxDVBMutex() pthread_mutex_lock(&LinuxDVBmutex)
#define releaseLinuxDVBMutex() pthread_mutex_unlock(&LinuxDVBmutex)
static int LinuxDvbMapBypassMode(int bypass)
static int LinuxDvbMapBypassMode(int bypass, bool primary)
{
if (0x30 == bypass && STB_DREAMBOX == GetSTBType())
if (STB_DREAMBOX == GetSTBType())
{
return 0x0f;
primary = !primary;
}
switch (bypass)
{
case AUDIOTYPE_RAW:
bypass = primary ? 0x30 : 0xf;
break;
case AUDIOTYPE_AC3_PLUS:
bypass = primary ? 0x22 : 7;
break;
case AUDIOTYPE_WMA:
bypass = primary ? 0x20 : 0xd;
break;
case AUDIOTYPE_WMA_PRO:
bypass = primary ? 0x21 : 0xe;
break;
default:
break;
};
return bypass;
}
static int LinuxDvbMapStreamType(int streamtype, bool primary)
{
if (STB_DREAMBOX == GetSTBType())
{
primary = !primary;
}
switch (streamtype)
{
case STREAMTYPE_MPEG4_H265:
streamtype = primary ? 7 : 22;
break;
case STREAMTYPE_VC1:
streamtype = primary ? 3 : 16;
break;
case STREAMTYPE_VC1_SM:
streamtype = primary ? 5 : 17;
break;
case STREAMTYPE_VB8:
streamtype = primary ? 8 : 20;
break;
case STREAMTYPE_VB9:
streamtype = primary ? 9 : 23;
break;
default:
break;
};
return streamtype;
}
int LinuxDvbOpen(Context_t *context __attribute__((unused)), char *type)
{
uint8_t video = !strcmp("video", type);
@@ -233,7 +283,9 @@ int LinuxDvbPlay(Context_t *context, char *type)
else
{
linuxdvb_printf(20, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
if (ioctl(videofd, VIDEO_SET_STREAMTYPE, (void *) writer->caps->dvbStreamType) == -1)
ret = ioctl(videofd, VIDEO_SET_STREAMTYPE, LinuxDvbMapStreamType(writer->caps->dvbStreamType, true));
if (ret < 0) ret = ioctl(videofd, VIDEO_SET_STREAMTYPE, LinuxDvbMapStreamType(writer->caps->dvbStreamType, false));
if (ret < 0)
{
linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno));
ret = cERR_LINUXDVB_ERROR;
@@ -274,7 +326,9 @@ int LinuxDvbPlay(Context_t *context, char *type)
else
{
linuxdvb_printf(20, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
if (ioctl(audiofd, AUDIO_SET_BYPASS_MODE, (void *) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) < 0)
ret = ioctl(audiofd, AUDIO_SET_BYPASS_MODE, LinuxDvbMapBypassMode(writer->caps->dvbStreamType, true));
if (ret < 0) ret = ioctl(audiofd, AUDIO_SET_BYPASS_MODE, LinuxDvbMapBypassMode(writer->caps->dvbStreamType, false));
if (ret < 0)
{
linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno));
ret = cERR_LINUXDVB_ERROR;
@@ -627,6 +681,7 @@ int LinuxDvbSwitch(Context_t *context, char *type)
uint8_t audio = !strcmp("audio", type);
uint8_t video = !strcmp("video", type);
Writer_t *writer;
int ret = 0;
linuxdvb_printf(10, "v%d a%d\n", video, audio);
@@ -662,7 +717,9 @@ int LinuxDvbSwitch(Context_t *context, char *type)
else
{
linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
if (ioctl(audiofd, AUDIO_SET_BYPASS_MODE, (void *) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) == -1)
ret = ioctl(audiofd, AUDIO_SET_BYPASS_MODE, LinuxDvbMapBypassMode(writer->caps->dvbStreamType, true));
if (ret < 0) ret = ioctl(audiofd, AUDIO_SET_BYPASS_MODE, LinuxDvbMapBypassMode(writer->caps->dvbStreamType, false));
if (ret < 0)
{
linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno));
}
@@ -708,7 +765,9 @@ int LinuxDvbSwitch(Context_t *context, char *type)
else
{
linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
if (ioctl(videofd, VIDEO_SET_STREAMTYPE, (void *) writer->caps->dvbStreamType) == -1)
ret = ioctl(videofd, VIDEO_SET_STREAMTYPE, LinuxDvbMapStreamType(writer->caps->dvbStreamType, true));
if (ret < 0) ret = ioctl(videofd, VIDEO_SET_STREAMTYPE, LinuxDvbMapStreamType(writer->caps->dvbStreamType, false));
if (ret < 0)
{
linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno));
}