Initial commit

This commit is contained in:
Sebastian Dröge 2021-02-05 19:03:21 +02:00
commit 577e9f936b
12 changed files with 3291 additions and 0 deletions

182
.clang-format Normal file
View file

@ -0,0 +1,182 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
...

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*build*/
.cache/
compile_commands.json

502
COPYING Normal file
View file

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser 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 Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey 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 library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

477
gstajacommon.cpp Normal file
View file

@ -0,0 +1,477 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
* Boston, MA 02110-1335, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <fcntl.h>
#include <semaphore.h>
#include "gstajacommon.h"
GST_DEBUG_CATEGORY_STATIC(gst_aja_debug);
#define GST_CAT_DEFAULT gst_aja_debug
static const NTV2VideoFormat supported_video_formats[] = {
NTV2_FORMAT_1080i_5000, NTV2_FORMAT_1080i_5994,
NTV2_FORMAT_1080i_6000, NTV2_FORMAT_720p_5994,
NTV2_FORMAT_720p_6000, NTV2_FORMAT_1080p_2997,
NTV2_FORMAT_1080p_3000, NTV2_FORMAT_1080p_2500,
NTV2_FORMAT_1080p_2398, NTV2_FORMAT_1080p_2400,
NTV2_FORMAT_720p_5000, NTV2_FORMAT_720p_2398,
NTV2_FORMAT_720p_2500, NTV2_FORMAT_1080p_5000_A,
NTV2_FORMAT_1080p_5994_A, NTV2_FORMAT_1080p_6000_A,
NTV2_FORMAT_625_5000, NTV2_FORMAT_525_5994,
NTV2_FORMAT_525_2398, NTV2_FORMAT_525_2400};
GstCaps *gst_ntv2_supported_caps(NTV2DeviceID device_id) {
GstCaps *caps = gst_caps_new_empty();
for (gsize i = 0; i < G_N_ELEMENTS(supported_video_formats); i++) {
NTV2VideoFormat format = supported_video_formats[i];
if (device_id == DEVICE_ID_INVALID ||
::NTV2DeviceCanDoVideoFormat(device_id, format)) {
gst_caps_append(caps, gst_ntv2_video_format_to_caps(format));
}
}
return caps;
}
GstCaps *gst_ntv2_video_format_to_caps(NTV2VideoFormat format) {
GstVideoInfo info;
guint width = ::GetDisplayWidth(format);
guint height = ::GetDisplayHeight(format);
NTV2FrameRate fps = ::GetNTV2FrameRateFromVideoFormat(format);
guint fps_n, fps_d;
::GetFramesPerSecond(fps, fps_n, fps_d);
gst_video_info_set_format(&info, GST_VIDEO_FORMAT_v210, width, height);
info.fps_n = fps_n;
info.fps_d = fps_d;
if (NTV2_IS_525_FORMAT(format)) {
info.par_n = 10;
info.par_d = 11;
} else if (NTV2_IS_625_FORMAT(format)) {
info.par_n = 12;
info.par_d = 11;
}
info.interlace_mode = !::IsProgressiveTransport(format)
? GST_VIDEO_INTERLACE_MODE_INTERLEAVED
: GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
return gst_video_info_to_caps(&info);
}
NTV2VideoFormat gst_ntv2_video_format_from_caps(GstCaps *caps) {
GstVideoInfo info;
if (!gst_video_info_from_caps(&info, caps)) return NTV2_FORMAT_UNKNOWN;
for (gsize i = 0; i < G_N_ELEMENTS(supported_video_formats); i++) {
NTV2VideoFormat format = supported_video_formats[i];
guint width = ::GetDisplayWidth(format);
guint height = ::GetDisplayHeight(format);
NTV2FrameRate fps = ::GetNTV2FrameRateFromVideoFormat(format);
guint fps_n, fps_d;
::GetFramesPerSecond(fps, fps_n, fps_d);
if (width == (guint)info.width && height == (guint)info.height &&
(guint)info.fps_n == fps_n && (guint)info.fps_d == fps_d &&
((!::IsProgressiveTransport(format) &&
info.interlace_mode == GST_VIDEO_INTERLACE_MODE_INTERLEAVED) ||
(::IsProgressiveTransport(format) &&
info.interlace_mode == GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)))
return format;
}
return NTV2_FORMAT_UNKNOWN;
}
GType gst_aja_audio_meta_api_get_type(void) {
static volatile GType type;
if (g_once_init_enter(&type)) {
static const gchar *tags[] = {NULL};
GType _type = gst_meta_api_type_register("GstAjaAudioMetaAPI", tags);
GST_INFO("registering");
g_once_init_leave(&type, _type);
}
return type;
}
static gboolean gst_aja_audio_meta_transform(GstBuffer *dest, GstMeta *meta,
GstBuffer *buffer, GQuark type,
gpointer data) {
GstAjaAudioMeta *dmeta, *smeta;
if (GST_META_TRANSFORM_IS_COPY(type)) {
smeta = (GstAjaAudioMeta *)meta;
GST_DEBUG("copy AJA audio metadata");
dmeta = gst_buffer_add_aja_audio_meta(dest, smeta->buffer);
if (!dmeta) return FALSE;
} else {
/* return FALSE, if transform type is not supported */
return FALSE;
}
return TRUE;
}
static gboolean gst_aja_audio_meta_init(GstMeta *meta, gpointer params,
GstBuffer *buffer) {
GstAjaAudioMeta *emeta = (GstAjaAudioMeta *)meta;
emeta->buffer = NULL;
return TRUE;
}
static void gst_aja_audio_meta_free(GstMeta *meta, GstBuffer *buffer) {
GstAjaAudioMeta *emeta = (GstAjaAudioMeta *)meta;
gst_buffer_replace(&emeta->buffer, NULL);
}
const GstMetaInfo *gst_aja_audio_meta_get_info(void) {
static const GstMetaInfo *meta_info = NULL;
if (g_once_init_enter((GstMetaInfo **)&meta_info)) {
const GstMetaInfo *mi = gst_meta_register(
GST_AJA_AUDIO_META_API_TYPE, "GstAjaAudioMeta", sizeof(GstAjaAudioMeta),
gst_aja_audio_meta_init, gst_aja_audio_meta_free,
gst_aja_audio_meta_transform);
g_once_init_leave((GstMetaInfo **)&meta_info, (GstMetaInfo *)mi);
}
return meta_info;
}
GstAjaAudioMeta *gst_buffer_add_aja_audio_meta(GstBuffer *buffer,
GstBuffer *audio_buffer) {
GstAjaAudioMeta *meta;
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(audio_buffer != NULL, NULL);
meta = (GstAjaAudioMeta *)gst_buffer_add_meta(buffer, GST_AJA_AUDIO_META_INFO,
NULL);
meta->buffer = gst_buffer_ref(audio_buffer);
return meta;
}
typedef struct {
GstMemory mem;
guint8 *data;
} GstAjaMemory;
G_DEFINE_TYPE(GstAjaAllocator, gst_aja_allocator, GST_TYPE_ALLOCATOR);
static inline void _aja_memory_init(GstAjaAllocator *alloc, GstAjaMemory *mem,
GstMemoryFlags flags, GstMemory *parent,
gpointer data, gsize maxsize, gsize offset,
gsize size) {
gst_memory_init(GST_MEMORY_CAST(mem), flags, GST_ALLOCATOR(alloc), parent,
maxsize, 4095, offset, size);
mem->data = (guint8 *)data;
}
static inline GstAjaMemory *_aja_memory_new(GstAjaAllocator *alloc,
GstMemoryFlags flags,
GstAjaMemory *parent, gpointer data,
gsize maxsize, gsize offset,
gsize size) {
GstAjaMemory *mem;
mem = (GstAjaMemory *)g_slice_alloc(sizeof(GstAjaMemory));
_aja_memory_init(alloc, mem, flags, (GstMemory *)parent, data, maxsize,
offset, size);
return mem;
}
static GstAjaMemory *_aja_memory_new_block(GstAjaAllocator *alloc,
GstMemoryFlags flags, gsize maxsize,
gsize offset, gsize size) {
GstAjaMemory *mem;
guint8 *data;
mem = (GstAjaMemory *)g_slice_alloc(sizeof(GstAjaMemory));
data = (guint8 *)AJAMemory::AllocateAligned(maxsize, 4096);
GST_DEBUG_OBJECT(alloc, "Allocated %" G_GSIZE_FORMAT " at %p", maxsize, data);
if (!alloc->device->device->DMABufferLock((ULWord *)data, maxsize, true)) {
GST_WARNING_OBJECT(alloc, "Failed to pre-lock memory");
}
_aja_memory_init(alloc, mem, flags, NULL, data, maxsize, offset, size);
return mem;
}
static gpointer _aja_memory_map(GstAjaMemory *mem, gsize maxsize,
GstMapFlags flags) {
return mem->data;
}
static gboolean _aja_memory_unmap(GstAjaMemory *mem) { return TRUE; }
static GstMemory *_aja_memory_copy(GstAjaMemory *mem, gssize offset,
gsize size) {
GstMemory *copy;
GstMapInfo map;
if (size == (gsize)-1)
size = mem->mem.size > (gsize)offset ? mem->mem.size - offset : 0;
copy = gst_allocator_alloc(mem->mem.allocator, size, NULL);
gst_memory_map(copy, &map, GST_MAP_READ);
GST_DEBUG("memcpy %" G_GSIZE_FORMAT " memory %p -> %p", size, mem, copy);
memcpy(map.data, mem->data + mem->mem.offset + offset, size);
gst_memory_unmap(copy, &map);
return copy;
}
static GstAjaMemory *_aja_memory_share(GstAjaMemory *mem, gssize offset,
gsize size) {
GstAjaMemory *sub;
GstAjaMemory *parent;
/* find the real parent */
if ((parent = (GstAjaMemory *)mem->mem.parent) == NULL)
parent = (GstAjaMemory *)mem;
if (size == (gsize)-1) size = mem->mem.size - offset;
sub = _aja_memory_new(GST_AJA_ALLOCATOR(parent->mem.allocator),
(GstMemoryFlags)(GST_MINI_OBJECT_FLAGS(parent) |
GST_MINI_OBJECT_FLAG_LOCK_READONLY),
parent, parent->data, mem->mem.maxsize,
mem->mem.offset + offset, size);
return sub;
}
static GstMemory *gst_aja_allocator_alloc(GstAllocator *alloc, gsize size,
GstAllocationParams *params) {
g_warn_if_fail(params->prefix == 0);
g_warn_if_fail(params->padding == 0);
return (GstMemory *)_aja_memory_new_block(GST_AJA_ALLOCATOR(alloc),
params->flags, size, 0, size);
}
static void gst_aja_allocator_free(GstAllocator *alloc, GstMemory *mem) {
GstAjaMemory *dmem = (GstAjaMemory *)mem;
if (!mem->parent) {
GstAjaAllocator *aja_alloc = GST_AJA_ALLOCATOR(alloc);
GST_DEBUG_OBJECT(alloc, "Freeing memory at %p", dmem->data);
aja_alloc->device->device->DMABufferUnlock((ULWord *)dmem->data,
mem->maxsize);
AJAMemory::FreeAligned(dmem->data);
}
g_slice_free1(sizeof(GstAjaMemory), dmem);
}
static void gst_aja_allocator_finalize(GObject *alloc) {
GstAjaAllocator *aja_alloc = GST_AJA_ALLOCATOR(alloc);
GST_DEBUG_OBJECT(alloc, "Freeing allocator");
gst_aja_device_unref(aja_alloc->device);
G_OBJECT_CLASS(gst_aja_allocator_parent_class)->finalize(alloc);
}
static void gst_aja_allocator_class_init(GstAjaAllocatorClass *klass) {
GObjectClass *gobject_class;
GstAllocatorClass *allocator_class;
gobject_class = (GObjectClass *)klass;
allocator_class = (GstAllocatorClass *)klass;
gobject_class->finalize = gst_aja_allocator_finalize;
allocator_class->alloc = gst_aja_allocator_alloc;
allocator_class->free = gst_aja_allocator_free;
}
static void gst_aja_allocator_init(GstAjaAllocator *aja_alloc) {
GstAllocator *alloc = GST_ALLOCATOR_CAST(aja_alloc);
alloc->mem_type = GST_AJA_ALLOCATOR_MEMTYPE;
alloc->mem_map = (GstMemoryMapFunction)_aja_memory_map;
alloc->mem_unmap = (GstMemoryUnmapFunction)_aja_memory_unmap;
alloc->mem_copy = (GstMemoryCopyFunction)_aja_memory_copy;
alloc->mem_share = (GstMemoryShareFunction)_aja_memory_share;
}
GstAllocator *gst_aja_allocator_new(GstAjaDevice *device) {
GstAjaAllocator *alloc =
(GstAjaAllocator *)g_object_new(GST_TYPE_AJA_ALLOCATOR, NULL);
alloc->device = gst_aja_device_ref(device);
GST_DEBUG_OBJECT(alloc, "Creating allocator for device %d",
device->device->GetIndexNumber());
return GST_ALLOCATOR(alloc);
}
GstAjaDevice *gst_aja_device_obtain(const gchar *device_identifier) {
CNTV2Device *device = new CNTV2Device();
if (!CNTV2DeviceScanner::GetFirstDeviceFromArgument(device_identifier,
*device)) {
delete device;
return NULL;
}
GstAjaDevice *dev = g_atomic_rc_box_new0(GstAjaDevice);
dev->device = device;
return dev;
}
GstAjaDevice *gst_aja_device_ref(GstAjaDevice *device) {
return (GstAjaDevice *)g_atomic_rc_box_acquire(device);
}
void gst_aja_device_unref(GstAjaDevice *device) {
g_atomic_rc_box_release_full(device, [](gpointer data) {
GstAjaDevice *dev = (GstAjaDevice *)data;
delete dev->device;
});
}
static gpointer init_setup_mutex(gpointer data) {
sem_t *s = SEM_FAILED;
s = sem_open("/gstreamer-aja-sem", O_CREAT, S_IRUSR | S_IWUSR, 1);
if (s == SEM_FAILED) {
g_critical("Failed to create SHM semaphore for GStreamer AJA plugin: %s",
g_strerror(errno));
}
return s;
}
static sem_t *get_setup_mutex(void) {
static GOnce once = G_ONCE_INIT;
g_once(&once, init_setup_mutex, NULL);
return (sem_t *)once.retval;
}
ShmMutexLocker::ShmMutexLocker() {
sem_t *s = get_setup_mutex();
if (s != SEM_FAILED) sem_wait(s);
}
ShmMutexLocker::~ShmMutexLocker() {
sem_t *s = get_setup_mutex();
if (s != SEM_FAILED) sem_post(s);
}
GType gst_aja_audio_system_get_type(void) {
static gsize id = 0;
static const GEnumValue modes[] = {
{GST_AJA_AUDIO_SYSTEM_AUTO, "auto", "Auto (based on selected channel)"},
{GST_AJA_AUDIO_SYSTEM_1, "1", "Audio system 1"},
{GST_AJA_AUDIO_SYSTEM_2, "2", "Audio system 2"},
{GST_AJA_AUDIO_SYSTEM_3, "3", "Audio system 3"},
{GST_AJA_AUDIO_SYSTEM_4, "4", "Audio system 4"},
{GST_AJA_AUDIO_SYSTEM_5, "5", "Audio system 5"},
{GST_AJA_AUDIO_SYSTEM_6, "6", "Audio system 6"},
{GST_AJA_AUDIO_SYSTEM_7, "7", "Audio system 7"},
{GST_AJA_AUDIO_SYSTEM_8, "8", "Audio system 8"},
{0, NULL, NULL}};
if (g_once_init_enter(&id)) {
GType tmp = g_enum_register_static("GstAjaAudioSystem", modes);
g_once_init_leave(&id, tmp);
}
return (GType)id;
}
GType gst_aja_output_destination_get_type(void) {
static gsize id = 0;
static const GEnumValue modes[] = {
{GST_AJA_OUTPUT_DESTINATION_AUTO, "auto",
"Auto (based on selected channel)"},
{GST_AJA_OUTPUT_DESTINATION_ANALOG, "analog", "Analog Output"},
{GST_AJA_OUTPUT_DESTINATION_SDI1, "sdi-1", "SDI Output 1"},
{GST_AJA_OUTPUT_DESTINATION_SDI2, "sdi-2", "SDI Output 2"},
{GST_AJA_OUTPUT_DESTINATION_SDI3, "sdi-3", "SDI Output 3"},
{GST_AJA_OUTPUT_DESTINATION_SDI4, "sdi-4", "SDI Output 4"},
{GST_AJA_OUTPUT_DESTINATION_SDI5, "sdi-5", "SDI Output 5"},
{GST_AJA_OUTPUT_DESTINATION_SDI6, "sdi-6", "SDI Output 6"},
{GST_AJA_OUTPUT_DESTINATION_SDI7, "sdi-7", "SDI Output 7"},
{GST_AJA_OUTPUT_DESTINATION_SDI8, "sdi-8", "SDI Output 8"},
{GST_AJA_OUTPUT_DESTINATION_HDMI, "hdmi", "HDMI Output"},
{0, NULL, NULL}};
if (g_once_init_enter(&id)) {
GType tmp = g_enum_register_static("GstAjaOutputDestination", modes);
g_once_init_leave(&id, tmp);
}
return (GType)id;
}
GType gst_aja_reference_source_get_type(void) {
static gsize id = 0;
static const GEnumValue modes[] = {
{GST_AJA_REFERENCE_SOURCE_AUTO, "auto", "Auto"},
{GST_AJA_REFERENCE_SOURCE_FREERUN, "freerun", "Freerun"},
{GST_AJA_REFERENCE_SOURCE_EXTERNAL, "external", "External"},
{GST_AJA_REFERENCE_SOURCE_INPUT_1, "input-1", "SDI Input 1"},
{GST_AJA_REFERENCE_SOURCE_INPUT_2, "input-2", "SDI Input 2"},
{GST_AJA_REFERENCE_SOURCE_INPUT_3, "input-3", "SDI Input 3"},
{GST_AJA_REFERENCE_SOURCE_INPUT_4, "input-4", "SDI Input 4"},
{GST_AJA_REFERENCE_SOURCE_INPUT_5, "input-5", "SDI Input 5"},
{GST_AJA_REFERENCE_SOURCE_INPUT_6, "input-6", "SDI Input 6"},
{GST_AJA_REFERENCE_SOURCE_INPUT_7, "input-7", "SDI Input 7"},
{GST_AJA_REFERENCE_SOURCE_INPUT_8, "input-8", "SDI Input 8"},
{0, NULL, NULL}};
if (g_once_init_enter(&id)) {
GType tmp = g_enum_register_static("GstAjaReferenceSource", modes);
g_once_init_leave(&id, tmp);
}
return (GType)id;
}
void gst_aja_common_init(void) {
GST_DEBUG_CATEGORY_INIT(gst_aja_debug, "aja", 0,
"Debug category for AJA plugin");
}

