[libdvdnav-devel] [Git][videolan/libdvdnav][master] add dvdnav_get_number_of_streams

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Mar 7 20:54:06 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdnav


Commits:
8d1e595a by Miguel Borges de Freitas at 2022-03-06T18:48:27+00:00
add dvdnav_get_number_of_streams

Allows to obtain the stream count provided its type (subtitles, audio)
for vts titles and dvdmenus

- - - - -


3 changed files:

- src/dvdnav.c
- src/dvdnav/dvd_types.h
- src/dvdnav/dvdnav.h


Changes:

=====================================
src/dvdnav.c
=====================================
@@ -1111,6 +1111,54 @@ int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) {
   return retval;
 }
 
+int8_t dvdnav_get_number_of_streams(dvdnav_t *this, dvdnav_stream_type_t stream_type) {
+
+  if (stream_type != DVD_SUBTITLE_STREAM && stream_type != DVD_AUDIO_STREAM) {
+    printerr("Invalid provided stream type");
+    return -1;
+  }
+
+  if (!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
+
+  pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return -1;
+  }
+
+  if (this->vm->state.domain != DVD_DOMAIN_VTSTitle &&
+      this->vm->state.domain != DVD_DOMAIN_VTSMenu)
+  {
+    printerr("Invalid domain provided");
+    pthread_mutex_unlock(&this->vm_lock);
+    return -1;
+  }
+
+  int8_t count = 0;
+  switch (stream_type) {
+  case DVD_SUBTITLE_STREAM:
+    for (int i = 0; i < 32; i++)
+    {
+      if (this->vm->state.pgc->subp_control[i] & (1<<31))
+        count++;
+    }
+    break;
+  case DVD_AUDIO_STREAM:
+    for (int i = 0; i < 8; i++)
+    {
+      if (this->vm->state.pgc->audio_control[i] & (1<<15))
+        count++;
+    }
+    break;
+  }
+  pthread_mutex_unlock(&this->vm_lock);
+  return count;
+}
+
 dvdnav_status_t dvdnav_get_audio_attr(dvdnav_t *this, uint8_t audio_num, audio_attr_t *audio_attr) {
   if(!this->started) {
     printerr("Virtual DVD machine not started.");


=====================================
src/dvdnav/dvd_types.h
=====================================
@@ -44,6 +44,15 @@ typedef enum {
   DVD_MENU_Part       = 7
 } DVDMenuID_t;
 
+/*
+ * Stream Types
+ * (see dvdnav_get_number_of_streams())
+ */
+typedef enum {
+  DVD_SUBTITLE_STREAM = 0,
+  DVD_AUDIO_STREAM    = 1
+} dvdnav_stream_type_t;
+
 /* Domain */
 typedef enum {
   DVD_DOMAIN_FirstPlay = 1,  /* First Play Domain */


=====================================
src/dvdnav/dvdnav.h
=====================================
@@ -673,6 +673,11 @@ int8_t dvdnav_get_active_spu_stream(dvdnav_t *self);
  */
 user_ops_t dvdnav_get_restrictions(dvdnav_t *self);
 
+/*
+ * Returns the number of streams provided its type (e.g. subtitles, audio, etc)
+ */
+int8_t dvdnav_get_number_of_streams(dvdnav_t *self, dvdnav_stream_type_t stream_type);
+
 
 /*********************************************************************
  * multiple angles                                                   *



View it on GitLab: https://code.videolan.org/videolan/libdvdnav/-/commit/8d1e595aa39e15fda408c83de9539658944ef42d

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/-/commit/8d1e595aa39e15fda408c83de9539658944ef42d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the libdvdnav-devel mailing list