The 25 days of C++mas - December 8 - A/V Capture Devices and Sensors

By: David Intersimone

Abstract: David I discusses C++Builder classes for identifying, managing and using the audio and video capture devices that are available on your target Windows and Mac computers

This is a copy of a blog post from David I's Sip from the Firehose blog. Click to blog post title below to see the original blog post and comments.

  The 25 days of C++mas - December 8 - A/V Capture Devices and Sensors

C++Builder XE3 includes classes for identifying, managing and using the audio and video capture devices that are available on your target Windows and Mac computers. Classes are also provided for identifying, managing and using any sensors that are available on your target Windows and Mac computers. In this blog post I show you how to use C++Builder XE3 and FireMonkey 2 (FM2) to list all of the A/V capture devices and sensors that are available on a computer.

On my MacBook Pro, the code will find several audio devices, and the built-in camera:

On my Samsung Slate series 7 running Windows 8 Professional, the following is the output from the program showing several A/V capture devices and several sensors:

As you can see from the application displays above, the main form contains two TButton, two TLabel and two TMemo components. The C++ code for the project’s button onClick event handler(s) source code is:


#pragma hdrstop

#include "MainUnit.h"
#include "FMX.Media.hpp"
#include "System.Sensors.hpp"
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm4 *Form4;
__fastcall TForm4::TForm4(TComponent* Owner)
	: TForm(Owner)
void __fastcall TForm4::Button1Click(TObject *Sender)
  // get list of found devices - if any
  int NumberOfDevices = TCaptureDeviceManager::Current->Count;
  Label1->Text = "Devices: "+IntToStr(NumberOfDevices);
  for (int i = 0; i < NumberOfDevices; i++) {
	  + ": "
	  + TCaptureDeviceManager::Current->Devices[i]->Name
	  + ". MediaType: "
	  + System::Typinfo::GetEnumName(
	  + ". State: "
	  + System::Typinfo::GetEnumName(
void __fastcall TForm4::Button2Click(TObject *Sender)
  // get list of found sensors - if any
  TSensorManager::Current->Active = true;
  int NumberOfSensors = TSensorManager::Current->Count;
  Label2->Text = "Sensors: "+IntToStr(NumberOfSensors);
  for (int i = 0; i < NumberOfSensors;i++) {
	  + ": "
	  + TSensorManager::Current->Sensors[i]->Name
	  + ". Category: "
	  + System::Typinfo::GetEnumName(
	  + ". State: "
	  + System::Typinfo::GetEnumName(
  TSensorManager::Current->Active = false;

Additional information about how to use Delphi RTTI type information, "GetEnumName", in your C++Builder applications is available at

Additional information about the TCaptureDeviceManager and TSensorManager classes is available on the Embarcadero DocWiki at

Sensor Categories and Types

Sensor APIs (TSensorCategory) supported by C++Builder XE3 include:

  • Location
  • Environmental
  • Motion
  • Orientation
  • Electrical
  • Mechanical
  • Biometric
  • Light
  • Scanner

For each sensor category, the following are the possible sensor types defined in the System.Sensors.hpp file:

  • enum class TLocationSensorType : unsigned char { GPS, Static, Lookup, Triangulation, Broadcast, DeadReckoning, Other };
  • enum class TEnvironmentalSensorType : unsigned char { Temperature, AtmosphericPressure, Humidity, WindSpeed, WindDirection };
  • enum class TMotionSensorType : unsigned char { Accelerometer1D, Accelerometer2D, Accelerometer3D, MotionDetector, Gyrometer1D, Gyrometer2D, Gyrometer3D, Speedometer };
  • enum class TOrientationSensorType : unsigned char { Compass1D, Compass2D, Compass3D, Inclinometer1D, Inclinometer2D, Inclinometer3D, Distance1D, Distance2D, Distance3D };
  • enum class TElectricalSensorType : unsigned char { Voltage, Current, Capacitance, Resistance, Inductance, ElectricalPower, Potentiometer };
  • enum class TMechanicalSensorType : unsigned char { BooleanSwitch, BooleanSwitchArray, MultiValueSwitch, Force, Scale, Pressure, Strain };
  • enum class TBiometricSensorType : unsigned char { HumanPresence, HumanProximity, Touch };
  • enum class TLightSensorType : unsigned char { AmbientLight };
  • enum class TScannerSensorType : unsigned char { RFID, Barcode };

CodeRage 7 C++ Conference, December 10-12, 2012

The CodeRage 7 C++ conference starts next Monday, December 10, 2012 at 6am Pacific Standard Time (14:00 UTC).  There are 3 days of C++ sessions including my special live, online conversation with Bjarne Stroustrup at 8am PST (16:00 UTC) on Monday.  Some of the C++ sessions you won’t want to miss are included in my blog post on November 21 -

Happy C++mas!

During the first 25 days of December leading up to Christmas, I will blog about the upcoming release of the C++Builder 64-bit compiler for Microsoft Windows and C++Builder XE3support for building VCL and FireMonkey 2 applications.

Server Response from: ETNASC03