168
gstajacommon.h Normal file
View file

@ -0,0 +1,168 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <ajabase/common/types.h>
#include <ajabase/system/memory.h>
#include <ajabase/system/thread.h>
#include <ajantv2/includes/ntv2card.h>
#include <ajantv2/includes/ntv2devicefeatures.h>
#include <ajantv2/includes/ntv2devicescanner.h>
#include <ajantv2/includes/ntv2enums.h>
#include <ajantv2/includes/ntv2signalrouter.h>
#include <gst/base/base.h>
#include <gst/gst.h>
#include <gst/video/video.h>
G_BEGIN_DECLS
typedef struct {
GstMeta meta;
GstBuffer *buffer;
} GstAjaAudioMeta;
G_GNUC_INTERNAL
GType gst_aja_audio_meta_api_get_type(void);
#define GST_AJA_AUDIO_META_API_TYPE (gst_aja_audio_meta_api_get_type())
G_GNUC_INTERNAL
const GstMetaInfo *gst_aja_audio_meta_get_info(void);
#define GST_AJA_AUDIO_META_INFO (gst_aja_audio_meta_get_info())
#define gst_buffer_get_aja_audio_meta(b) \
((GstAjaAudioMeta *)gst_buffer_get_meta((b), GST_AJA_AUDIO_META_API_TYPE))
G_GNUC_INTERNAL
GstAjaAudioMeta *gst_buffer_add_aja_audio_meta(GstBuffer *buffer,
GstBuffer *audio_buffer);
G_GNUC_INTERNAL
GstCaps *gst_ntv2_supported_caps(NTV2DeviceID device_id);
G_GNUC_INTERNAL
GstCaps *gst_ntv2_video_format_to_caps(NTV2VideoFormat format);
G_GNUC_INTERNAL
NTV2VideoFormat gst_ntv2_video_format_from_caps(GstCaps *caps);
typedef struct {
CNTV2Card *device;
} GstAjaDevice;
G_GNUC_INTERNAL
GstAjaDevice *gst_aja_device_obtain(const gchar *device_identifier);
G_GNUC_INTERNAL
GstAjaDevice *gst_aja_device_ref(GstAjaDevice *device);
G_GNUC_INTERNAL
void gst_aja_device_unref(GstAjaDevice *device);
#define GST_AJA_ALLOCATOR_MEMTYPE "aja"
#define GST_TYPE_AJA_ALLOCATOR (gst_aja_allocator_get_type())
#define GST_AJA_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AJA_ALLOCATOR, GstAjaAllocator))
#define GST_AJA_ALLOCATOR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AJA_ALLOCATOR, \
GstAjaAllocatorClass))
#define GST_IS_Aja_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AJA_ALLOCATOR))
#define GST_IS_Aja_ALLOCATOR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AJA_ALLOCATOR))
#define GST_AJA_ALLOCATOR_CAST(obj) ((GstAjaAllocator *)(obj))
typedef struct _GstAjaAllocator GstAjaAllocator;
typedef struct _GstAjaAllocatorClass GstAjaAllocatorClass;
struct _GstAjaAllocator {
GstAllocator allocator;
GstAjaDevice *device;
};
struct _GstAjaAllocatorClass {
GstAllocatorClass parent_class;
};
G_GNUC_INTERNAL
GType gst_aja_allocator_get_type(void);
G_GNUC_INTERNAL
GstAllocator *gst_aja_allocator_new(GstAjaDevice *device);
typedef enum {
GST_AJA_AUDIO_SYSTEM_AUTO,
GST_AJA_AUDIO_SYSTEM_1,
GST_AJA_AUDIO_SYSTEM_2,
GST_AJA_AUDIO_SYSTEM_3,
GST_AJA_AUDIO_SYSTEM_4,
GST_AJA_AUDIO_SYSTEM_5,
GST_AJA_AUDIO_SYSTEM_6,
GST_AJA_AUDIO_SYSTEM_7,
GST_AJA_AUDIO_SYSTEM_8,
} GstAjaAudioSystem;
#define GST_TYPE_AJA_AUDIO_SYSTEM (gst_aja_audio_system_get_type())
G_GNUC_INTERNAL
GType gst_aja_audio_system_get_type(void);
typedef enum {
GST_AJA_OUTPUT_DESTINATION_AUTO,
GST_AJA_OUTPUT_DESTINATION_ANALOG,
GST_AJA_OUTPUT_DESTINATION_SDI1,
GST_AJA_OUTPUT_DESTINATION_SDI2,
GST_AJA_OUTPUT_DESTINATION_SDI3,
GST_AJA_OUTPUT_DESTINATION_SDI4,
GST_AJA_OUTPUT_DESTINATION_SDI5,
GST_AJA_OUTPUT_DESTINATION_SDI6,
GST_AJA_OUTPUT_DESTINATION_SDI7,
GST_AJA_OUTPUT_DESTINATION_SDI8,
GST_AJA_OUTPUT_DESTINATION_HDMI,
} GstAjaOutputDestination;
#define GST_TYPE_AJA_OUTPUT_DESTINATION (gst_aja_output_destination_get_type())
G_GNUC_INTERNAL
GType gst_aja_output_destination_get_type(void);
typedef enum {
GST_AJA_REFERENCE_SOURCE_AUTO,
GST_AJA_REFERENCE_SOURCE_FREERUN,
GST_AJA_REFERENCE_SOURCE_EXTERNAL,
GST_AJA_REFERENCE_SOURCE_INPUT_1,
GST_AJA_REFERENCE_SOURCE_INPUT_2,
GST_AJA_REFERENCE_SOURCE_INPUT_3,
GST_AJA_REFERENCE_SOURCE_INPUT_4,
GST_AJA_REFERENCE_SOURCE_INPUT_5,
GST_AJA_REFERENCE_SOURCE_INPUT_6,
GST_AJA_REFERENCE_SOURCE_INPUT_7,
GST_AJA_REFERENCE_SOURCE_INPUT_8,
} GstAjaReferenceSource;
#define GST_TYPE_AJA_REFERENCE_SOURCE (gst_aja_reference_source_get_type())
G_GNUC_INTERNAL
GType gst_aja_reference_source_get_type(void);
G_GNUC_INTERNAL
void gst_aja_common_init(void);
G_END_DECLS
class ShmMutexLocker {
public:
ShmMutexLocker();
~ShmMutexLocker();
};

