1.3.11. Utility Feeds
Overview
A key aspect of SDK feeds are their ability to share audio and video media with other clients or session participants. However, there is a category of feed that we call a utility feed, which is stand-alone and does not require a session. These feeds can be used for a variety of purposes, such as local preview of video input before a session is started.
Utility feeds are created and managed in a similar way to other feeds, but they are
typically created using just feed components, properties and settings, and do not require
a session object like a MediaServerSession
to be created.
Utility feed example
One example of a utility feed is a UtilityVideoLocalFeed
.
This feed takes a video input/source component (e.g. a webcam) and transfers it to a
video output component (e.g. a window).
The following snippet shows how to create such a utility feed:
PxMedia::UtilityVideoLocalFeed::FeedProperties props("webcam-preview");
PxMedia::VideoInputFeedV4Linux2 input;
PxMedia::VideoOutputFeedAuto output;
auto created = PxMedia::UtilityVideoLocalFeed::create(pxContext, props, input, output);
if (!created) {
// Handle error...
}
auto utilityFeed = created.value();
The feed just takes a regular ProximieContext
(see the ProximieContext guide), and the two input and output video components.
For simplicity we don’t show any additional properties and settings for the components in this example.
Utility feeds can use feed stages like any other feed, see the guide section Feed Stages for more details.
Once the feed is created, it is started using startFeed()
:
auto started = utilityFeed->startFeed();
if (!started) {
// Handle error...
Utility feeds support start & stop notifications as callbacks:
utilityFeed->onFeedStarted([](auto& feed) {
// Feed has started
});
utilityFeed->onFeedStopped([](auto& feed, error_code error) {
// Feed has stopped, possibly with an error
if (error) {
// Handle error...
}
});
Finally, feeds may be stopped using stopFeed()
:
auto stopped = utilityFeed->stopFeed();
if (!stopped) {
// Handle error...