Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions container/container_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
static int32_t ac3_software_decode = 0;
static int32_t eac3_software_decode = 0;
static int32_t dts_software_decode = 0;
static int32_t truehd_software_decode = 0;
static int32_t amr_software_decode = 1;
static int32_t vorbis_software_decode = 1;
static int32_t opus_software_decode = 1;
Expand Down Expand Up @@ -294,6 +295,11 @@
dts_software_decode = val;
}

void truehd_software_decoder_set(const int32_t val)
{
truehd_software_decode = val;
}

void amr_software_decoder_set(const int32_t val)
{
amr_software_decode = val;
Expand Down Expand Up @@ -450,8 +456,9 @@
return (wma_software_decode) ? "A_IPCM" : "A_WMA/PRO";
case AV_CODEC_ID_WMALOSSLESS:
return "A_IPCM";
case AV_CODEC_ID_TRUEHD:
case AV_CODEC_ID_MLP:
return "A_IPCM";
return truehd_software_decode ? "A_IPCM" : "A_TRUEHD";
case AV_CODEC_ID_RA_144:
return "A_IPCM";
case AV_CODEC_ID_RA_288:
Expand Down Expand Up @@ -749,12 +756,14 @@
}
}
reset_finish_timeout();
/*
if (bufferSize > 0)
{
context->output->Command(context, OUTPUT_CLEAR, NULL);
}
*/
/* OUTPUT_CLEAR here was tried as a gstreamer FLUSH equivalent
* but this path is NOT the seek boundary — it runs every
* av_read_frame iteration that still passes the gate. On
* HLS stitched sources (PlutoTV) it fired on every stitcher
* segment boundary and starved the audio producer: vpts
* stuck for minutes with av_drift = -425000 ms. Leaving
* disabled. dream_audio's da_reset_anchor_locked() stays
* available for when a real seek-completed wiring exists. */
}
else
{
Expand Down Expand Up @@ -892,8 +901,8 @@
#endif
{
bool skipPacket = false;
currentVideoPts = videoTrack->pts = pts = calcPts(cAVIdx, videoTrack->stream, packet.pts);

Check warning on line 904 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp5&open=AZ7SyK8zlwJ5gPmbEJp5&pullRequest=3

Check warning on line 904 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp3&open=AZ7SyK8zlwJ5gPmbEJp3&pullRequest=3
videoTrack->dts = dts = calcPts(cAVIdx, videoTrack->stream, packet.dts);

Check warning on line 905 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "dts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp4&open=AZ7SyK8zlwJ5gPmbEJp4&pullRequest=3

if ((currentVideoPts != INVALID_PTS_VALUE) && (currentVideoPts > latestPts))
{
Expand Down Expand Up @@ -960,7 +969,7 @@
else if (audioTrack && (audioTrack->AVIdx == cAVIdx) && (audioTrack->Id == pid))
{
uint8_t skipPacket = 0;
currentAudioPts = audioTrack->pts = pts = calcPts(cAVIdx, audioTrack->stream, packet.pts);

Check warning on line 972 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp6&open=AZ7SyK8zlwJ5gPmbEJp6&pullRequest=3

Check warning on line 972 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp7&open=AZ7SyK8zlwJ5gPmbEJp7&pullRequest=3
dts = calcPts(cAVIdx, audioTrack->stream, packet.dts);

if ((currentAudioPts != INVALID_PTS_VALUE) && (currentAudioPts > latestPts) && (!videoTrack))
Expand Down Expand Up @@ -1233,7 +1242,7 @@
((AVStream*) audioTrack->stream)->time_base.den,
((AVStream*) audioTrack->stream)->time_base.num * (int64_t)out_sample_rate * c->sample_rate);

currentAudioPts = audioTrack->pts = pts = calcPts(cAVIdx, audioTrack->stream, next_out_pts);

Check warning on line 1245 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp9&open=AZ7SyK8zlwJ5gPmbEJp9&pullRequest=3

Check warning on line 1245 in container/container_ffmpeg.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "pts" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK8zlwJ5gPmbEJp8&open=AZ7SyK8zlwJ5gPmbEJp8&pullRequest=3
out_samples = swr_convert(swr, &output[0], out_samples, (const uint8_t **) &decoded_frame->data[0], in_samples);

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1894,6 +1903,18 @@
av_dict_set(&avio_opts, "reconnect_streamed", "1", 0);
}

/* HLS-only; persistent keep-alive + larger recv buffer upset
* low-bitrate icecast otherwise. */
if (strstr(filename, ".m3u"))
{
av_dict_set(&avio_opts, "recv_buffer_size", "4194304", 0);
av_dict_set(&avio_opts, "multiple_requests", "1", 0);
av_dict_set(&avio_opts, "live_start_index", "-3", 0);
av_dict_set(&avio_opts, "max_reload", "10", 0);
av_dict_set(&avio_opts, "http_persistent", "1", 0);
av_dict_set(&avio_opts, "http_multiple", "1", 0);
}

if( strncmp(filename, "http://127.0.0.1", 16) == 0 )
{
/* when using with ArchivCZSK, then indicate DRM support */
Expand All @@ -1903,6 +1924,21 @@

pavio_opts = &avio_opts;

/* Cap the probe for local files; avformat_open_input ignores the
* matching av_dict keys, so pre-allocate the context and set them
* directly. Network URIs keep the defaults. */
{
const int is_local = (strstr(filename, "://") == NULL)
|| (strncmp(filename, "file://", 7) == 0);
if (is_local) {
avContextTab[AVIdx] = avformat_alloc_context();
if (avContextTab[AVIdx]) {
avContextTab[AVIdx]->probesize = 10000000;
avContextTab[AVIdx]->max_analyze_duration = 3000000;
}
}
}

if ((err = avformat_open_input(&avContextTab[AVIdx], filename, fmt, pavio_opts)) != 0)
{
if (rtmp_proto_impl == 0 && //err == AVERROR_UNKNOWN &&
Expand Down
79 changes: 60 additions & 19 deletions main/exteplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
extern void aac_software_decoder_set(const int32_t val);
extern void aac_latm_software_decoder_set(const int32_t val);
extern void dts_software_decoder_set(const int32_t val);
extern void truehd_software_decoder_set(const int32_t val);
extern void wma_software_decoder_set(const int32_t val);
extern void ac3_software_decoder_set(const int32_t val);
extern void eac3_software_decoder_set(const int32_t val);
Expand Down Expand Up @@ -326,7 +327,7 @@
ffmpeg_av_dict_set("cenc_decryption_audio_key", str+2, 0);
break;
}
start = end = -1;

Check warning on line 330 in main/exteplayer.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract the assignment to "end" from this expression.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK7LlwJ5gPmbEJpy&open=AZ7SyK7LlwJ5gPmbEJpy&pullRequest=3
}
idx++;
}
Expand Down Expand Up @@ -890,24 +891,56 @@
}

#ifdef HAVE_DREAMNEXTGEN
/* DreamNextGen (AMlogic dreamone/dreamtwo) has no kernel ES audio
* decoder — force every codec through libavcodec → libswresample so
* container_ffmpeg.c always emits A_IPCM (S16 PCM) into our ALSA
* sink in output/dream_audio.c.
*
* Must run AFTER ParseParams: serviceapp invokes us with `-a 0 -n 0`
* etc. which would otherwise clear the flags right after we set them. */
printf("DreamAudio: forcing software decode for AAC/AC3/EAC3/DTS/MP3/WMA/Vorbis/Opus/AMR\n");
aac_software_decoder_set(1);
aac_latm_software_decoder_set(1);
ac3_software_decoder_set(1);
eac3_software_decoder_set(1);
dts_software_decoder_set(1);
mp3_software_decoder_set(1);
wma_software_decoder_set(1);
vorbis_software_decoder_set(1);
opus_software_decoder_set(1);
amr_software_decoder_set(1);
/* No kernel ES audio decoder: force SW decode for every codec except
* those the user opted into passthrough for. Must run after ParseParams
* (serviceapp's -a/-n args would otherwise clear the flags again). */
{
int pt_ac3 = 0, pt_eac3 = 0, pt_dts = 0, pt_truehd = 0;

Check warning on line 898 in main/exteplayer.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define each identifier in a dedicated statement.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK7LlwJ5gPmbEJp0&open=AZ7SyK7LlwJ5gPmbEJp0&pullRequest=3
FILE *f = fopen("/sys/class/audiodsp/digital_raw", "r");
int digital_raw = 0;
if (f) { if (fscanf(f, "%d", &digital_raw) != 1) digital_raw = 0; fclose(f); }

Check warning on line 901 in main/exteplayer.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This statement will not be executed conditionally.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK7LlwJ5gPmbEJp1&open=AZ7SyK7LlwJ5gPmbEJp1&pullRequest=3
if (digital_raw > 0) {
FILE *s = fopen("/etc/enigma2/settings", "r");
char eac3_val[64] = "passthrough"; /* default-on for EAC3 */
char dts_val[64] = ""; /* default-off for DTS */
char truehd_val[64] = ""; /* default-off for TrueHD */
if (s) {
char line[256];
while (fgets(line, sizeof(line), s)) {
if (strncmp(line, "config.av.transcodeac3plus=", 27) == 0) {

Check failure on line 910 in main/exteplayer.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK7LlwJ5gPmbEJpz&open=AZ7SyK7LlwJ5gPmbEJpz&pullRequest=3
char *nl = strchr(line, '\n'); if (nl) *nl = 0;
snprintf(eac3_val, sizeof(eac3_val), "%s", line + 27);
} else if (strncmp(line, "config.av.dtshd=", 16) == 0) {
char *nl = strchr(line, '\n'); if (nl) *nl = 0;
snprintf(dts_val, sizeof(dts_val), "%s", line + 16);
} else if (strncmp(line, "config.av.truehd=", 17) == 0) {
char *nl = strchr(line, '\n'); if (nl) *nl = 0;
snprintf(truehd_val, sizeof(truehd_val), "%s", line + 17);
}
}
fclose(s);
}
pt_ac3 = 1;
pt_eac3 = (strcmp(eac3_val, "passthrough") == 0
|| strcmp(eac3_val, "use_hdmi_caps") == 0);
pt_dts = (dts_val[0] && strcmp(dts_val, "downmix") != 0);
pt_truehd = (truehd_val[0] == 0 /* default: try passthrough */
|| strcmp(truehd_val, "downmix") != 0);
}
printf("DreamAudio: SW decode (passthrough: ac3=%d eac3=%d dts=%d truehd=%d)\n",
pt_ac3, pt_eac3, pt_dts, pt_truehd);
aac_software_decoder_set(1);
aac_latm_software_decoder_set(1);
if (!pt_ac3) ac3_software_decoder_set(1);
if (!pt_eac3) eac3_software_decoder_set(1);
if (!pt_dts) dts_software_decoder_set(1);
if (!pt_truehd) truehd_software_decoder_set(1);
mp3_software_decoder_set(1);
wma_software_decoder_set(1);
vorbis_software_decoder_set(1);
opus_software_decoder_set(1);
amr_software_decoder_set(1);
}
#endif

ffmpeg_av_dict_set("fake_last_subtitle", "1", 0);
Expand Down Expand Up @@ -970,7 +1003,15 @@
g_player->output->Command(g_player, OUTPUT_SET_BUFFER_SIZE, &linuxDvbBufferSizeMB);

g_player->manager->video->Command(g_player, MANAGER_REGISTER_UPDATED_TRACK_INFO, UpdateVideoTrack);
if (strncmp(playbackFiles.szFirstFile, "rtmp", 4) && strncmp(playbackFiles.szFirstFile, "ffrtmp", 4))
/* noprobe sets max_analyze_duration=1us so avformat_find_stream_info
* returns almost immediately. Fine for local files where SPS/PPS sit
* right in the first packet, fatal for HLS/DASH where codec params
* arrive in later segments — ffmpeg then reports "unspecified size"
* for h264 and the AML hw decoder gets no dimensions, no video. */
if (strncmp(playbackFiles.szFirstFile, "rtmp", 4) &&
strncmp(playbackFiles.szFirstFile, "ffrtmp", 6) &&
strncmp(playbackFiles.szFirstFile, "http://", 7) &&

Check warning on line 1013 in main/exteplayer.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using HTTP is insecure. Use HTTPS instead.

See more on https://sonarcloud.io/project/issues?id=oe-alliance_exteplayer3&issues=AZ7SyK7LlwJ5gPmbEJp2&open=AZ7SyK7LlwJ5gPmbEJp2&pullRequest=3
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
strncmp(playbackFiles.szFirstFile, "https://", 8))
{
g_player->playback->noprobe = 1;
}
Expand Down
Loading
Loading