1373
gstajasink.cpp Normal file

File diff suppressed because it is too large Load diff

95
gstajasink.h Normal file
View file

@ -0,0 +1,95 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/base/base.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstajacommon.h"
G_BEGIN_DECLS
#define GST_TYPE_AJA_SINK (gst_aja_sink_get_type())
#define GST_AJA_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AJA_SINK, GstAjaSink))
#define GST_AJA_SINK_CAST(obj) ((GstAjaSink *)obj)
#define GST_AJA_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AJA_SINK, GstAjaSinkClass))
#define GST_IS_AJA_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AJA_SINK))
#define GST_IS_AJA_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AJA_SINK))
typedef struct _GstAjaSink GstAjaSink;
typedef struct _GstAjaSinkClass GstAjaSinkClass;
struct _GstAjaSink {
GstBaseSink parent;
// Everything below protected by queue lock
GMutex queue_lock;
GCond queue_cond;
GstQueueArray *queue;
gboolean eos;
gboolean playing;
gboolean shutdown;
gboolean draining;
// Hold by set_caps() to wait until drained
GCond drain_cond;
gboolean flushing;
GstAjaDevice *device;
NTV2DeviceID device_id;
GstAllocator *allocator;
// Only allocated on demand
GstBufferPool *buffer_pool;
GstBufferPool *audio_buffer_pool;
// Properties
gchar *device_identifier;
NTV2Channel channel;
guint queue_size;
guint output_cpu_core;
GstAjaAudioSystem audio_system_setting;
GstAjaOutputDestination output_destination;
GstAjaReferenceSource reference_source;
NTV2AudioSystem audio_system;
NTV2VideoFormat video_format;
guint32 f2_start_line;
GstCaps *configured_caps;
GstVideoInfo configured_info;
gint configured_audio_channels;
AJAThread *output_thread;
};
struct _GstAjaSinkClass {
GstBaseSinkClass parent_class;
};
G_GNUC_INTERNAL
GType gst_aja_sink_get_type(void);
G_END_DECLS

