webcamoid / akvirtualcamera

akvirtualcamera, virtual camera for Mac and Windows
GNU General Public License v3.0
393 stars 51 forks source link

WIP: Example program (For comments - do not merge) #2

Closed correa closed 3 years ago

correa commented 4 years ago

This program tries to show a red frame on the virtual camera, but it just crashes the application that has the camera open. Do you have any idea what could be wrong here?

hipersayanX commented 4 years ago

The problem is that AkVCam::IpcBridge is internal, it will not be publicly available, instead you will communicate with the camera using the manager and public interfaces, in the case of Mac it will use CoreMediaIO and in the case of Windows it will use DirectShow, this way you will not need to link against any library to use the virtual camera, and we will able to change and improve the plugins internally as much as we want without worrying to break compatibility with third party apps.

correa commented 4 years ago

Same APIs IpcBridge uses today?

hipersayanX commented 4 years ago

Some things may change while others will remain the same, for example, let say I want to add a new camera, with the current API you must use deviceCreate(), but if I map this to the command line it would be something like this:

# manager create "My Virtual Camera" "YUY2 640x480 30FPS, YUY2 1280x720 15FPS, RGB24 800x600 60FPS, ..."

which looks awful, instead my idea is to modularize the device creation, to something like:


# manager add "My Virtual Camera"
/akvcam/video0
# manager add-format /akvcam/video0 YUY2 640 480 30
# manager add-format /akvcam/video0 YUY2 1280 720 15
# manager add-format /akvcam/video0 RGB24 800 600 60
...
# manager update

add will return a device id if successful, then you will use that id to edit the formats (and other camera parameters), finally you call update to reload the camera settings in Mac assistant or to reload the filter in Windows. Listing the cameras would be like:

$ manager list
/akvcam/video0
/akvcam/video1
/akvcam/video2
...
$ manager description /akvcam/video0
My Virtual Camera

Listing formats would be like:

$ manager list-formats /akvcam/video0
Format 0: YUY2 640x480 30 FPS
Format 1: YUY2 1280x720 15 FPS
Format 2: RGB24 800x600 60 FPS
...

or in the parseable form:

$ manager list-formats -p /akvcam/video0
YUY2 640 480 30
YUY2 1280 720 15
RGB24 800 600 60
...

Removing a format would be like:

# manager remove-format /akvcam/video0 1

Removing a camera would be like:

# manager remove /akvcam/video0

My idea is to adopt a command sub-command format like this:

manager <-m --anager --options> sub-command <-s -u- b --options> arg0 arg1 arg2 ...
hipersayanX commented 4 years ago

This is more or less the command line options for the manager:

AkVCamManager [OPTIONS...] COMMAND [COMMAND_OPTIONS...] ...

AkVirtualCamera virtual device manager.

General Options:

    -h, --help         Show help.
    -p, --parseable    Show parseable output.

Commands:

    devices                                                            List devices.
    add-device         DESCRIPTION                                     Add a new device.

        -i, --input     Add an input device.
        -o, --output    Add an output device.

    remove-device      DEVICE                                          Remove a device.
    device-type        DEVICE                                          Show device type.
    device-description DEVICE                                          Show device description.
    supported-formats                                                  Show supported formats.

        -i, --input     Show supported input formats.
        -o, --output    Show supported output formats.

    formats            DEVICE                                          Show device formats.
    add-format         DEVICE FORMAT WIDTH HEIGHT FPS                  Add a new device format.

        -i, --index INDEX    Add format at INDEX.

    remove-format      INDEX                                           Remove device format.
    update                                                             Update devices.
    connections        [DEVICE]                                        Show device connections.
    connect            OUTPUT_DEVICE INPUTDEVICE [INPUT_DEVICE ...]    Connect devices.
    disconnect         OUTPUT_DEVICE INPUTDEVICE                       Disconnect devices.
    options            DEVICE                                          Show device options.
    get-option         DEVICE OPTION                                   Read device option.
    set-option         DEVICE OPTION VALUE                             Write device option value.
    clients                                                            Show clients using the camera.

Now I need to add support for input devices, add the missing functionality to the manager, and from there is just documenting how to connect to the input device and how to use the manager and that's all.

hipersayanX commented 3 years ago

Examples added. Closing.