@@ -213,7 +213,7 @@ implementations for the overridden class members.
213213 std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;
214214
215215 int start(Camera *camera, const ControlList *controls) override;
216- void stop (Camera *camera) override;
216+ void stopDevice (Camera *camera) override;
217217
218218 int queueRequestDevice(Camera *camera, Request *request) override;
219219
@@ -247,7 +247,7 @@ implementations for the overridden class members.
247247 return -1;
248248 }
249249
250- void PipelineHandlerVivid::stop (Camera *camera)
250+ void PipelineHandlerVivid::stopDevice (Camera *camera)
251251 {
252252 }
253253
@@ -521,14 +521,14 @@ handler and camera manager using `registerCamera`_.
521521Finally with a successful construction, we return 'true' indicating that the
522522PipelineHandler successfully matched and constructed a device.
523523
524- .. _Camera::create : https://libcamera.org/api-html/classlibcamera_1_1Camera.html#a453740e0d2a2f495048ae307a85a2574
524+ .. _Camera::create : https://libcamera.org/internal- api-html/classlibcamera_1_1Camera.html#adf5e6c22411f953bfaa1ae21155d6c31
525525.. _registerCamera : https://libcamera.org/api-html/classlibcamera_1_1PipelineHandler.html#adf02a7f1bbd87aca73c0e8d8e0e6c98b
526526
527527.. code-block :: cpp
528528
529529 std::set<Stream *> streams{ &data->stream_ };
530- std::shared_ptr<Camera> camera = Camera::create(this , data->video_->deviceName(), streams);
531- registerCamera(std::move(camera), std::move(data) );
530+ std::shared_ptr<Camera> camera = Camera::create(std::move(data) , data->video_->deviceName(), streams);
531+ registerCamera(std::move(camera));
532532
533533 return true;
534534
@@ -554,8 +554,7 @@ Our match function should now look like the following:
554554
555555 /* Create and register the camera. */
556556 std::set<Stream *> streams{ &data->stream_ };
557- const std::string &id = data->video_->deviceName();
558- std::shared_ptr<Camera> camera = Camera::create(data.release(), id, streams);
557+ std::shared_ptr<Camera> camera = Camera::create(std::move(data), data->video_->deviceName(), streams);
559558 registerCamera(std::move(camera));
560559
561560 return true;
@@ -593,11 +592,11 @@ immutable properties of the ``Camera`` device.
593592The libcamera controls and properties are defined in YAML form which is
594593processed to automatically generate documentation and interfaces. Controls are
595594defined by the src/libcamera/`control_ids_core.yaml `_ file and camera properties
596- are defined by src/libcamera/`properties_ids_core .yaml `_.
595+ are defined by src/libcamera/`property_ids_core .yaml `_.
597596
598597.. _controls framework : https://libcamera.org/api-html/controls_8h.html
599598.. _control_ids_core.yaml : https://libcamera.org/api-html/control__ids_8h.html
600- .. _ properties_ids_core .yaml : https://libcamera.org/api-html/property__ids_8h.html
599+ .. _ property_ids_core .yaml : https://libcamera.org/api-html/property__ids_8h.html
601600
602601Pipeline handlers can optionally register the list of controls an application
603602can set as well as a list of immutable camera properties. Being both
@@ -800,8 +799,7 @@ derived class, and assign it to a base class pointer.
800799
801800.. code-block :: cpp
802801
803- VividCameraData *data = cameraData(camera);
804- CameraConfiguration *config = new VividCameraConfiguration();
802+ auto config = std::make_unique<VividCameraConfiguration>();
805803
806804 A ``CameraConfiguration `` is specific to each pipeline, so you can only create
807805it from the pipeline handler code path. Applications can also generate an empty
@@ -829,9 +827,7 @@ To generate a ``StreamConfiguration``, you need a list of pixel formats and
829827frame sizes which are supported as outputs of the stream. You can fetch a map of
830828the ``V4LPixelFormat `` and ``SizeRange `` supported by the underlying output
831829device, but the pipeline handler needs to convert this to a
832- ``libcamera::PixelFormat `` type to pass to applications. We do this here using
833- ``std::transform `` to convert the formats and populate a new ``PixelFormat `` map
834- as shown below.
830+ ``libcamera::PixelFormat `` type to pass to applications.
835831
836832Continue adding the following code example to our ``generateConfiguration ``
837833implementation.
@@ -841,14 +837,12 @@ implementation.
841837 std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =
842838 data->video_->formats();
843839 std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
844- std::transform(v4l2Formats.begin(), v4l2Formats.end(),
845- std::inserter(deviceFormats, deviceFormats.begin()),
846- [&](const decltype(v4l2Formats)::value_type &format) {
847- return decltype(deviceFormats)::value_type{
848- format.first.toPixelFormat(),
849- format.second
850- };
851- });
840+
841+ for (auto &[v4l2PixelFormat, sizes] : v4l2Formats) {
842+ PixelFormat pixelFormat = v4l2PixelFormat.toPixelFormat();
843+ if (pixelFormat.isValid())
844+ deviceFormats.try_emplace(pixelFormat, std::move(sizes));
845+ }
852846
853847 The `StreamFormats `_ class holds information about the pixel formats and frame
854848sizes that a stream can support. The class groups size information by the pixel
@@ -938,9 +932,9 @@ Add the following function implementation to your file:
938932
939933 StreamConfiguration &cfg = config_[0];
940934
941- const std::vector<libcamera::PixelFormat> formats = cfg.formats().pixelformats();
935+ const std::vector<libcamera::PixelFormat> & formats = cfg.formats().pixelformats();
942936 if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) {
943- cfg.pixelFormat = cfg. formats().pixelformats() [0];
937+ cfg.pixelFormat = formats[0];
944938 LOG(VIVID, Debug) << "Adjusting format to " << cfg.pixelFormat.toString();
945939 status = Adjusted;
946940 }
@@ -1158,7 +1152,7 @@ available to the devices which have to be started and ready to produce
11581152images. At the end of a capture session the ``Camera `` device needs to be
11591153stopped, to gracefully clean up any allocated memory and stop the hardware
11601154devices. Pipeline handlers implement two functions for these purposes, the
1161- ``start() `` and ``stop () `` functions.
1155+ ``start() `` and ``stopDevice () `` functions.
11621156
11631157The memory initialization phase that happens at ``start() `` time serves to
11641158configure video devices to be able to use memory buffers exported as dma-buf
@@ -1261,8 +1255,8 @@ algorithms, or other devices you should also stop them.
12611255.. _releaseBuffers : https://libcamera.org/api-html/classlibcamera_1_1V4L2VideoDevice.html#a191619c152f764e03bc461611f3fcd35
12621256
12631257Of course we also need to handle the corresponding actions to stop streaming on
1264- a device, Add the following to the ``stop `` function, to stop the stream with
1265- the `streamOff `_ function and release all buffers.
1258+ a device, Add the following to the ``stopDevice() `` function, to stop the
1259+ stream with the `streamOff `_ function and release all buffers.
12661260
12671261.. _streamOff : https://libcamera.org/api-html/classlibcamera_1_1V4L2VideoDevice.html#a61998710615bdf7aa25a046c8565ed66
12681262
0 commit comments