summaryrefslogtreecommitdiff
path: root/src/liana
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-05 20:42:51 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-05 20:42:51 -0500
commit240ee00a9177d6ff80ef48ce577b06d93cb554c2 (patch)
tree0f759e7a9fe28ae0d21a54917ca893131aef9dda /src/liana
parent9362f2223038b59954c8402963932b4eb77030be (diff)
downloadcamu-240ee00a9177d6ff80ef48ce577b06d93cb554c2.tar.gz
camu-240ee00a9177d6ff80ef48ce577b06d93cb554c2.tar.bz2
camu-240ee00a9177d6ff80ef48ce577b06d93cb554c2.zip
Temp fix for stream selection, compile fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/liana')
-rw-r--r--src/liana/client.c48
-rw-r--r--src/liana/handlers/codec_client.c2
2 files changed, 33 insertions, 17 deletions
diff --git a/src/liana/client.c b/src/liana/client.c
index daf32b0..b6635af 100644
--- a/src/liana/client.c
+++ b/src/liana/client.c
@@ -22,6 +22,12 @@ static void parse_info_packet(struct lia_client *client, struct nn_packet *packe
str liana;
nn_packet_read_str(packet, &liana);
client->duration = nn_packet_read_u64(packet);
+ // TODO: This should be made into 2 steps.
+ // 1. Collect all streams into an array
+ // 2. Perform selection based on prefrences.
+ bool have_audio = false;
+ bool have_video = false;
+ bool have_subs = false;
u32 count = nn_packet_read_u32(packet);
for (u32 i = 0; i < count; i++) {
u8 mode = nn_packet_read_u8(packet);
@@ -52,37 +58,42 @@ static void parse_info_packet(struct lia_client *client, struct nn_packet *packe
}
#ifdef CAMU_HAVE_FFMPEG
case CAMU_FFMPEG_COMPAT: {
+ enum AVCodecID codec_id = nn_packet_read_av_codec_id(packet);
+ const AVCodec *codec = avcodec_find_decoder(codec_id);
+ AVFormatContext *format_context = avformat_alloc_context();
+ AVStream *stream = nn_packet_read_av_stream(format_context, codec, packet);
switch (type) {
case CAMU_STREAM_AUDIO:
+ if (have_audio) {
+ goto skip;
+ }
client->mask |= 1 << index;
+ have_audio = true;
break;
case CAMU_STREAM_VIDEO:
+ if (have_video) {
+ goto skip;
+ }
client->mask |= 1 << index;
+ have_video = true;
break;
case CAMU_STREAM_SUBTITLE:
+ if (have_subs || codec_id != AV_CODEC_ID_ASS) {
+ goto skip;
+ }
client->mask |= 1 << index;
+ have_subs = true;
break;
- case CAMU_STREAM_ATTACHMENT:
- // Assume all the data we need is in the AVStream object.
- break;
- default:
- continue;
- }
- enum AVCodecID codec_id = nn_packet_read_av_codec_id(packet);
- const AVCodec *codec = avcodec_find_decoder(codec_id);
- AVFormatContext *format_context = avformat_alloc_context();
- AVStream *stream = nn_packet_read_av_stream(format_context, codec, packet);
- if (type == CAMU_STREAM_SUBTITLE && codec_id != AV_CODEC_ID_ASS) {
- client->mask &= ~(1 << index);
- continue;
- }
- if (type == CAMU_STREAM_ATTACHMENT) {
+ case CAMU_STREAM_ATTACHMENT: {
struct camu_codec_stream attachment;
attachment.type = CAMU_STREAM_ATTACHMENT;
attachment.av.stream = stream;
client->callback(client->userdata, LIANA_CLIENT_CONFIGURE, &attachment, track);
- avformat_free_context(format_context);
- continue;
+ // Assume all the data we need is in the AVStream object.
+ // fallthrough
+ }
+ default:
+ goto skip;
}
track = al_alloc_object(struct lia_vcr_track);
track->stream.av.format_context = format_context;
@@ -95,6 +106,9 @@ static void parse_info_packet(struct lia_client *client, struct nn_packet *packe
fmt->channel_count = stream->codecpar->ch_layout.nb_channels;
}
break;
+skip:
+ avformat_free_context(format_context);
+ continue;
}
#endif
}
diff --git a/src/liana/handlers/codec_client.c b/src/liana/handlers/codec_client.c
index 2492533..0aef69f 100644
--- a/src/liana/handlers/codec_client.c
+++ b/src/liana/handlers/codec_client.c
@@ -65,9 +65,11 @@ static bool codec_client_handle_packet(struct lia_client_handler *handler, struc
case CAMU_NORMAL:
codec->dec->push(codec->dec, NULL);
break;
+#ifdef CAMU_HAVE_FFMPEG
case CAMU_FFMPEG_COMPAT:
codec->dec->push_av_packet(codec->dec, NULL);
break;
+#endif
}
// process() could still error.
s32 ret = codec->dec->process(codec->dec);