QMediaCaptureSession Class
The QMediaCaptureSession class allows capturing of audio and video content. More...
Header: | #include <QMediaCaptureSession> |
CMake: | find_package(Qt6 COMPONENTS Multimedia REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
Inherits: | QObject |
Properties
- camera : QCamera*
- imageCapture : QImageCapture*
- recorder : QMediaRecorder*
Public Functions
QMediaCaptureSession(QObject *parent = nullptr) | |
virtual | ~QMediaCaptureSession() |
QAudioInput * | audioInput() const |
QCamera * | camera() const |
QImageCapture * | imageCapture() |
QMediaRecorder * | recorder() |
void | setAudioInput(QAudioInput *device) |
void | setCamera(QCamera *camera) |
void | setImageCapture(QImageCapture *imageCapture) |
void | setRecorder(QMediaRecorder *recorder) |
void | setVideoOutput(QObject *output) |
QObject * | videoOutput() const |
Signals
void | audioInputChanged() |
void | cameraChanged() |
void | imageCaptureChanged() |
void | recorderChanged() |
void | videoOutputChanged() |
Detailed Description
The QMediaCaptureSession is the central class that manages capturing of media on the local device.
You can connect a camera and a microphone to QMediaCaptureSession using setCamera() and setAudioInput(). A preview of the captured media can be seen by setting a QVideoSink of QVideoWidget using setVideoOutput() and heard by routing the audio to an output device using setAudioOutput().
You can capture still images from a camera by setting a QImageCapture object on the capture session, and record audio/video using a QMediaRecorder.
If you need a simple class that records media from the default camera and microphone, you can use QMediaRecorder. That class uses a QMediaCaptureSession behind the scene to support audio and video capture.
See also QCamera, QAudioDevice, QMediaRecorder, QImageCapture, and QMediaRecorder.
Property Documentation
camera : QCamera*
This property holds the camera used to capture video.
Record the camera or take images by adding a camera t the capture session using this property,
Access functions:
QCamera * | camera() const |
void | setCamera(QCamera *camera) |
Notifier signal:
void | cameraChanged() |
imageCapture : QImageCapture*
This property holds the object used to capture still images.
Add a QImageCapture object to the capture session to enable capturing of still images from the camera.
Access functions:
QImageCapture * | imageCapture() |
void | setImageCapture(QImageCapture *imageCapture) |
Notifier signal:
void | imageCaptureChanged() |
recorder : QMediaRecorder*
This property holds the recorder object used to capture audio/video.
Add a QMediaRecorder object to the capture session to enable recording of audio and/or video from the capture session.
Access functions:
QMediaRecorder * | recorder() |
void | setRecorder(QMediaRecorder *recorder) |
Notifier signal:
void | recorderChanged() |
Member Function Documentation
QMediaCaptureSession::QMediaCaptureSession(QObject *parent = nullptr)
Creates a session for media capture.
[virtual]
QMediaCaptureSession::~QMediaCaptureSession()
Destroys the session.
QAudioInput *QMediaCaptureSession::audioInput() const
Returns the device that is being used to capture audio.
Note: Getter function for property audioInput.
See also setAudioInput().
void QMediaCaptureSession::setAudioInput(QAudioInput *device)
Sets the audio input device to device. If setting it to an empty QAudioDevice the capture session will use the default input as defined by the operating system.
Use setMuted(), if you want to disable audio input.
Note: Setter function for property audioInput.
See also audioInput(), muted(), and setMuted().
void QMediaCaptureSession::setVideoOutput(QObject *output)
Sets a QObject based video preview for the capture session.
A QObject based preview is expected to have an invokable videoSink() method that returns a QVideoSink.
The previously set preview is detached.
Note: Setter function for property videoOutput.
See also videoOutput().