294
gstajasinkcombiner.cpp Normal file
View file

@ -0,0 +1,294 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
* Boston, MA 02110-1335, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstajacommon.h"
#include "gstajasinkcombiner.h"
GST_DEBUG_CATEGORY_STATIC(gst_aja_sink_combiner_debug);
#define GST_CAT_DEFAULT gst_aja_sink_combiner_debug
static GstStaticPadTemplate video_sink_template = GST_STATIC_PAD_TEMPLATE(
"video", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-raw"));
static GstStaticPadTemplate audio_sink_template =
GST_STATIC_PAD_TEMPLATE("audio", GST_PAD_SINK, GST_PAD_REQUEST,
GST_STATIC_CAPS("audio/x-raw, "
"format = (string) S32LE, "
"rate = (int) 48000, "
"channels = (int) [ 1, 16 ], "
"layout = (string) interleaved"));
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE(
"src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-raw"));
G_DEFINE_TYPE(GstAjaSinkCombiner, gst_aja_sink_combiner, GST_TYPE_AGGREGATOR);
#define parent_class gst_aja_sink_combiner_parent_class
static void gst_aja_sink_combiner_finalize(GObject *object) {
GstAjaSinkCombiner *self = GST_AJA_SINK_COMBINER(object);
GST_OBJECT_LOCK(self);
gst_caps_replace(&self->audio_caps, NULL);
gst_caps_replace(&self->video_caps, NULL);
GST_OBJECT_UNLOCK(self);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
static GstFlowReturn gst_aja_sink_combiner_aggregate(GstAggregator *aggregator,
gboolean timeout) {
GstAjaSinkCombiner *self = GST_AJA_SINK_COMBINER(aggregator);
GstBuffer *video_buffer, *audio_buffer;
if (gst_aggregator_pad_is_eos(GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad)) &&
gst_aggregator_pad_is_eos(GST_AGGREGATOR_PAD_CAST(self->video_sinkpad))) {
GST_DEBUG_OBJECT(self, "All pads EOS");
return GST_FLOW_EOS;
}
// FIXME: We currently assume that upstream provides
// - properly chunked buffers (1 buffer = 1 video frame)
// - properly synchronized buffers (audio/video starting at the same time)
// - no gaps
//
// This can be achieved externally with elements like audiobuffersplit and
// videorate.
video_buffer = gst_aggregator_pad_peek_buffer(
GST_AGGREGATOR_PAD_CAST(self->video_sinkpad));
if (!video_buffer) return GST_AGGREGATOR_FLOW_NEED_DATA;
audio_buffer = gst_aggregator_pad_peek_buffer(
GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad));
if (!audio_buffer && !gst_aggregator_pad_is_eos(
GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad))) {
gst_buffer_unref(video_buffer);
GST_TRACE_OBJECT(self, "Audio not ready yet, waiting");
return GST_AGGREGATOR_FLOW_NEED_DATA;
}
gst_aggregator_pad_drop_buffer(GST_AGGREGATOR_PAD_CAST(self->video_sinkpad));
video_buffer = gst_buffer_make_writable(video_buffer);
GST_TRACE_OBJECT(self,
"Outputting buffer with video %" GST_PTR_FORMAT
" and audio %" GST_PTR_FORMAT,
video_buffer, audio_buffer);
if (audio_buffer) {
gst_buffer_add_aja_audio_meta(video_buffer, audio_buffer);
gst_buffer_unref(audio_buffer);
gst_aggregator_pad_drop_buffer(
GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad));
}
if (!gst_pad_has_current_caps(GST_AGGREGATOR_SRC_PAD(self)) ||
self->caps_changed) {
GstCaps *caps = gst_caps_copy(self->video_caps);
GstStructure *s;
s = gst_caps_get_structure(caps, 0);
if (self->audio_caps) {
const GstStructure *s2;
gint audio_channels;
s2 = gst_caps_get_structure(self->audio_caps, 0);
gst_structure_get_int(s2, "channels", &audio_channels);
gst_structure_set(s, "audio-channels", G_TYPE_INT, audio_channels, NULL);
} else {
gst_structure_set(s, "audio-channels", G_TYPE_INT, 0, NULL);
}
GST_DEBUG_OBJECT(self, "Configuring caps %" GST_PTR_FORMAT, caps);
gst_aggregator_set_src_caps(GST_AGGREGATOR(self), caps);
gst_caps_unref(caps);
self->caps_changed = FALSE;
}
// Update the position for synchronization purposes
GST_AGGREGATOR_PAD_CAST(GST_AGGREGATOR_SRC_PAD(self))->segment.position =
GST_BUFFER_PTS(video_buffer);
if (GST_BUFFER_DURATION_IS_VALID(video_buffer))
GST_AGGREGATOR_PAD_CAST(GST_AGGREGATOR_SRC_PAD(self))->segment.position +=
GST_BUFFER_DURATION(video_buffer);
return gst_aggregator_finish_buffer(GST_AGGREGATOR_CAST(self), video_buffer);
}
static gboolean gst_aja_sink_combiner_sink_event(GstAggregator *aggregator,
GstAggregatorPad *agg_pad,
GstEvent *event) {
GstAjaSinkCombiner *self = GST_AJA_SINK_COMBINER(aggregator);
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_SEGMENT: {
const GstSegment *segment;
gst_event_parse_segment(event, &segment);
gst_aggregator_update_segment(GST_AGGREGATOR(self), segment);
break;
}
case GST_EVENT_CAPS: {
GstCaps *caps;
gst_event_parse_caps(event, &caps);
if (agg_pad == GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad)) {
GST_OBJECT_LOCK(self);
gst_caps_replace(&self->audio_caps, caps);
self->caps_changed = TRUE;
GST_OBJECT_UNLOCK(self);
} else if (agg_pad == GST_AGGREGATOR_PAD_CAST(self->video_sinkpad)) {
GST_OBJECT_LOCK(self);
gst_caps_replace(&self->video_caps, caps);
self->caps_changed = TRUE;
GST_OBJECT_UNLOCK(self);
}
break;
}
default:
break;
}
return GST_AGGREGATOR_CLASS(parent_class)
->sink_event(aggregator, agg_pad, event);
}
static gboolean gst_aja_sink_combiner_sink_query(GstAggregator *aggregator,
GstAggregatorPad *agg_pad,
GstQuery *query) {
GstAjaSinkCombiner *self = GST_AJA_SINK_COMBINER(aggregator);
switch (GST_QUERY_TYPE(query)) {
case GST_QUERY_CAPS: {
GstCaps *filter, *caps;
gst_query_parse_caps(query, &filter);
if (agg_pad == GST_AGGREGATOR_PAD_CAST(self->audio_sinkpad)) {
caps = gst_pad_get_pad_template_caps(GST_PAD(agg_pad));
} else if (agg_pad == GST_AGGREGATOR_PAD_CAST(self->video_sinkpad)) {
caps = gst_pad_peer_query_caps(GST_AGGREGATOR_SRC_PAD(self), NULL);
caps = gst_caps_make_writable(caps);
guint caps_size = gst_caps_get_size(caps);
for (guint i = 0; i < caps_size; i++) {
GstStructure *s = gst_caps_get_structure(caps, i);
gst_structure_remove_field(s, "audio-channels");
}
} else {
g_assert_not_reached();
}
if (filter) {
GstCaps *tmp = gst_caps_intersect(filter, caps);
gst_caps_unref(caps);
caps = tmp;
}
gst_query_set_caps_result(query, caps);
return TRUE;
}
case GST_QUERY_ALLOCATION: {
// Proxy to the sink for both pads so that the AJA allocator can be
// used upstream as needed.
return gst_pad_peer_query(GST_AGGREGATOR_SRC_PAD(self), query);
}
default:
break;
}
return GST_AGGREGATOR_CLASS(parent_class)
->sink_query(aggregator, agg_pad, query);
}
static gboolean gst_aja_sink_combiner_negotiate(GstAggregator *aggregator) {
return TRUE;
}
static gboolean gst_aja_sink_combiner_stop(GstAggregator *aggregator) {
GstAjaSinkCombiner *self = GST_AJA_SINK_COMBINER(aggregator);
GST_OBJECT_LOCK(self);
gst_caps_replace(&self->audio_caps, NULL);
gst_caps_replace(&self->video_caps, NULL);
GST_OBJECT_UNLOCK(self);
return TRUE;
}
static void gst_aja_sink_combiner_class_init(GstAjaSinkCombinerClass *klass) {
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAggregatorClass *aggregator_class;
gobject_class = (GObjectClass *)klass;
gstelement_class = (GstElementClass *)klass;
aggregator_class = (GstAggregatorClass *)klass;
gobject_class->finalize = gst_aja_sink_combiner_finalize;
gst_element_class_set_static_metadata(
gstelement_class, "AJA sink audio/video combiner", "Audio/Video/Combiner",
"Combines corresponding audio/video frames",
"Sebastian Dröge <sebastian@centricular.com>");
gst_element_class_add_static_pad_template_with_gtype(
gstelement_class, &video_sink_template, GST_TYPE_AGGREGATOR_PAD);
gst_element_class_add_static_pad_template_with_gtype(
gstelement_class, &audio_sink_template, GST_TYPE_AGGREGATOR_PAD);
gst_element_class_add_static_pad_template_with_gtype(
gstelement_class, &src_template, GST_TYPE_AGGREGATOR_PAD);
aggregator_class->aggregate = gst_aja_sink_combiner_aggregate;
aggregator_class->stop = gst_aja_sink_combiner_stop;
aggregator_class->sink_event = gst_aja_sink_combiner_sink_event;
aggregator_class->sink_query = gst_aja_sink_combiner_sink_query;
aggregator_class->negotiate = gst_aja_sink_combiner_negotiate;
aggregator_class->get_next_time = gst_aggregator_simple_get_next_time;
// We don't support requesting new pads
gstelement_class->request_new_pad = NULL;
GST_DEBUG_CATEGORY_INIT(gst_aja_sink_combiner_debug, "ajasinkcombiner", 0,
"AJA sink combiner");
}
static void gst_aja_sink_combiner_init(GstAjaSinkCombiner *self) {
GstPadTemplate *templ;
templ = gst_static_pad_template_get(&video_sink_template);
self->video_sinkpad =
GST_PAD(g_object_new(GST_TYPE_AGGREGATOR_PAD, "name", "video",
"direction", GST_PAD_SINK, "template", templ, NULL));
gst_object_unref(templ);
gst_element_add_pad(GST_ELEMENT_CAST(self), self->video_sinkpad);
templ = gst_static_pad_template_get(&audio_sink_template);
self->audio_sinkpad =
GST_PAD(g_object_new(GST_TYPE_AGGREGATOR_PAD, "name", "audio",
"direction", GST_PAD_SINK, "template", templ, NULL));
gst_object_unref(templ);
gst_element_add_pad(GST_ELEMENT_CAST(self), self->audio_sinkpad);
}

