ningwebbeginner

原项目

要显示太多修改。

为保证性能只显示 27 of 27+ 个文件。

mac_task:
matrix:
- name: MacOS Sequoia (15.0)
macos_instance:
image: ghcr.io/cirruslabs/macos-sequoia-base:latest
env:
UPLOAD: 0
- name: MacOS Sonoma (14.0)
macos_instance:
image: ghcr.io/cirruslabs/macos-sonoma-base:latest
env:
UPLOAD: 0
- name: MacOS Ventura (13.0)
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
UPLOAD: 0
- name: MacOS Monterrey (12.0)
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-base:latest
env:
UPLOAD: 0
env:
GITHUB_TOKEN: ENCRYPTED[fa47530508b5b9a63cbf1a9b4b9b2741c01c2f430b5ef0b39319fe7c1cd4cb285cf5e0c2ed5aa1bf990adb6200bcc742]
HOMEBREW_PATH: /opt/homebrew
NJOBS: 4
env:
only_if: ${CIRRUS_TAG} == ""
DAILY_BUILD: 1
env:
only_if: ${CIRRUS_TAG} != ""
DAILY_BUILD: 0
macos_instance:
cpu: 2
memory: 4G
timeout_in: 60m
install_script:
- chmod +x ports/ci/mac/install_deps.sh
- ./ports/ci/mac/install_deps.sh
script:
- chmod +x ports/ci/mac/build.sh
- ./ports/ci/mac/build.sh
deploy_script:
- chmod +x ports/ci/mac/deploy.sh
- ./ports/ci/mac/deploy.sh
upload_script:
- chmod +x ports/ci/mac/upload.sh
- ./ports/ci/mac/upload.sh
... ...
github: hipersayanX
patreon: hipersayanx
ko_fi: hipersayanx
liberapay: hipersayanx
custom: ["https://www.paypal.me/WebcamoidDonations", "https://buymeacoffee.com/hipersayanx", "https://webcamoid.github.io/donations#crypto"]
... ...
name: Linux MinGW
on: [push, pull_request]
env:
NSIS_VERSION: 3.10
DOCKERIMG: archlinux:latest
ARCH_ROOT_URL: https://mirror.rackspace.com/archlinux
NJOBS: 4
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: false
matrix:
include:
- compiler: gcc
- compiler: clang
steps:
- uses: actions/checkout@v2
- name: Build
uses: addnab/docker-run-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: gcr.io
image: ${{ env.DOCKERIMG }}
options: >-
-v ${{ github.workspace }}:/sources
-e GITHUB_REF=${{ github.ref }}
-e GITHUB_SERVER_URL=${{ github.server_url }}
-e GITHUB_REPOSITORY=${{ github.repository }}
-e GITHUB_RUN_ID=${{ github.run_id }}
-e GIT_COMMIT_HASH=${{ github.sha }}
-e GIT_BRANCH_NAME=${{ github.ref_name }}
-e NSIS_VERSION=${{ env.NSIS_VERSION }}
-e TARGET_ARCH=${{ matrix.target_arch }}
-e COMPILER=${{ matrix.compiler }}
-e DOCKERIMG=${{ env.DOCKERIMG }}
-e ARCH_ROOT_URL=${{ env.ARCH_ROOT_URL }}
-e NJOBS=${{ env.NJOBS }}
run: |
cd /sources
echo
echo Install dependencies
echo
chmod +x ports/ci/linux-mingw/install_deps.sh
./ports/ci/linux-mingw/install_deps.sh
echo
echo Release Build
echo
chmod +x ports/ci/linux-mingw/build.sh
./ports/ci/linux-mingw/build.sh
echo
echo Release Deploy
echo
chmod +x ports/ci/linux-mingw/deploy.sh
./ports/ci/linux-mingw/deploy.sh
... ...
name: Mac
on: [push, pull_request]
env:
HOMEBREW_PATH: /usr/local
NJOBS: 4
jobs:
build:
strategy:
max-parallel: 10
fail-fast: false
matrix:
include:
- os: macos-15
upload: 0
- os: macos-14
upload: 1
- os: macos-13
upload: 1
runs-on: ${{ matrix.os }}
env:
UPLOAD: ${{ matrix.upload }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
chmod +x ports/ci/mac/install_deps.sh
./ports/ci/mac/install_deps.sh
- name: Release Build
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
chmod +x ports/ci/mac/build.sh
./ports/ci/mac/build.sh
- name: Release Deploy
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
chmod +x ports/ci/mac/deploy.sh
./ports/ci/mac/deploy.sh
- name: Daily Build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
DAILY_BUILD: 1
run: |
chmod +x ports/ci/mac/build.sh
./ports/ci/mac/build.sh
- name: Daily Deploy
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
DAILY_BUILD: 1
run: |
chmod +x ports/ci/mac/deploy.sh
./ports/ci/mac/deploy.sh
- name: Release Upload
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.upload }}
with:
files: packages/mac/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Daily Build Upload
uses: softprops/action-gh-release@v1
if: ${{ !startsWith(github.ref, 'refs/tags/') && matrix.upload }}
with:
body: "${{ github.event.head_commit.message }} (commit: [${{ github.sha }}](https://github.com/webcamoid/akvirtualcamera/commit/${{ github.sha }}))<hr>**Note**: Ignore the commit information of the tag, the files in the release keep updating with every new build, these packages were built from [${{ github.sha }}](https://github.com/webcamoid/akvirtualcamera/commit/${{ github.sha }}) commit."
prerelease: true
files: packages/mac/*
name: Daily Build
tag_name: daily-build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
... ...
name: Windows MSYS
on: [push, pull_request]
env:
DISABLE_CCACHE: 1
NJOBS: 4
jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
max-parallel: 10
fail-fast: false
matrix:
include:
- compiler: gcc
- compiler: clang
env:
COMPILER: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: mingw64
install: >-
ccache
clang
cmake
git
make
pkgconf
python3
mingw-w64-i686-binutils
mingw-w64-i686-clang
mingw-w64-i686-cmake
mingw-w64-i686-gcc
mingw-w64-i686-pkgconf
mingw-w64-x86_64-binutils
mingw-w64-x86_64-clang
mingw-w64-x86_64-cmake
mingw-w64-x86_64-gcc
mingw-w64-x86_64-pkgconf
- name: Release Build
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: ./ports/ci/windows-msys/build.sh
- name: Release Deploy
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: ./ports/ci/windows-msys/deploy.sh
- name: Daily Build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
DAILY_BUILD: 1
run: ./ports/ci/windows-msys/build.sh
- name: Daily Deploy
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
DAILY_BUILD: 1
run: ./ports/ci/windows-msys/deploy.sh
- name: Release Upload
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
files: packages/windows-gcc/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Daily Build Upload
uses: softprops/action-gh-release@v1
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
body: "${{ github.event.head_commit.message }} (commit: [${{ github.sha }}](https://github.com/webcamoid/akvirtualcamera/commit/${{ github.sha }}))<hr>**Note**: Ignore the commit information of the tag, the files in the release keep updating with every new build, these packages were built from [${{ github.sha }}](https://github.com/webcamoid/akvirtualcamera/commit/${{ github.sha }}) commit."
prerelease: true
files: packages/windows-gcc/*
name: Daily Build
tag_name: daily-build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
... ...
name: Windows Visual Studio
on: [push, pull_request]
env:
CMAKE_GENERATOR: Visual Studio 17 2022
PYTHON_VERSION: Python312
NJOBS: 4
jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v2
- name: Build
run: ports\ci\windows-vs\build.bat
- name: Deploy
run: ports\ci\windows-vs\deploy.bat
... ...
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.so.*
*.so.debug
*.run
*.AppImage
*.framework
# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.xz
# Logs and databases #
######################
*.log
*.sql
*.sqlite
vgcore.*
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
*~
*_resource.rc
# Ignore files generated by Qt #
################################
*.a
*.moc
moc_*.cpp
ui_*.h
*.obj
*.dylib
Makefile*
*.prl
*.app
*.autosave
*.qmlc
.qmake.stash
.qmake.cache
callgrind.out.*
*.debug
*.plugin
*_qmlcache.qrc
test.o-*
object_script.*
*.user.*
*.user
# Ignore files generated by Python #
####################################
__pycache__
*.pyc
# Android files #
#################
android-build
android-*-deployment-settings.json
# VIM temporary files #
#######################
.*.swp
# Kate temporary files #
#######################
.*.kate-swp
# KDevelop generated files #
############################
.kdev4
*.kdev4
# MinGW files #
###############
*.Debug
*.Release
# MSVC files #
##############
*.exp
*.ilk
*.lib
*.pdb
# Failed patch #
################
*.orig
*.rej
# Project Files #
#################
AkVCamAssistant
# Ignore Directories #
######################
build
debug
release
# Ignore Auto Generated Files #
###############################
*_auto*
# Ignore Private Files and Folders #
####################################
*_priv
*_priv.*
... ...
# akvirtualcamera, virtual camera for Mac and Windows.
# Copyright (C) 2021 Gonzalo Exequiel Pedone
#
# akvirtualcamera is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# akvirtualcamera is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
#
# Web-Site: http://webcamoid.github.io/
cmake_minimum_required(VERSION 3.5)
project(AkVirtualCamera)
include(commons.cmake)
add_subdirectory(VCamUtils)
add_subdirectory(Manager)
add_subdirectory(Service)
add_subdirectory(cmio)
add_subdirectory(dshow)
configure_file(package_info.conf.in package_info.conf)
... ...
# akvcam Individual Contributor License Agreement #
Thank you for your interest in contributing to akvcam ("We" or "Us").
This contributor agreement ("Agreement") documents the rights granted by contributors to Us. To make this document effective, please sign it and send it to Us by email, following the instructions at CONTRIBUTING.md. This is a legally binding document, so please read it carefully before agreeing to it. The Agreement may cover more than one software project managed by Us.
You are accepting this agreement by making a pull request to the repository.
## 1. Definitions ##
"You" means the individual who Submits a Contribution to Us.
"Contribution" means any work of authorship that is Submitted by You to Us in which You own or assert ownership of the Copyright. If You do not own the Copyright in the entire work of authorship, please follow the instructions in CONTRIBUTING.md.
"Copyright" means all rights protecting works of authorship owned or controlled by You, including copyright, moral and neighboring rights, as appropriate, for the full term of their existence including any extensions by You.
"Material" means the work of authorship which is made available by Us to third parties. When this Agreement covers more than one software project, the Material means the work of authorship to which the Contribution was Submitted. After You Submit the Contribution, it may be included in the Material.
"Submit" means any form of electronic, verbal, or written communication sent to Us or our representatives, including but not limited to electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Us for the purpose of discussing and improving the Material, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
"Submission Date" means the date on which You Submit a Contribution to Us.
"Effective Date" means the date You execute this Agreement or the date You first Submit a Contribution to Us, whichever is earlier.
"Media" means any portion of a Contribution which is not software.
## 2. Grant of Rights ##
### 2.1 Copyright License ###
(a) You retain ownership of the Copyright in Your Contribution and have the same rights to use or license the Contribution which You would have had without entering into the Agreement.
(b) To the maximum extent permitted by the relevant law, You grant to Us a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable license under the Copyright covering the Contribution, with the right to sublicense such rights through multiple tiers of sublicensees, to reproduce, modify, display, perform and distribute the Contribution as part of the Material; provided that this license is conditioned upon compliance with Section 2.3.
### 2.2 Patent License ###
For patent claims including, without limitation, method, process, and apparatus claims which You own, control or have the right to grant, now or in the future, You grant to Us a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable patent license, with the right to sublicense these rights to multiple tiers of sublicensees, to make, have made, use, sell, offer for sale, import and otherwise transfer the Contribution and the Contribution in combination with the Material (and portions of such combination). This license is granted only to the extent that the exercise of the licensed rights infringes such patent claims; and provided that this license is conditioned upon compliance with Section 2.3.
### 2.3 Outbound License ###
As a condition on the grant of rights in Sections 2.1 and 2.2, We agree to license the Contribution only under the terms of the license or licenses which We are using on the Submission Date for the Material or any licenses on the Free Software Foundation's list of "Recommended copyleft licenses" on or after the Effective Date, whether or not such licenses are subsequently disapproved (including any right to adopt any future version of a license if permitted).
In addition, We may use the following licenses for Media in the Contribution: Creative Commons Attribution Share Alike 3.0 (including any right to adopt any future version of a license if permitted).
**2.4 Moral Rights.** If moral rights apply to the Contribution, to the maximum extent permitted by law, You waive and agree not to assert such moral rights against Us or our successors in interest, or any of our licensees, either direct or indirect.
**2.5 Our Rights.** You acknowledge that We are not obligated to use Your Contribution as part of the Material and may decide to include any Contribution We consider appropriate.
**2.6 Reservation of Rights.** Any rights not expressly licensed under this section are expressly reserved by You.
## 3. Agreement ##
You confirm that:
(a) You have the legal authority to enter into this Agreement.
(b) You own the Copyright and patent claims covering the Contribution which are required to grant the rights under Section 2.
(c) The grant of rights under Section 2 does not violate any grant of rights which You have made to third parties, including Your employer. If You are an employee, You have had Your employer approve this Agreement or sign the Entity version of this document. If You are less than eighteen years old, please have Your parents or guardian sign the Agreement.
(d) You have followed the instructions in CONTRIBUTING.md, if You do not own the Copyright in the entire work of authorship Submitted.
## 4. Disclaimer ##
EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3, THE CONTRIBUTION IS PROVIDED "AS IS". MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US. TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW.
## 5. Consequential Damage Waiver ##
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR OTHERWISE) UPON WHICH THE CLAIM IS BASED.
## 6. Miscellaneous ##
6.1 This Agreement will be governed by and construed in accordance with the laws of Argentina excluding its conflicts of law provisions. Under certain circumstances, the governing law in this section might be superseded by the United Nations Convention on Contracts for the International Sale of Goods ("UN Convention") and the parties intend to avoid the application of the UN Convention to this Agreement and, thus, exclude the application of the UN Convention in its entirety to this Agreement.
6.2 This Agreement sets out the entire agreement between You and Us for Your Contributions to Us and overrides all other agreements or understandings.
6.3 If You or We assign the rights or obligations received through this Agreement to a third party, as a condition of the assignment, that third party must agree in writing to abide by all the rights and obligations in the Agreement.
6.4 The failure of either party to require performance by the other party of any provision of this Agreement in one situation shall not affect the right of a party to require such performance at any time in the future. A waiver of performance under a provision in one situation shall not be considered a waiver of the performance of the provision in the future or a waiver of the provision in its entirety.
6.5 If any provision of this Agreement is found void and unenforceable, such provision will be replaced to the extent possible with a provision that comes closest to the meaning of the original provision and which is enforceable. The terms and conditions set forth in this Agreement shall apply notwithstanding any failure of essential purpose of this Agreement or any limited remedy to the maximum extent possible under law.
... ...
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
... ...
akvirtualcamera 9.1.3:
- Quote file path if it contains spaces (issue #75).
- Added --build-info flag.
akvirtualcamera 9.1.2:
- Added ARM 64 packages for Mac.
akvirtualcamera 9.1.1:
- Mark Mac packages architecture.
akvirtualcamera 9.1.0:
- Added -f, --force flags to the manager, this bypass the virtual camera usage
check.
- Fixed output example in Windows.
- Now distributing the Mac installer as a pkg.
akvirtualcamera 9.0.0:
- Code forked from Webcamoid. This virtual camera isn't compatible with
Webcamoid 8.x and older releases.
- Build system switched to Cmake.
- Fixed plugins installers and switched to NSIS in Windows.
- Added a command line tool to communicate with the virtual camera
(AkVCamManager).
- Added support for PNG and JPG for the placeholder picture.
- Added documentation and example usages.
... ...
# README
Some considerations before doing anything:
* Search the [issues list](https://github.com/webcamoid/akvirtualcamera/issues) for similar topics before opening a new one.
* If you know how to fix the problem, consider doing a [pull request](https://github.com/webcamoid/akvirtualcamera/pulls) instead of opening a new issue.
* Only report problems in [latest](https://github.com/webcamoid/akvirtualcamera/releases) and [development](https://github.com/webcamoid/akvirtualcamera/) version. Reporting issues related to older versions will be rejected.
* Use [gist](https://gist.github.com/) to post logs longer than 1024 characters.
* akvirtualcamera as project, is not affiliated or endorsed to any distribution, report packaging problems in their respective issue tracker.
* Respect the templates, we need as much information as possible.
* Don't open an issue and disappear, we need you at least the first week to clear up missing information.
* Missing information makes useless and unsolvable an issue report.
* You are our debbuger, eyes and hands, if an issue is not reproducible then you will be the only person able to solve it.
* Take a seat and wait for your turn, as many others that has their issues open, or much better try fixing it your self and collaborate with the solution :smile:
Choose one of the templates bellow that fit better your issue.
# Reporting a problem?
## Summary
Write here a brief description of the problem.
## Current Behavior
Describe the problem the best as you can, don't omit information.
## Expected Behavior
How it should have work?
## Steps to Reproduce
If akvirtualcamera crashed, try to reproduce the crash several times to be sure where is the problem. Write the steps to reproduce the issue bellow:
1. Open this
2. Click that
3. Drag those
4. ...
## Suggestions and tips
How would you solve the problem?
## Your Environment
* akvirtualcamera inormation: (version) (architecture)
* Operating System information: (name) (numeric version and codename if applied) (architecture)
* Any other useful information: (logs, gdb backtrace, valgrind logs, screenshots, hardware, etc.)
# Want a new feature?
Describe your idea the best as you can, include sketches, mockups and diagrams if required.
Be patient, take in mind that there may be other priorities. Your idea will be accepted if fit in project goals.
# Questinons and other matters?
Go ahead!
... ...
# akvirtualcamera, virtual camera for Mac and Windows.
# Copyright (C) 2021 Gonzalo Exequiel Pedone
#
# akvirtualcamera is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# akvirtualcamera is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
#
# Web-Site: http://webcamoid.github.io/
cmake_minimum_required(VERSION 3.5)
project(Manager LANGUAGES CXX)
include(../commons.cmake)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Manager
src/cmdparser.h
src/main.cpp
src/cmdparser.cpp)
if (APPLE OR FAKE_APPLE)
set_target_properties(Manager PROPERTIES
OUTPUT_NAME ${AKVCAM_MANAGER_NAME}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${DATAROOTDIR})
else ()
set_target_properties(Manager PROPERTIES
OUTPUT_NAME ${AKVCAM_MANAGER_NAME}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${BINDIR}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${BINDIR})
endif ()
add_dependencies(Manager VCamUtils)
if (APPLE OR FAKE_APPLE)
add_dependencies(Manager
VCamIPC_cmio
PlatformUtils_cmio)
elseif (WIN32)
add_dependencies(Manager
VCamIPC_dshow
PlatformUtils_dshow)
endif ()
target_include_directories(Manager
PRIVATE ..)
target_link_libraries(Manager
VCamUtils)
if (APPLE OR FAKE_APPLE)
target_link_libraries(Manager
VCamIPC_cmio
PlatformUtils_cmio)
elseif (WIN32)
target_link_libraries(Manager
VCamIPC_dshow
PlatformUtils_dshow)
endif ()
if (APPLE OR FAKE_APPLE)
if (APPLE)
find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation)
find_library(COREMEDIA_FRAMEWORK NAMES CoreMedia)
find_library(COREMEDIAIO_FRAMEWORK NAMES CoreMediaIO)
find_library(COREVIDEO_FRAMEWORK NAMES CoreVideo)
find_library(FOUNDATION_FRAMEWORK NAMES Foundation)
find_library(IOKIT_FRAMEWORK NAMES IOKit)
set(EXTRA_LIBS ${COREFOUNDATION_FRAMEWORK}
${COREMEDIA_FRAMEWORK}
${COREMEDIAIO_FRAMEWORK}
${COREVIDEO_FRAMEWORK}
${FOUNDATION_FRAMEWORK}
${IOKIT_FRAMEWORK})
target_link_libraries(Manager ${EXTRA_LIBS})
endif ()
elseif (WIN32)
target_link_libraries(Manager
advapi32
gdi32
ole32
oleaut32
shell32
strmiids
uuid)
endif ()
if (APPLE OR FAKE_APPLE)
install(TARGETS Manager DESTINATION ${DATAROOTDIR})
elseif (WIN32)
install(TARGETS Manager DESTINATION ${BINDIR})
endif ()
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#include <algorithm>
#include <cerrno>
#include <chrono>
#include <cmath>
#include <codecvt>
#include <csignal>
#include <cstring>
#include <iostream>
#include <functional>
#include <locale>
#include <sstream>
#include <thread>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#endif
#include "cmdparser.h"
#include "VCamUtils/src/ipcbridge.h"
#include "VCamUtils/src/settings.h"
#include "VCamUtils/src/videoformat.h"
#include "VCamUtils/src/videoframe.h"
#include "VCamUtils/src/logger.h"
#define COMMONS_PROJECT_COMMIT_URL "https://github.com/webcamoid/akvirtualcamera/commit"
#define AKVCAM_BIND_FUNC(member) \
std::bind(&member, this->d, std::placeholders::_1, std::placeholders::_2)
namespace AkVCam {
using StringMatrix = std::vector<StringVector>;
using VideoFormatMatrix = std::vector<std::vector<VideoFormat>>;
struct CmdParserFlags
{
StringVector flags;
std::string value;
std::string helpString;
};
struct CmdParserCommand
{
std::string command;
std::string arguments;
std::string helpString;
ProgramOptionsFunc func;
std::vector<CmdParserFlags> flags;
bool advanced {false};
CmdParserCommand();
CmdParserCommand(const std::string &command,
const std::string &arguments,
const std::string &helpString,
const ProgramOptionsFunc &func,
const std::vector<CmdParserFlags> &flags,
bool advanced);
};
class CmdParserPrivate
{
public:
std::vector<CmdParserCommand> m_commands;
IpcBridge m_ipcBridge;
bool m_parseable {false};
bool m_force {false};
static const std::map<ControlType, std::string> &typeStrMap();
void printFlags(const std::vector<CmdParserFlags> &cmdFlags,
size_t indent);
size_t maxCommandLength(bool showAdvancedHelp);
size_t maxArgumentsLength(bool showAdvancedHelp);
size_t maxFlagsLength(const std::vector<CmdParserFlags> &flags);
size_t maxFlagsValueLength(const std::vector<CmdParserFlags> &flags);
size_t maxColumnLength(const StringVector &table,
size_t width,
size_t column);
std::vector<size_t> maxColumnsLength(const StringVector &table,
size_t width);
void drawTableHLine(const std::vector<size_t> &columnsLength,
bool toStdErr=false);
void drawTable(const StringVector &table,
size_t width,
bool toStdErr=false);
CmdParserCommand *parserCommand(const std::string &command);
const CmdParserFlags *parserFlag(const std::vector<CmdParserFlags> &cmdFlags,
const std::string &flag);
bool containsFlag(const StringMap &flags,
const std::string &command,
const std::string &flagAlias);
std::string flagValue(const StringMap &flags,
const std::string &command,
const std::string &flagAlias);
int defaultHandler(const StringMap &flags,
const StringVector &args);
int showHelp(const StringMap &flags, const StringVector &args);
int showDevices(const StringMap &flags, const StringVector &args);
int addDevice(const StringMap &flags, const StringVector &args);
int removeDevice(const StringMap &flags, const StringVector &args);
int removeDevices(const StringMap &flags, const StringVector &args);
int showDeviceDescription(const StringMap &flags,
const StringVector &args);
int setDeviceDescription(const StringMap &flags,
const StringVector &args);
int showSupportedFormats(const StringMap &flags,
const StringVector &args);
int showDefaultFormat(const StringMap &flags,
const StringVector &args);
int showFormats(const StringMap &flags, const StringVector &args);
int addFormat(const StringMap &flags, const StringVector &args);
int removeFormat(const StringMap &flags, const StringVector &args);
int removeFormats(const StringMap &flags, const StringVector &args);
int update(const StringMap &flags, const StringVector &args);
int loadSettings(const StringMap &flags, const StringVector &args);
int stream(const StringMap &flags, const StringVector &args);
int listenEvents(const StringMap &flags, const StringVector &args);
int showControls(const StringMap &flags, const StringVector &args);
int readControl(const StringMap &flags, const StringVector &args);
int writeControls(const StringMap &flags, const StringVector &args);
int picture(const StringMap &flags, const StringVector &args);
int setPicture(const StringMap &flags, const StringVector &args);
int logLevel(const StringMap &flags, const StringVector &args);
int setLogLevel(const StringMap &flags, const StringVector &args);
int showClients(const StringMap &flags, const StringVector &args);
int dumpInfo(const StringMap &flags, const StringVector &args);
int hacks(const StringMap &flags, const StringVector &args);
int hackInfo(const StringMap &flags, const StringVector &args);
int hack(const StringMap &flags, const StringVector &args);
void loadGenerals(Settings &settings);
VideoFormatMatrix readFormats(Settings &settings);
std::vector<VideoFormat> readFormat(Settings &settings);
StringMatrix matrixCombine(const StringMatrix &matrix);
void matrixCombineP(const StringMatrix &matrix,
size_t index,
StringVector combined,
StringMatrix &combinations);
void createDevices(Settings &settings,
const VideoFormatMatrix &availableFormats);
void createDevice(Settings &settings,
const VideoFormatMatrix &availableFormats);
std::vector<VideoFormat> readDeviceFormats(Settings &settings,
const VideoFormatMatrix &availableFormats);
};
std::string operator *(const std::string &str, size_t n);
std::string operator *(size_t n, const std::string &str);
}
AkVCam::CmdParser::CmdParser()
{
this->d = new CmdParserPrivate();
auto logFile = this->d->m_ipcBridge.logPath("AkVCamManager");
AkLogInfo() << "Sending debug output to " << logFile << std::endl;
AkVCam::Logger::setLogFile(logFile);
this->d->m_commands.push_back({});
this->setDefaultFuntion(AKVCAM_BIND_FUNC(CmdParserPrivate::defaultHandler));
this->addFlags("",
{"-h", "--help"},
"Show help.");
this->addFlags("",
{"--help-all"},
"Show advanced help.");
this->addFlags("",
{"-v", "--version"},
"Show program version.");
this->addFlags("",
{"-p", "--parseable"},
"Show parseable output.");
this->addFlags("",
{"-f", "--force"},
"Force command.");
this->addFlags("",
{"--build-info"},
"Show build information.");
this->addCommand("devices",
"",
"List devices.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showDevices));
this->addCommand("add-device",
"DESCRIPTION",
"Add a new device.",
AKVCAM_BIND_FUNC(CmdParserPrivate::addDevice));
this->addFlags("add-device",
{"-i", "--id"},
"DEVICEID",
"Create device as DEVICEID.");
this->addCommand("remove-device",
"DEVICE",
"Remove a device.",
AKVCAM_BIND_FUNC(CmdParserPrivate::removeDevice));
this->addCommand("remove-devices",
"",
"Remove all devices.",
AKVCAM_BIND_FUNC(CmdParserPrivate::removeDevices));
this->addCommand("description",
"DEVICE",
"Show device description.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showDeviceDescription));
this->addCommand("set-description",
"DEVICE DESCRIPTION",
"Set device description.",
AKVCAM_BIND_FUNC(CmdParserPrivate::setDeviceDescription));
this->addCommand("supported-formats",
"",
"Show supported formats.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showSupportedFormats));
this->addFlags("supported-formats",
{"-i", "--input"},
"Show supported input formats.");
this->addFlags("supported-formats",
{"-o", "--output"},
"Show supported output formats.");
this->addCommand("default-format",
"",
"Default device format.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showDefaultFormat));
this->addFlags("default-format",
{"-i", "--input"},
"Default input format.");
this->addFlags("default-format",
{"-o", "--output"},
"Default output format.");
this->addCommand("formats",
"DEVICE",
"Show device formats.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showFormats));
this->addCommand("add-format",
"DEVICE FORMAT WIDTH HEIGHT FPS",
"Add a new device format.",
AKVCAM_BIND_FUNC(CmdParserPrivate::addFormat));
this->addFlags("add-format",
{"-i", "--index"},
"INDEX",
"Add format at INDEX.");
this->addCommand("remove-format",
"DEVICE INDEX",
"Remove device format.",
AKVCAM_BIND_FUNC(CmdParserPrivate::removeFormat));
this->addCommand("remove-formats",
"DEVICE",
"Remove all device formats.",
AKVCAM_BIND_FUNC(CmdParserPrivate::removeFormats));
this->addCommand("update",
"",
"Update devices.",
AKVCAM_BIND_FUNC(CmdParserPrivate::update));
this->addCommand("load",
"SETTINGS.INI",
"Create devices from a setting file.",
AKVCAM_BIND_FUNC(CmdParserPrivate::loadSettings));
this->addCommand("stream",
"DEVICE FORMAT WIDTH HEIGHT",
"Read frames from stdin and send them to the device.",
AKVCAM_BIND_FUNC(CmdParserPrivate::stream));
this->addFlags("stream",
{"-f", "--fps"},
"FPS",
"Read stream input at a constant frame rate.");
this->addCommand("listen-events",
"",
"Keep the manager running and listening to global events.",
AKVCAM_BIND_FUNC(CmdParserPrivate::listenEvents));
this->addCommand("controls",
"DEVICE",
"Show device controls.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showControls));
this->addCommand("get-control",
"DEVICE CONTROL",
"Read device control.",
AKVCAM_BIND_FUNC(CmdParserPrivate::readControl));
this->addFlags("get-control",
{"-c", "--description"},
"Show control description.");
this->addFlags("get-control",
{"-t", "--type"},
"Show control type.");
this->addFlags("get-control",
{"-m", "--min"},
"Show minimum value for the control.");
this->addFlags("get-control",
{"-M", "--max"},
"Show maximum value for the control.");
this->addFlags("get-control",
{"-s", "--step"},
"Show increment/decrement step for the control.");
this->addFlags("get-control",
{"-d", "--default"},
"Show default value for the control.");
this->addFlags("get-control",
{"-l", "--menu"},
"Show options of a memu type control.");
this->addCommand("set-controls",
"DEVICE CONTROL_1=VALUE CONTROL_2=VALUE...",
"Write device controls values.",
AKVCAM_BIND_FUNC(CmdParserPrivate::writeControls));
this->addCommand("picture",
"",
"Placeholder picture to show when no streaming.",
AKVCAM_BIND_FUNC(CmdParserPrivate::picture));
this->addCommand("set-picture",
"FILE",
"Set placeholder picture.",
AKVCAM_BIND_FUNC(CmdParserPrivate::setPicture));
this->addCommand("loglevel",
"",
"Show current debugging level.",
AKVCAM_BIND_FUNC(CmdParserPrivate::logLevel));
this->addCommand("set-loglevel",
"LEVEL",
"Set debugging level.",
AKVCAM_BIND_FUNC(CmdParserPrivate::setLogLevel));
this->addCommand("clients",
"",
"Show clients using the camera.",
AKVCAM_BIND_FUNC(CmdParserPrivate::showClients));
this->addCommand("dump",
"",
"Show all information in a parseable XML format.",
AKVCAM_BIND_FUNC(CmdParserPrivate::dumpInfo));
this->addCommand("hacks",
"",
"List system hacks to make the virtual camera work.",
AKVCAM_BIND_FUNC(CmdParserPrivate::hacks),
true);
this->addCommand("hack-info",
"HACK",
"Show hack information.",
AKVCAM_BIND_FUNC(CmdParserPrivate::hackInfo),
true);
this->addFlags("hack-info",
{"-s", "--issafe"},
"Is hack safe?");
this->addFlags("hack-info",
{"-c", "--description"},
"Show hack description.");
this->addCommand("hack",
"HACK PARAMS...",
"Apply system hack.",
AKVCAM_BIND_FUNC(CmdParserPrivate::hack),
true);
this->addFlags("hack",
{"-y", "--yes"},
"Accept all risks and continue anyway.");
}
AkVCam::CmdParser::~CmdParser()
{
delete this->d;
}
int AkVCam::CmdParser::parse(int argc, char **argv)
{
auto program = basename(argv[0]);
auto command = &this->d->m_commands[0];
StringMap flags;
StringVector arguments {program};
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
char *p = nullptr;
strtod(arg.c_str(), &p);
if (arg[0] == '-' && p && strnlen(p, 1024) != 0) {
auto flag = this->d->parserFlag(command->flags, arg);
if (!flag) {
if (command->command.empty())
std::cout << "Invalid option '"
<< arg
<< "'"
<< std::endl;
else
std::cout << "Invalid option '"
<< arg << "' for '"
<< command->command
<< "'"
<< std::endl;
return -EINVAL;
}
std::string value;
if (!flag->value.empty()) {
auto next = i + 1;
if (next < argc) {
value = argv[next];
i++;
}
}
flags[arg] = value;
} else {
if (command->command.empty()) {
if (!flags.empty()) {
auto result = command->func(flags, {program});
if (result < 0)
return result;
flags.clear();
}
auto cmd = this->d->parserCommand(arg);
if (cmd) {
command = cmd;
flags.clear();
} else {
std::cout << "Unknown command '" << arg << "'" << std::endl;
return -EINVAL;
}
} else {
arguments.push_back(arg);
}
}
}
if (!this->d->m_force && this->d->m_ipcBridge.isBusyFor(command->command)) {
std::cerr << "This operation is not permitted." << std::endl;
std::cerr << "The virtual camera is in use. Stop or close the virtual "
<< "camera clients and try again." << std::endl;
std::cerr << std::endl;
auto clients = this->d->m_ipcBridge.clientsPids();
if (!clients.empty()) {
std::vector<std::string> table {
"Pid",
"Executable"
};
auto columns = table.size();
for (auto &pid: clients) {
table.push_back(std::to_string(pid));
table.push_back(this->d->m_ipcBridge.clientExe(pid));
}
this->d->drawTable(table, columns, true);
}
return -EBUSY;
}
if (this->d->m_ipcBridge.needsRoot(command->command)
|| (command->command == "hack"
&& arguments.size() >= 2
&& this->d->m_ipcBridge.hackNeedsRoot(arguments[1]))) {
std::cerr << "You must run this command with administrator privileges." << std::endl;
return -EPERM;
}
return command->func(flags, arguments);
}
void AkVCam::CmdParser::setDefaultFuntion(const ProgramOptionsFunc &func)
{
this->d->m_commands[0].func = func;
}
void AkVCam::CmdParser::addCommand(const std::string &command,
const std::string &arguments,
const std::string &helpString,
const ProgramOptionsFunc &func,
bool advanced)
{
auto it =
std::find_if(this->d->m_commands.begin(),
this->d->m_commands.end(),
[&command] (const CmdParserCommand &cmd) -> bool {
return cmd.command == command;
});
if (it == this->d->m_commands.end()) {
this->d->m_commands.push_back({command,
arguments,
helpString,
func,
{},
advanced});
} else {
it->command = command;
it->arguments = arguments;
it->helpString = helpString;
it->func = func;
it->advanced = advanced;
}
}
void AkVCam::CmdParser::addFlags(const std::string &command,
const StringVector &flags,
const std::string &value,
const std::string &helpString)
{
auto it =
std::find_if(this->d->m_commands.begin(),
this->d->m_commands.end(),
[&command] (const CmdParserCommand &cmd) -> bool {
return cmd.command == command;
});
if (it == this->d->m_commands.end())
return;
it->flags.push_back({flags, value, helpString});
}
void AkVCam::CmdParser::addFlags(const std::string &command,
const StringVector &flags,
const std::string &helpString)
{
this->addFlags(command, flags, "", helpString);
}
const std::map<AkVCam::ControlType, std::string> &AkVCam::CmdParserPrivate::typeStrMap()
{
static const std::map<ControlType, std::string> typeStr {
{ControlTypeInteger, "Integer"},
{ControlTypeBoolean, "Boolean"},
{ControlTypeMenu , "Menu" },
};
return typeStr;
}
void AkVCam::CmdParserPrivate::printFlags(const std::vector<CmdParserFlags> &cmdFlags,
size_t indent)
{
std::vector<char> spaces(indent, ' ');
auto maxFlagsLen = this->maxFlagsLength(cmdFlags);
auto maxFlagsValueLen = this->maxFlagsValueLength(cmdFlags);
for (auto &flag: cmdFlags) {
auto allFlags = join(flag.flags, ", ");
std::cout << std::string(spaces.data(), indent)
<< fill(allFlags, maxFlagsLen);
if (maxFlagsValueLen > 0)
std::cout << " " << fill(flag.value, maxFlagsValueLen);
std::cout << " "
<< flag.helpString
<< std::endl;
}
}
size_t AkVCam::CmdParserPrivate::maxCommandLength(bool showAdvancedHelp)
{
size_t length = 0;
for (auto &cmd: this->m_commands)
if (!cmd.advanced || showAdvancedHelp)
length = std::max(cmd.command.size(), length);
return length;
}
size_t AkVCam::CmdParserPrivate::maxArgumentsLength(bool showAdvancedHelp)
{
size_t length = 0;
for (auto &cmd: this->m_commands)
if (!cmd.advanced || showAdvancedHelp)
length = std::max(cmd.arguments.size(), length);
return length;
}
size_t AkVCam::CmdParserPrivate::maxFlagsLength(const std::vector<CmdParserFlags> &flags)
{
size_t length = 0;
for (auto &flag: flags)
length = std::max(join(flag.flags, ", ").size(), length);
return length;
}
size_t AkVCam::CmdParserPrivate::maxFlagsValueLength(const std::vector<CmdParserFlags> &flags)
{
size_t length = 0;
for (auto &flag: flags)
length = std::max(flag.value.size(), length);
return length;
}
size_t AkVCam::CmdParserPrivate::maxColumnLength(const AkVCam::StringVector &table,
size_t width,
size_t column)
{
size_t length = 0;
size_t height = table.size() / width;
for (size_t y = 0; y < height; y++) {
auto &str = table[y * width + column];
length = std::max(str.size(), length);
}
return length;
}
std::vector<size_t> AkVCam::CmdParserPrivate::maxColumnsLength(const AkVCam::StringVector &table,
size_t width)
{
std::vector<size_t> lengths;
for (size_t x = 0; x < width; x++)
lengths.push_back(this->maxColumnLength(table, width, x));
return lengths;
}
void AkVCam::CmdParserPrivate::drawTableHLine(const std::vector<size_t> &columnsLength,
bool toStdErr)
{
std::ostream *out = &std::cout;
if (toStdErr)
out = &std::cerr;
*out << '+';
for (auto &len: columnsLength)
*out << std::string("-") * (len + 2) << '+';
*out << std::endl;
}
void AkVCam::CmdParserPrivate::drawTable(const AkVCam::StringVector &table,
size_t width,
bool toStdErr)
{
size_t height = table.size() / width;
auto columnsLength = this->maxColumnsLength(table, width);
this->drawTableHLine(columnsLength, toStdErr);
std::ostream *out = &std::cout;
if (toStdErr)
out = &std::cerr;
for (size_t y = 0; y < height; y++) {
*out << "|";
for (size_t x = 0; x < width; x++) {
auto &element = table[x + y * width];
*out << " " << fill(element, columnsLength[x]) << " |";
}
*out << std::endl;
if (y == 0 && height > 1)
this->drawTableHLine(columnsLength, toStdErr);
}
this->drawTableHLine(columnsLength, toStdErr);
}
AkVCam::CmdParserCommand *AkVCam::CmdParserPrivate::parserCommand(const std::string &command)
{
for (auto &cmd: this->m_commands)
if (cmd.command == command)
return &cmd;
return nullptr;
}
const AkVCam::CmdParserFlags *AkVCam::CmdParserPrivate::parserFlag(const std::vector<CmdParserFlags> &cmdFlags,
const std::string &flag)
{
for (auto &flags: cmdFlags)
for (auto &f: flags.flags)
if (f == flag)
return &flags;
return nullptr;
}
bool AkVCam::CmdParserPrivate::containsFlag(const StringMap &flags,
const std::string &command,
const std::string &flagAlias)
{
for (auto &cmd: this->m_commands)
if (cmd.command == command) {
for (auto &flag: cmd.flags) {
auto it = std::find(flag.flags.begin(),
flag.flags.end(),
flagAlias);
if (it != flag.flags.end()) {
for (auto &f1: flags)
for (auto &f2: flag.flags)
if (f1.first == f2)
return true;
return false;
}
}
return false;
}
return false;
}
std::string AkVCam::CmdParserPrivate::flagValue(const AkVCam::StringMap &flags,
const std::string &command,
const std::string &flagAlias)
{
for (auto &cmd: this->m_commands)
if (cmd.command == command) {
for (auto &flag: cmd.flags) {
auto it = std::find(flag.flags.begin(),
flag.flags.end(),
flagAlias);
if (it != flag.flags.end()) {
for (auto &f1: flags)
for (auto &f2: flag.flags)
if (f1.first == f2)
return f1.second;
return {};
}
}
return {};
}
return {};
}
int AkVCam::CmdParserPrivate::defaultHandler(const StringMap &flags,
const StringVector &args)
{
if (flags.empty()
|| this->containsFlag(flags, "", "-h")
|| this->containsFlag(flags, "", "--help-all")) {
return this->showHelp(flags, args);
}
if (this->containsFlag(flags, "", "-v")) {
std::cout << COMMONS_VERSION << std::endl;
return 0;
}
if (this->containsFlag(flags, "", "--build-info")) {
#ifdef GIT_COMMIT_HASH
std::string commitHash = GIT_COMMIT_HASH;
std::string commitUrl = COMMONS_PROJECT_COMMIT_URL "/" GIT_COMMIT_HASH;
if (commitHash.empty())
commitHash = "Unknown";
if (commitUrl.empty())
commitUrl = "Unknown";
#else
std::string commitHash;
std::string commitUrl;
#endif
std::cout << "Commit hash: " << commitHash << std::endl;
std::cout << "Commit URL: " << commitUrl << std::endl;
return 0;
}
if (this->containsFlag(flags, "", "-p"))
this->m_parseable = true;
if (this->containsFlag(flags, "", "-f"))
this->m_force = true;
return 0;
}
int AkVCam::CmdParserPrivate::showHelp(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
std::cout << args[0]
<< " [OPTIONS...] COMMAND [COMMAND_OPTIONS...] ..."
<< std::endl;
std::cout << std::endl;
std::cout << "AkVirtualCamera virtual device manager." << std::endl;
std::cout << std::endl;
std::cout << "General Options:" << std::endl;
std::cout << std::endl;
this->printFlags(this->m_commands[0].flags, 4);
std::cout << std::endl;
std::cout << "Commands:" << std::endl;
std::cout << std::endl;
bool showAdvancedHelp = this->containsFlag(flags, "", "--help-all");
auto maxCmdLen = this->maxCommandLength(showAdvancedHelp);
auto maxArgsLen = this->maxArgumentsLength(showAdvancedHelp);
for (auto &cmd: this->m_commands) {
if (cmd.command.empty()
|| (cmd.advanced && !showAdvancedHelp))
continue;
std::cout << " "
<< fill(cmd.command, maxCmdLen)
<< " "
<< fill(cmd.arguments, maxArgsLen)
<< " "
<< cmd.helpString << std::endl;
if (!cmd.flags.empty())
std::cout << std::endl;
this->printFlags(cmd.flags, 8);
if (!cmd.flags.empty())
std::cout << std::endl;
}
return 0;
}
int AkVCam::CmdParserPrivate::showDevices(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto devices = this->m_ipcBridge.devices();
if (devices.empty())
return 0;
std::sort(devices.begin(), devices.end());
if (this->m_parseable) {
for (auto &device: devices)
std::cout << device << std::endl;
} else {
std::vector<std::string> table {
"Device",
"Description"
};
auto columns = table.size();
for (auto &device: devices) {
table.push_back(device);
table.push_back(this->m_ipcBridge.description(device));
}
this->drawTable(table, columns);
}
return 0;
}
int AkVCam::CmdParserPrivate::addDevice(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Device description not provided." << std::endl;
return -EINVAL;
}
auto deviceId = this->flagValue(flags, "add-device", "-i");
deviceId = this->m_ipcBridge.addDevice(args[1], deviceId);
if (deviceId.empty()) {
std::cerr << "Failed to create device." << std::endl;
return -EIO;
}
if (this->m_parseable)
std::cout << deviceId << std::endl;
else
std::cout << "Device created as " << deviceId << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::removeDevice(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto it = std::find(devices.begin(), devices.end(), deviceId);
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
this->m_ipcBridge.removeDevice(args[1]);
return 0;
}
int AkVCam::CmdParserPrivate::removeDevices(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto devices = this->m_ipcBridge.devices();
for (auto &device: devices)
this->m_ipcBridge.removeDevice(device);
return 0;
}
int AkVCam::CmdParserPrivate::showDeviceDescription(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto it = std::find(devices.begin(), devices.end(), deviceId);
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
std::cout << this->m_ipcBridge.description(args[1]) << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::setDeviceDescription(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
this->m_ipcBridge.setDescription(deviceId, args[2]);
return 0;
}
int AkVCam::CmdParserPrivate::showSupportedFormats(const StringMap &flags,
const StringVector &args)
{
UNUSED(args);
auto type =
this->containsFlag(flags, "supported-formats", "-i")?
IpcBridge::StreamType_Input:
IpcBridge::StreamType_Output;
auto formats = this->m_ipcBridge.supportedPixelFormats(type);
if (!this->m_parseable) {
if (type == IpcBridge::StreamType_Input)
std::cout << "Input formats:" << std::endl;
else
std::cout << "Output formats:" << std::endl;
std::cout << std::endl;
}
for (auto &format: formats)
std::cout << VideoFormat::stringFromFourcc(format) << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::showDefaultFormat(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(args);
auto type =
this->containsFlag(flags, "default-format", "-i")?
IpcBridge::StreamType_Input:
IpcBridge::StreamType_Output;
auto format = this->m_ipcBridge.defaultPixelFormat(type);
std::cout << VideoFormat::stringFromFourcc(format) << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::showFormats(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto it = std::find(devices.begin(), devices.end(), deviceId);
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
if (this->m_parseable) {
for (auto &format: this->m_ipcBridge.formats(args[1]))
std::cout << VideoFormat::stringFromFourcc(format.fourcc())
<< ' '
<< format.width()
<< ' '
<< format.height()
<< ' '
<< format.minimumFrameRate().num()
<< ' '
<< format.minimumFrameRate().den()
<< std::endl;
} else {
int i = 0;
for (auto &format: this->m_ipcBridge.formats(args[1])) {
std::cout << i
<< ": "
<< VideoFormat::stringFromFourcc(format.fourcc())
<< ' '
<< format.width()
<< 'x'
<< format.height()
<< ' '
<< format.minimumFrameRate().num()
<< '/'
<< format.minimumFrameRate().den()
<< " FPS"
<< std::endl;
i++;
}
}
return 0;
}
int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
const StringVector &args)
{
if (args.size() < 6) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
auto format = VideoFormat::fourccFromString(args[2]);
if (!format) {
std::cerr << "Invalid pixel format." << std::endl;
return -EINVAL;
}
auto formats =
this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamType_Output);
auto fit = std::find(formats.begin(), formats.end(), format);
if (fit == formats.end()) {
std::cerr << "Format not supported." << std::endl;
return -EINVAL;
}
char *p = nullptr;
auto width = strtoul(args[3].c_str(), &p, 10);
if (*p) {
std::cerr << "Width must be an unsigned integer." << std::endl;
return -EINVAL;
}
p = nullptr;
auto height = strtoul(args[4].c_str(), &p, 10);
if (*p) {
std::cerr << "Height must be an unsigned integer." << std::endl;
return -EINVAL;
}
Fraction fps(args[5]);
if (fps.num() < 1 || fps.den() < 1) {
std::cerr << "Invalid frame rate." << std::endl;
return -EINVAL;
}
auto indexStr = this->flagValue(flags, "add-format", "-i");
int index = -1;
if (!indexStr.empty()) {
p = nullptr;
index = int(strtoul(indexStr.c_str(), &p, 10));
if (*p) {
std::cerr << "Index must be an unsigned integer." << std::endl;
return -EINVAL;
}
}
VideoFormat fmt(format, int(width), int(height), {fps});
this->m_ipcBridge.addFormat(deviceId, fmt, index);
return 0;
}
int AkVCam::CmdParserPrivate::removeFormat(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
char *p = nullptr;
auto index = strtoul(args[2].c_str(), &p, 10);
if (*p) {
std::cerr << "Index must be an unsigned integer." << std::endl;
return -EINVAL;
}
auto formats = this->m_ipcBridge.formats(deviceId);
if (index >= formats.size()) {
std::cerr << "Index is out of range." << std::endl;
return -ERANGE;
}
this->m_ipcBridge.removeFormat(deviceId, int(index));
return 0;
}
int AkVCam::CmdParserPrivate::removeFormats(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
this->m_ipcBridge.setFormats(deviceId, {});
return 0;
}
int AkVCam::CmdParserPrivate::update(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
UNUSED(args);
this->m_ipcBridge.updateDevices();
return 0;
}
int AkVCam::CmdParserPrivate::loadSettings(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Settings file not provided." << std::endl;
return -EINVAL;
}
Settings settings;
if (!settings.load(args[1])) {
std::cerr << "Settings file not valid." << std::endl;
return -EIO;
}
this->loadGenerals(settings);
auto devices = this->m_ipcBridge.devices();
for (auto &device: devices)
this->m_ipcBridge.removeDevice(device);
this->createDevices(settings, this->readFormats(settings));
return 0;
}
int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 5) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
auto format = VideoFormat::fourccFromString(args[2]);
if (!format) {
std::cerr << "Invalid pixel format." << std::endl;
return -EINVAL;
}
auto formats =
this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamType_Output);
auto fit = std::find(formats.begin(), formats.end(), format);
if (fit == formats.end()) {
std::cerr << "Format not supported." << std::endl;
return -EINVAL;
}
char *p = nullptr;
auto width = strtoul(args[3].c_str(), &p, 10);
if (*p) {
std::cerr << "Width must be an unsigned integer." << std::endl;
return -EINVAL;
}
p = nullptr;
auto height = strtoul(args[4].c_str(), &p, 10);
if (*p) {
std::cerr << "Height must be an unsigned integer." << std::endl;
return -EINVAL;
}
auto fpsStr = this->flagValue(flags, "stream", "-f");
double fps = std::numeric_limits<double>::quiet_NaN();
if (!fpsStr.empty()) {
p = nullptr;
fps = int(strtod(fpsStr.c_str(), &p));
if (*p) {
if (!Fraction::isFraction(fpsStr)) {
std::cerr << "The framerate must be a number or a fraction." << std::endl;
return -EINVAL;
}
fps = Fraction(fpsStr).value();
}
if (fps <= 0 || std::isinf(fps)) {
std::cerr << "The framerate is out of range." << std::endl;
return -ERANGE;
}
}
VideoFormat fmt(format, int(width), int(height), {{30, 1}});
if (!this->m_ipcBridge.deviceStart(IpcBridge::StreamType_Output, deviceId)) {
std::cerr << "Can't start stream." << std::endl;
return -EIO;
}
static bool exit = false;
auto signalHandler = [] (int) {
exit = true;
};
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
#ifndef _WIN32
signal(SIGPIPE, [] (int) {
});
#endif
AkVCam::VideoFrame frame(fmt);
size_t bufferSize = 0;
#ifdef _WIN32
// Set std::cin in binary mode.
_setmode(_fileno(stdin), _O_BINARY);
#endif
auto clock = [] (const std::chrono::time_point<std::chrono::high_resolution_clock> &since) -> double {
return std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - since).count();
};
const double minThreshold = 0.04;
const double maxThreshold = 0.1;
const double framedupThreshold = 0.1;
const double nosyncThreshold = 10.0;
double lastPts = 0.0;
auto t0 = std::chrono::high_resolution_clock::now();
double drift = 0;
uint64_t i = 0;
do {
std::cin.read(reinterpret_cast<char *>(frame.data().data()
+ bufferSize),
std::streamsize(frame.data().size() - bufferSize));
bufferSize += size_t(std::cin.gcount());
if (bufferSize == frame.data().size()) {
if (fpsStr.empty()) {
this->m_ipcBridge.write(deviceId, frame);
} else {
double pts = double(i) / fps;
for (;;) {
double clock_pts = clock(t0) + drift;
double diff = pts - clock_pts;
double delay = pts - lastPts;
double syncThreshold =
std::max(minThreshold,
std::min(delay, maxThreshold));
if (!std::isnan(diff)
&& std::abs(diff) < nosyncThreshold
&& delay < framedupThreshold) {
if (diff <= -syncThreshold) {
lastPts = pts;
break;
}
if (diff > syncThreshold) {
std::this_thread::sleep_for(std::chrono::duration<double>(diff - syncThreshold));
continue;
}
} else {
drift = clock(t0) - pts;
}
this->m_ipcBridge.write(deviceId, frame);
lastPts = pts;
break;
}
i++;
}
bufferSize = 0;
}
} while (!std::cin.eof() && !exit);
this->m_ipcBridge.deviceStop(deviceId);
return 0;
}
int AkVCam::CmdParserPrivate::listenEvents(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto devicesChanged = [] (void *, const std::vector<std::string> &) {
std::cout << "DevicesUpdated" << std::endl;
};
auto pictureChanged = [] (void *, const std::string &) {
std::cout << "PictureUpdated" << std::endl;
};
this->m_ipcBridge.connectDevicesChanged(this, devicesChanged);
this->m_ipcBridge.connectPictureChanged(this, pictureChanged);
static bool exit = false;
auto signalHandler = [] (int) {
exit = true;
};
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
while (!exit)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
return 0;
}
int AkVCam::CmdParserPrivate::showControls(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
if (this->m_parseable) {
for (auto &control: this->m_ipcBridge.controls(deviceId))
std::cout << control.id << std::endl;
} else {
auto typeStr = typeStrMap();
std::vector<std::string> table {
"Control",
"Description",
"Type",
"Minimum",
"Maximum",
"Step",
"Default",
"Value"
};
auto columns = table.size();
for (auto &control: this->m_ipcBridge.controls(deviceId)) {
table.push_back(control.id);
table.push_back(control.description);
table.push_back(typeStr[control.type]);
table.push_back(std::to_string(control.minimum));
table.push_back(std::to_string(control.maximum));
table.push_back(std::to_string(control.step));
table.push_back(std::to_string(control.defaultValue));
table.push_back(std::to_string(control.value));
}
this->drawTable(table, columns);
}
return 0;
}
int AkVCam::CmdParserPrivate::readControl(const StringMap &flags,
const StringVector &args)
{
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
for (auto &control: this->m_ipcBridge.controls(deviceId))
if (control.id == args[2]) {
if (flags.empty()) {
std::cout << control.value << std::endl;
} else {
if (this->containsFlag(flags, "get-control", "-c")) {
std::cout << control.description << std::endl;
}
if (this->containsFlag(flags, "get-control", "-t")) {
auto typeStr = typeStrMap();
std::cout << typeStr[control.type] << std::endl;
}
if (this->containsFlag(flags, "get-control", "-m")) {
std::cout << control.minimum << std::endl;
}
if (this->containsFlag(flags, "get-control", "-M")) {
std::cout << control.maximum << std::endl;
}
if (this->containsFlag(flags, "get-control", "-s")) {
std::cout << control.step << std::endl;
}
if (this->containsFlag(flags, "get-control", "-d")) {
std::cout << control.defaultValue << std::endl;
}
if (this->containsFlag(flags, "get-control", "-l")) {
for (size_t i = 0; i < control.menu.size(); i++)
if (this->m_parseable)
std::cout << control.menu[i] << std::endl;
else
std::cout << i
<< ": "
<< control.menu[i]
<< std::endl;
}
}
return 0;
}
std::cerr << "'" << args[2] << "' control not available." << std::endl;
return -ENOSYS;
}
int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto deviceId = args[1];
auto devices = this->m_ipcBridge.devices();
auto dit = std::find(devices.begin(), devices.end(), deviceId);
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -ENODEV;
}
std::map<std::string, int> controls;
for (size_t i = 2; i < args.size(); i++) {
if (args[i].find('=') == std::string::npos) {
std::cerr << "Argumment "
<< i
<< " is not in the form KEY=VALUE."
<< std::endl;
return -EINVAL;
}
auto pair = splitOnce(args[i], "=");
if (pair.first.empty()) {
std::cerr << "Key for argumment "
<< i
<< " is emty."
<< std::endl;
return -EINVAL;
}
auto key = trimmed(pair.first);
auto value = trimmed(pair.second);
bool found = false;
for (auto &control: this->m_ipcBridge.controls(deviceId))
if (control.id == key) {
switch (control.type) {
case ControlTypeInteger: {
char *p = nullptr;
auto val = strtol(value.c_str(), &p, 10);
if (*p) {
std::cerr << "Value at argument "
<< i
<< " must be an integer."
<< std::endl;
return -EINVAL;
}
controls[key] = val;
break;
}
case ControlTypeBoolean: {
std::locale loc;
std::transform(value.begin(),
value.end(),
value.begin(),
[&loc](char c) {
return std::tolower(c, loc);
});
if (value == "0" || value == "false") {
controls[key] = 0;
} else if (value == "1" || value == "true") {
controls[key] = 1;
} else {
std::cerr << "Value at argument "
<< i
<< " must be a boolean."
<< std::endl;
return -EINVAL;
}
break;
}
case ControlTypeMenu: {
char *p = nullptr;
auto val = strtoul(value.c_str(), &p, 10);
if (*p) {
auto it = std::find(control.menu.begin(),
control.menu.end(),
value);
if (it == control.menu.end()) {
std::cerr << "Value at argument "
<< i
<< " is not valid."
<< std::endl;
return -EINVAL;
}
controls[key] = int(it - control.menu.begin());
} else {
if (val >= control.menu.size()) {
std::cerr << "Value at argument "
<< i
<< " is out of range."
<< std::endl;
return -ERANGE;
}
controls[key] = int(val);
}
break;
}
default:
break;
}
found = true;
break;
}
if (!found) {
std::cerr << "No such '"
<< key
<< "' control in argument "
<< i
<< "."
<< std::endl;
return -ENOSYS;
}
}
this->m_ipcBridge.setControls(deviceId, controls);
return 0;
}
int AkVCam::CmdParserPrivate::picture(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
std::cout << this->m_ipcBridge.picture() << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::setPicture(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
this->m_ipcBridge.setPicture(args[1]);
return 0;
}
int AkVCam::CmdParserPrivate::logLevel(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto level = this->m_ipcBridge.logLevel();
if (this->m_parseable)
std::cout << level << std::endl;
else
std::cout << AkVCam::Logger::levelToString(level) << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::setLogLevel(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto levelStr = args[1];
char *p = nullptr;
auto level = strtol(levelStr.c_str(), &p, 10);
if (*p)
level = AkVCam::Logger::levelFromString(levelStr);
this->m_ipcBridge.setLogLevel(level);
return 0;
}
int AkVCam::CmdParserPrivate::showClients(const StringMap &flags,
const StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto clients = this->m_ipcBridge.clientsPids();
if (clients.empty())
return 0;
if (this->m_parseable) {
for (auto &pid: clients)
std::cout << pid
<< " "
<< this->m_ipcBridge.clientExe(pid)
<< std::endl;
} else {
std::vector<std::string> table {
"Pid",
"Executable"
};
auto columns = table.size();
for (auto &pid: clients) {
table.push_back(std::to_string(pid));
table.push_back(this->m_ipcBridge.clientExe(pid));
}
this->drawTable(table, columns);
}
return 0;
}
int AkVCam::CmdParserPrivate::dumpInfo(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
static const auto indent = 4 * std::string(" ");
std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << std::endl;
std::cout << "<info>" << std::endl;
std::cout << indent << "<devices>" << std::endl;
auto devices = this->m_ipcBridge.devices();
for (auto &device: devices) {
std::cout << 2 * indent << "<device>" << std::endl;
std::cout << 3 * indent << "<id>" << device << "</id>" << std::endl;
std::cout << 3 * indent
<< "<description>"
<< this->m_ipcBridge.description(device)
<< "</description>"
<< std::endl;
std::cout << 3 * indent << "<formats>" << std::endl;
for (auto &format: this->m_ipcBridge.formats(device)) {
std::cout << 4 * indent << "<format>" << std::endl;
std::cout << 5 * indent
<< "<pixel-format>"
<< VideoFormat::stringFromFourcc(format.fourcc())
<< "</pixel-format>"
<< std::endl;
std::cout << 5 * indent
<< "<width>"
<< format.width()
<< "</width>"
<< std::endl;
std::cout << 5 * indent
<< "<height>"
<< format.height()
<< "</height>"
<< std::endl;
std::cout << 5 * indent
<< "<fps>"
<< format.minimumFrameRate().toString()
<< "</fps>"
<< std::endl;
std::cout << 4 * indent << "</format>" << std::endl;
}
std::cout << 3 * indent << "</formats>" << std::endl;
std::cout << 3 * indent << "<controls>" << std::endl;
for (auto &control: this->m_ipcBridge.controls(device)) {
std::cout << 4 * indent << "<control>" << std::endl;
std::cout << 5 * indent
<< "<id>"
<< control.id
<< "</id>"
<< std::endl;
std::cout << 5 * indent
<< "<description>"
<< control.description
<< "</description>"
<< std::endl;
auto typeStr = typeStrMap();
std::cout << 5 * indent
<< "<type>"
<< typeStr[control.type]
<< "</type>"
<< std::endl;
std::cout << 5 * indent
<< "<minimum>"
<< control.minimum
<< "</minimum>"
<< std::endl;
std::cout << 5 * indent
<< "<maximum>"
<< control.maximum
<< "</maximum>"
<< std::endl;
std::cout << 5 * indent
<< "<step>"
<< control.step
<< "</step>"
<< std::endl;
std::cout << 5 * indent
<< "<default-value>"
<< control.defaultValue
<< "</default-value>"
<< std::endl;
std::cout << 5 * indent
<< "<value>"
<< control.value
<< "</value>"
<< std::endl;
if (!control.menu.empty() && control.type == ControlTypeMenu) {
std::cout << 5 * indent << "<menu>" << std::endl;
for (auto &item: control.menu)
std::cout << 6 * indent
<< "<item>"
<< item
<< "</item>"
<< std::endl;
std::cout << 5 * indent << "</menu>" << std::endl;
}
std::cout << 4 * indent << "</control>" << std::endl;
}
std::cout << 3 * indent << "</controls>" << std::endl;
std::cout << 2 * indent << "</device>" << std::endl;
}
std::cout << indent << "</devices>" << std::endl;
std::cout << indent << "<input-formats>" << std::endl;
for (auto &format: this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamType_Input))
std::cout << 2 * indent
<< "<pixel-format>"
<< VideoFormat::stringFromFourcc(format)
<< "</pixel-format>"
<< std::endl;
std::cout << indent << "</input-formats>" << std::endl;
auto defInputFormat =
this->m_ipcBridge.defaultPixelFormat(IpcBridge::StreamType_Input);
std::cout << indent
<< "<default-input-format>"
<< VideoFormat::stringFromFourcc(defInputFormat)
<< "</default-input-format>"
<< std::endl;
std::cout << indent << "<output-formats>" << std::endl;
for (auto &format: this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamType_Output))
std::cout << 2 * indent
<< "<pixel-format>"
<< VideoFormat::stringFromFourcc(format)
<< "</pixel-format>"
<< std::endl;
std::cout << indent << "</output-formats>" << std::endl;
auto defOutputFormat =
this->m_ipcBridge.defaultPixelFormat(IpcBridge::StreamType_Output);
std::cout << indent
<< "<default-output-format>"
<< VideoFormat::stringFromFourcc(defOutputFormat)
<< "</default-output-format>"
<< std::endl;
std::cout << indent << "<clients>" << std::endl;
for (auto &pid: this->m_ipcBridge.clientsPids()) {
std::cout << 2 * indent << "<client>" << std::endl;
std::cout << 3 * indent << "<pid>" << pid << "</pid>" << std::endl;
std::cout << 3 * indent
<< "<exe>"
<< this->m_ipcBridge.clientExe(pid)
<< "</exe>"
<< std::endl;
std::cout << 2 * indent << "</client>" << std::endl;
}
std::cout << indent << "</clients>" << std::endl;
std::cout << indent
<< "<picture>"
<< this->m_ipcBridge.picture()
<< "</picture>"
<< std::endl;
std::cout << indent
<< "<loglevel>"
<< this->m_ipcBridge.logLevel()
<< "</loglevel>"
<< std::endl;
std::cout << "</info>" << std::endl;
return 0;
}
int AkVCam::CmdParserPrivate::hacks(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
UNUSED(flags);
UNUSED(args);
auto hacks = this->m_ipcBridge.hacks();
if (hacks.empty())
return 0;
if (this->m_parseable) {
for (auto &hack: hacks)
std::cout << hack << std::endl;
} else {
std::cout << "Hacks are intended to fix common problems with the "
"virtual camera, and are intended to be used by developers "
"and advanced users only." << std::endl;
std::cout << std::endl;
std::cout << "WARNING: Unsafe hacks can brick your system, make it "
"unstable, or expose it to a serious security risk, "
"remember to make a backup of your files and system. You "
"are solely responsible of whatever happens for using "
"them. You been warned, don't come and cry later."
<< std::endl;
std::cout << std::endl;
std::vector<std::string> table {
"Hack",
"Is safe?",
"Description"
};
auto columns = table.size();
for (auto &hack: hacks) {
table.push_back(hack);
table.push_back(this->m_ipcBridge.hackIsSafe(hack)? "Yes": "No");
table.push_back(this->m_ipcBridge.hackDescription(hack));
}
this->drawTable(table, columns);
}
return 0;
}
int AkVCam::CmdParserPrivate::hackInfo(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto hack = args[1];
auto hacks = this->m_ipcBridge.hacks();
auto dit = std::find(hacks.begin(), hacks.end(), hack);
if (dit == hacks.end()) {
std::cerr << "Unknown hack: " << hack << "." << std::endl;
return -ENOSYS;
}
if (this->containsFlag(flags, "hack-info", "-c"))
std::cout << this->m_ipcBridge.hackDescription(hack) << std::endl;
if (this->containsFlag(flags, "hack-info", "-s")) {
if (this->m_ipcBridge.hackIsSafe(hack))
std::cout << "Yes" << std::endl;
else
std::cout << "No" << std::endl;
}
return 0;
}
int AkVCam::CmdParserPrivate::hack(const AkVCam::StringMap &flags,
const AkVCam::StringVector &args)
{
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -EINVAL;
}
auto hack = args[1];
auto hacks = this->m_ipcBridge.hacks();
auto dit = std::find(hacks.begin(), hacks.end(), hack);
if (dit == hacks.end()) {
std::cerr << "Unknown hack: " << hack << "." << std::endl;
return -ENOSYS;
}
bool accepted = this->m_parseable | this->m_ipcBridge.hackIsSafe(hack);
if (!accepted && !this->m_parseable) {
std::cout << "WARNING: Applying this hack can brick your system, make "
"it unstable, or expose it to a serious security risk, "
"remember to make a backup of your files and system. "
"Agreeing to continue, you accept the full responsability "
"of whatever happens from now on."
<< std::endl;
std::cout << std::endl;
if (this->containsFlag(flags, "hack", "-y")) {
std::cout << "You agreed to continue from command line."
<< std::endl;
std::cout << std::endl;
accepted = true;
} else {
std::cout << "If you agree to continue write YES: ";
std::string answer;
std::cin >> answer;
std::cout << std::endl;
accepted = answer == "YES";
}
}
if (!accepted) {
std::cerr << "Hack not applied." << std::endl;
return -EIO;
}
StringVector hargs;
for (size_t i = 2; i < args.size(); i++)
hargs.push_back(args[i]);
auto result = this->m_ipcBridge.execHack(hack, hargs);
if (result == 0)
std::cout << "Success" << std::endl;
else
std::cout << "Failed" << std::endl;
return result;
}
void AkVCam::CmdParserPrivate::loadGenerals(Settings &settings)
{
settings.beginGroup("General");
if (settings.contains("default_frame"))
this->m_ipcBridge.setPicture(settings.value("default_frame"));
if (settings.contains("loglevel")) {
auto logLevel= settings.value("loglevel");
char *p = nullptr;
auto level = strtol(logLevel.c_str(), &p, 10);
if (*p)
level = AkVCam::Logger::levelFromString(logLevel);
this->m_ipcBridge.setLogLevel(level);
}
settings.endGroup();
}
AkVCam::VideoFormatMatrix AkVCam::CmdParserPrivate::readFormats(Settings &settings)
{
VideoFormatMatrix formatsMatrix;
settings.beginGroup("Formats");
auto nFormats = settings.beginArray("formats");
for (size_t i = 0; i < nFormats; i++) {
settings.setArrayIndex(i);
formatsMatrix.push_back(this->readFormat(settings));
}
settings.endArray();
settings.endGroup();
return formatsMatrix;
}
std::vector<AkVCam::VideoFormat> AkVCam::CmdParserPrivate::readFormat(Settings &settings)
{
std::vector<AkVCam::VideoFormat> formats;
auto pixFormats = settings.valueList("format", ",");
auto widths = settings.valueList("width", ",");
auto heights = settings.valueList("height", ",");
auto frameRates = settings.valueList("fps", ",");
if (pixFormats.empty()
|| widths.empty()
|| heights.empty()
|| frameRates.empty()) {
std::cerr << "Error reading formats." << std::endl;
return {};
}
StringMatrix formatMatrix;
formatMatrix.push_back(pixFormats);
formatMatrix.push_back(widths);
formatMatrix.push_back(heights);
formatMatrix.push_back(frameRates);
for (auto &format_list: this->matrixCombine(formatMatrix)) {
auto pixFormat = VideoFormat::fourccFromString(format_list[0]);
char *p = nullptr;
auto width = strtol(format_list[1].c_str(), &p, 10);
p = nullptr;
auto height = strtol(format_list[2].c_str(), &p, 10);
Fraction frame_rate(format_list[3]);
VideoFormat format(pixFormat,
width,
height,
{frame_rate});
if (format.isValid())
formats.push_back(format);
}
return formats;
}
AkVCam::StringMatrix AkVCam::CmdParserPrivate::matrixCombine(const StringMatrix &matrix)
{
StringVector combined;
StringMatrix combinations;
this->matrixCombineP(matrix, 0, combined, combinations);
return combinations;
}
/* A matrix is a list of lists where each element in the main list is a row,
* and each element in a row is a column. We combine each element in a row with
* each element in the next rows.
*/
void AkVCam::CmdParserPrivate::matrixCombineP(const StringMatrix &matrix,
size_t index,
StringVector combined,
StringMatrix &combinations)
{
if (index >= matrix.size()) {
combinations.push_back(combined);
return;
}
for (auto &data: matrix[index]) {
auto combinedP1 = combined;
combinedP1.push_back(data);
this->matrixCombineP(matrix, index + 1, combinedP1, combinations);
}
}
void AkVCam::CmdParserPrivate::createDevices(Settings &settings,
const VideoFormatMatrix &availableFormats)
{
auto devices = this->m_ipcBridge.devices();
for (auto &device: devices)
this->m_ipcBridge.removeDevice(device);
settings.beginGroup("Cameras");
size_t nCameras = settings.beginArray("cameras");
for (size_t i = 0; i < nCameras; i++) {
settings.setArrayIndex(i);
this->createDevice(settings, availableFormats);
}
settings.endArray();
settings.endGroup();
this->m_ipcBridge.updateDevices();
}
void AkVCam::CmdParserPrivate::createDevice(Settings &settings,
const VideoFormatMatrix &availableFormats)
{
auto description = settings.value("description");
if (description.empty()) {
std::cerr << "Device description is empty" << std::endl;
return;
}
auto formats = this->readDeviceFormats(settings, availableFormats);
if (formats.empty()) {
std::cerr << "Can't read device formats" << std::endl;
return;
}
auto deviceId = settings.value("id");
deviceId = this->m_ipcBridge.addDevice(description, deviceId);
auto supportedFormats =
this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamType_Output);
for (auto &format: formats) {
auto it = std::find(supportedFormats.begin(),
supportedFormats.end(),
format.fourcc());
if (it != supportedFormats.end())
this->m_ipcBridge.addFormat(deviceId, format, -1);
}
}
std::vector<AkVCam::VideoFormat> AkVCam::CmdParserPrivate::readDeviceFormats(Settings &settings,
const VideoFormatMatrix &availableFormats)
{
std::vector<AkVCam::VideoFormat> formats;
auto formatsIndex = settings.valueList("formats", ",");
for (auto &indexStr: formatsIndex) {
char *p = nullptr;
auto index = strtoul(indexStr.c_str(), &p, 10);
if (*p)
continue;
index--;
if (index >= availableFormats.size())
continue;
for (auto &format: availableFormats[index])
formats.push_back(format);
}
return formats;
}
std::string AkVCam::operator *(const std::string &str, size_t n)
{
std::stringstream ss;
for (size_t i = 0; i < n; i++)
ss << str;
return ss.str();
}
std::string AkVCam::operator *(size_t n, const std::string &str)
{
std::stringstream ss;
for (size_t i = 0; i < n; i++)
ss << str;
return ss.str();
}
AkVCam::CmdParserCommand::CmdParserCommand()
{
}
AkVCam::CmdParserCommand::CmdParserCommand(const std::string &command,
const std::string &arguments,
const std::string &helpString,
const AkVCam::ProgramOptionsFunc &func,
const std::vector<AkVCam::CmdParserFlags> &flags,
bool advanced):
command(command),
arguments(arguments),
helpString(helpString),
func(func),
flags(flags),
advanced(advanced)
{
}
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#ifndef CMDPARSER_H
#define CMDPARSER_H
#include <functional>
#include <map>
#include <string>
#include <vector>
namespace AkVCam {
class CmdParserPrivate;
using StringVector = std::vector<std::string>;
using StringMap = std::map<std::string, std::string>;
using ProgramOptionsFunc = std::function<int (const StringMap &flags,
const StringVector &args)>;
class CmdParser
{
public:
CmdParser();
~CmdParser();
int parse(int argc, char **argv);
void setDefaultFuntion(const ProgramOptionsFunc &func);
void addCommand(const std::string &command,
const std::string &arguments,
const std::string &helpString,
const ProgramOptionsFunc &func,
bool advanced=false);
void addFlags(const std::string &command,
const StringVector &flags,
const std::string &value,
const std::string &helpString);
void addFlags(const std::string &command,
const StringVector &flags,
const std::string &helpString);
private:
CmdParserPrivate *d;
};
}
#endif // CMDPARSER_H
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#include "cmdparser.h"
int main(int argc, char **argv)
{
return AkVCam::CmdParser().parse(argc, argv);
}
... ...
# README
Before contributing, please read [the contributing document](https://github.com/webcamoid/akvirtualcamera/blob/master/CONTRIBUTING.md), and the [coding style and conventions](https://github.com/webcamoid/webcamoid/wiki/Coding-style-and-conventions) guide.
Search the [pull request list](https://github.com/webcamoid/akvirtualcamera/pulls) for similar pulls before opening a new one.
Check your code doesn't throw any warning or error message while compiling, and doesn't give any warning in Clang static analyzer. Make sure your code is GCC, Clang, MinGW and MSVC compliant (use Github actions for that).
Check your code using GDB, Valgrind and similar tools to remove all possible memory leaks and segfaults.
# Pull request
## Type of change
Is your pull request a bug fix, new feature, code refactor, breaking change, etc.?
If your change is too big consider [discussing it](https://github.com/webcamoid/akvirtualcamera/issues) before pulling.
## Summary
Describe your pull request the best as you can.
## Related Issue
Is this pull request related to some [issue](https://github.com/webcamoid/akvirtualcamera/issues)? Cite the issue as #NNN, where NNN is the number of issue.
## More info
Provide screenshots, logs, etc. if required.
## Added dependencies
Does your pull request add more dependencies to the project? This may require some discussion. Minimal dependencies is a requirement.
## Target Environment
Is this pull request specific to a target operating system?
* Operating System information: (name) (numeric version and codename if applied) (architecture)
... ...
# akvirtualcamera, virtual camera for Mac and Windows
akvirtualcamera is virtual camera implemented as a DirectShow filter in Windows, and as a CoreMediaIO plugin in Mac.
## Features
* Supports emulated camera controls in capture devices (brightness, contrast, saturation, etc.).
* Configurable default picture in case no input signal available.
## Build and Install
Visit the [wiki](https://github.com/webcamoid/akvirtualcamera/wiki) for a comprehensive compile and install instructions.
## Downloads ##
[![Download](https://img.shields.io/badge/Download-Releases-3f2a7e.svg)](https://github.com/webcamoid/akvirtualcamera/releases)
[![Daily Build](https://img.shields.io/badge/Download-Daily%20Build-3f2a7e.svg)](https://github.com/webcamoid/akvirtualcamera/releases/tag/daily-build)
[![Total Downloads](https://img.shields.io/github/downloads/webcamoid/akvirtualcamera/total.svg?label=Total%20Downloads&color=3f2a7e)](https://tooomm.github.io/github-release-stats/?username=webcamoid&repository=akvirtualcamera)
## Donations ##
If you are interested in donating to the project you can look at all available methods in the [donations page](https://webcamoid.github.io/donations).
## Status
[![Linux MinGW](https://github.com/webcamoid/akvirtualcamera/actions/workflows/linux-mingw.yml/badge.svg)](https://github.com/webcamoid/akvirtualcamera/actions/workflows/linux-mingw.yml)
[![Mac](https://github.com/webcamoid/akvirtualcamera/actions/workflows/mac.yml/badge.svg)](https://github.com/webcamoid/akvirtualcamera/actions/workflows/mac.yml)
[![Windows MSYS](https://github.com/webcamoid/akvirtualcamera/actions/workflows/windows-msys.yml/badge.svg)](https://github.com/webcamoid/akvirtualcamera/actions/workflows/windows-msys.yml)
[![Windows MSVC](https://github.com/webcamoid/akvirtualcamera/actions/workflows/windows-vs.yml/badge.svg)](https://github.com/webcamoid/akvirtualcamera/actions/workflows/windows-vs.yml)
[![Build status](https://api.cirrus-ci.com/github/webcamoid/akvirtualcamera.svg)](https://cirrus-ci.com/github/webcamoid/akvirtualcamera)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1cee2645a3604633a506a203fb8c3161)](https://www.codacy.com/gh/webcamoid/akvirtualcamera/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=webcamoid/akvirtualcamera&amp;utm_campaign=Badge_Grade)
[![Project Stats](https://www.openhub.net/p/akvirtualcamera/widgets/project_thin_badge.gif)](https://www.openhub.net/p/akvirtualcamera)
## Reporting Bugs
Report all issues in the [issues tracker](https://github.com/webcamoid/akvirtualcamera/issues).
... ...
# Security Policy
## Supported Versions
Only report vulnerabilities in the [latest stable](https://github.com/webcamoid/akvirtualcamera/releases) version and the [master repository](https://github.com/webcamoid/akvirtualcamera) (that includes [daily build](https://bintray.com/webcamoid/webcamoid/akvirtualcamera/daily/link)).
## Reporting a Vulnerability
Report all vulnerabilities at the [issues section](https://github.com/webcamoid/akvirtualcamera/issues).
\ No newline at end of file
... ...
# akvirtualcamera, virtual camera for Mac and Windows.
# Copyright (C) 2021 Gonzalo Exequiel Pedone
#
# akvirtualcamera is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# akvirtualcamera is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
#
# Web-Site: http://webcamoid.github.io/
cmake_minimum_required(VERSION 3.5)
project(Service LANGUAGES CXX)
include(../commons.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Service
src/main.cpp
src/service.cpp
src/service.h)
if (APPLE OR FAKE_APPLE)
set_target_properties(Service PROPERTIES
OUTPUT_NAME ${AKVCAM_SERVICE_NAME}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${DATAROOTDIR})
else ()
set_target_properties(Service PROPERTIES
OUTPUT_NAME ${AKVCAM_SERVICE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${BINDIR}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR}/${BINDIR})
endif ()
add_dependencies(Service
VCamUtils)
if (APPLE OR FAKE_APPLE)
add_dependencies(Service
VCamIPC_cmio PlatformUtils_cmio)
elseif (WIN32)
add_dependencies(Service
VCamIPC_dshow PlatformUtils_dshow)
endif ()
target_include_directories(Service
PRIVATE
..)
target_link_libraries(Service
VCamUtils)
if (APPLE OR FAKE_APPLE)
target_include_directories(Service
PRIVATE
../cmio)
if (FAKE_APPLE)
target_include_directories(Service
PRIVATE
../cmio/FakeAPI)
endif ()
target_link_libraries(Service
VCamIPC_cmio
PlatformUtils_cmio)
elseif (WIN32)
target_include_directories(Service
PRIVATE
../dshow)
target_link_libraries(Service
VCamIPC_dshow
PlatformUtils_dshow)
endif ()
if (WIN32)
target_link_libraries(Service
ws2_32)
endif ()
if (APPLE OR FAKE_APPLE)
install(TARGETS Service DESTINATION ${DATAROOTDIR})
elseif (WIN32)
install(TARGETS Service DESTINATION ${BINDIR})
endif ()
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#include <string>
#include <csignal>
#include "service.h"
#include "PlatformUtils/src/preferences.h"
#include "PlatformUtils/src/utils.h"
#include "VCamUtils/src/logger.h"
AkVCam::Service *servicePtr = nullptr;
int main(int argc, char **argv)
{
auto loglevel = AkVCam::Preferences::logLevel();
AkVCam::Logger::setLogLevel(loglevel);
auto defaultLogFile = AkVCam::tempPath()
+ "/"
+ AkVCam::basename(argv[0])
+ ".log";
auto logFile = AkVCam::Preferences::readString("logfile", defaultLogFile);
AkVCam::Logger::setLogFile(logFile);
AkVCam::Service service;
servicePtr = &service;
signal(SIGTERM, [] (int) {
servicePtr->stop();
});
#ifndef _WIN32
signal(SIGPIPE, [] (int) {
});
#endif
return service.run();
}
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#include <algorithm>
#include <condition_variable>
#include <iostream>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include <thread>
#include "service.h"
#include "PlatformUtils/src/preferences.h"
#include "VCamUtils/src/logger.h"
#include "VCamUtils/src/message.h"
#include "VCamUtils/src/messageserver.h"
#include "VCamUtils/src/servicemsg.h"
#include "VCamUtils/src/videoformat.h"
#include "VCamUtils/src/videoframe.h"
namespace AkVCam
{
struct Peer
{
uint64_t clientId {0};
uint64_t pid {0};
Peer(uint64_t clientId=0, uint64_t pid=0):
clientId(clientId),
pid(pid)
{
}
};
struct BroadcastSlot
{
Peer broadcaster;
std::vector<Peer> listeners;
VideoFrame frame;
};
typedef std::map<std::string, BroadcastSlot> Broadcasts;
class ServicePrivate
{
public:
MessageServer m_messageServer;
// Broadcasting and listen
Broadcasts m_broadcasts;
std::condition_variable_any m_frameAvailable;
std::mutex m_peerMutex;
ServicePrivate();
static void removeClientById(void *userData, uint64_t clientId);
bool clients(uint64_t clientId,
const Message &inMessage,
Message &outMessage);
bool broadcast(uint64_t clientId,
const Message &inMessage,
Message &outMessage);
bool listen(uint64_t clientId,
const Message &inMessage,
Message &outMessage);
};
}
AkVCam::Service::Service()
{
this->d = new ServicePrivate;
}
AkVCam::Service::~Service()
{
delete this->d;
}
int AkVCam::Service::run()
{
AkLogFunction();
return this->d->m_messageServer.run();
}
void AkVCam::Service::stop()
{
AkLogFunction();
this->d->m_messageServer.stop();
}
#define BIND(member) \
std::bind(&member, \
this, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3)
AkVCam::ServicePrivate::ServicePrivate()
{
AkLogFunction();
this->m_messageServer.setPort(Preferences::servicePort());
this->m_messageServer.subscribe(AKVCAM_SERVICE_MSG_CLIENTS , BIND(ServicePrivate::clients) );
this->m_messageServer.subscribe(AKVCAM_SERVICE_MSG_BROADCAST, BIND(ServicePrivate::broadcast));
this->m_messageServer.subscribe(AKVCAM_SERVICE_MSG_LISTEN , BIND(ServicePrivate::listen) );
this->m_messageServer.connectConnectionClosed(this, &ServicePrivate::removeClientById);
}
void AkVCam::ServicePrivate::removeClientById(void *userData,
uint64_t clientId)
{
AkLogFunction();
AkLogDebug() << "Removing client: " << clientId << std::endl;
auto self = reinterpret_cast<ServicePrivate *>(userData);
self->m_peerMutex.lock();
std::string removeDevice;
for (auto &slot: self->m_broadcasts) {
if (slot.second.broadcaster.clientId == clientId) {
slot.second.broadcaster = {0, 0};
if (slot.second.listeners.empty())
removeDevice = slot.first;
break;
} else {
auto it = std::find_if(slot.second.listeners.begin(),
slot.second.listeners.end(),
[&clientId] (const Peer &peer) -> bool {
return peer.clientId == clientId;
});
if (it != slot.second.listeners.end()) {
slot.second.listeners.erase(it);
if (slot.second.broadcaster.pid == 0
&& slot.second.listeners.empty()) {
removeDevice = slot.first;
}
break;
}
}
}
if (!removeDevice.empty())
self->m_broadcasts.erase(removeDevice);
self->m_peerMutex.unlock();
}
bool AkVCam::ServicePrivate::clients(uint64_t clientId,
const Message &inMessage,
Message &outMessage)
{
AkLogFunction();
UNUSED(clientId);
MsgClients msgClients(inMessage);
std::vector<uint64_t> clients;
this->m_peerMutex.lock();
for (auto &slot: this->m_broadcasts) {
if (msgClients.clientType() == MsgClients::ClientType_Any
&& slot.second.broadcaster.pid
&& std::find(clients.begin(),
clients.end(),
slot.second.broadcaster.pid) == clients.end()) {
clients.push_back(slot.second.broadcaster.pid);
}
for (auto &client: slot.second.listeners)
if (std::find(clients.begin(),
clients.end(),
client.pid) == clients.end())
clients.push_back(client.pid);
}
this->m_peerMutex.unlock();
outMessage = MsgClients(msgClients.clientType(),
clients,
inMessage.queryId()).toMessage();
return true;
}
bool AkVCam::ServicePrivate::broadcast(uint64_t clientId,
const Message &inMessage,
Message &outMessage)
{
AkLogFunction();
MsgBroadcast msgBroadcast(inMessage);
MsgStatus status(-1, inMessage.queryId());
this->m_peerMutex.lock();
bool isBroadcasting = this->m_broadcasts.count(msgBroadcast.device()) < 1;
AkLogDebug() << "Device" << msgBroadcast.device() << "is broadcasting?:" << (isBroadcasting? "YES": "NO") << std::endl;
if (isBroadcasting) {
AkLogDebug() << "Adding device slot:" << std::endl;
AkLogDebug() << " Device ID:" << msgBroadcast.device() << std::endl;
AkLogDebug() << " Client ID:" << clientId << std::endl;
AkLogDebug() << " Client PID:" << msgBroadcast.pid() << std::endl;
this->m_broadcasts[msgBroadcast.device()] =
{{clientId, msgBroadcast.pid()}, {}, {}};
}
AkLogDebug() << "Get slot" << std::endl;
auto &slot = this->m_broadcasts[msgBroadcast.device()];
if (slot.broadcaster.pid == 0) {
AkLogDebug() << "Set client as broadcaster" << std::endl;
slot.broadcaster = {clientId, msgBroadcast.pid()};
}
if (slot.broadcaster.pid == msgBroadcast.pid()
&& slot.broadcaster.clientId == clientId) {
AkLogDebug() << "Save frame" << std::endl;
slot.frame = msgBroadcast.frame();
status = MsgStatus(0, inMessage.queryId());
this->m_frameAvailable.notify_all();
}
this->m_peerMutex.unlock();
AkLogDebug() << "Sending the response" << std::endl;
outMessage = status.toMessage();
return status.status() == 0;
}
bool AkVCam::ServicePrivate::listen(uint64_t clientId,
const Message &inMessage,
Message &outMessage)
{
AkLogFunction();
MsgListen msgListen(inMessage);
bool ok = false;
this->m_peerMutex.lock();
if (this->m_broadcasts.count(msgListen.device()) < 1)
this->m_broadcasts[msgListen.device()] = {};
auto &slot = this->m_broadcasts[msgListen.device()];
slot.listeners.push_back({clientId, msgListen.pid()});
if (!slot.frame)
this->m_frameAvailable.wait_for(this->m_peerMutex,
std::chrono::seconds(1));
outMessage = MsgFrameReady(msgListen.device(),
slot.frame,
slot.broadcaster.pid != 0,
inMessage.queryId()).toMessage();
slot.frame = {};
ok = true;
this->m_peerMutex.unlock();
return ok;
}
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#ifndef SERVICE_H
#define SERVICE_H
namespace AkVCam
{
class ServicePrivate;
class Service
{
public:
Service();
~Service();
int run();
void stop();
private:
ServicePrivate *d;
};
}
#endif // SERVICE_H
... ...
# akvirtualcamera, virtual camera for Mac and Windows.
# Copyright (C) 2021 Gonzalo Exequiel Pedone
#
# akvirtualcamera is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# akvirtualcamera is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
#
# Web-Site: http://webcamoid.github.io/
cmake_minimum_required(VERSION 3.14)
project(VCamUtils LANGUAGES CXX)
include(../commons.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(VCamUtils STATIC
src/color.h
src/fraction.cpp
src/fraction.h
src/ipcbridge.h
src/logger.cpp
src/logger.h
src/message.cpp
src/message.h
src/messageclient.cpp
src/messageclient.h
src/messageserver.cpp
src/messageserver.h
src/servicemsg.h
src/settings.cpp
src/settings.h
src/sockets.cpp
src/sockets.h
src/timer.cpp
src/timer.h
src/utils.cpp
src/utils.h
src/videoformat.cpp
src/videoformat.h
src/videoformattypes.h
src/videoframe.cpp
src/videoframe.h
src/videoframetypes.h)
if (WIN32)
target_link_libraries(VCamUtils
ws2_32)
endif ()
target_compile_definitions(VCamUtils PRIVATE VCAMUTILS_LIBRARY)
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#ifndef AKVCAMUTILS_COLOR_H
#define AKVCAMUTILS_COLOR_H
#include <cstdint>
namespace AkVCam
{
namespace Color
{
inline uint32_t rgb(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
{
return (a << 24) | (r << 16) | (g << 8) | b;
}
inline uint32_t red(uint32_t rgba)
{
return (rgba >> 16) & 0xff;
}
inline uint32_t green(uint32_t rgba)
{
return (rgba >> 8) & 0xff;
}
inline uint32_t blue(uint32_t rgba)
{
return rgba & 0xff;
}
inline uint32_t alpha(uint32_t rgba)
{
return rgba >> 24;
}
}
}
#endif // AKVCAMUTILS_COLOR_H
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <string>
#include "fraction.h"
#include "utils.h"
namespace AkVCam
{
class FractionPrivate
{
public:
int64_t m_num;
int64_t m_den;
template<typename T> inline static int sign(T value)
{
return value < 0? -1: 1;
}
};
}
AkVCam::Fraction::Fraction()
{
this->d = new FractionPrivate;
this->d->m_num = 0;
this->d->m_den = 0;
}
AkVCam::Fraction::Fraction(int64_t num, int64_t den)
{
this->d = new FractionPrivate;
this->d->m_num = num;
this->d->m_den = den;
}
AkVCam::Fraction::Fraction(const std::string &str)
{
this->d = new FractionPrivate;
this->d->m_num = 0;
this->d->m_den = 1;
auto pos = str.find('/');
if (pos == std::string::npos) {
auto strCpy = trimmed(str);
this->d->m_num = uint32_t(strtol(strCpy.c_str(), nullptr, 10));
} else {
auto numStr = trimmed(str.substr(0, pos));
auto denStr = trimmed(str.substr(pos + 1));
this->d->m_num = uint32_t(strtol(numStr.c_str(), nullptr, 10));
this->d->m_den = uint32_t(strtol(denStr.c_str(), nullptr, 10));
if (this->d->m_den < 1) {
this->d->m_num = 0;
this->d->m_den = 1;
}
}
}
AkVCam::Fraction::Fraction(const Fraction &other)
{
this->d = new FractionPrivate;
this->d->m_num = other.d->m_num;
this->d->m_den = other.d->m_den;
}
AkVCam::Fraction::~Fraction()
{
delete this->d;
}
AkVCam::Fraction &AkVCam::Fraction::operator =(const Fraction &other)
{
if (this != &other) {
this->d->m_num = other.d->m_num;
this->d->m_den = other.d->m_den;
}
return *this;
}
bool AkVCam::Fraction::operator ==(const Fraction &other) const
{
if (this->d->m_den == 0 && other.d->m_den != 0)
return false;
if (this->d->m_den != 0 && other.d->m_den == 0)
return false;
return this->d->m_num * other.d->m_den == this->d->m_den * other.d->m_num;
}
bool AkVCam::Fraction::operator <(const Fraction &other) const
{
return this->d->m_num * other.d->m_den < this->d->m_den * other.d->m_num;
}
int64_t AkVCam::Fraction::num() const
{
return this->d->m_num;
}
int64_t &AkVCam::Fraction::num()
{
return this->d->m_num;
}
int64_t AkVCam::Fraction::den() const
{
return this->d->m_den;
}
int64_t &AkVCam::Fraction::den()
{
return this->d->m_den;
}
double AkVCam::Fraction::value() const
{
return double(this->d->m_num) / double(this->d->m_den);
}
std::string AkVCam::Fraction::toString() const
{
std::stringstream ss;
ss << this->d->m_num << '/' << this->d->m_den;
return ss.str();
}
bool AkVCam::Fraction::isInfinity() const
{
return this->d->m_num != 0 && this->d->m_den == 0;
}
int AkVCam::Fraction::sign() const
{
return FractionPrivate::sign(this->d->m_num) == FractionPrivate::sign(this->d->m_den)? 1: -1;
}
bool AkVCam::Fraction::isFraction(const std::string &str)
{
auto pos = str.find('/');
if (pos == std::string::npos) {
auto strCpy = trimmed(str);
char *p = nullptr;
strtol(strCpy.c_str(), &p, 10);
if (*p)
return false;
} else {
auto numStr = trimmed(str.substr(0, pos));
auto denStr = trimmed(str.substr(pos + 1));
char *p = nullptr;
char *q = nullptr;
strtol(numStr.c_str(), &p, 10);
strtol(denStr.c_str(), &q, 10);
if (*p || *q)
return false;
}
return true;
}
std::ostream &operator <<(std::ostream &os, const AkVCam::Fraction &fraction)
{
os << fraction.toString();
return os;
}
... ...
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#ifndef FRACTION_H
#define FRACTION_H
#include <cstdint>
#include <string>
namespace AkVCam
{
class Fraction;
class FractionPrivate;
using FractionRange = std::pair<Fraction, Fraction>;
class Fraction
{
public:
Fraction();
Fraction(int64_t num, int64_t den);
Fraction(const std::string &str);
Fraction(const Fraction &other);
virtual ~Fraction();
Fraction &operator =(const Fraction &other);
bool operator ==(const Fraction &other) const;
bool operator <(const Fraction &other) const;
int64_t num() const;
int64_t &num();
int64_t den() const;
int64_t &den();
double value() const;
std::string toString() const;
bool isInfinity() const;
int sign() const;
static bool isFraction(const std::string &str);
private:
FractionPrivate *d;
};
}
std::ostream &operator <<(std::ostream &os, const AkVCam::Fraction &fraction);
#endif // FRACTION_H
... ...