[libbluray-devel] improve error resilence and logging
hpi1
git at videolan.org
Mon Apr 14 10:58:06 CEST 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Apr 14 10:48:12 2014 +0300| [c94349fc32ac49695a2cda1d6103594eade2e4b2] | committer: hpi1
improve error resilence and logging
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=c94349fc32ac49695a2cda1d6103594eade2e4b2
---
src/libbluray/bdnav/clpi_parse.c | 10 ++++---
src/libbluray/bdnav/index_parse.c | 54 +++++++++++++++++++++++++++++--------
src/libbluray/bdnav/mpls_parse.c | 11 +++++---
src/libbluray/hdmv/hdmv_vm.c | 6 ++---
src/libbluray/hdmv/mobj_parse.c | 8 ++++--
5 files changed, 67 insertions(+), 22 deletions(-)
diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
index b8e956d..d87628c 100644
--- a/src/libbluray/bdnav/clpi_parse.c
+++ b/src/libbluray/bdnav/clpi_parse.c
@@ -18,11 +18,14 @@
* <http://www.gnu.org/licenses/>.
*/
-#include "util/macro.h"
+#include "clpi_parse.h"
+
+#include "extdata_parse.h"
+
#include "file/file.h"
#include "util/bits.h"
-#include "extdata_parse.h"
-#include "clpi_parse.h"
+#include "util/macro.h"
+#include "util/logging.h"
#include <stdlib.h>
#include <string.h>
@@ -598,6 +601,7 @@ static int _parse_clpi_extension(BITSTREAM *bits, int id1, int id2, void *handle
}
}
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "_parse_clpi_extension(): unhandled extension %d.%d\n", id1, id2);
return 0;
}
diff --git a/src/libbluray/bdnav/index_parse.c b/src/libbluray/bdnav/index_parse.c
index f07c261..d76a9c9 100644
--- a/src/libbluray/bdnav/index_parse.c
+++ b/src/libbluray/bdnav/index_parse.c
@@ -17,12 +17,13 @@
* <http://www.gnu.org/licenses/>.
*/
+#include "index_parse.h"
+
#include "file/file.h"
#include "util/bits.h"
#include "util/logging.h"
#include "util/macro.h"
#include "util/strutl.h"
-#include "index_parse.h"
#include <stdlib.h>
#include <string.h>
@@ -35,6 +36,12 @@ static int _parse_hdmv_obj(BITSTREAM *bs, INDX_HDMV_OBJ *hdmv)
hdmv->id_ref = bs_read(bs, 16);
bs_skip(bs, 32);
+ if (hdmv->playback_type != indx_hdmv_playback_type_movie &&
+ hdmv->playback_type != indx_hdmv_playback_type_interactive) {
+
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: invalid HDMV playback type %d\n", hdmv->playback_type);
+ }
+
return 1;
}
@@ -46,6 +53,12 @@ static int _parse_bdj_obj(BITSTREAM *bs, INDX_BDJ_OBJ *bdj)
bdj->name[5] = 0;
bs_skip(bs, 8);
+ if (bdj->playback_type != indx_bdj_playback_type_movie &&
+ bdj->playback_type != indx_bdj_playback_type_interactive) {
+
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: invalid BD-J playback type %d\n", bdj->playback_type);
+ }
+
return 1;
}
@@ -54,11 +67,16 @@ static int _parse_playback_obj(BITSTREAM *bs, INDX_PLAY_ITEM *obj)
obj->object_type = bs_read(bs, 2);
bs_skip(bs, 30);
- if (obj->object_type == 1) {
- return _parse_hdmv_obj(bs, &obj->hdmv);
- } else {
- return _parse_bdj_obj(bs, &obj->bdj);
+ switch (obj->object_type) {
+ case indx_object_type_hdmv:
+ return _parse_hdmv_obj(bs, &obj->hdmv);
+
+ case indx_object_type_bdj:
+ return _parse_bdj_obj(bs, &obj->bdj);
}
+
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: unknown object type %d\n", obj->object_type);
+ return 0;
}
static int _parse_index(BITSTREAM *bs, INDX_ROOT *index)
@@ -89,10 +107,20 @@ static int _parse_index(BITSTREAM *bs, INDX_ROOT *index)
index->titles[i].access_type = bs_read(bs, 2);
bs_skip(bs, 28);
- if (index->titles[i].object_type == 1) {
- _parse_hdmv_obj(bs, &index->titles[i].hdmv);
- } else {
- _parse_bdj_obj(bs, &index->titles[i].bdj);
+ switch (index->titles[i].object_type) {
+ case indx_object_type_hdmv:
+ if (!_parse_hdmv_obj(bs, &index->titles[i].hdmv))
+ return 0;
+ break;
+
+ case indx_object_type_bdj:
+ if (!_parse_bdj_obj(bs, &index->titles[i].bdj))
+ return 0;
+ break;
+
+ default:
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: unknown object type %d (#%d)\n", index->titles[i].object_type, i);
+ return 0;
}
}
@@ -140,8 +168,8 @@ static int _parse_header(BITSTREAM *bs, int *index_start, int *extension_data_st
if (sig1 != INDX_SIG1 ||
(sig2 != INDX_SIG2A &&
sig2 != INDX_SIG2B)) {
- BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv failed signature match: expected INDX0100 got %8.8s\n", bs->buf);
- return 0;
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv failed signature match: expected INDX0100 got %8.8s\n", bs->buf);
+ return 0;
}
*index_start = bs_read(bs, 32);
@@ -172,6 +200,10 @@ static INDX_ROOT *_indx_parse(const char *file_name)
goto error;
}
+ if (extension_data_start) {
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: unknown extension data at %d\n", extension_data_start);
+ }
+
if (!_parse_app_info(&bs, &index->app_info)) {
BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: error parsing app info\n");
goto error;
diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index dd8ce9f..7db2e08 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -18,11 +18,14 @@
* <http://www.gnu.org/licenses/>.
*/
-#include "util/macro.h"
+#include "mpls_parse.h"
+
+#include "extdata_parse.h"
+
#include "file/file.h"
#include "util/bits.h"
-#include "extdata_parse.h"
-#include "mpls_parse.h"
+#include "util/logging.h"
+#include "util/macro.h"
#include <stdlib.h>
#include <string.h>
@@ -897,6 +900,8 @@ _parse_mpls_extension(BITSTREAM *bits, int id1, int id2, void *handle)
}
}
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "_parse_mpls_extension(): unhandled extension %d.%d\n", id1, id2);
+
return 0;
}
diff --git a/src/libbluray/hdmv/hdmv_vm.c b/src/libbluray/hdmv/hdmv_vm.c
index 60e5a77..ee11870 100644
--- a/src/libbluray/hdmv/hdmv_vm.c
+++ b/src/libbluray/hdmv/hdmv_vm.c
@@ -516,14 +516,14 @@ static int _call_title(HDMV_VM *p, uint32_t title)
static int _play_at(HDMV_VM *p, int playlist, int playitem, int playmark)
{
if (p->ig_object && playlist >= 0) {
- BD_DEBUG(DBG_HDMV, "play_at(list %d, item %d, mark %d): "
+ BD_DEBUG(DBG_HDMV | DBG_CRIT, "play_at(list %d, item %d, mark %d): "
"playlist change not allowed in interactive composition\n",
playlist, playitem, playmark);
return -1;
}
if (!p->ig_object && playlist < 0) {
- BD_DEBUG(DBG_HDMV, "play_at(list %d, item %d, mark %d): "
+ BD_DEBUG(DBG_HDMV | DBG_CRIT, "play_at(list %d, item %d, mark %d): "
"playlist not given in movie object (link commands not allowed)\n",
playlist, playitem, playmark);
return -1;
@@ -551,7 +551,7 @@ static int _play_at(HDMV_VM *p, int playlist, int playitem, int playmark)
static int _play_stop(HDMV_VM *p)
{
if (!p->ig_object) {
- BD_DEBUG(DBG_HDMV, "_play_stop() not allowed in movie object\n");
+ BD_DEBUG(DBG_HDMV | DBG_CRIT, "_play_stop() not allowed in movie object\n");
return -1;
}
diff --git a/src/libbluray/hdmv/mobj_parse.c b/src/libbluray/hdmv/mobj_parse.c
index dafaf6c..ae30398 100644
--- a/src/libbluray/hdmv/mobj_parse.c
+++ b/src/libbluray/hdmv/mobj_parse.c
@@ -17,14 +17,14 @@
* <http://www.gnu.org/licenses/>.
*/
+#include "mobj_parse.h"
+
#include "file/file.h"
#include "util/bits.h"
#include "util/logging.h"
#include "util/macro.h"
#include "util/strutl.h"
-#include "mobj_parse.h"
-
#include <stdlib.h>
#include <string.h>
@@ -142,6 +142,10 @@ static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
goto error;
}
+ if (extension_data_start) {
+ BD_DEBUG(DBG_NAV | DBG_CRIT, "MovieObject.bdmv: unknown extension data at %d\n", extension_data_start);
+ }
+
bs_seek_byte(&bs, 40);
data_len = bs_read(&bs, 32);
More information about the libbluray-devel
mailing list