123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System;
- namespace Agora.Rtc
- {
- public sealed class VideoDeviceManager : IVideoDeviceManager
- {
- private IRtcEngine _rtcEngineInstance = null;
- private VideoDeviceManagerImpl _videoDeviecManagerImpl = null;
- private const int ErrorCode = -7;
- private VideoDeviceManager(IRtcEngine rtcEngine, VideoDeviceManagerImpl impl)
- {
- _rtcEngineInstance = rtcEngine;
- _videoDeviecManagerImpl = impl;
- }
- ~VideoDeviceManager()
- {
- _rtcEngineInstance = null;
- }
- private static IVideoDeviceManager instance = null;
- public static IVideoDeviceManager Instance
- {
- get
- {
- return instance;
- }
- }
- public override DeviceInfo[] EnumerateVideoDevices()
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return null;
- }
- return _videoDeviecManagerImpl.EnumerateVideoDevices();
- }
- public override int SetDevice(string deviceIdUTF8)
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.SetDevice(deviceIdUTF8);
- }
- public override int GetDevice(ref string deviceIdUTF8)
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.GetDevice(ref deviceIdUTF8);
- }
- public override int StartDeviceTest(IntPtr hwnd)
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.StartDeviceTest(hwnd);
- }
- public override int StopDeviceTest()
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.StopDeviceTest();
- }
- public override int GetCapability(string deviceIdUTF8, uint deviceCapabilityNumber, out VideoFormat capability)
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- capability = new VideoFormat();
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.GetCapability(deviceIdUTF8, deviceCapabilityNumber, out capability);
- }
- public override int NumberOfCapabilities(string deviceIdUTF8)
- {
- if (_rtcEngineInstance == null || _videoDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _videoDeviecManagerImpl.NumberOfCapabilities(deviceIdUTF8);
- }
- internal static IVideoDeviceManager GetInstance(IRtcEngine rtcEngine, VideoDeviceManagerImpl impl)
- {
- return instance ?? (instance = new VideoDeviceManager(rtcEngine, impl));
- }
- internal static void ReleaseInstance()
- {
- instance = null;
- }
- }
- }
|