VideoCapabilities.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 { return mIsCameraSupported; }
  44. }
  45. /// <summary>Returns whether the device has a microphone and we can use it.</summary>
  46. public bool IsMicSupported
  47. {
  48. get { return mIsMicSupported; }
  49. }
  50. /// <summary>Returns whether the device has an external storage device and we can use it.</summary>
  51. public bool IsWriteStorageSupported
  52. {
  53. get { return mIsWriteStorageSupported; }
  54. }
  55. /// <summary>Returns whether the device supports the given capture mode.</summary>
  56. public bool SupportsCaptureMode(VideoCaptureMode captureMode)
  57. {
  58. if (captureMode != VideoCaptureMode.Unknown)
  59. {
  60. return mCaptureModesSupported[(int) captureMode];
  61. }
  62. else
  63. {
  64. Logger.w("SupportsCaptureMode called with an unknown captureMode.");
  65. return false;
  66. }
  67. }
  68. /// <summary>Returns whether the device supports the given quality level.</summary>
  69. public bool SupportsQualityLevel(VideoQualityLevel qualityLevel)
  70. {
  71. if (qualityLevel != VideoQualityLevel.Unknown)
  72. {
  73. return mQualityLevelsSupported[(int) qualityLevel];
  74. }
  75. else
  76. {
  77. Logger.w("SupportsCaptureMode called with an unknown qualityLevel.");
  78. return false;
  79. }
  80. }
  81. public override string ToString()
  82. {
  83. return string.Format(
  84. "[VideoCapabilities: mIsCameraSupported={0}, mIsMicSupported={1}, mIsWriteStorageSupported={2}, " +
  85. "mCaptureModesSupported={3}, mQualityLevelsSupported={4}]",
  86. mIsCameraSupported,
  87. mIsMicSupported,
  88. mIsWriteStorageSupported,
  89. string.Join(",", mCaptureModesSupported.Select(p => p.ToString()).ToArray()),
  90. string.Join(",", mQualityLevelsSupported.Select(p => p.ToString()).ToArray()));
  91. }
  92. }
  93. }