#88 reduce code duplication in metadata.c

open
5
2014-08-15
2012-08-22
Lukas Jirkovsky
No

This patch improves video metadata handling a bit, while it also reduces some code duplication. It is closely related my previous question [1] on the forum. I hope it's useful.

Patch description
-----------------
The current code works like this:
1. check whether the container is one of the possibly supported, but non-DLNA compliant containers and fill mime type
2. a) if it's one of these non-compliant containers, jump to an end
b) if it's not one of these, run the DLNA parsing code and do the same check as in 1. to fill mime type (except the jump)

The patched code works like this:
1. check whether the container is one of the DLNA-compliant containers (ASF, MP4 etc.)
2. a) if it's DLNA compliant, run the DLNA parsing code
b) otherwise jump to 3.
3. fill mime type (using same check as in 1. in the current code)

Why I think it's an improvement
-------------------------------
The check in point 1. in the current code may wrongly determine container as being DLNA-compliant. Eg. if the ctx->iformat->name was "bink", it would run the DLNA parsing code instead of jumping to video_no_dlna label. The other improvement is that the code from point 1. was duplicated in the DLNA parsing code.

[1] https://sourceforge.net/projects/minidlna/forums/forum/879957/topic/5460668

Discussion