@@ -28,7 +28,7 @@ namespace CameraQt6QVideoSink{
2828
2929
3030
31- const QCameraFormat* build_format_set (
31+ QCameraFormat build_format_set (
3232 Logger& logger,
3333 VideoFormatSet& format_set,
3434 const QCameraDevice& device,
@@ -38,17 +38,17 @@ const QCameraFormat* build_format_set(
3838 QList<QCameraFormat> formats = device.videoFormats ();
3939 if (formats.empty ()){
4040 logger.log (" No usable resolutions: " + device.description ().toStdString (), COLOR_RED );
41- return nullptr ;
41+ return QCameraFormat () ;
4242 }
4343
4444 std::map<
4545 Resolution,
4646 std::map<
4747 VideoFormat,
48- std::pair<QVideoFrameFormat::PixelFormat, const QCameraFormat*>
48+ std::pair<QVideoFrameFormat::PixelFormat, QCameraFormat*>
4949 >
5050 > resolution_map;
51- for (const QCameraFormat& format : formats){
51+ for (QCameraFormat& format : formats){
5252 Resolution resolution (format.resolution ().width (), format.resolution ().height ());
5353// cout << resolution.width << " x " << resolution.height << " : " << (int)format.pixelFormat()
5454// << ", Min FPS = " << format.minFrameRate() << ", Max FPS = " << format.maxFrameRate()
@@ -74,7 +74,7 @@ const QCameraFormat* build_format_set(
7474
7575// cout << "Chosen: " << resolution_map[Resolution(3840, 2160)]->maxFrameRate() << endl;
7676
77- const QCameraFormat* current_qformat = nullptr ;
77+ QCameraFormat* current_qformat = nullptr ;
7878 format_set.clear ();
7979 for (const auto & res : resolution_map){
8080 for (const auto & entry : res.second ){
@@ -97,7 +97,7 @@ const QCameraFormat* build_format_set(
9797 current_qformat = resolution_map.rbegin ()->second .begin ()->second .second ;
9898 }
9999
100- return current_qformat;
100+ return std::move (* current_qformat) ;
101101}
102102
103103
@@ -203,25 +203,25 @@ void CameraVideoSource::init(
203203 return ;
204204 }
205205
206- const QCameraFormat* format = build_format_set (
206+ QCameraFormat format = build_format_set (
207207 m_logger,
208208 m_formats,
209209 *device,
210210 desired_resolution,
211211 desired_format
212212 );
213- if (format == nullptr ){
213+ if (format. isNull () ){
214214 return ;
215215 }
216216
217- QSize size = format-> resolution ();
217+ QSize size = format. resolution ();
218218 m_resolution = Resolution (size.width (), size.height ());
219219 m_logger.log (" Resolution: " + m_resolution.to_string ());
220220
221- m_format = QVideoFrameFormat_to_VideoFormat (format-> pixelFormat ());
221+ m_format = QVideoFrameFormat_to_VideoFormat (format. pixelFormat ());
222222 m_logger.log (" Format: " + VideoFormat_database ().find (m_format)->display );
223223
224- m_camera.reset (new QCameraThread (m_logger, *device, * format));
224+ m_camera.reset (new QCameraThread (m_logger, *device, format));
225225 m_video_sink.reset (new QVideoSink ());
226226 m_capture.reset (new QMediaCaptureSession ());
227227 m_capture->setCamera (&m_camera->camera ());
0 commit comments