60
gstajasinkcombiner.h Normal file
View file

@ -0,0 +1,60 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/base/base.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstajacommon.h"
G_BEGIN_DECLS
#define GST_TYPE_AJA_SINK_COMBINER (gst_aja_sink_combiner_get_type())
#define GST_AJA_SINK_COMBINER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AJA_SINK_COMBINER, \
GstAjaSinkCombiner))
#define GST_AJA_SINK_COMBINER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AJA_SINK_COMBINER, \
GstAjaSinkCombinerClass))
#define IS_GST_AJA_SINK_COMBINER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AJA_SINK_COMBINER))
#define IS_GST_AJA_SINK_COMBINER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AJA_SINK_COMBINER))
typedef struct _GstAjaSinkCombiner GstAjaSinkCombiner;
typedef struct _GstAjaSinkCombinerClass GstAjaSinkCombinerClass;
struct _GstAjaSinkCombiner {
GstAggregator parent;
GstPad *audio_sinkpad, *video_sinkpad;
GstCaps *audio_caps, *video_caps;
gboolean caps_changed;
};
struct _GstAjaSinkCombinerClass {
GstAggregatorClass parent_class;
};
G_GNUC_INTERNAL
GType gst_aja_sink_combiner_get_type(void);
G_END_DECLS

97
meson.build Normal file
View file

