[libdvdnav-devel] [Git][videolan/libdvdnav][master] 2 commits: navigation: refactor getting title properties
Jean-Baptiste Kempf
gitlab at videolan.org
Wed Mar 4 10:29:25 CET 2020
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdnav
Commits:
4386224a by Francois Cartegnie at 2020-03-03T20:48:47+01:00
navigation: refactor getting title properties
- - - - -
de34b412 by Francois Cartegnie at 2020-03-03T20:48:47+01:00
add dvdnav_get_number_of_angles
- - - - -
2 changed files:
- src/dvdnav/dvdnav.h
- src/navigation.c
Changes:
=====================================
src/dvdnav/dvdnav.h
=====================================
@@ -271,6 +271,11 @@ dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *self, int32_t *titles);
*/
dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *self, int32_t title, int32_t *parts);
+/*
+ * Returns the number of angles for the given title.
+ */
+dvdnav_status_t dvdnav_get_number_of_angles(dvdnav_t *self, int32_t title, int32_t *angles);
+
/*
* Plays the specified title of the DVD from its beginning (that is: part 1).
*/
=====================================
src/navigation.c
=====================================
@@ -64,19 +64,38 @@ dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
return DVDNAV_STATUS_OK;
}
-dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
- if (!this->vm->vmgi) {
- printerr("Bad VM state.");
- return DVDNAV_STATUS_ERR;
- }
- if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
- printerr("Passed a title number out of range.");
- return DVDNAV_STATUS_ERR;
- }
+static dvdnav_status_t get_title_by_number(dvdnav_t *this, int32_t title,
+ title_info_t **pp_title)
+{
+ int32_t titlescount;
+ dvdnav_status_t status = dvdnav_get_number_of_titles(this, &titlescount);
+ if(status == DVDNAV_STATUS_OK)
+ {
+ if ((title < 1) || (title > titlescount)) {
+ printerr("Passed a title number out of range.");
+ status = DVDNAV_STATUS_ERR;
+ }
+ else {
+ *pp_title = &vm_get_vmgi(this->vm)->tt_srpt->title[title-1];
+ }
+ }
+ return status;
+}
- (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts;
+dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
+ title_info_t *info;
+ dvdnav_status_t status = get_title_by_number(this, title, &info);
+ if(status == DVDNAV_STATUS_OK)
+ (*parts) = info->nr_of_ptts;
+ return status;
+}
- return DVDNAV_STATUS_OK;
+dvdnav_status_t dvdnav_get_number_of_angles(dvdnav_t *this, int32_t title, int32_t *angles) {
+ title_info_t *info;
+ dvdnav_status_t status = get_title_by_number(this, title, &info);
+ if(status == DVDNAV_STATUS_OK)
+ (*angles) = info->nr_of_angles;
+ return status;
}
dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) {
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/-/compare/4a529d1f2586dbd157b15d24ddc3f7264093a4e3...de34b412ca0c040bac78cfd3448c99c9257b7422
--
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/-/compare/4a529d1f2586dbd157b15d24ddc3f7264093a4e3...de34b412ca0c040bac78cfd3448c99c9257b7422
You're receiving this email because of your account on code.videolan.org.
More information about the libdvdnav-devel
mailing list