2.2.16. Video Inputs

Outgoing video feed types provided by the SDK (MediaServerOutgoingVideoFeed, PeerLocalVideoFeed) accept video input from a variety of sources, such as:

providing the ability to capture and transmit video from, respectively:

  • a V4L2 device (e.g. a webcam)

  • an X11 desktop or window

  • a test pattern generator

  • a file

  • the output of another feed via inter (a cross-feed communication pipe)

For other video input components, see subclasses of the VideoInputFeedComponent and VideoFormattedInputFeedComponent classes.

For example, to transmit a webcam to a media server:

    PxMedia::VideoInputFeedV4Linux2 inputVideo;
    inputVideo.deviceProperties().device("/dev/video0");
    inputVideo.videoCapabilities().frameRate(30).mediaType(
        PxMedia::VideoCapabilities::MediaType::IMAGE_JPEG);
    auto outgoingFeed =
        PxMedia::MediaServerOutgoingVideoFeed::create(mediaSession, props, inputVideo, localOut);

To transmit a screen or window capture to a peer:

    PxMedia::VideoInputFeedXImage inputVideo;
    inputVideo.videoCapabilities().frameRate(30);
    PxUtility::Rectangle<int> captureArea;
    captureArea.right(1279).bottom(719);
    inputVideo.captureArea(captureArea);
    auto outgoingFeed = PxMedia::PeerLocalVideoFeed::create(
        peerSession, feedProperties, inputVideo, localOut, &encoderProperties);

To transmit a test video stream to a media server:

    PxMedia::VideoInputFeedTestPattern inputVideo;
    inputVideo.videoCapabilities().frameRate(30).width(1280).height(720);
    auto outgoingFeed =
        PxMedia::MediaServerOutgoingVideoFeed::create(mediaSession, props, inputVideo, localOut);

To transmit a test video file to a media server:

    PxMedia::VideoInputFeedFile inputVideo;
    inputVideo.filename(videoFilename);
    inputVideo.baseFormat(PxMedia::VideoMediaFormat::BaseMedia::VIDEO_ENCODED);
    inputVideo.videoCapabilities().frameRate(30).mediaType(
        Proximie::PxMedia::VideoCapabilities::MediaType::VIDEO_XRAW);
    auto outgoingFeed =
        PxMedia::MediaServerOutgoingVideoFeed::create(mediaSession, props, inputVideo, localOut);

Video file sources have a natural end while single-image files repeat the single image frame indefinitely. If the feed internally consumes the video data without transmitting to another feed then the feed will stop automatically when the end of the video is reached and the onFeedStopped callback will be executed if present. This is the case for UtilityVideoLocalFeed and AVOutputFeedFile. Otherwise the feed will continue in the playing state when the video ends. The output component will receive and retain the final image from the video.

To transmit video sourced from the output of another feed:

    PxMedia::VideoInputFeedInter inputVideo = outInter.makeInput();
    auto                         outgoingFeed =
        PxMedia::MediaServerOutgoingVideoFeed::create(mediaSession, props, inputVideo, localOut);

VideoInputFeedInter instances must be obtained via makeInput() before the associated output is passed to a feed create() call. Each instance can only be used in a single feed — violating either constraint is detected and surfaces as a PipelineElementBadProps error when the affected feed is created.