@ -0,0 +1,97 @@
project('gst-aja', 'cpp',
version : '0.1.0',
meson_version : '>= 0.54.0',
default_options : [ 'warning_level=1',
'buildtype=debugoptimized',
'cpp_std=c++11',
'cpp_eh=none',
'cpp_rtti=false',
]
)
plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
cxx = meson.get_compiler('cpp')
if cxx.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'cpp')
endif
if cxx.get_id() == 'msvc'
# Ignore several spurious warnings for things gstreamer does very commonly
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
# NOTE: Only add warnings here if you are sure they're spurious
test_cppflags = []
msvc_args = [
'/wd4018', # implicit signed/unsigned conversion
'/wd4146', # unary minus on unsigned (beware INT_MIN)
'/wd4244', # lossy type conversion (e.g. double -> int)
'/wd4305', # truncating type conversion (e.g. double -> float)
]
add_project_arguments(msvc_args, language : 'cpp')
# Disable SAFESEH with MSVC for plugins and libs that use external deps that
# are built with MinGW
noseh_link_args = ['/SAFESEH:NO']
else
test_cppflags = ['-Wno-non-virtual-dtor']
noseh_link_args = []
endif
common_flags = [
'-DAJALinux=1',
'-DAJA_LINUX=1',
]
foreach cxxflag: test_cppflags
if cxx.has_argument(cxxflag)
common_flags += [ cxxflag ]
endif
endforeach
gst_dep = dependency('gstreamer-1.0', version : '>= 1.18', required : true)
gstbase_dep = dependency('gstreamer-base-1.0', version : '>= 1.18', required : true)
gstaudio_dep = dependency('gstreamer-audio-1.0', version : '>= 1.18', required : true)
gstvideo_dep = dependency('gstreamer-video-1.0', version : '>= 1.18', required : true)
thread_dep = dependency('threads')
rt_dep = cxx.find_library('rt', required : false)
aja_sdk_dir = get_option('aja-sdk-dir')
aja_includedirs = [
'-I@0@/ajalibraries'.format(aja_sdk_dir),
'-I@0@/ajalibraries/ajantv2/includes'.format(aja_sdk_dir),
'-I@0@/ajalibraries/ajantv2/src/lin'.format(aja_sdk_dir),
]
message('Looking for AJA SDK in directory ' + aja_sdk_dir)
if not cxx.has_header('ajabase/common/videotypes.h',
args : aja_includedirs,
)
error('Cannot find AJA SDK')
endif
aja_libdir = '@0@/lib'.format(aja_sdk_dir)
ajantv2_dep = cxx.find_library('ajantv2',
required : true,
dirs : [aja_libdir],
)
gstaja = library('gstaja',
['plugin.cpp',
'gstajacommon.cpp',
'gstajasink.cpp',
'gstajasinkcombiner.cpp',
],
cpp_args : [
aja_includedirs,
'-DPACKAGE="gst-aja"',
'-DGST_PACKAGE_NAME="gstreamer-aja"',
'-DGST_PACKAGE_ORIGIN="https://github.com/centricular/gstreamer-aja"',
'-DVERSION="@0@"'.format(meson.project_version())] + common_flags,
link_args : noseh_link_args,
dependencies : [gstvideo_dep, gstaudio_dep, gstbase_dep, gst_dep, ajantv2_dep, thread_dep, rt_dep],
install : true,
install_dir : plugins_install_dir,
)

2
meson_options.txt Normal file
View file

@ -0,0 +1,2 @@
option('aja-sdk-dir', type : 'string', value : 'ntv2sdklinux_16.0.0.4',
description : 'Directory with AJA SDK, e.g. ntv2sdklinux_16.0.0.4')

38
plugin.cpp Normal file
View file

@ -0,0 +1,38 @@
/* GStreamer
* Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
* Boston, MA 02110-1335, USA.
*/
#include <gst/gst.h>
#include "gstajacommon.h"
#include "gstajasink.h"
#include "gstajasinkcombiner.h"
static gboolean plugin_init(GstPlugin* plugin) {
gst_aja_common_init();
gst_element_register(plugin, "ajasink", GST_RANK_NONE, GST_TYPE_AJA_SINK);
gst_element_register(plugin, "ajasinkcombiner", GST_RANK_NONE,
GST_TYPE_AJA_SINK_COMBINER);
return TRUE;
}
GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR, aja,
"GStreamer AJA plugin", plugin_init, VERSION, "LGPL",
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)