VideoCapabilities.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // <copyright file="VideoCapabilities.cs" company="Google Inc.">
  2. // Copyright (C) 2016 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. namespace GooglePlayGames.BasicApi.Video
  17. {
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using GooglePlayGames.OurUtils;
  21. /// <summary>
  22. /// Represents the video recording capabilities.
  23. /// </summary>
  24. public class VideoCapabilities
  25. {
  26. private bool mIsCameraSupported;
  27. private bool mIsMicSupported;
  28. private bool mIsWriteStorageSupported;
  29. private bool[] mCaptureModesSupported;
  30. private bool[] mQualityLevelsSupported;
  31. internal VideoCapabilities(bool isCameraSupported, bool isMicSupported, bool isWriteStorageSupported,
  32. bool[] captureModesSupported, bool[] qualityLevelsSupported)
  33. {
  34. mIsCameraSupported = isCameraSupported;
  35. mIsMicSupported = isMicSupported;
  36. mIsWriteStorageSupported = isWriteStorageSupported;
  37. mCaptureModesSupported = captureModesSupported;
  38. mQualityLevelsSupported = qualityLevelsSupported;
  39. }
  40. /// <summary>Returns whether the device has a front-facing camera and we can use it.</summary>
  41. public bool IsCameraSupported
  42. {
  43. get
  44. {
  45. return mIsCameraSupported;
  46. }
  47. }
  48. /// <summary>Returns whether the device has a microphone and we can use it.</summary>
  49. public bool IsMicSupported
  50. {
  51. get
  52. {
  53. return mIsMicSupported;
  54. }
  55. }
  56. /// <summary>Returns whether the device has an external storage device and we can use it.</summary>
  57. public bool IsWriteStorageSupported
  58. {
  59. get
  60. {
  61. return mIsWriteStorageSupported;
  62. }
  63. }
  64. /// <summary>Returns whether the device supports the given capture mode.</summary>
  65. public bool SupportsCaptureMode(VideoCaptureMode captureMode)
  66. {
  67. if (captureMode != VideoCaptureMode.Unknown)
  68. {
  69. return mCaptureModesSupported[(int)captureMode];
  70. }
  71. else
  72. {
  73. Logger.w("SupportsCaptureMode called with an unknown captureMode.");
  74. return false;
  75. }
  76. }
  77. /// <summary>Returns whether the device supports the given quality level.</summary>
  78. public bool SupportsQualityLevel(VideoQualityLevel qualityLevel)
  79. {
  80. if (qualityLevel != VideoQualityLevel.Unknown)
  81. {
  82. return mQualityLevelsSupported[(int)qualityLevel];
  83. }
  84. else
  85. {
  86. Logger.w("SupportsCaptureMode called with an unknown qualityLevel.");
  87. return false;
  88. }
  89. }
  90. public override string ToString()
  91. {
  92. return string.Format("[VideoCapabilities: mIsCameraSupported={0}, mIsMicSupported={1}, mIsWriteStorageSupported={2}, " +
  93. "mCaptureModesSupported={3}, mQualityLevelsSupported={4}]",
  94. mIsCameraSupported,
  95. mIsMicSupported,
  96. mIsWriteStorageSupported,
  97. string.Join(",", mCaptureModesSupported.Select(p => p.ToString()).ToArray()),
  98. string.Join(",", mQualityLevelsSupported.Select(p => p.ToString()).ToArray()));
  99. }
  100. }
  101. }