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

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun May 8 17:19:28 UTC 2022



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


Commits:
e5425979 by Miguel Borges de Freitas at 2022-05-08T17:18:23+00:00
add dvdnav_set_active_stream

Provided the physical stream index and its type (audio or subtitles) set
it as active on the vm.

- - - - -


2 changed files:

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


Changes:

=====================================
src/dvdnav.c
=====================================
@@ -1252,6 +1252,57 @@ int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) {
   return retval;
 }
 
+dvdnav_status_t dvdnav_set_active_stream(dvdnav_t *this, uint8_t stream_num, dvdnav_stream_type_t stream_type) {
+   if (stream_type != DVD_SUBTITLE_STREAM && stream_type != DVD_AUDIO_STREAM) {
+    printerr("Invalid provided stream type");
+    return DVDNAV_STATUS_ERR;
+  }
+
+  if (!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return DVDNAV_STATUS_ERR;
+  }
+
+  pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  if (this->vm->state.domain != DVD_DOMAIN_VTSTitle &&
+      this->vm->state.domain != DVD_DOMAIN_VTSMenu)
+  {
+    printerr("Invalid active domain");
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  switch (stream_type) {
+  case DVD_SUBTITLE_STREAM:
+    if (stream_num >= 32 ||
+        !(this->vm->state.pgc->subp_control[stream_num] & (1 << 31))) {
+      printerr("Invalid stream index not allowed");
+      pthread_mutex_unlock(&this->vm_lock);
+      return DVDNAV_STATUS_ERR;
+    }
+    // set state without changing the current visibility
+    this->vm->state.SPST_REG = stream_num | (this->vm->state.SPST_REG & 0x40);
+    break;
+  case DVD_AUDIO_STREAM:
+    if (stream_num >= 8 ||
+        !(this->vm->state.pgc->audio_control[stream_num] & (1 << 15))) {
+      printerr("Invalid stream index not allowed");
+      pthread_mutex_unlock(&this->vm_lock);
+      return DVDNAV_STATUS_ERR;
+    }
+    this->vm->state.AST_REG = stream_num;
+    break;
+  }
+  pthread_mutex_unlock(&this->vm_lock);
+  return DVDNAV_STATUS_OK;
+}
+
 dvdnav_status_t dvdnav_toggle_spu_stream(dvdnav_t *this, uint8_t visibility) {
   if(!this->started) {
     printerr("Virtual DVD machine not started.");


=====================================
src/dvdnav/dvdnav.h
=====================================
@@ -703,6 +703,14 @@ int8_t dvdnav_get_number_of_streams(dvdnav_t *self, dvdnav_stream_type_t stream_
  */
 dvdnav_status_t dvdnav_toggle_spu_stream(dvdnav_t *self, uint8_t visibility);
 
+/*
+ * Set the given stream id and stream type as active
+ * stream_num - the physical index of the stream
+ * stream_type - the stream type (audio or subtitles)
+ */
+dvdnav_status_t dvdnav_set_active_stream(dvdnav_t *self, uint8_t stream_num,
+                                        dvdnav_stream_type_t stream_type);
+
 /*********************************************************************
  * multiple angles                                                   *
  *********************************************************************/



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

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/-/commit/e54259797d69c73b909a106eec1957c795b334a3
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