[totem-pl-parser] disc: Add support for detecting Blu-ray discs



commit 2ea7afe2b6d403e8c5abdc3e4541adfd665301f2
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 21 18:45:19 2014 +0100

    disc: Add support for detecting Blu-ray discs

 plparse/totem-disc.c |   45 ++++++++++++++++++++++++++++++++++++++++++---
 plparse/totem-disc.h |    4 +++-
 2 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/plparse/totem-disc.c b/plparse/totem-disc.c
index e78f635..dba9f27 100644
--- a/plparse/totem-disc.c
+++ b/plparse/totem-disc.c
@@ -305,6 +305,11 @@ cd_cache_check_archive (CdCache *cache,
       content_types[0] = "x-content/video-svcd";
       cache->content_types = g_strdupv ((gchar**) content_types);
       break;
+    } else if (g_ascii_strcasecmp (name, "BDAV") == 0 ||
+               g_ascii_strcasecmp (name, "BDMV") == 0) {
+      content_types[0] = "x-content/video-bluray";
+      cache->content_types = g_strdupv ((gchar**) content_types);
+      break;
     }
     archive_read_data_skip(a);
   }
@@ -638,6 +643,22 @@ cd_cache_disc_is_dvd (CdCache *cache,
   return MEDIA_TYPE_DATA;
 }
 
+static TotemDiscMediaType
+cd_cache_disc_is_bd (CdCache *cache,
+                    GError **error)
+{
+  /* open disc, check capabilities and open mount */
+  if (!cd_cache_open_device (cache, error))
+    return MEDIA_TYPE_ERROR;
+  if (!cd_cache_open_mountpoint (cache, error))
+    return MEDIA_TYPE_ERROR;
+
+  if (cd_cache_has_content_type (cache, "x-content/video-bluray") != FALSE)
+    return MEDIA_TYPE_BD;
+
+  return MEDIA_TYPE_DATA;
+}
+
 /**
  * totem_cd_mrl_from_type:
  * @scheme: a scheme (e.g. "dvd")
@@ -712,7 +733,8 @@ totem_cd_detect_type_from_dir (const char *dir, char **mrl, GError **error)
   if (!(cache = cd_cache_new (dir, error)))
     return MEDIA_TYPE_ERROR;
   if ((type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA &&
-      (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) {
+      (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA &&
+      (type = cd_cache_disc_is_bd (cache, error)) == MEDIA_TYPE_DATA) {
     /* is it the directory itself? */
     char *parent;
 
@@ -726,7 +748,8 @@ totem_cd_detect_type_from_dir (const char *dir, char **mrl, GError **error)
     if (!cache)
       return MEDIA_TYPE_ERROR;
     if ((type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA &&
-       (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) {
+       (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA &&
+       (type = cd_cache_disc_is_bd (cache, error)) == MEDIA_TYPE_DATA) {
       /* crap, nothing found */
       cd_cache_free (cache);
       return type;
@@ -742,6 +765,8 @@ totem_cd_detect_type_from_dir (const char *dir, char **mrl, GError **error)
     *mrl = totem_cd_mrl_from_type ("dvd", cache->mountpoint ? cache->mountpoint : cache->device);
   } else if (type == MEDIA_TYPE_VCD) {
     *mrl = totem_cd_mrl_from_type ("vcd", cache->mountpoint);
+  } else if (type == MEDIA_TYPE_BD) {
+    *mrl = totem_cd_mrl_from_type ("bluray", cache->mountpoint);
   }
 
   cd_cache_free (cache);
@@ -787,7 +812,8 @@ totem_cd_detect_type_with_url (const char *device,
 
   if ((type == MEDIA_TYPE_DATA || type == MEDIA_TYPE_ERROR) &&
       (type = cd_cache_disc_is_vcd (cache, error)) == MEDIA_TYPE_DATA &&
-      (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA) {
+      (type = cd_cache_disc_is_dvd (cache, error)) == MEDIA_TYPE_DATA &&
+      (type = cd_cache_disc_is_bd (cache, error)) == MEDIA_TYPE_DATA) {
     /* crap, nothing found */
   }
 
@@ -830,6 +856,17 @@ totem_cd_detect_type_with_url (const char *device,
        *mrl = totem_cd_mrl_from_type ("cdda", dev);
     }
     break;
+  case MEDIA_TYPE_BD:
+    {
+      const char *str;
+
+      if (!cache->is_iso)
+       str = cache->mountpoint ? cache->mountpoint : device;
+      else
+       str = cache->device;
+      *mrl = totem_cd_mrl_from_type ("bluray", str);
+    }
+    break;
   case MEDIA_TYPE_DATA:
     if (cache->is_iso) {
       type = MEDIA_TYPE_ERROR;
@@ -914,6 +951,8 @@ totem_cd_get_human_readable_name (TotemDiscMediaType type)
     return N_("DVD");
   case MEDIA_TYPE_DVB:
     return N_("Digital Television");
+  case MEDIA_TYPE_BD:
+    return N_("Blu-ray");
   case MEDIA_TYPE_ERROR:
   case MEDIA_TYPE_DATA:
   default:
diff --git a/plparse/totem-disc.h b/plparse/totem-disc.h
index b5b72e5..ccc755e 100644
--- a/plparse/totem-disc.h
+++ b/plparse/totem-disc.h
@@ -35,6 +35,7 @@ G_BEGIN_DECLS
  * @MEDIA_TYPE_VCD: video CD
  * @MEDIA_TYPE_DVD: video DVD
  * @MEDIA_TYPE_DVB: digital television
+ * @MEDIA_TYPE_BD: video Blu-Ray
  *
  * Gives the media type of a disc, or %MEDIA_TYPE_ERROR if the media type
  * could not be determined.
@@ -45,7 +46,8 @@ typedef enum {
   MEDIA_TYPE_CDDA,
   MEDIA_TYPE_VCD,
   MEDIA_TYPE_DVD,
-  MEDIA_TYPE_DVB
+  MEDIA_TYPE_DVB,
+  MEDIA_TYPE_BD
 } TotemDiscMediaType;
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]