device_info_fake.cc (1924B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "device_info_fake.h" 8 9 #include <string.h> 10 11 namespace webrtc::videocapturemodule { 12 13 int32_t DeviceInfoFake::GetDeviceName( 14 uint32_t aDeviceNumber, char* aDeviceNameUTF8, uint32_t aDeviceNameLength, 15 char* aDeviceUniqueIdUTF8, uint32_t aDeviceUniqueIdUTF8Length, 16 char* aProductUniqueIdUTF8, uint32_t aProductUniqueIdUTF8Length, 17 pid_t* aPid, bool* deviceIsPlaceholder) { 18 if (aDeviceNumber != 0) { 19 return -1; 20 } 21 22 strncpy(aDeviceNameUTF8, kName, aDeviceNameLength - 1); 23 aDeviceNameUTF8[aDeviceNameLength - 1] = '\0'; 24 25 strncpy(aDeviceUniqueIdUTF8, kId, aDeviceUniqueIdUTF8Length - 1); 26 aDeviceUniqueIdUTF8[aDeviceUniqueIdUTF8Length - 1] = '\0'; 27 28 return 0; 29 } 30 31 int32_t DeviceInfoFake::NumberOfCapabilities(const char* aDeviceUniqueIdUTF8) { 32 if (strcmp(aDeviceUniqueIdUTF8, kId) == 0) { 33 return 2; 34 } 35 return 0; 36 } 37 38 int32_t DeviceInfoFake::GetCapability(const char* aDeviceUniqueIdUTF8, 39 const uint32_t aDeviceCapabilityNumber, 40 VideoCaptureCapability& aCapability) { 41 if (strcmp(aDeviceUniqueIdUTF8, kId) != 0) { 42 return -1; 43 } 44 45 switch (aDeviceCapabilityNumber) { 46 case 0: 47 aCapability.width = 640; 48 aCapability.height = 480; 49 aCapability.maxFPS = 30; 50 aCapability.videoType = VideoType::kI420; 51 return 0; 52 case 1: 53 aCapability.width = 1280; 54 aCapability.height = 720; 55 aCapability.maxFPS = 10; 56 aCapability.videoType = VideoType::kI420; 57 return 0; 58 default: 59 return -1; 60 } 61 } 62 } // namespace webrtc::videocapturemodule