UVCDevice.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //#define ENABLE_LOG
  2. /*
  3. * Copyright (c) 2014 - 2022 t_saki@serenegiant.com
  4. */
  5. using System;
  6. using System.Runtime.InteropServices;
  7. /*
  8. * THETA S vid:1482, pid:1001
  9. * THETA V vid:1482, pid:1002
  10. * THETA Z1 vid:1482, pid:1005
  11. */
  12. namespace Serenegiant.UVC
  13. {
  14. [Serializable]
  15. public class UVCDevice
  16. {
  17. public readonly Int32 id;
  18. public readonly int vid;
  19. public readonly int pid;
  20. public readonly int deviceClass;
  21. public readonly int deviceSubClass;
  22. public readonly int deviceProtocol;
  23. public readonly string name;
  24. public UVCDevice(IntPtr devicePtr) {
  25. id = GetId(devicePtr);
  26. vid = GetVendorId(devicePtr);
  27. pid = GetProductId(devicePtr);
  28. name = GetName(devicePtr);
  29. deviceClass = GetDeviceClass(devicePtr);
  30. deviceSubClass = GetDeviceSubClass(devicePtr);
  31. deviceProtocol = GetDeviceProtocol(devicePtr);
  32. }
  33. public override string ToString()
  34. {
  35. return $"{base.ToString()}(id={id},vid={vid},pid={pid},name={name},deviceClass={deviceClass},deviceSubClass={deviceSubClass},deviceProtocol={deviceProtocol})";
  36. }
  37. /**
  38. * Ricohの製品かどうか
  39. * @param info
  40. */
  41. public bool IsRicoh
  42. {
  43. get { return (vid == 1482); }
  44. }
  45. /**
  46. * THETA S/V/Z1のいずれかかどうか
  47. */
  48. public bool IsTHETA
  49. {
  50. get { return IsTHETA_S || IsTHETA_V || IsTHETA_Z1; }
  51. }
  52. /**
  53. * THETA Sかどうか
  54. */
  55. public bool IsTHETA_S
  56. {
  57. get { return (vid == 1482) && (pid == 10001); }
  58. }
  59. /**
  60. * THETA Vかどうか
  61. */
  62. public bool IsTHETA_V
  63. {
  64. // THETA Vからのpid=872はUVCでなくて動かないので注意(THETA側は静止画/動画モード)
  65. get { return (vid == 1482) && (pid == 10002); }
  66. }
  67. /**
  68. * THETA Z1かどうか
  69. * @param info
  70. */
  71. public bool IsTHETA_Z1
  72. {
  73. // THETA Z1からのpid=877はUVCではなくて動かないので注意(THETA側は静止画/動画モード)
  74. get { return (vid == 1482) && (pid == 10005); }
  75. }
  76. //--------------------------------------------------------------------------------
  77. // プラグインのインターフェース関数
  78. //--------------------------------------------------------------------------------
  79. /**
  80. * 機器idを取得(これだけはpublicにする)
  81. */
  82. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_id")]
  83. public static extern Int32 GetId(IntPtr devicePtr);
  84. /**
  85. * デバイスクラスを取得
  86. */
  87. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_device_class")]
  88. private static extern Byte GetDeviceClass(IntPtr devicePtr);
  89. /**
  90. * デバイスサブクラスを取得
  91. */
  92. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_device_sub_class")]
  93. private static extern Byte GetDeviceSubClass(IntPtr devicePtr);
  94. /**
  95. * デバイスプロトコルを取得
  96. */
  97. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_device_protocol")]
  98. private static extern Byte GetDeviceProtocol(IntPtr devicePtr);
  99. /**
  100. * ベンダーIDを取得
  101. */
  102. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_vendor_id")]
  103. private static extern UInt16 GetVendorId(IntPtr devicePtr);
  104. /**
  105. * プロダクトIDを取得
  106. */
  107. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_product_id")]
  108. private static extern UInt16 GetProductId(IntPtr devicePtr);
  109. /**
  110. * 機器名を取得
  111. */
  112. [DllImport("unityuvcplugin", EntryPoint = "DeviceInfo_get_name")]
  113. [return: MarshalAs(UnmanagedType.LPStr)]
  114. private static extern string GetName(IntPtr devicePtr);
  115. } // UVCDevice
  116. } // namespace Serenegiant.UVC