Initial commit for release

This commit is contained in:
Eduardo Ramos 2021-06-17 10:35:42 +02:00
commit efb8c4fd71
133 changed files with 17521 additions and 0 deletions

220
.gitignore vendored Normal file
View File

@ -0,0 +1,220 @@
# Created by https://www.gitignore.io/api/java,netbeans,node,intellij,eclipse,osx
### NetBeans ###
nbproject/
nbproject
nbproject/private/
./build/
nbbuild/
dist/
nbdist/
nbactions.xml
.nb-gradle/
### Node ###
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea
*.iml
# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

93
README.md Normal file
View File

@ -0,0 +1,93 @@
# Introduction
This is a native driver for [Webcam Capture](https://github.com/sarxos/webcam-capture) that is reliable, has very good performance, fast startup time and is able to correctly list the detailed capabilities of video devices such as resolutions and device IDs.
Currently it works on Windows only, with the `CaptureManagerDriver`, based on [CaptureManager-SDK](https://www.codeproject.com/Articles/1017223/CaptureManager-SDK-Capturing-Recording-and-Streami), which uses the MediaFoundation Windows API.
# How to use
1. Download this repository and run `mvn install`
2. Add `com.github.eduramiba:webcam-capture-driver-native:1.0.0-SNAPSHOT` dependency to your application.
3. Copy the DLLs of the `natives` folder for your system into the java library path.
4. Use the driver with `Webcam.setDriver(new CaptureManagerDriver())`
5. List the devices with `Webcam.getWebcams()` as normal and use the library in your preferred way. In JavaFX it's recommended to do it as in the example below.
# Simple example with JavaFX
```java
import com.github.eduramiba.webcamcapture.drivers.WebcamDeviceWithBufferOperations;
import com.github.eduramiba.webcamcapture.drivers.capturemanager.CaptureManagerDriver;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamDevice;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestCaptureManagerDriver extends Application {
private static final Logger LOG = LoggerFactory.getLogger(TestCaptureManagerDriver.class);
public static final ScheduledExecutorService EXECUTOR = Executors.newScheduledThreadPool(4);
public static void main(String[] args) {
Webcam.setDriver(new CaptureManagerDriver());
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
ImageView imageView = new ImageView();
HBox root = new HBox();
root.getChildren().add(imageView);
Webcam.getWebcams().stream()
.findFirst()
.ifPresent((final Webcam camera) -> {
final WebcamDevice device = camera.getDevice();
LOG.info("Found camera: {}, device = {}", camera, device);
final int width = device.getResolution().width;
final int height = device.getResolution().height;
final WritableImage fxImage = new WritableImage(width, height);
Platform.runLater(() -> {
imageView.setImage(fxImage);
});
camera.open();
if (device instanceof WebcamDeviceWithBufferOperations) {
EXECUTOR.scheduleAtFixedRate(() -> {
((WebcamDeviceWithBufferOperations) device).updateFXIMage(fxImage);
}, 0, 16, TimeUnit.MILLISECONDS);
}
});
// Create the Scene
Scene scene = new Scene(root);
// Add the scene to the Stage
stage.setScene(scene);
// Set the title of the Stage
stage.setTitle("Displaying an Image");
// Display the Stage
stage.show();
}
}
```
# Future work
* Publish this as a maven central artifact. At the moment you will need to build it yourself.
* Implement MacOS and Linux native driver that uses LibUVC.
# Notes
The source code in `natives` folder and `capturemanager` java package has been copied from [CaptureManager-SDK](https://www.codeproject.com/Articles/1017223/CaptureManager-SDK-Capturing-Recording-and-Streami) and slightly improved for this driver.

67
maven-version-rules.xml Normal file
View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" comparisonMethod="maven" xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<ignoreVersions>
<!-- Ignore Alpha's, Beta's, release candidates and milestones -->
<ignoreVersion type="regex">(?i).*alpha.*</ignoreVersion>
<ignoreVersion type="regex">(?i).*beta.*</ignoreVersion>
<ignoreVersion type="regex">(?i).*[-.]b([0-9]+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*[-.](rc|cr)[-]?([0-9]+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*[-.]m([0-9]+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*[-.]pr([0-9]+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*jboss.*</ignoreVersion>
<ignoreVersion type="regex">(?i).*\-b[0-9]+\.[0-9]+$</ignoreVersion>
<!-- Ignore Netbeans RCP weird versions -->
<ignoreVersion type="regex">(?i)RELEASE.*</ignoreVersion>
<!-- Ignore old jre specific versions-->
<ignoreVersion type="regex">(?i).*[-.]jre[0-9]+</ignoreVersion>
<!-- Ignore openjfx early-access versions-->
<ignoreVersion type="regex">(?i).*[-.]ea\+[0-9]+[a-zA-Z]?</ignoreVersion>
</ignoreVersions>
<rules>
<!-- Obvious mismatches -->
<rule groupId="commons-collections" artifactId="commons-collections">
<ignoreVersions>
<ignoreVersion type="regex">^200.\d+(\.\d+)?$</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="commons-beanutils" artifactId="commons-beanutils">
<ignoreVersions>
<ignoreVersion type="regex">^200.\d+(\.\d+)?$</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="commons-codec" artifactId="commons-codec">
<ignoreVersions>
<ignoreVersion type="regex">^200.\d+(\.\d+)?$</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="commons-io" artifactId="commons-io">
<ignoreVersions>
<ignoreVersion type="regex">^200.\d+(\.\d+)?$</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="commons-logging" artifactId="commons-logging">
<ignoreVersions>
<ignoreVersion>99.0-does-not-exist</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="org.hamcrest">
<ignoreVersions>
<ignoreVersion>1.4-atlassian-1</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="org.nd4j">
<ignoreVersions>
<ignoreVersion>9.0.0</ignoreVersion>
</ignoreVersions>
</rule>
</rules>
</ruleset>

View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CaptureManagerNativeProxy", "CaptureManagerNativeProxy\CaptureManagerNativeProxy.vcxproj", "{1D0E9171-8D1E-4A94-A48A-F5E92326908C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Debug|Win32.ActiveCfg = Debug|Win32
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Debug|Win32.Build.0 = Debug|Win32
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Debug|x64.ActiveCfg = Debug|x64
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Debug|x64.Build.0 = Debug|x64
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Release|Win32.ActiveCfg = Release|Win32
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Release|Win32.Build.0 = Release|Win32
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Release|x64.ActiveCfg = Release|x64
{1D0E9171-8D1E-4A94-A48A-F5E92326908C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,114 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_CaptureManagerControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_CaptureManagerControlNative
* Method: createControl
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerControlNative_createControl
(JNIEnv *aPtrEnv, jobject, jlong aPtr, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ICaptureManagerControl> lICaptureManagerControl;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lICaptureManagerControl));
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lIID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lIID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lIUnknown;
lhr = lICaptureManagerControl->createControl(
lIID,
&lIUnknown);
if (FAILED(lhr))
break;
lresult = (jlong)lIUnknown.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_CaptureManagerControlNative
* Method: createMisc
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerControlNative_createMisc
(JNIEnv *aPtrEnv, jobject, jlong aPtr, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ICaptureManagerControl> lICaptureManagerControl;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lICaptureManagerControl));
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lIID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lIID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lIUnknown;
lhr = lICaptureManagerControl->createMisc(
lIID,
&lIUnknown);
if (FAILED(lhr))
break;
lresult = (jlong)lIUnknown.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,156 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Commdlg.h>
#include <Objbase.h>
#include "JNI\capturemanager_classes_CaptureManagerNativeProxy.h"
#include "ComPtrCustom.h"
BOOL gComInit = FALSE;
typedef HRESULT(STDAPICALLTYPE *PDllGetClassObject) (REFCLSID, REFIID, void**);
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy_getPtrClass
* Method: explicitGetPtrClass
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_explicitGetPtrClass
(JNIEnv * aPtrEnv, jobject aClass, jstring aStringFilePath, jstring aStringCLSID, jstring aStringGUID)
{
jlong lresult = 0;
do
{
HRESULT lhresult(E_FAIL);
gComInit = TRUE;
HMODULE lhLibrary = nullptr;
if (lhLibrary == nullptr)
{
const jchar *lPtrStringFilePath = aPtrEnv->GetStringChars(aStringFilePath, nullptr);
lhLibrary = GetModuleHandle((wchar_t*)lPtrStringFilePath);
if (lhLibrary == nullptr)
break;
}
PDllGetClassObject lPtrFuncDllGetClassObject = nullptr;
lPtrFuncDllGetClassObject = (PDllGetClassObject)GetProcAddress(lhLibrary, "DllGetClassObject");
if (lPtrFuncDllGetClassObject == nullptr)
break;
const jchar *lPtrStringCLSID = aPtrEnv->GetStringChars(aStringCLSID, nullptr);
CLSID lCLSID;
lhresult = CLSIDFromString((wchar_t*)lPtrStringCLSID, &lCLSID);
if (FAILED(lhresult))
break;
CComPtrCustom<IClassFactory> lClassFactory;
lhresult = lPtrFuncDllGetClassObject(lCLSID, IID_PPV_ARGS(&lClassFactory));
if (FAILED(lhresult))
break;
if (!lClassFactory)
break;
const jchar *lPtrStringGUID = aPtrEnv->GetStringChars(aStringGUID, nullptr);
CLSID lInterfaceID;
lhresult = CLSIDFromString((wchar_t*)lPtrStringGUID, &lInterfaceID);
if (FAILED(lhresult))
break;
CComPtrCustom<IUnknown> lIUnknown;
lhresult = lClassFactory->CreateInstance(
nullptr,
lInterfaceID,
(void**)&lIUnknown);
if (FAILED(lhresult))
break;
if (!lIUnknown)
break;
lresult = (jlong)lIUnknown.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy_getPtrClass
* Method: getPtrClass
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_freeLibrary
(JNIEnv * aPtrEnv, jobject aClass, jstring aFileName)
{
do
{
HMODULE lhLibrary = nullptr;
const jchar *lPtrFileName = aPtrEnv->GetStringChars(aFileName, nullptr);
lhLibrary = GetModuleHandle((wchar_t*)lPtrFileName);
if (lhLibrary == nullptr)
break;
BOOL lresult = FreeLibrary(lhLibrary);
while (lresult != FALSE)
{
lresult = FreeLibrary(lhLibrary);
}
} while (false);
}
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy_Release
* Method: Release
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_Release
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
do
{
if (aPtr != 0)
{
IUnknown* aPtrIUnknown = (IUnknown*)aPtr;
if (aPtrIUnknown != nullptr)
aPtrIUnknown->Release();
}
} while (false);
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1D0E9171-8D1E-4A94-A48A-F5E92326908C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CaptureManagerNativeProxy</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>.\Includes;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>.\Includes;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>.\Includes;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>.\Includes;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CAPTUREMANAGERNATIVEPROXY_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>jawt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)JavaLib\$(PlatformTarget);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CAPTUREMANAGERNATIVEPROXY_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Program Files\Java\jdk1.8.0_92\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>jawt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CAPTUREMANAGERNATIVEPROXY_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<CompileAs>Default</CompileAs>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)JavaLib\$(PlatformTarget);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>jawt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CAPTUREMANAGERNATIVEPROXY_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<CompileAs>Default</CompileAs>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>jawt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)JavaLib\$(PlatformTarget);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CaptureManagerTypeInfo.h" />
<ClInclude Include="ComPtrCustom.h" />
<ClInclude Include="JNI\capturemanager_classes_CaptureManagerControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_CaptureManagerNativeProxy.h" />
<ClInclude Include="JNI\capturemanager_classes_EncoderControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_EncoderNodeFactoryNative.h" />
<ClInclude Include="JNI\capturemanager_classes_EVRSinkFactoryNative.h" />
<ClInclude Include="JNI\capturemanager_classes_FileSinkFactoryNative.h" />
<ClInclude Include="JNI\capturemanager_classes_LogPrintOutControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallbackSinkFactoryNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallSinkFactoryNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SessionControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SessionNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SinkControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_SourceControlNative.h" />
<ClInclude Include="JNI\capturemanager_classes_StrideForBitmapNative.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CaptureManagerControlNative.cpp" />
<ClCompile Include="CaptureManagerNativeProxy.cpp" />
<ClCompile Include="EncoderControlNative.cpp" />
<ClCompile Include="EncoderNodeFactoryNative.cpp" />
<ClCompile Include="EVRSinkFactoryNative.cpp" />
<ClCompile Include="FileSinkFactoryNative.cpp" />
<ClCompile Include="LogPrintOutControlNative.cpp" />
<ClCompile Include="SampleGrabberCallbackSinkFactoryNative.cpp" />
<ClCompile Include="SampleGrabberCallNative.cpp" />
<ClCompile Include="SampleGrabberCallSinkFactoryNative.cpp" />
<ClCompile Include="SessionControlNative.cpp" />
<ClCompile Include="SessionNative.cpp" />
<ClCompile Include="SinkControlNative.cpp" />
<ClCompile Include="SourceControlNative.cpp" />
<ClCompile Include="StrideForBitmapNative.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="JNI\capturemanager_classes_LogPrintOutControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ComPtrCustom.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_CaptureManagerNativeProxy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CaptureManagerTypeInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_CaptureManagerControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SourceControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SinkControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_EVRSinkFactoryNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SessionControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SessionNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_StrideForBitmapNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallSinkFactoryNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_SampleGrabberCallbackSinkFactoryNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_EncoderControlNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_EncoderNodeFactoryNative.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="JNI\capturemanager_classes_FileSinkFactoryNative.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CaptureManagerNativeProxy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LogPrintOutControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CaptureManagerControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SourceControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SinkControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EVRSinkFactoryNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SessionControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SessionNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StrideForBitmapNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SampleGrabberCallNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SampleGrabberCallSinkFactoryNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SampleGrabberCallbackSinkFactoryNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EncoderControlNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EncoderNodeFactoryNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileSinkFactoryNative.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,263 @@
#pragma once
template <typename T>
class CComPtrCustom
{
public:
CComPtrCustom(T *aPtrElement)
:element(aPtrElement)
{
}
CComPtrCustom()
:element(nullptr)
{
}
virtual ~CComPtrCustom()
{
Release();
}
T* Detach()
{
auto lOutPtr = element;
element = nullptr;
return lOutPtr;
}
T* detach()
{
return Detach();
}
void Release()
{
if (element == nullptr)
return;
auto k = element->Release();
element = nullptr;
}
CComPtrCustom& operator = (T *pElement)
{
Release();
if (pElement == nullptr)
return *this;
auto k = pElement->AddRef();
element = pElement;
return *this;
}
void Swap(CComPtrCustom& other)
{
T* pTemp = element;
element = other.element;
other.element = pTemp;
}
T* operator->()
{
return element;
}
operator T*()
{
return element;
}
operator T*() const
{
return element;
}
T* get()
{
return element;
}
T* get() const
{
return element;
}
T** operator &()
{
return &element;
}
bool operator !()const
{
return element == nullptr;
}
operator bool()const
{
return element != nullptr;
}
bool operator == (const T *pElement)const
{
return element == pElement;
}
CComPtrCustom(const CComPtrCustom& aCComPtrCustom)
{
if (aCComPtrCustom.operator!())
{
element = nullptr;
return;
}
element = aCComPtrCustom;
auto h = element->AddRef();
h++;
}
CComPtrCustom& operator = (const CComPtrCustom& aCComPtrCustom)
{
Release();
element = aCComPtrCustom;
auto k = element->AddRef();
return *this;
}
_Check_return_ HRESULT CopyTo(T** ppT) throw()
{
if (ppT == NULL)
return E_POINTER;
*ppT = element;
if (element)
element->AddRef();
return S_OK;
}
HRESULT CoCreateInstance(const CLSID aCLSID)
{
T* lPtrTemp;
auto lresult = ::CoCreateInstance(aCLSID, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&lPtrTemp));
if (SUCCEEDED(lresult))
{
if (lPtrTemp != nullptr)
{
Release();
element = lPtrTemp;
}
}
return lresult;
}
protected:
T* element;
};
template <class T, const IID* piid = &__uuidof(T)>
class CComQIPtrCustom :
public CComPtrCustom<T>
{
public:
CComQIPtrCustom() throw()
{
}
CComQIPtrCustom(decltype(__nullptr)) throw()
{
}
CComQIPtrCustom(_Inout_opt_ T* lp) throw() :
CComPtrCustom<T>(lp)
{
}
CComQIPtrCustom(_Inout_opt_ IUnknown* lp) throw()
{
if (lp != NULL)
{
if (FAILED(lp->QueryInterface(*piid, (void **)&element)))
element = NULL;
}
}
T* operator=(decltype(__nullptr)) throw()
{
CComQIPtrCustom(nullptr).Swap(*this);
return nullptr;
}
T* operator=(_Inout_opt_ T* lp) throw()
{
if (*this != lp)
{
CComQIPtrCustom(lp).Swap(*this);
}
return *this;
}
T* operator=(_Inout_opt_ IUnknown* lp) throw()
{
if (*this != lp)
{
if (FAILED(lp->QueryInterface(*piid, (void **)&element)))
element = NULL;
else
return element;
}
return *this;
}
};
template<>
class CComQIPtrCustom<IUnknown, &IID_IUnknown> :
public CComPtrCustom<IUnknown>
{
public:
CComQIPtrCustom() throw()
{
}
CComQIPtrCustom(_Inout_opt_ IUnknown* lp) throw()
{
if (lp != NULL)
{
if (FAILED(lp->QueryInterface(__uuidof(IUnknown), (void **)&element)))
element = NULL;
}
}
CComQIPtrCustom(_Inout_ const CComQIPtrCustom<IUnknown, &IID_IUnknown>& lp) throw()
{
this->element = lp.get();
}
IUnknown* operator=(_Inout_ const CComQIPtrCustom<IUnknown, &IID_IUnknown>& lp) throw()
{
if (this->get() != lp.get())
{
this->element = lp.get();
}
return *this;
}
};
typedef CComQIPtrCustom<IDispatch, &__uuidof(IDispatch)> CComDispatchDriver;

View File

@ -0,0 +1,91 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "jawt_md.h"
#include "JNI\capturemanager_classes_EVRSinkFactoryNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EVRSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/awt/Component;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EVRSinkFactoryNative_createOutputNode
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jobject aGraphicComponent)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aGraphicComponent == nullptr)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEVRSinkFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
JAWT lJAWT;
JAWT_DrawingSurface* lPtrJAWT_DrawingSurface;
JAWT_DrawingSurfaceInfo* lPtrJAWT_DrawingSurfaceInfo;
JAWT_Win32DrawingSurfaceInfo* lPtrJAWT_Win32DrawingSurfaceInfo;
jboolean result;
jint lock;
lJAWT.version = JAWT_VERSION_1_3;
if (JAWT_GetAWT(aPtrEnv, &lJAWT) == JNI_FALSE)
break;
lPtrJAWT_DrawingSurface = lJAWT.GetDrawingSurface(aPtrEnv, aGraphicComponent);
lock = lPtrJAWT_DrawingSurface->Lock(lPtrJAWT_DrawingSurface);
lPtrJAWT_DrawingSurfaceInfo = lPtrJAWT_DrawingSurface->GetDrawingSurfaceInfo(lPtrJAWT_DrawingSurface);
lPtrJAWT_Win32DrawingSurfaceInfo = (JAWT_Win32DrawingSurfaceInfo*)lPtrJAWT_DrawingSurfaceInfo->platformInfo;
HWND lHWND = lPtrJAWT_Win32DrawingSurfaceInfo->hwnd;
CComPtrCustom<IUnknown> lEVRTopologyNode;
lhr = lObject->createOutputNode(lHWND, &lEVRTopologyNode);
lPtrJAWT_DrawingSurface->Unlock(lPtrJAWT_DrawingSurface);
if (FAILED(lhr))
break;
lresult = (jlong)lEVRTopologyNode.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,192 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_EncoderControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: createSinkFactory
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderControlNative_createEncoderNodeFactory
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aStringContainerTypeGUID, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEncoderControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringContainerTypeGUID = aPtrEnv->GetStringChars(aStringContainerTypeGUID, nullptr);
CLSID lContainerTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringContainerTypeGUID, &lContainerTypeGUID);
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lInterfaceID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lInterfaceID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lIUnknown;
lhr = lObject->createEncoderNodeFactory(
lContainerTypeGUID,
lInterfaceID,
&lIUnknown);
if (FAILED(lhr))
break;
if (!lIUnknown)
break;
lresult = (jlong)lIUnknown.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: getCollectionOfSinks
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_EncoderControlNative_getCollectionOfEncoders
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jstring lresult = nullptr;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEncoderControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
BSTR lXMLstring = nullptr;
lhr = lObject->getCollectionOfEncoders(&lXMLstring);
if (FAILED(lhr))
break;
auto lLength = SysStringLen(lXMLstring);
lresult = aPtrEnv->NewString((jchar*)lXMLstring, lLength);
SysFreeString(lXMLstring);
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: getMediaTypeCollectionOfEncoder
* Signature: (JJLjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_EncoderControlNative_getMediaTypeCollectionOfEncoder
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jlong aIndex, jstring aStringEncoderCLSID)
{
jstring lresult = nullptr;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aStringEncoderCLSID == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEncoderControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringEncoderCLSID = aPtrEnv->GetStringChars(aStringEncoderCLSID, nullptr);
CLSID lEncoderCLSID;
lhr = CLSIDFromString((wchar_t*)lPtrStringEncoderCLSID, &lEncoderCLSID);
if (FAILED(lhr))
break;
lPtrIUnknown = (IUnknown*)aIndex;
BSTR lXMLstring = nullptr;
lhr = lObject->getMediaTypeCollectionOfEncoder(
lPtrIUnknown,
lEncoderCLSID,
&lXMLstring);
if (FAILED(lhr))
break;
auto lLength = SysStringLen(lXMLstring);
lresult = aPtrEnv->NewString((jchar*)lXMLstring, lLength);
SysFreeString(lXMLstring);
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,161 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_EncoderNodeFactoryNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EncoderNodeFactoryNative
* Method: createCompressedMediaType
* Signature: (JJLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderNodeFactoryNative_createCompressedMediaType
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jlong aPtrUncompressedMediaType,
jstring aStringEncodingModeGUID, jint aEncoderModeValue, jint aCompressedMediaTypeIndex)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aPtrUncompressedMediaType == 0)
break;
if (aStringEncodingModeGUID == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEncoderNodeFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringEncodingModeGUID = aPtrEnv->GetStringChars(aStringEncodingModeGUID, nullptr);
CLSID lEncodingModeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringEncodingModeGUID, &lEncodingModeGUID);
if (FAILED(lhr))
break;
lPtrIUnknown = (IUnknown*)aPtrUncompressedMediaType;
CComPtrCustom<IUnknown> l_CompressedMediaType;
lhr = lObject->createCompressedMediaType(
lPtrIUnknown,
lEncodingModeGUID,
aEncoderModeValue,
aCompressedMediaTypeIndex,
&l_CompressedMediaType);
if (FAILED(lhr))
break;
if (!l_CompressedMediaType)
break;
lresult = (jlong)l_CompressedMediaType.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_EncoderNodeFactoryNative
* Method: createEncoderNode
* Signature: (JJLjava/lang/String;IIJ)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderNodeFactoryNative_createEncoderNode
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jlong aPtrUncompressedMediaType,
jstring aStringEncodingModeGUID, jint aEncodingModeValue, jint aIndexCompressedMediaType,
jlong aPtrDownStreamNode)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aPtrUncompressedMediaType == 0)
break;
if (aStringEncodingModeGUID == nullptr)
break;
if (aPtrDownStreamNode == 0)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IEncoderNodeFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringEncodingModeGUID = aPtrEnv->GetStringChars(aStringEncodingModeGUID, nullptr);
CLSID lEncodingModeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringEncodingModeGUID, &lEncodingModeGUID);
if (FAILED(lhr))
break;
lPtrIUnknown = (IUnknown*)aPtrUncompressedMediaType;
IUnknown* lPtrIUnknownDownStreamNode = (IUnknown*)aPtrDownStreamNode;
CComPtrCustom<IUnknown> l_Unknown;
lhr = lObject->createEncoderNode(
lPtrIUnknown,
lEncodingModeGUID,
aEncodingModeValue,
aIndexCompressedMediaType,
lPtrIUnknownDownStreamNode,
&l_Unknown);
if (FAILED(lhr))
break;
if (!l_Unknown)
break;
lresult = (jlong)l_Unknown.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,196 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include <vector>
#include <memory>
#include "jawt_md.h"
#include "JNI\capturemanager_classes_FileSinkFactoryNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_FileSinkFactoryNative
* Method: createOutputNodes
* Signature: (J[JLjava/lang/String;)[J
*/
JNIEXPORT jlongArray JNICALL Java_capturemanager_classes_FileSinkFactoryNative_createOutputNodes
(JNIEnv * aPtrEnv,
jobject aClass,
jlong aPtr,
jlongArray aArrayPtrCompressedMediaTypes,
jstring aPtrFileName)
{
jlongArray lresult = nullptr;
do
{
if (aPtr == 0)
break;
if (aArrayPtrCompressedMediaTypes == nullptr)
break;
if (aPtrEnv == nullptr)
break;
if (aPtrFileName == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IFileSinkFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrFileName = aPtrEnv->GetStringChars(aPtrFileName, nullptr);
auto lPtrSourceNodesOfTopologys = aPtrEnv->GetLongArrayElements(aArrayPtrCompressedMediaTypes, nullptr);
if (lPtrSourceNodesOfTopologys == nullptr)
break;
auto lArrayLength = aPtrEnv->GetArrayLength(aArrayPtrCompressedMediaTypes);
SAFEARRAY* pSA = NULL;
SAFEARRAYBOUND bound[1];
bound[0].lLbound = 0;
bound[0].cElements = lArrayLength;
pSA = SafeArrayCreate(VT_VARIANT, 1, bound);
for (long i = 0; i < lArrayLength; i++)
{
jlong lPtr = lPtrSourceNodesOfTopologys[i];
if (lPtr == 0)
continue;
IUnknown* lPtrIUnknown = (IUnknown*)lPtr;
VARIANT lVar;
VariantInit(&lVar);
lVar.vt = VT_UNKNOWN;
lVar.punkVal = lPtrIUnknown;
lhr = SafeArrayPutElement(pSA, &i, &lVar);
if (FAILED(lhr))
break;
}
if (FAILED(lhr))
break;
VARIANT theArray;
VariantInit(&theArray);
theArray.vt = VT_SAFEARRAY | VT_UNKNOWN;
theArray.parray = pSA;
VARIANT theOutputNodes;
VariantInit(&theOutputNodes);
CComPtrCustom<IUnknown> lSession;
lhr = lObject->createOutputNodes(
theArray,
(wchar_t*)lPtrFileName,
&theOutputNodes);
SafeArrayDestroy(pSA);
VariantClear(&theArray);
std::vector<IUnknown*> lCompressedMediaTypes;
if (theOutputNodes.vt == VT_SAFEARRAY | VT_UNKNOWN && theOutputNodes.parray != nullptr)
{
LONG lBoundMediaTypes(0);
LONG uBoundMediaTypes(0);
SafeArrayGetUBound( theOutputNodes.parray, 1, &uBoundMediaTypes);
SafeArrayGetLBound( theOutputNodes.parray, 1, &lBoundMediaTypes);
for (LONG lIndex = lBoundMediaTypes; lIndex <= uBoundMediaTypes; lIndex++)
{
VARIANT lVar;
auto lr = SafeArrayGetElement(theOutputNodes.parray, &lIndex, &lVar);
if (SUCCEEDED(lr) && lVar.vt == VT_UNKNOWN && lVar.punkVal != nullptr)
{
lCompressedMediaTypes.push_back(lVar.punkVal);
}
//VariantClear(&lVar);
}
SafeArrayDestroy(theOutputNodes.parray);
theOutputNodes.parray = nullptr;
}
VariantClear(&theOutputNodes);
if (FAILED(lhr))
break;
lresult = aPtrEnv->NewLongArray(lCompressedMediaTypes.size());
if (lresult == nullptr)
break;
jlong* l_longs = new jlong[lCompressedMediaTypes.size()];
int l_index = 0;
for (auto& l_item : lCompressedMediaTypes)
{
l_longs[l_index++] = (jlong)l_item;
}
aPtrEnv->SetLongArrayRegion(lresult, 0, lCompressedMediaTypes.size(), l_longs);
delete[] l_longs;
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,299 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
#ifndef _JAVASOFT_JAWT_H_
#define _JAVASOFT_JAWT_H_
#include "jni.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* AWT native interface (new in JDK 1.3)
*
* The AWT native interface allows a native C or C++ application a means
* by which to access native structures in AWT. This is to facilitate moving
* legacy C and C++ applications to Java and to target the needs of the
* community who, at present, wish to do their own native rendering to canvases
* for performance reasons. Standard extensions such as Java3D also require a
* means to access the underlying native data structures of AWT.
*
* There may be future extensions to this API depending on demand.
*
* A VM does not have to implement this API in order to pass the JCK.
* It is recommended, however, that this API is implemented on VMs that support
* standard extensions, such as Java3D.
*
* Since this is a native API, any program which uses it cannot be considered
* 100% pure java.
*/
/*
* AWT Native Drawing Surface (JAWT_DrawingSurface).
*
* For each platform, there is a native drawing surface structure. This
* platform-specific structure can be found in jawt_md.h. It is recommended
* that additional platforms follow the same model. It is also recommended
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
*
*******************
* EXAMPLE OF USAGE:
*******************
*
* In Win32, a programmer wishes to access the HWND of a canvas to perform
* native rendering into it. The programmer has declared the paint() method
* for their canvas subclass to be native:
*
*
* MyCanvas.java:
*
* import java.awt.*;
*
* public class MyCanvas extends Canvas {
*
* static {
* System.loadLibrary("mylib");
* }
*
* public native void paint(Graphics g);
* }
*
*
* myfile.c:
*
* #include "jawt_md.h"
* #include <assert.h>
*
* JNIEXPORT void JNICALL
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
* {
* JAWT awt;
* JAWT_DrawingSurface* ds;
* JAWT_DrawingSurfaceInfo* dsi;
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
* jboolean result;
* jint lock;
*
* // Get the AWT
* awt.version = JAWT_VERSION_1_3;
* result = JAWT_GetAWT(env, &awt);
* assert(result != JNI_FALSE);
*
* // Get the drawing surface
* ds = awt.GetDrawingSurface(env, canvas);
* assert(ds != NULL);
*
* // Lock the drawing surface
* lock = ds->Lock(ds);
* assert((lock & JAWT_LOCK_ERROR) == 0);
*
* // Get the drawing surface info
* dsi = ds->GetDrawingSurfaceInfo(ds);
*
* // Get the platform-specific drawing info
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
*
* //////////////////////////////
* // !!! DO PAINTING HERE !!! //
* //////////////////////////////
*
* // Free the drawing surface info
* ds->FreeDrawingSurfaceInfo(dsi);
*
* // Unlock the drawing surface
* ds->Unlock(ds);
*
* // Free the drawing surface
* awt.FreeDrawingSurface(ds);
* }
*
*/
/*
* JAWT_Rectangle
* Structure for a native rectangle.
*/
typedef struct jawt_Rectangle {
jint x;
jint y;
jint width;
jint height;
} JAWT_Rectangle;
struct jawt_DrawingSurface;
/*
* JAWT_DrawingSurfaceInfo
* Structure for containing the underlying drawing information of a component.
*/
typedef struct jawt_DrawingSurfaceInfo {
/*
* Pointer to the platform-specific information. This can be safely
* cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
* JAWT_X11DrawingSurfaceInfo on Solaris. On Mac OS X this is a
* pointer to a NSObject that conforms to the JAWT_SurfaceLayers
* protocol. See jawt_md.h for details.
*/
void* platformInfo;
/* Cached pointer to the underlying drawing surface */
struct jawt_DrawingSurface* ds;
/* Bounding rectangle of the drawing surface */
JAWT_Rectangle bounds;
/* Number of rectangles in the clip */
jint clipSize;
/* Clip rectangle array */
JAWT_Rectangle* clip;
} JAWT_DrawingSurfaceInfo;
#define JAWT_LOCK_ERROR 0x00000001
#define JAWT_LOCK_CLIP_CHANGED 0x00000002
#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004
#define JAWT_LOCK_SURFACE_CHANGED 0x00000008
/*
* JAWT_DrawingSurface
* Structure for containing the underlying drawing information of a component.
* All operations on a JAWT_DrawingSurface MUST be performed from the same
* thread as the call to GetDrawingSurface.
*/
typedef struct jawt_DrawingSurface {
/*
* Cached reference to the Java environment of the calling thread.
* If Lock(), Unlock(), GetDrawingSurfaceInfo() or
* FreeDrawingSurfaceInfo() are called from a different thread,
* this data member should be set before calling those functions.
*/
JNIEnv* env;
/* Cached reference to the target object */
jobject target;
/*
* Lock the surface of the target component for native rendering.
* When finished drawing, the surface must be unlocked with
* Unlock(). This function returns a bitmask with one or more of the
* following values:
*
* JAWT_LOCK_ERROR - When an error has occurred and the surface could not
* be locked.
*
* JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
*
* JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
*
* JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
*/
jint (JNICALL *Lock)
(struct jawt_DrawingSurface* ds);
/*
* Get the drawing surface info.
* The value returned may be cached, but the values may change if
* additional calls to Lock() or Unlock() are made.
* Lock() must be called before this can return a valid value.
* Returns NULL if an error has occurred.
* When finished with the returned value, FreeDrawingSurfaceInfo must be
* called.
*/
JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
(struct jawt_DrawingSurface* ds);
/*
* Free the drawing surface info.
*/
void (JNICALL *FreeDrawingSurfaceInfo)
(JAWT_DrawingSurfaceInfo* dsi);
/*
* Unlock the drawing surface of the target component for native rendering.
*/
void (JNICALL *Unlock)
(struct jawt_DrawingSurface* ds);
} JAWT_DrawingSurface;
/*
* JAWT
* Structure for containing native AWT functions.
*/
typedef struct jawt {
/*
* Version of this structure. This must always be set before
* calling JAWT_GetAWT()
*/
jint version;
/*
* Return a drawing surface from a target jobject. This value
* may be cached.
* Returns NULL if an error has occurred.
* Target must be a java.awt.Component (should be a Canvas
* or Window for native rendering).
* FreeDrawingSurface() must be called when finished with the
* returned JAWT_DrawingSurface.
*/
JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
(JNIEnv* env, jobject target);
/*
* Free the drawing surface allocated in GetDrawingSurface.
*/
void (JNICALL *FreeDrawingSurface)
(JAWT_DrawingSurface* ds);
/*
* Since 1.4
* Locks the entire AWT for synchronization purposes
*/
void (JNICALL *Lock)(JNIEnv* env);
/*
* Since 1.4
* Unlocks the entire AWT for synchronization purposes
*/
void (JNICALL *Unlock)(JNIEnv* env);
/*
* Since 1.4
* Returns a reference to a java.awt.Component from a native
* platform handle. On Windows, this corresponds to an HWND;
* on Solaris and Linux, this is a Drawable. For other platforms,
* see the appropriate machine-dependent header file for a description.
* The reference returned by this function is a local
* reference that is only valid in this environment.
* This function returns a NULL reference if no component could be
* found with matching platform information.
*/
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
} JAWT;
/*
* Get the AWT native structure. This function returns JNI_FALSE if
* an error occurs.
*/
_JNI_IMPORT_OR_EXPORT_
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
#define JAWT_VERSION_1_3 0x00010003
#define JAWT_VERSION_1_4 0x00010004
#define JAWT_VERSION_1_7 0x00010007
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* !_JAVASOFT_JAWT_H_ */

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
#ifndef _JAVASOFT_JAWT_MD_H_
#define _JAVASOFT_JAWT_MD_H_
#include <windows.h>
#include "jawt.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Win32-specific declarations for AWT native interface.
* See notes in jawt.h for an example of use.
*/
typedef struct jawt_Win32DrawingSurfaceInfo {
/* Native window, DDB, or DIB handle */
union {
HWND hwnd;
HBITMAP hbitmap;
void* pbits;
};
/*
* This HDC should always be used instead of the HDC returned from
* BeginPaint() or any calls to GetDC().
*/
HDC hdc;
HPALETTE hpalette;
} JAWT_Win32DrawingSurfaceInfo;
#ifdef __cplusplus
}
#endif
#endif /* !_JAVASOFT_JAWT_MD_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */

View File

@ -0,0 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_CaptureManagerControlNative */
#ifndef _Included_capturemanager_classes_CaptureManagerControlNative
#define _Included_capturemanager_classes_CaptureManagerControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_CaptureManagerControlNative
* Method: createControl
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerControlNative_createControl
(JNIEnv *, jobject, jlong, jstring);
/*
* Class: capturemanager_classes_CaptureManagerControlNative
* Method: createMisc
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerControlNative_createMisc
(JNIEnv *, jobject, jlong, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,37 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_CaptureManagerNativeProxy */
#ifndef _Included_capturemanager_classes_CaptureManagerNativeProxy
#define _Included_capturemanager_classes_CaptureManagerNativeProxy
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy
* Method: explicitGetPtrClass
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_explicitGetPtrClass
(JNIEnv *, jobject, jstring, jstring, jstring);
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy
* Method: getPtrClass
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_freeLibrary
(JNIEnv *, jobject, jstring);
/*
* Class: capturemanager_classes_CaptureManagerNativeProxy
* Method: Release
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_CaptureManagerNativeProxy_Release
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_EVRSinkFactoryNative */
#ifndef _Included_capturemanager_classes_EVRSinkFactoryNative
#define _Included_capturemanager_classes_EVRSinkFactoryNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EVRSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/awt/Component;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EVRSinkFactoryNative_createOutputNode
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,37 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_EncoderControlNative */
#ifndef _Included_capturemanager_classes_EncoderControlNative
#define _Included_capturemanager_classes_EncoderControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: createEncoderNodeFactory
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderControlNative_createEncoderNodeFactory
(JNIEnv *, jobject, jlong, jstring, jstring);
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: getCollectionOfEncoders
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_EncoderControlNative_getCollectionOfEncoders
(JNIEnv *, jobject, jlong);
/*
* Class: capturemanager_classes_EncoderControlNative
* Method: getMediaTypeCollectionOfEncoder
* Signature: (JJLjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_EncoderControlNative_getMediaTypeCollectionOfEncoder
(JNIEnv *, jobject, jlong, jlong, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_EncoderNodeFactoryNative */
#ifndef _Included_capturemanager_classes_EncoderNodeFactoryNative
#define _Included_capturemanager_classes_EncoderNodeFactoryNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_EncoderNodeFactoryNative
* Method: createCompressedMediaType
* Signature: (JJLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderNodeFactoryNative_createCompressedMediaType
(JNIEnv *, jobject, jlong, jlong, jstring, jint, jint);
/*
* Class: capturemanager_classes_EncoderNodeFactoryNative
* Method: createEncoderNode
* Signature: (JJLjava/lang/String;IIJ)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_EncoderNodeFactoryNative_createEncoderNode
(JNIEnv *, jobject, jlong, jlong, jstring, jint, jint, jlong);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_FileSinkFactoryNative */
#ifndef _Included_capturemanager_classes_FileSinkFactoryNative
#define _Included_capturemanager_classes_FileSinkFactoryNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_FileSinkFactoryNative
* Method: createOutputNodes
* Signature: (J[JLjava/lang/String;)[J
*/
JNIEXPORT jlongArray JNICALL Java_capturemanager_classes_FileSinkFactoryNative_createOutputNodes
(JNIEnv *, jobject, jlong, jlongArray, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,37 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_LogPrintOutControlNative */
#ifndef _Included_capturemanager_classes_LogPrintOutControlNative
#define _Included_capturemanager_classes_LogPrintOutControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: addPrintOutDestinationNative
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_addPrintOutDestinationNative
(JNIEnv *, jobject, jlong, jint, jstring);
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: removePrintOutDestinationNative
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_removePrintOutDestinationNative
(JNIEnv *, jobject, jlong, jint, jstring);
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: setVerboseNative
* Signature: (JILjava/lang/String;Ljava/lang/Boolean;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_setVerboseNative
(JNIEnv *, jobject, jlong, jint, jstring, jboolean);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,24 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SampleGrabberCallNative */
#ifndef _Included_capturemanager_classes_SampleGrabberCallNative
#define _Included_capturemanager_classes_SampleGrabberCallNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallNative
* Method: readData
* Signature: (J[B)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_SampleGrabberCallNative_readData
(JNIEnv *, jobject, jlong, jobject);
JNIEXPORT void JNICALL Java_capturemanager_classes_SampleGrabberCallNative_RGB32ToARGB
(JNIEnv*, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SampleGrabberCallSinkFactoryNative */
#ifndef _Included_capturemanager_classes_SampleGrabberCallSinkFactoryNative
#define _Included_capturemanager_classes_SampleGrabberCallSinkFactoryNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/lang/String;Ljava/lang/String;ILjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SampleGrabberCallSinkFactoryNative_createOutputNode
(JNIEnv *, jobject, jlong, jstring, jstring, jint, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SampleGrabberCallbackSinkFactoryNative */
#ifndef _Included_capturemanager_classes_SampleGrabberCallbackSinkFactoryNative
#define _Included_capturemanager_classes_SampleGrabberCallbackSinkFactoryNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallbackSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/Object;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SampleGrabberCallbackSinkFactoryNative_createOutputNode
(JNIEnv *, jobject, jlong, jstring, jstring, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SessionControlNative */
#ifndef _Included_capturemanager_classes_SessionControlNative
#define _Included_capturemanager_classes_SessionControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SessionControlNative
* Method: createSession
* Signature: (J[JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SessionControlNative_createSession
(JNIEnv *, jobject, jlong, jlongArray, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,61 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SessionNative */
#ifndef _Included_capturemanager_classes_SessionNative
#define _Included_capturemanager_classes_SessionNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SessionNative
* Method: closeSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_closeSession
(JNIEnv *, jobject, jlong);
/*
* Class: capturemanager_classes_SessionNative
* Method: addIUpdateStateListener
* Signature: (JLjava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_addIUpdateStateListener
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: capturemanager_classes_SessionNative
* Method: getSessionDescriptor
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_SessionNative_getSessionDescriptor
(JNIEnv *, jobject, jlong);
/*
* Class: capturemanager_classes_SessionNative
* Method: pauseSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_pauseSession
(JNIEnv *, jobject, jlong);
/*
* Class: capturemanager_classes_SessionNative
* Method: startSession
* Signature: (JJLjava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_startSession
(JNIEnv *, jobject, jlong, jlong, jstring);
/*
* Class: capturemanager_classes_SessionNative
* Method: stopSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_stopSession
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SinkControlNative */
#ifndef _Included_capturemanager_classes_SinkControlNative
#define _Included_capturemanager_classes_SinkControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SinkControlNative
* Method: createSinkFactory
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SinkControlNative_createSinkFactory
(JNIEnv *, jobject, jlong, jstring, jstring);
/*
* Class: capturemanager_classes_SinkControlNative
* Method: getCollectionOfSinks
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_SinkControlNative_getCollectionOfSinks
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,53 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_SourceControlNative */
#ifndef _Included_capturemanager_classes_SourceControlNative
#define _Included_capturemanager_classes_SourceControlNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceControl
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceControl
(JNIEnv *, jobject, jlong, jstring, jstring);
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceNode
* Signature: (JLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceNode
(JNIEnv *, jobject, jlong, jstring, jint, jint);
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceNodeWithDownStreamConnection
* Signature: (JLjava/lang/String;IIJ)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceNodeWithDownStreamConnection
(JNIEnv *, jobject, jlong, jstring, jint, jint, jlong);
/*
* Class: capturemanager_classes_SourceControlNative
* Method: getCollectionOfSources
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_SourceControlNative_getCollectionOfSources
(JNIEnv *, jobject, jlong);
/*
* Class: capturemanager_classes_SourceControlNative
* Method: getSourceOutputMediaType
* Signature: (JLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_getSourceOutputMediaType
(JNIEnv *, jobject, jlong, jstring, jint, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class capturemanager_classes_StrideForBitmapNative */
#ifndef _Included_capturemanager_classes_StrideForBitmapNative
#define _Included_capturemanager_classes_StrideForBitmapNative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_StrideForBitmapNative
* Method: getStrideForBitmap
* Signature: (JLjava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_StrideForBitmapNative_getStrideForBitmap
(JNIEnv *, jobject, jlong, jstring, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,102 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_LogPrintOutControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: addPrintOutDestinationNative
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_addPrintOutDestinationNative
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jint aLevel, jstring aFilePath)
{
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
ILogPrintOutControl* lPtrILogPrintOutControl = (ILogPrintOutControl*)aPtr;
const jchar *lPtrFilePath = aPtrEnv->GetStringChars(aFilePath, nullptr);
HRESULT lres = lPtrILogPrintOutControl->addPrintOutDestination(
aLevel,
(BSTR)lPtrFilePath);
if (FAILED(lres))
{
lres = E_FAIL;
}
} while (false);
}
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: removePrintOutDestinationNative
* Signature: (JILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_removePrintOutDestinationNative
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jint aLevel, jstring aFilePath)
{
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
ILogPrintOutControl* lPtrILogPrintOutControl = (ILogPrintOutControl*)aPtr;
const jchar *lPtrFilePath = aPtrEnv->GetStringChars(aFilePath, nullptr);
lPtrILogPrintOutControl->removePrintOutDestination(
aLevel,
(BSTR)lPtrFilePath);
} while (false);
}
/*
* Class: capturemanager_classes_LogPrintOutControlNative
* Method: setVerboseNative
* Signature: (JILjava/lang/String;Ljava/lang/Boolean;)V
*/
JNIEXPORT void JNICALL Java_capturemanager_classes_LogPrintOutControlNative_setVerboseNative
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jint aLevel, jstring aFilePath, jboolean aState)
{
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
ILogPrintOutControl* lPtrILogPrintOutControl = (ILogPrintOutControl*)aPtr;
const jchar *lPtrFilePath = aPtrEnv->GetStringChars(aFilePath, nullptr);
lPtrILogPrintOutControl->setVerbose(
aLevel,
(BSTR)lPtrFilePath,
aState);
} while (false);
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,83 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_SampleGrabberCallNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallNative
* Method: readData
* Signature: (J[B)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_SampleGrabberCallNative_readData
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jobject byteBuffer)
{
jint lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (byteBuffer == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISampleGrabberCall> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
void* bufferAddress = aPtrEnv->GetDirectBufferAddress(byteBuffer);
if (bufferAddress == nullptr)
break;
DWORD lReadSize;
lhr = lObject->readData(
bufferAddress,
&lReadSize);
if (FAILED(lhr))
break;
lresult = (jint) lReadSize;
} while (false);
return lresult;
}
JNIEXPORT void JNICALL Java_capturemanager_classes_SampleGrabberCallNative_RGB32ToBGRA
(JNIEnv* aPtrEnv, jobject aClass, jobject byteBuffer)
{
jbyte* bufferAddress = (jbyte*) aPtrEnv->GetDirectBufferAddress(byteBuffer);
if (bufferAddress == nullptr)
return;
jlong capacity = aPtrEnv->GetDirectBufferCapacity(byteBuffer);
//We just actually need to fill the alpha, all other values are in place for Java's BGRA. RGB32 does not set alpha (is 0).
for (jlong i = 0; i < capacity; i += 4) {
bufferAddress[i + 3] = 0xFF;//Alpha = 1.0
}
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,98 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_SampleGrabberCallSinkFactoryNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/lang/String;Ljava/lang/String;ILjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SampleGrabberCallSinkFactoryNative_createOutputNode
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aStringMajorType, jstring aStringSubType, jint aSampleByteSize, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aStringMajorType == nullptr)
break;
if (aStringSubType == nullptr)
break;
if (aStringIID == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISampleGrabberCallSinkFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringMajorType = aPtrEnv->GetStringChars(aStringMajorType, nullptr);
CLSID lMajorTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringMajorType, &lMajorTypeGUID);
if (FAILED(lhr))
break;
const jchar *lPtrStringSubType = aPtrEnv->GetStringChars(aStringSubType, nullptr);
CLSID lSubTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringSubType, &lSubTypeGUID);
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lIID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lIID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lOutputNode;
lhr = lObject->createOutputNode(
lMajorTypeGUID,
lSubTypeGUID,
aSampleByteSize,
lIID,
&lOutputNode);
if (FAILED(lhr))
break;
lresult = (jlong)lOutputNode.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,283 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include <atomic>
#include "JNI\capturemanager_classes_SampleGrabberCallbackSinkFactoryNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
class SampleGrabberCallback : public ISampleGrabberCallback
{
private:
JavaVM * mPtrJavaVM = nullptr;
jobject mIUpdateStateListener = nullptr;
public:
SampleGrabberCallback(
JavaVM * aPtrJavaVM,
jobject aIUpdateStateListener) :
mRefCount(1),
mPtrJavaVM(aPtrJavaVM),
mIUpdateStateListener(aIUpdateStateListener)
{}
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE invoke(
/* [in] */ REFGUID aGUIDMajorMediaType,
/* [in] */ DWORD aSampleFlags,
/* [in] */ LONGLONG aSampleTime,
/* [in] */ LONGLONG aSampleDuration,
/* [in] */ LPVOID aPtrSampleBuffer,
/* [in] */ DWORD aSampleSize)
{
do
{
if (mPtrJavaVM == nullptr)
break;
JNIEnv * lPtrEnv;
// double check it's all ok
int getEnvStat = mPtrJavaVM->GetEnv((void **)&lPtrEnv, JNI_VERSION_1_6);
if (getEnvStat == JNI_EDETACHED) {
if (mPtrJavaVM->AttachCurrentThread((void **)&lPtrEnv, NULL) != 0)
{
}
}
else if (getEnvStat == JNI_OK) {
//
}
else if (getEnvStat == JNI_EVERSION) {
//std::cout << "GetEnv: version not supported" << std::endl;
}
if (mIUpdateStateListener == nullptr)
break;
jclass thisClass = lPtrEnv->GetObjectClass(mIUpdateStateListener);
if (thisClass == nullptr)
break;
jmethodID linvoke = lPtrEnv->GetMethodID(thisClass,
"invoke", "([BI)V");
if (linvoke == nullptr)
break;
jbyteArray lByteArray = lPtrEnv->NewByteArray(aSampleSize);
//jdouble average = lPtrEnv->CallIntMethod(
// mIUpdateStateListener, linvoke, aCallbackEventCode, aSessionDescriptor);
mPtrJavaVM->DetachCurrentThread();
} while (false);
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject)
{
HRESULT lhresult = E_NOINTERFACE;
do
{
if (ppvObject == NULL)
{
lhresult = E_POINTER;
break;
}
lhresult = S_OK;
if (riid == IID_IUnknown)
{
*ppvObject = static_cast<IUnknown*>(this);
break;
}
else if (riid ==
__uuidof(ISessionCallback))
{
*ppvObject = static_cast<ISampleGrabberCallback*>(this);
break;
}
*ppvObject = NULL;
lhresult = E_NOINTERFACE;
} while (false);
if (SUCCEEDED(lhresult))
AddRef();
return lhresult;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void)
{
return ++mRefCount;
}
virtual ULONG STDMETHODCALLTYPE Release(void)
{
ULONG lCount = --mRefCount;
if (lCount == 0)
{
delete this;
}
return lCount;
}
private:
std::atomic<ULONG> mRefCount;
virtual ~SampleGrabberCallback()
{
if (mPtrJavaVM == nullptr)
return;
JNIEnv * lPtrEnv;
int getEnvStat = mPtrJavaVM->GetEnv((void **)&lPtrEnv, JNI_VERSION_1_6);
if (getEnvStat == JNI_EDETACHED) {
if (mPtrJavaVM->AttachCurrentThread((void **)&lPtrEnv, NULL) != 0)
{
}
}
else if (getEnvStat == JNI_OK) {
//
}
else if (getEnvStat == JNI_EVERSION) {
return;
}
if (lPtrEnv)
lPtrEnv->DeleteGlobalRef(mIUpdateStateListener);
mPtrJavaVM->DetachCurrentThread();
}
};
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SampleGrabberCallbackSinkFactoryNative
* Method: createOutputNode
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/Object;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SampleGrabberCallbackSinkFactoryNative_createOutputNode
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aStringMajorType, jstring aStringSubType, jobject aPtrISampleGrabberCallback)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aStringMajorType == nullptr)
break;
if (aStringSubType == nullptr)
break;
if (aPtrISampleGrabberCallback == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISampleGrabberCallbackSinkFactory> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringMajorType = aPtrEnv->GetStringChars(aStringMajorType, nullptr);
CLSID lMajorTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringMajorType, &lMajorTypeGUID);
if (FAILED(lhr))
break;
const jchar *lPtrStringSubType = aPtrEnv->GetStringChars(aStringSubType, nullptr);
CLSID lSubTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringSubType, &lSubTypeGUID);
if (FAILED(lhr))
break;
auto lGlobalISampleGrabberCallback = aPtrEnv->NewGlobalRef(aPtrISampleGrabberCallback);
JavaVM * lPtrJavaVM;
auto EnvStat = aPtrEnv->GetJavaVM(&lPtrJavaVM);
if (EnvStat != JNI_OK)
break;
//JNI_VERSION_1_8
CComPtrCustom<ISampleGrabberCallback> lSampleGrabberCallback = new SampleGrabberCallback(
lPtrJavaVM,
lGlobalISampleGrabberCallback);
CComPtrCustom<IUnknown> lOutputNode;
lhr = lObject->createOutputNode(
lMajorTypeGUID,
lSubTypeGUID,
lSampleGrabberCallback,
&lOutputNode);
if (FAILED(lhr))
break;
lresult = (jlong)lOutputNode.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,138 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "jawt_md.h"
#include "JNI\capturemanager_classes_SessionControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SessionControlNative
* Method: createSession
* Signature: (J[JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SessionControlNative_createSession
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jlongArray aPtrSourceNodesOfTopologys, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aClass == nullptr)
break;
if (aPtrEnv == nullptr)
break;
if (aPtrSourceNodesOfTopologys == nullptr)
break;
if (aStringIID == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISessionControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lInterfaceID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lInterfaceID);
if (FAILED(lhr))
break;
auto lPtrSourceNodesOfTopologys = aPtrEnv->GetLongArrayElements(aPtrSourceNodesOfTopologys, nullptr);
if (lPtrSourceNodesOfTopologys == nullptr)
break;
auto lArrayLength = aPtrEnv->GetArrayLength(aPtrSourceNodesOfTopologys);
SAFEARRAY* pSA = NULL;
SAFEARRAYBOUND bound[1];
bound[0].lLbound = 0;
bound[0].cElements = lArrayLength;
pSA = SafeArrayCreate(VT_VARIANT, 1, bound);
for (long i = 0; i < lArrayLength; i++)
{
jlong lPtr = lPtrSourceNodesOfTopologys[i];
if (lPtr == 0)
continue;
IUnknown* lPtrIUnknown = (IUnknown*)lPtr;
VARIANT lVar;
VariantInit(&lVar);
lVar.vt = VT_UNKNOWN;
lVar.punkVal = lPtrIUnknown;
lhr = SafeArrayPutElement(pSA, &i, &lVar);
if (FAILED(lhr))
break;
}
if (FAILED(lhr))
break;
VARIANT theArray;
VariantInit(&theArray);
theArray.vt = VT_SAFEARRAY | VT_UNKNOWN;
theArray.parray = pSA;
CComPtrCustom<IUnknown> lSession;
lhr = lObject->createSession(
theArray,
lInterfaceID,
&lSession);
SafeArrayDestroy(pSA);
VariantClear(&theArray);
if (FAILED(lhr))
break;
lresult = (jlong)lSession.detach();
} while (false);
return lresult;
};
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,475 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include <atomic>
#include "JNI\capturemanager_classes_SessionNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#define IID_PPV_ARGSIUnknown(ppType) __uuidof(**(ppType)), (IUnknown**)(ppType)
class SessionCallback : public ISessionCallback
{
private:
JavaVM * mPtrJavaVM = nullptr;
jobject mIUpdateStateListener = nullptr;
public:
SessionCallback(
JavaVM * aPtrJavaVM,
jobject aIUpdateStateListener) :
mRefCount(1),
mPtrJavaVM(aPtrJavaVM),
mIUpdateStateListener(aIUpdateStateListener)
{}
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE invoke(
/* [in] */ DWORD aCallbackEventCode,
/* [in] */ DWORD aSessionDescriptor)
{
do
{
if (mPtrJavaVM == nullptr)
break;
JNIEnv * lPtrEnv;
// double check it's all ok
int getEnvStat = mPtrJavaVM->GetEnv((void **)&lPtrEnv, JNI_VERSION_1_6);
if (getEnvStat == JNI_EDETACHED) {
if (mPtrJavaVM->AttachCurrentThread((void **)&lPtrEnv, NULL) != 0)
{
}
}
else if (getEnvStat == JNI_OK) {
//
}
else if (getEnvStat == JNI_EVERSION) {
//std::cout << "GetEnv: version not supported" << std::endl;
}
if (mIUpdateStateListener == nullptr)
break;
jclass thisClass = lPtrEnv->GetObjectClass(mIUpdateStateListener);
if (thisClass == nullptr)
break;
jmethodID linvoke = lPtrEnv->GetMethodID(thisClass,
"invoke", "(II)V");
if (linvoke == nullptr)
break;
jdouble average = lPtrEnv->CallIntMethod(
mIUpdateStateListener, linvoke, aCallbackEventCode, aSessionDescriptor);
mPtrJavaVM->DetachCurrentThread();
} while (false);
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject)
{
HRESULT lhresult = E_NOINTERFACE;
do
{
if (ppvObject == NULL)
{
lhresult = E_POINTER;
break;
}
lhresult = S_OK;
if (riid == IID_IUnknown)
{
*ppvObject = static_cast<IUnknown*>(this);
break;
}
else if (riid ==
__uuidof(ISessionCallback))
{
*ppvObject = static_cast<ISessionCallback*>(this);
break;
}
*ppvObject = NULL;
lhresult = E_NOINTERFACE;
} while (false);
if (SUCCEEDED(lhresult))
AddRef();
return lhresult;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void)
{
return ++mRefCount;
}
virtual ULONG STDMETHODCALLTYPE Release(void)
{
ULONG lCount = --mRefCount;
if (lCount == 0)
{
delete this;
}
return lCount;
}
private:
std::atomic<ULONG> mRefCount;
virtual ~SessionCallback()
{
if (mPtrJavaVM == nullptr)
return;
JNIEnv * lPtrEnv;
int getEnvStat = mPtrJavaVM->GetEnv((void **)&lPtrEnv, JNI_VERSION_1_6);
if (getEnvStat == JNI_EDETACHED) {
if (mPtrJavaVM->AttachCurrentThread((void **)&lPtrEnv, NULL) != 0)
{
}
}
else if (getEnvStat == JNI_OK) {
//
}
else if (getEnvStat == JNI_EVERSION) {
return;
}
if (lPtrEnv)
lPtrEnv->DeleteGlobalRef(mIUpdateStateListener);
mPtrJavaVM->DetachCurrentThread();
}
};
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SessionNative
* Method: closeSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_closeSession
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jboolean lresult = JNI_FALSE;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
lhr = lObject->closeSession();
if (FAILED(lhr))
break;
lresult = JNI_TRUE;
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SessionNative
* Method: addIUpdateStateListener
* Signature: (JLjava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_addIUpdateStateListener
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jobject aIUpdateStateListener)
{
jboolean lresult = JNI_FALSE;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
CComPtrCustom<IConnectionPointContainer> IConnectionPointContainer;
lhr = lObject->getIConnectionPointContainer(
IID_PPV_ARGSIUnknown(&IConnectionPointContainer));
if (FAILED(lhr))
break;
CComPtrCustom<IConnectionPoint> lConnectionPoint;
lhr = IConnectionPointContainer->FindConnectionPoint(
__uuidof(ISessionCallback),
&lConnectionPoint);
if (FAILED(lhr))
break;
auto lGlobalIUpdateStateListener = aPtrEnv->NewGlobalRef(aIUpdateStateListener);
JavaVM * lPtrJavaVM;
auto EnvStat = aPtrEnv->GetJavaVM(&lPtrJavaVM);
if (EnvStat != JNI_OK)
break;
//JNI_VERSION_1_8
CComPtrCustom<ISessionCallback> lSessionCallback = new SessionCallback(
lPtrJavaVM,
lGlobalIUpdateStateListener);
DWORD lStreamID;
lhr = lConnectionPoint->Advise(
lSessionCallback,
&lStreamID);
if (FAILED(lhr))
break;
lresult = JNI_TRUE;
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SessionNative
* Method: getSessionDescriptor
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_SessionNative_getSessionDescriptor
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jint lresult = -1;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
DWORD lSessionDescriptor = 0;
lhr = lObject->getSessionDescriptor(&lSessionDescriptor);
if (FAILED(lhr))
break;
lresult = lSessionDescriptor;
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SessionNative
* Method: pauseSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_pauseSession
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jboolean lresult = JNI_FALSE;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
lhr = lObject->pauseSession();
if (FAILED(lhr))
break;
lresult = JNI_TRUE;
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SessionNative
* Method: startSession
* Signature: (JJLjava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_startSession
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jlong aStartTime, jstring aStringGUIDTimeType)
{
jboolean lresult = JNI_FALSE;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringGUIDTimeType, nullptr);
CLSID lGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lGUID);
if (FAILED(lhr))
break;
lhr = lObject->startSession(
aStartTime,
lGUID);
if (FAILED(lhr))
break;
lresult = JNI_TRUE;
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SessionNative
* Method: stopSession
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_capturemanager_classes_SessionNative_stopSession
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jboolean lresult = JNI_FALSE;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISession> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
lhr = lObject->stopSession();
if (FAILED(lhr))
break;
lresult = JNI_TRUE;
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,127 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_SinkControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SinkControlNative
* Method: createSinkFactory
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SinkControlNative_createSinkFactory
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aStringContainerTypeGUID, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISinkControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringContainerTypeGUID = aPtrEnv->GetStringChars(aStringContainerTypeGUID, nullptr);
CLSID lContainerTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringContainerTypeGUID, &lContainerTypeGUID);
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lInterfaceID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lInterfaceID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lIUnknown;
lhr = lObject->createSinkFactory(
lContainerTypeGUID,
lInterfaceID,
&lIUnknown);
if (FAILED(lhr))
break;
if (!lIUnknown)
break;
lresult = (jlong)lIUnknown.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SinkControlNative
* Method: getCollectionOfSinks
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_SinkControlNative_getCollectionOfSinks
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jstring lresult = nullptr;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISinkControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
BSTR lXMLstring = nullptr;
lhr = lObject->getCollectionOfSinks(&lXMLstring);
if (FAILED(lhr))
break;
auto lLength = SysStringLen(lXMLstring);
lresult = aPtrEnv->NewString((jchar*)lXMLstring, lLength);
SysFreeString(lXMLstring);
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,273 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_SourceControlNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceControl
* Signature: (JLjava/lang/String;Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceControl
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aSymbolicLink, jstring aStringIID)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aSymbolicLink == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISourceControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringIID = aPtrEnv->GetStringChars(aStringIID, nullptr);
CLSID lIID;
lhr = CLSIDFromString((wchar_t*)lPtrStringIID, &lIID);
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lControl;
const jchar *lPtrSymbolicLink = aPtrEnv->GetStringChars(aSymbolicLink, nullptr);
lhr = lObject->createSourceControl(
(wchar_t*)lPtrSymbolicLink,
lIID,
&lControl);
if (FAILED(lhr))
break;
lresult = (jlong)lControl.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceNode
* Signature: (JLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceNode
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aSymbolicLink, jint aStreamIndex, jint aMediaTypeIndex)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aSymbolicLink == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISourceControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lSourceNode;
const jchar *lPtrSymbolicLink = aPtrEnv->GetStringChars(aSymbolicLink, nullptr);
lhr = lObject->createSourceNode(
(wchar_t*)lPtrSymbolicLink,
aStreamIndex,
aMediaTypeIndex,
&lSourceNode);
if (FAILED(lhr))
break;
lresult = (jlong)lSourceNode.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SourceControlNative
* Method: createSourceNodeWithDownStreamConnection
* Signature: (JLjava/lang/String;IIJ)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_createSourceNodeWithDownStreamConnection
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aSymbolicLink, jint aStreamIndex, jint aMediaTypeIndex, jlong aDownStreamPtr)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aDownStreamPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISourceControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
IUnknown* lPtrDownStream = (IUnknown*)aDownStreamPtr;
CComPtrCustom<IUnknown> lSourceNode;
const jchar *lPtrSymbolicLink = aPtrEnv->GetStringChars(aSymbolicLink, nullptr);
lhr = lObject->createSourceNodeWithDownStreamConnection(
(wchar_t*)lPtrSymbolicLink,
aStreamIndex,
aMediaTypeIndex,
lPtrDownStream,
&lSourceNode);
if (FAILED(lhr))
break;
lresult = (jlong)lSourceNode.detach();
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SourceControlNative
* Method: getCollectionOfSources
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_capturemanager_classes_SourceControlNative_getCollectionOfSources
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr)
{
jstring lresult = nullptr;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISourceControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
BSTR lXMLstring = nullptr;
lhr = lObject->getCollectionOfSources(&lXMLstring);
if (FAILED(lhr))
break;
auto lLength = SysStringLen(lXMLstring);
lresult = aPtrEnv->NewString((jchar*)lXMLstring, lLength);
SysFreeString(lXMLstring);
} while (false);
return lresult;
}
/*
* Class: capturemanager_classes_SourceControlNative
* Method: getSourceOutputMediaType
* Signature: (JLjava/lang/String;II)J
*/
JNIEXPORT jlong JNICALL Java_capturemanager_classes_SourceControlNative_getSourceOutputMediaType
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aSymbolicLink, jint aStreamIndex, jint aMediaTypeIndex)
{
jlong lresult = 0;
do
{
if (aPtr == 0)
break;
if (aSymbolicLink == 0)
break;
if (aPtrEnv == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<ISourceControl> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
CComPtrCustom<IUnknown> lMediaType;
const jchar *lPtrSymbolicLink = aPtrEnv->GetStringChars(aSymbolicLink, nullptr);
lhr = lObject->getSourceOutputMediaType(
(wchar_t*)lPtrSymbolicLink,
aStreamIndex,
aMediaTypeIndex,
&lMediaType);
if (FAILED(lhr))
break;
lresult = (jlong)lMediaType.detach();
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,72 @@
#define WIN32_LEAN_AND_MEAN
#include <Unknwnbase.h>
#include "JNI\capturemanager_classes_StrideForBitmapNative.h"
#include "CaptureManagerTypeInfo.h"
#include "ComPtrCustom.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: capturemanager_classes_StrideForBitmapNative
* Method: getStrideForBitmap
* Signature: (JLjava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_capturemanager_classes_StrideForBitmapNative_getStrideForBitmap
(JNIEnv * aPtrEnv, jobject aClass, jlong aPtr, jstring aStringMediaType, jint aWidthInPixels)
{
jint lresult = 0;
do
{
if (aPtr == 0)
break;
if (aPtrEnv == nullptr)
break;
if (aStringMediaType == nullptr)
break;
IUnknown* lPtrIUnknown = (IUnknown*)aPtr;
CComPtrCustom<IStrideForBitmap> lObject;
HRESULT lhr = lPtrIUnknown->QueryInterface(IID_PPV_ARGS(&lObject));
if (FAILED(lhr))
break;
const jchar *lPtrStringContainerTypeGUID = aPtrEnv->GetStringChars(aStringMediaType, nullptr);
CLSID lMediaTypeGUID;
lhr = CLSIDFromString((wchar_t*)lPtrStringContainerTypeGUID, &lMediaTypeGUID);
if (FAILED(lhr))
break;
LONG lStride = 0;
lhr = lObject->getStrideForBitmap(
lMediaTypeGUID,
aWidthInPixels,
&lStride);
if (FAILED(lhr))
break;
lresult = (jint)lStride;
} while (false);
return lresult;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,9 @@
# Introduction
This is the code for the proxy DLL that the Java JNI code in this repository uses to communicate with the real CaptureManagerSDK DLL.
I have not coded this, it's just a copy of `CaptureManagerToJavaProxy.zip` downloaded from https://www.codeproject.com/Articles/1017223/CaptureManager-SDK-Capturing-Recording-and-Streami with a very simple modification in method `Java_capturemanager_classes_SampleGrabberCallNative_readData` of file `SampleGrabberCallNative.cpp` to avoid very high memory usage due to copying. This method received an array argument where data was copied. With my modified version it receives a direct Java ByteBuffer instance.
The already-built DLLs can be found in the natives directory of this same repository. The code is here for reference and bulding a custom DLL.
Note: Only `SampleGrabberCallNative` mode is used in the Java driver. I was not able to make Callback mode work correctly. Fortunately reading directly from the buffer into JavaFX images is possible, avoiding the conversion to a `BufferedImage` every frame.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

346
pom.xml Normal file
View File

@ -0,0 +1,346 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.github.eduramiba</groupId>
<artifactId>webcam-capture-driver-native</artifactId>
<version>1.0.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<name>Webcam Capture Driver Native</name>
<description>Native driver for Webcam-capture project</description>
<inceptionYear>2021</inceptionYear>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Dependencies versions -->
<driver.slf4j.version>1.7.30</driver.slf4j.version>
<driver.webcam-capture.version>0.3.13-SNAPSHOT</driver.webcam-capture.version>
<driver.aalto-xml.version>1.3.0</driver.aalto-xml.version>
<driver.commons-lang3.version>3.12.0</driver.commons-lang3.version>
<driver.javafx.version>16</driver.javafx.version>
<!-- Plugins versions -->
<driver.maven-compiler-plugin.version>3.8.1</driver.maven-compiler-plugin.version>
<driver.maven-assembly-plugin.version>3.3.0</driver.maven-assembly-plugin.version>
<driver.maven-clean-plugin.version>3.1.0</driver.maven-clean-plugin.version>
<driver.maven-deploy-plugin.version>2.8.2</driver.maven-deploy-plugin.version>
<driver.maven-install-plugin.version>2.5.2</driver.maven-install-plugin.version>
<driver.maven-jar-plugin.version>3.2.0</driver.maven-jar-plugin.version>
<driver.maven-dependency-plugin.version>3.2.0</driver.maven-dependency-plugin.version>
<driver.maven-resources-plugin.version>3.2.0</driver.maven-resources-plugin.version>
<driver.copy-rename-maven-plugin.version>1.0.1</driver.copy-rename-maven-plugin.version>
<driver.maven-site-plugin.version>3.9.1</driver.maven-site-plugin.version>
<driver.build-helper-maven-plugin.version>3.2.0</driver.build-helper-maven-plugin.version>
<driver.maven-surefire-plugin.version>2.22.2</driver.maven-surefire-plugin.version>
<driver.maven-failsafe-plugin.version>2.22.2</driver.maven-failsafe-plugin.version>
<driver.maven-exec-plugin.version>3.0.0</driver.maven-exec-plugin.version>
<driver.modernizer-plugin.version>2.2.0</driver.modernizer-plugin.version>
<driver.versions-maven-plugin.version>2.8.1</driver.versions-maven-plugin.version>
<driver.help-maven-plugin.version>3.2.0</driver.help-maven-plugin.version>
<driver.maven-enforcer-plugin.version>3.0.0-M2</driver.maven-enforcer-plugin.version>
<driver.maven-enforcer-plugin.extra-rules.version>1.3</driver.maven-enforcer-plugin.extra-rules.version>
<driver.errorprone-plugin.version>2.7.1</driver.errorprone-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.sarxos</groupId>
<artifactId>webcam-capture</artifactId>
<version>${driver.webcam-capture.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>aalto-xml</artifactId>
<version>${driver.aalto-xml.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${driver.javafx.version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${driver.slf4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.sarxos</groupId>
<artifactId>webcam-capture</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>aalto-xml</artifactId>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<scope>provided</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${driver.maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release><!-- Ensure Java version compatibility by checking APIs used -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${driver.maven-assembly-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${driver.maven-clean-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${driver.maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${driver.maven-install-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${driver.maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${driver.maven-dependency-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${driver.maven-resources-plugin.version}</version>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>${driver.copy-rename-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${driver.maven-site-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${driver.build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${driver.maven-surefire-plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${driver.maven-failsafe-plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${driver.maven-exec-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>${driver.modernizer-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${driver.maven-enforcer-plugin.version}</version>
</plugin>
<plugin>
<!--
Check new versions with:
mvn versions:display-property-updates
-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${driver.versions-maven-plugin.version}</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<rulesUri>file:///${session.executionRootDirectory}/maven-version-rules.xml</rulesUri>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>${driver.help-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${driver.maven-enforcer-plugin.version}</version>
<executions>
<execution>
<id>maven-enforcer-check</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.6.0,)</version>
<message>Maven 3.6.0 or newer required</message>
</requireMavenVersion>
<enforceBytecodeVersion>
<maxJdkVersion>${java.version}</maxJdkVersion>
<ignoreClasses>
<ignoreClass>module-info</ignoreClass>
</ignoreClasses>
<ignoredScopes>test</ignoredScopes>
</enforceBytecodeVersion>
<banCircularDependencies/>
<banDuplicateClasses>
<findAllDuplicates>true</findAllDuplicates>
<ignoreWhenIdentical>true</ignoreWhenIdentical>
</banDuplicateClasses>
<requireReleaseDeps>
<message>No Snapshots Allowed For Release Versions</message>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
<dependencyConvergence/>
<reactorModuleConvergence>
<message>The reactor is not valid</message>
<ignoreModuleDependencies>true</ignoreModuleDependencies>
</reactorModuleConvergence>
</rules>
<fail>true</fail>
<failFast>true</failFast>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>${driver.maven-enforcer-plugin.extra-rules.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<!-- Checks uses of deprecated Java APIs and fails the build if any is
present -->
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<javaVersion>${java.version}</javaVersion>
<failOnViolations>true</failOnViolations>
<ignorePackages>org.driver.os.rest.security.html</ignorePackages>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>check-error-prone</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${driver.maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release><!-- Ensure Java version compatibility by checking APIs used -->
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${driver.errorprone-plugin.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deployment</id>
<build>
<plugins>
<plugin>
<!-- Attach sources when deploying -->
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,145 @@
package capturemanager.classes;
import capturemanager.interfaces.*;
public class CaptureManager {
private static CaptureManager mInstance = null;
private ICaptureManagerNativeProxy mCaptureManagerNativeProxy = null;
private ICaptureManagerControl mICaptureManagerControl = null;
private ILogPrintOutControl mILogPrintOutControl = null;
private static Object mlockObject = new Object();
public static CaptureManager getInstance() {
synchronized (mlockObject) {
if (mInstance != null)
return mInstance;
boolean lstate = false;
try {
if (mInstance == null) {
mInstance = new CaptureManager();
mInstance.mCaptureManagerNativeProxy = CaptureManagerNativeProxy.getInstance();
lstate = true;
}
} finally {
if (mInstance != null && lstate == false)
mInstance.mCaptureManagerNativeProxy = null;
}
}
return mInstance;
}
private CaptureManager() {
}
private boolean checkFailNative() {
return mCaptureManagerNativeProxy == null;
}
public void freeLibrary() {
do {
if (checkFailNative())
break;
try {
if (mICaptureManagerControl != null)
mICaptureManagerControl.release();
if (mILogPrintOutControl != null)
mILogPrintOutControl.release();
mCaptureManagerNativeProxy.freeLibrary(
CaptureManagerNativeProxy.CaptureManagerFileName
);
mCaptureManagerNativeProxy = null;
CaptureManagerNativeProxy.freeInstance();
CaptureManagerNativeProxy.release();
} finally {
}
}
while (false);
}
public ILogPrintOutControl getILogPrintOutControl() {
ILogPrintOutControl lresult = null;
do {
if (checkFailNative())
break;
try {
long aPtr = mCaptureManagerNativeProxy.explicitGetPtrClass(
CaptureManagerNativeProxy.CaptureManagerFileName,
LogPrintOutControl.CLSID_CoLogPrintOut,
LogPrintOutControl.IID_ILogPrintOutControl);
if (aPtr == 0)
break;
lresult = new LogPrintOutControl(aPtr);
mILogPrintOutControl = lresult;
} finally {
}
}
while (false);
return mILogPrintOutControl;
}
public ICaptureManagerControl getICaptureManagerControl() {
ICaptureManagerControl lresult = new CaptureManagerControl(0);
do {
if (checkFailNative())
break;
try {
if (mICaptureManagerControl != null) {
lresult = mICaptureManagerControl;
break;
}
long aPtr = mCaptureManagerNativeProxy.explicitGetPtrClass(
CaptureManagerNativeProxy.CaptureManagerFileName,
CaptureManagerControl.CLSID_CoCaptureManager,
CaptureManagerControl.IID_ICaptureManagerControl);
if (aPtr == 0)
break;
lresult = new CaptureManagerControl(aPtr);
mICaptureManagerControl = lresult;
} finally {
}
}
while (false);
return lresult;
}
}

View File

@ -0,0 +1,235 @@
package capturemanager.classes;
import capturemanager.interfaces.*;
final class CaptureManagerControl extends CaptureManagerControlNative implements ICaptureManagerControl {
protected static final String CLSID_CoCaptureManager = "{D5F07FB8-CE60-4017-B215-95C8A0DDF42A}";
protected static final String IID_ICaptureManagerControl = "{D4F5F10A-8F70-43CF-8CF1-EC331DA2F829}";
CaptureManagerControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
public void release() {
if (mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public String getCollectionOfSources() {
String lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
SourceControl.IID);
if (lPtr == 0)
break;
ISourceControl lISourceControl = new SourceControl(lPtr);
lresult = lISourceControl.getCollectionOfSources();
}
while (false);
return lresult;
}
@Override
public String getCollectionOfSinks() {
String lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
SinkControl.IID);
if (lPtr == 0)
break;
ISinkControl lISinkControl = new SinkControl(lPtr);
lresult = lISinkControl.getCollectionOfSinks();
}
while (false);
return lresult;
}
@Override
public ISourceControl createSourceControl() {
ISourceControl lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
SourceControl.IID);
if (lPtr == 0)
break;
lresult = new SourceControl(lPtr);
} while (false);
return lresult;
}
@Override
public ISessionControl createSessionControl() {
ISessionControl lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
SessionControl.IID);
if (lPtr == 0)
break;
lresult = new SessionControl(lPtr);
} while (false);
return lresult;
}
@Override
public ISinkControl createSinkControl() {
ISinkControl lresult = null;
do {
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
SinkControl.IID);
if (lPtr == 0)
break;
lresult = new SinkControl(lPtr);
}
while (false);
} while (false);
return lresult;
}
@Override
public IStreamControl createStreamControl() {
IStreamControl lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
StreamControl.IID);
if (lPtr == 0)
break;
lresult = new StreamControl(lPtr);
} while (false);
return lresult;
}
@Override
public IEncoderControl createEncoderControl() {
IEncoderControl lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createControl(
mPtr,
EncoderControl.IID);
if (lPtr == 0)
break;
lresult = new EncoderControl(lPtr);
} while (false);
return lresult;
}
@Override
public int getStrideForBitmapInfoHeader(
String aStringMFVideoFormat,
int aWidthInPixels) {
int lresult = 0;
do {
if (mPtr == 0)
break;
long lPtr = createMisc(
mPtr,
StrideForBitmap.IID);
if (lPtr == 0)
break;
IStrideForBitmap lStrideForBitmap = new StrideForBitmap(lPtr);
lresult = lStrideForBitmap.getStrideForBitmap(aStringMFVideoFormat, aWidthInPixels);
} while (false);
return lresult;
}
@Override
public IVersionControl getVersionControl() {
IVersionControl lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = createMisc(
mPtr,
VersionControl.IID);
if (lPtr == 0)
break;
lresult = new VersionControl(lPtr);
} while (false);
return lresult;
}
}

View File

@ -0,0 +1,12 @@
package capturemanager.classes;
abstract class CaptureManagerControlNative {
native protected long createControl(
long aPtr,
String aStringIID);
native protected long createMisc(
long aPtr,
String aStringIID);
}

View File

@ -0,0 +1,68 @@
package capturemanager.classes;
import capturemanager.interfaces.ICaptureManagerNativeProxy;
import capturemanager.utils.NativeUtils;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class CaptureManagerNativeProxy implements ICaptureManagerNativeProxy {
private static final Logger LOG = LoggerFactory.getLogger(CaptureManagerNativeProxy.class);
private static final String NativeProxyFile = "CaptureManagerNativeProxy.dll";
private static final String CaptureManagerFile = "CaptureManager.dll";
public static String CaptureManagerFileName = "";
public static String NativeProxyFileName = "";
private static File CaptureManagerFileRef = null;
private static File NativeProxyFilePath = null;
static {
try {
CaptureManagerFileRef = NativeUtils.loadLibrary(CaptureManagerFile);
CaptureManagerFileName = CaptureManagerFileRef.getName();
NativeProxyFilePath = NativeUtils.loadLibrary(NativeProxyFile);
NativeProxyFileName = NativeProxyFilePath.getName();
} catch (IOException ex) {
LOG.error("Unexpected error loading CaptureManager libraries", ex);
}
}
private static ICaptureManagerNativeProxy mInstance = null;
private CaptureManagerNativeProxy() {
}
protected static ICaptureManagerNativeProxy getInstance() {
if (mInstance == null) {
mInstance = new CaptureManagerNativeProxy();
}
return mInstance;
}
protected static void freeInstance() {
mInstance = null;
}
static public void release() {
//NOOP
//This used to delete the dll file. Not nice idea
}
public native long explicitGetPtrClass(String aStringFilePath, String aStringCLSID, String aStringGUID);
public native void freeLibrary(String aFileName);
public native void Release(long aPtr);
}

View File

@ -0,0 +1,74 @@
package capturemanager.classes;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
*
* Simple custom class loader implementation
*
*/
public class CustomClassLoader extends ClassLoader {
/**
* The HashMap where the classes will be cached
*/
private Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
@Override
public String toString() {
return CustomClassLoader.class.getName();
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (classes.containsKey(name)) {
return classes.get(name);
}
byte[] classData;
try {
classData = loadClassData(name);
} catch (IOException e) {
throw new ClassNotFoundException("Class [" + name
+ "] could not be found", e);
}
Class<?> c = defineClass(name, classData, 0, classData.length);
resolveClass(c);
classes.put(name, c);
return c;
}
/**
* Load the class file into byte array
*
* @param name
* The name of the class e.g. com.codeslices.test.TestClass}
* @return The class file as byte array
* @throws IOException
*/
private byte[] loadClassData(String name) throws IOException {
BufferedInputStream in = new BufferedInputStream(
ClassLoader.getSystemResourceAsStream(name.replace(".", "/")
+ ".class"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int i;
while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
byte[] classData = out.toByteArray();
out.close();
return classData;
}
}

View File

@ -0,0 +1,50 @@
package capturemanager.classes;
import capturemanager.interfaces.IEVRSinkFactory;
import capturemanager.interfaces.IStreamNode;
import java.awt.Component;
final class EVRSinkFactory extends EVRSinkFactoryNative implements IEVRSinkFactory {
EVRSinkFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IStreamNode createOutputNode(Component aGraphicComponent) {
IStreamNode lresult = null;
do
{
long lPtr = createOutputNode(
mPtr,
aGraphicComponent);
if(lPtr == 0)
break;
lresult = new StreamNode(lPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,10 @@
package capturemanager.classes;
import java.awt.Component;
abstract class EVRSinkFactoryNative {
native protected long createOutputNode(
long aPtr,
Component aGraphicComponent);
}

View File

@ -0,0 +1,88 @@
package capturemanager.classes;
import capturemanager.interfaces.IEncoderControl;
import capturemanager.interfaces.IEncoderNodeFactory;
import capturemanager.interfaces.IMediaType;
class EncoderControl extends EncoderControlNative implements IEncoderControl {
protected static final String IID = "{96223507-D8FF-4EC1-B125-71AA7F9726A4}";
EncoderControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IEncoderNodeFactory createEncoderNodeFactory(String aEncoderCLSID) {
IEncoderNodeFactory lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createEncoderNodeFactory(
mPtr,
aEncoderCLSID,
"{A56E11D8-D602-4792-8570-38C283FC0AA3}");
if(lPtr == 0)
break;
lresult = new EncoderNodeFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public String getCollectionOfEncoders() {
return super.getCollectionOfEncoders(
mPtr);
}
@Override
public String getMediaTypeCollectionOfEncoder(
IMediaType aPtrUncompressedMediaType,
String aEncoderCLSID) {
String lresult = null;
do
{
if(mPtr == 0)
break;
MediaType lMediaType = (MediaType)aPtrUncompressedMediaType;
if(lMediaType == null)
break;
lresult = super.getMediaTypeCollectionOfEncoder(
mPtr,
lMediaType.mPtr,
aEncoderCLSID);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,17 @@
package capturemanager.classes;
abstract class EncoderControlNative {
native protected long createEncoderNodeFactory(
long aPtr,
String aStringEncoderCLSID,
String aStringIID);
native protected String getCollectionOfEncoders(
long aPtr);
native protected String getMediaTypeCollectionOfEncoder(
long aPtr,
long aPtrUncompressedMediaType,
String aStringEncoderCLSID);
}

View File

@ -0,0 +1,106 @@
package capturemanager.classes;
import capturemanager.interfaces.*;
final class EncoderNodeFactory extends EncoderNodeFactoryNative implements IEncoderNodeFactory {
EncoderNodeFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IMediaType createCompressedMediaType(
IMediaType aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType) {
IMediaType lresult = null;
do
{
if(mPtr == 0)
break;
MediaType lMediaType = (MediaType)aPtrUncompressedMediaType;
if(lMediaType == null)
break;
long lPtr = super.createCompressedMediaType(
mPtr,
lMediaType.mPtr,
aStringEncodingModeGUID,
aEncodingModeValue,
aIndexCompressedMediaType);
if(lPtr == 0)
break;
lresult = new MediaType(lPtr);
}
while(false);
return lresult;
}
@Override
public IStreamNode createEncoderNode(
IMediaType aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType,
IStreamNode aPtrDownStreamNode) {
IStreamNode lresult = null;
do
{
if(mPtr == 0)
break;
MediaType lMediaType = (MediaType)aPtrUncompressedMediaType;
if(lMediaType == null)
break;
StreamNode lStreamNode = (StreamNode)aPtrDownStreamNode;
if(lStreamNode == null)
break;
long lPtr = super.createEncoderNode(
mPtr,
lMediaType.mPtr,
aStringEncodingModeGUID,
aEncodingModeValue,
aIndexCompressedMediaType,
lStreamNode.mPtr);
if(lPtr == 0)
break;
lresult = new StreamNode(lPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,20 @@
package capturemanager.classes;
abstract class EncoderNodeFactoryNative {
native protected long createCompressedMediaType(
long aPtr,
long aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType);
native protected long createEncoderNode(
long aPtr,
long aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType,
long aPtrDownStreamNode);
}

View File

@ -0,0 +1,72 @@
package capturemanager.classes;
import capturemanager.interfaces.IFileSinkFactory;
import capturemanager.interfaces.IMediaType;
import capturemanager.interfaces.IStreamNode;
import java.util.ArrayList;
import java.util.List;
final class FileSinkFactory extends FileSinkFactoryNative implements IFileSinkFactory {
FileSinkFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public List<IStreamNode> createOutputNodes(
List<IMediaType> aArrayPtrCompressedMediaTypes,
String aPtrFileName) {
List<IStreamNode> lresult = new ArrayList<IStreamNode>();
do
{
if(mPtr == 0)
break;
if(aArrayPtrCompressedMediaTypes == null)
break;
long[] PtrCompressedMediaTypes = new long[aArrayPtrCompressedMediaTypes.size()];
for(int lIndex = 0; lIndex < aArrayPtrCompressedMediaTypes.size(); lIndex++)
{
MediaType lMediaType = (MediaType)aArrayPtrCompressedMediaTypes.get(lIndex);
if(lMediaType != null)
PtrCompressedMediaTypes[lIndex] = lMediaType.mPtr;
}
long[] lPtrOutputNodes = super.createOutputNodes(
mPtr,
PtrCompressedMediaTypes,
aPtrFileName);
if(lPtrOutputNodes == null)
break;
for(int lIndex = 0; lIndex < lPtrOutputNodes.length; lIndex++)
{
lresult.add(new StreamNode(lPtrOutputNodes[lIndex]));
}
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,9 @@
package capturemanager.classes;
abstract class FileSinkFactoryNative {
native protected long[] createOutputNodes(
long aPtr,
long[] aArrayPtrCompressedMediaTypes,
String aPtrFileName);
}

View File

@ -0,0 +1,59 @@
package capturemanager.classes;
import capturemanager.interfaces.ILogPrintOutControl;
class LogPrintOutControl extends LogPrintOutControlNative implements ILogPrintOutControl {
protected static final String CLSID_CoLogPrintOut = "{4563EE3E-DA1E-4911-9F40-88A284E2DD69}";
protected static final String IID_ILogPrintOutControl = "{73B67834-E7BD-40B7-9730-8C13BF098B9F}";
LogPrintOutControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
public void release()
{
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public void addPrintOutDestination(int aLevelType, String aFilePath) {
if(mPtr != 0)
addPrintOutDestinationNative(
mPtr,
aLevelType,
aFilePath);
}
@Override
public void removePrintOutDestination(int aLevelType, String aFilePath) {
if(mPtr != 0)
removePrintOutDestinationNative(
mPtr,
aLevelType,
aFilePath);
}
@Override
public void setVerbose(int aLevelType, String aFilePath, Boolean aState) {
if(mPtr != 0)
setVerboseNative(
mPtr,
aLevelType,
aFilePath,
aState);
}
}

View File

@ -0,0 +1,21 @@
package capturemanager.classes;
abstract class LogPrintOutControlNative
{
native protected void addPrintOutDestinationNative(
long aPtr,
int aLevelType,
String aFilePath);
native protected void removePrintOutDestinationNative(
long aPtr,
int aLevelType,
String aFilePath);
native protected void setVerboseNative(
long aPtr,
int aLevelType,
String aFilePath,
boolean aState);
}

View File

@ -0,0 +1,23 @@
package capturemanager.classes;
import capturemanager.interfaces.IMediaType;
final class MediaType implements IMediaType {
MediaType(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
}

View File

@ -0,0 +1,34 @@
package capturemanager.classes;
import capturemanager.interfaces.ISampleGrabberCall;
import capturemanager.interfaces.IStreamNode;
import java.nio.ByteBuffer;
final class SampleGrabberCall extends SampleGrabberCallNative implements ISampleGrabberCall {
private StreamNode mStreamNode = null;
SampleGrabberCall(long aPtr) {
mStreamNode = new StreamNode(aPtr);
}
@Override
public int readData(ByteBuffer byteBuffer) {
if (!byteBuffer.isDirect()) {
throw new IllegalArgumentException("You must user a direct byte buffer");
}
return super.readData(mStreamNode.mPtr, byteBuffer);
}
@Override
public void RGB32ToBGRA(ByteBuffer byteBuffer) {
super.RGB32ToBGRA(byteBuffer);
}
@Override
public IStreamNode getStreamNode() {
return mStreamNode;
}
}

View File

@ -0,0 +1,13 @@
package capturemanager.classes;
import java.nio.ByteBuffer;
abstract class SampleGrabberCallNative {
native protected int readData(
long aPtr,
ByteBuffer byteBuffer);
native protected void RGB32ToBGRA(
ByteBuffer byteBuffer);
}

View File

@ -0,0 +1,55 @@
package capturemanager.classes;
import capturemanager.interfaces.*;
final class SampleGrabberCallSinkFactory extends SampleGrabberCallSinkFactoryNative
implements ISampleGrabberCallSinkFactory {
SampleGrabberCallSinkFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public ISampleGrabberCall createOutputNode(
String aStringMajorType,
String aStringSubType,
int aSampleByteSize) {
ISampleGrabberCall lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createOutputNode(
mPtr,
aStringMajorType,
aStringSubType,
aSampleByteSize,
"{118AD3F7-D9A3-4146-AB35-F16421DC995E}");
SampleGrabberCall lSampleGrabberCall = new SampleGrabberCall(lPtr);
lresult = lSampleGrabberCall;
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,10 @@
package capturemanager.classes;
abstract class SampleGrabberCallSinkFactoryNative {
native protected long createOutputNode(
long aPtr,
String aStringMajorType,
String aStringSubType,
int aSampleByteSize,
String aStringIID);
}

View File

@ -0,0 +1,44 @@
package capturemanager.classes;
import capturemanager.interfaces.*;
import java.util.*;
final class SampleGrabberCallback extends SampleGrabberCallbackNative implements ISampleGrabberCallback {
private StreamNode mStreamNode = null;
SampleGrabberCallback() {
}
void setPtr(long aPtr) {
mStreamNode = new StreamNode(aPtr);
}
void invoke(byte[] aSampleBuffer, int aSampleSize)
{
synchronized(listeners)
{
for(int lIndex=0; lIndex < listeners.size(); ++lIndex)
{
listeners.get(lIndex).invoke(aSampleBuffer, aSampleSize);
}
}
}
private List<ICallbackListener> listeners = new ArrayList<ICallbackListener>();
@Override
public void addCallbackListener(ICallbackListener aICallbackListener) {
synchronized(listeners)
{
listeners.add(aICallbackListener);
}
}
@Override
public IStreamNode getStreamNode() {
return mStreamNode;
}
}

View File

@ -0,0 +1,8 @@
package capturemanager.classes;
abstract class SampleGrabberCallbackNative {
native protected int registerCallback(
long aPtr);
}

View File

@ -0,0 +1,58 @@
package capturemanager.classes;
import capturemanager.interfaces.ISampleGrabberCallback;
import capturemanager.interfaces.ISampleGrabberCallbackSinkFactory;
class SampleGrabberCallbackSinkFactory extends SampleGrabberCallbackSinkFactoryNative
implements ISampleGrabberCallbackSinkFactory {
SampleGrabberCallbackSinkFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable {
super.finalize();
if (mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public ISampleGrabberCallback createOutputNode(
String aStringMajorType,
String aStringSubType) {
ISampleGrabberCallback lresult = null;
do {
if (mPtr == 0)
break;
SampleGrabberCallback lSampleGrabberCallback = new SampleGrabberCallback();
long lPtr = createOutputNode(
mPtr,
aStringMajorType,
aStringSubType,
lSampleGrabberCallback
);
if (lPtr == 0) {
break;
}
lSampleGrabberCallback.setPtr(lPtr);
lresult = lSampleGrabberCallback;
}
while (false);
return lresult;
}
}

View File

@ -0,0 +1,10 @@
package capturemanager.classes;
abstract class SampleGrabberCallbackSinkFactoryNative {
native protected long createOutputNode(
long aPtr,
String aStringMajorType,
String aStringSubType,
Object aPtrISampleGrabberCallback);
}

View File

@ -0,0 +1,131 @@
package capturemanager.classes;
import capturemanager.interfaces.ISession;
import capturemanager.interfaces.IUpdateStateListener;
final class Session extends SessionNative implements ISession {
Session(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public boolean startSession(
long aStartPositionInHundredNanosecondUnits,
String aStringGUIDTimeFormat) {
boolean lresult = false;
do
{
if(mPtr == 0)
break;
lresult = startSession(
mPtr,
aStartPositionInHundredNanosecondUnits,
aStringGUIDTimeFormat);
}
while(false);
return lresult;
}
@Override
public boolean pauseSession() {
boolean lresult = false;
do
{
if(mPtr == 0)
break;
lresult = pauseSession(
mPtr);
}
while(false);
return lresult;
}
@Override
public boolean stopSession() {
boolean lresult = false;
do
{
if(mPtr == 0)
break;
lresult = stopSession(
mPtr);
}
while(false);
return lresult;
}
@Override
public boolean closeSession() {
boolean lresult = false;
do
{
if(mPtr == 0)
break;
lresult = closeSession(
mPtr);
}
while(false);
return lresult;
}
@Override
public int getSessionDescriptor() {
int lresult = -1;
do
{
if(mPtr == 0)
break;
lresult = getSessionDescriptor(
mPtr);
}
while(false);
return lresult;
}
@Override
public void addUpdateStateListener(IUpdateStateListener aIUpdateStateListener) {
do
{
if(mPtr == 0)
break;
addIUpdateStateListener(
mPtr,
aIUpdateStateListener);
}
while(false);
}
}

View File

@ -0,0 +1,68 @@
package capturemanager.classes;
import capturemanager.interfaces.ISession;
import capturemanager.interfaces.ISessionControl;
import capturemanager.interfaces.IStreamNode;
import java.util.List;
final class SessionControl extends SessionControlNative implements ISessionControl {
protected static final String IID = "{D0C58520-A941-4C0F-81B0-3ED8A4DE11ED}";
SessionControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public ISession createSession(
List<IStreamNode> aArrayPtrSourceNodesOfTopology) {
ISession lresult = null;
do
{
if(mPtr == 0)
break;
long[] lPtrSourceNodesOfTopologys = new long[aArrayPtrSourceNodesOfTopology.size()];
for(int lIndex = 0; lIndex < aArrayPtrSourceNodesOfTopology.size(); ++lIndex)
{
StreamNode lStreamNode = (StreamNode)aArrayPtrSourceNodesOfTopology.get(lIndex);
if(lStreamNode == null)
continue;
lPtrSourceNodesOfTopologys[lIndex] = lStreamNode.mPtr;
}
long lPtr = createSession(
mPtr,
lPtrSourceNodesOfTopologys,
"{742AC001-D1E0-40A8-8EFE-BA1A550F8805}");
if(lPtr == 0)
break;
lresult = new Session(lPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,8 @@
package capturemanager.classes;
abstract class SessionControlNative {
native protected long createSession(
long aPtr,
long[] aArrayPtrSourceNodesOfTopology,
String aStringIID);
}

View File

@ -0,0 +1,21 @@
package capturemanager.classes;
abstract class SessionNative {
native protected boolean closeSession(long aPtr);
native protected boolean addIUpdateStateListener(
long aPtr,
Object aIUpdateStateListener);
native protected int getSessionDescriptor(long aPtr);
native protected boolean pauseSession(long aPtr);
native protected boolean startSession(
long aPtr,
long aStartPositionInHundredNanosecondUnits,
String aStringGUIDTimeFormat);
native protected boolean stopSession(long aPtr);
}

View File

@ -0,0 +1,146 @@
package capturemanager.classes;
import capturemanager.interfaces.IEVRSinkFactory;
import capturemanager.interfaces.IFileSinkFactory;
import capturemanager.interfaces.ISampleGrabberCallSinkFactory;
import capturemanager.interfaces.ISampleGrabberCallbackSinkFactory;
import capturemanager.interfaces.ISinkControl;
final class SinkControl extends SinkControlNative implements ISinkControl {
protected static final String IID = "{C6BA3732-197E-438B-8E73-277759A7B58F}";
SinkControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IFileSinkFactory createFileSinkFactory(String aStringContainerTypeGUID) {
IFileSinkFactory lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createSinkFactory(
mPtr,
aStringContainerTypeGUID,
"{D6E342E3-7DDD-4858-AB91-4253643864C2}");
if(lPtr == 0)
break;
lresult = new FileSinkFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public ISampleGrabberCallSinkFactory createSampleGrabberCallSinkFactory(String aStringContainerTypeGUID) {
ISampleGrabberCallSinkFactory lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createSinkFactory(
mPtr,
aStringContainerTypeGUID,
"{759D24FF-C5D6-4B65-8DDF-8A2B2BECDE39}");
if(lPtr == 0)
break;
lresult = new SampleGrabberCallSinkFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public ISampleGrabberCallbackSinkFactory createSampleGrabberCallbackSinkFactory(String aStringContainerTypeGUID) {
ISampleGrabberCallbackSinkFactory lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createSinkFactory(
mPtr,
aStringContainerTypeGUID,
"{3D64C48E-EDA4-4EE1-8436-58B64DD7CF13}");
if(lPtr == 0)
break;
lresult = new SampleGrabberCallbackSinkFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public IEVRSinkFactory createEVRSinkFactory(String aStringContainerTypeGUID) {
IEVRSinkFactory lresult = null;
do
{
if(mPtr == 0)
break;
long lPtr = createSinkFactory(
mPtr,
aStringContainerTypeGUID,
"{2F34AF87-D349-45AA-A5F1-E4104D5C458E}");
if(lPtr == 0)
break;
lresult = new EVRSinkFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public String getCollectionOfSinks() {
String lresult = null;
do
{
if(mPtr == 0)
break;
lresult = getCollectionOfSinks(mPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,12 @@
package capturemanager.classes;
abstract class SinkControlNative {
native protected long createSinkFactory(
long aPtr,
String aStringContainerTypeGUID,
String aStringIID);
native protected String getCollectionOfSinks(
long aPtr);
}

View File

@ -0,0 +1,144 @@
package capturemanager.classes;
import capturemanager.interfaces.IMediaType;
import capturemanager.interfaces.ISourceControl;
import capturemanager.interfaces.IStreamNode;
final class SourceControl extends SourceControlNative implements ISourceControl {
protected static final String IID = "{1276CC17-BCA8-4200-87BB-7180EF562447}";
SourceControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable {
super.finalize();
if (mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IStreamNode createSourceNode(
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType,
IStreamNode aPtrDownStreamTopologyNode) {
IStreamNode lresult = null;
do {
if (mPtr == 0)
break;
if (aPtrDownStreamTopologyNode == null)
break;
StreamNode lPtrDownStreamTopologyNode = (StreamNode) aPtrDownStreamTopologyNode;
long lPtr = createSourceNodeWithDownStreamConnection(
mPtr,
aSymbolicLink,
aIndexStream,
aIndexMediaType,
lPtrDownStreamTopologyNode.mPtr);
if (lPtr == 0)
break;
lresult = new StreamNode(lPtr);
}
while (false);
return lresult;
}
@Override
public IStreamNode createSourceNode(
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType) {
IStreamNode lresult = null;
do {
if (mPtr == 0)
break;
if (aSymbolicLink == null)
break;
long lPtr = createSourceNode(
mPtr,
aSymbolicLink,
aIndexStream,
aIndexMediaType);
if (lPtr == 0)
break;
lresult = new StreamNode(lPtr);
}
while (false);
return lresult;
}
@Override
public String getCollectionOfSources() {
String lresult = null;
do {
if (mPtr == 0)
break;
lresult = getCollectionOfSources(
mPtr);
}
while (false);
return lresult;
}
@Override
public IMediaType getSourceOutputMediaType(
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType) {
IMediaType lresult = null;
do {
if (mPtr == 0)
break;
long lPtr = getSourceOutputMediaType(
mPtr,
aSymbolicLink,
aIndexStream,
aIndexMediaType);
if (lPtr == 0)
break;
lresult = new MediaType(lPtr);
}
while (false);
return lresult;
}
}

View File

@ -0,0 +1,44 @@
package capturemanager.classes;
abstract class SourceControlNative {
// native protected long createSource(
// String aSymbolicLink,
// out object aPtrPtrMediaSource);
native protected long createSourceControl(
long aPtr,
String aSymbolicLink,
String aStringIID);
// void createSourceFromCaptureProcessor(object aPtrCaptureProcessor, out object aPtrPtrMediaSource);
native protected long createSourceNode(
long aPtr,
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType);
// void createSourceNodeFromExternalSource(object aPtrMediaSource, uint aIndexStream, uint aIndexMediaType, out object aPtrPtrTopologyNode);
// void createSourceNodeFromExternalSourceWithDownStreamConnection(object aPtrMediaSource, uint aIndexStream, uint aIndexMediaType, object aPtrDownStreamTopologyNode, out object aPtrPtrTopologyNode);
native protected long createSourceNodeWithDownStreamConnection(
long aPtr,
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType,
long aPtrDownStreamTopologyNode);
native protected String getCollectionOfSources(
long aPtr);
native protected long getSourceOutputMediaType(
long aPtr,
String aSymbolicLink,
int aIndexStream,
int aIndexMediaType);
// void getSourceOutputMediaTypeFromMediaSource(object aPtrMediaSource, uint aIndexStream, uint aIndexMediaType, out object aPtrPtrOutputMediaType);
}

View File

@ -0,0 +1,63 @@
package capturemanager.classes;
import capturemanager.interfaces.ISpreaderNodeFactory;
import capturemanager.interfaces.IStreamNode;
import java.util.List;
final class SpreaderNodeFactory extends SpreaderNodeFactoryNative implements ISpreaderNodeFactory {
SpreaderNodeFactory(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public IStreamNode createSpreaderNode(List<IStreamNode> aDownStreamTopologyNodelist) {
IStreamNode lresult = null;
do
{
if(mPtr == 0)
break;
if(aDownStreamTopologyNodelist == null)
break;
long[] lDownStreamTopologyNodelist = new long[aDownStreamTopologyNodelist.size()];
for(int lIndex = 0; lIndex < aDownStreamTopologyNodelist.size(); lIndex++)
{
StreamNode lStreamNode = (StreamNode)aDownStreamTopologyNodelist.get(lIndex);
if(lStreamNode != null)
lDownStreamTopologyNodelist[lIndex] = lStreamNode.mPtr;
}
long lPtr = createSpreaderNode(
mPtr,
lDownStreamTopologyNodelist);
if(lPtr == 0)
break;
lresult = new StreamNode(lPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,7 @@
package capturemanager.classes;
abstract class SpreaderNodeFactoryNative {
native protected long createSpreaderNode(
long aPtr,
long[] aArrayPtrDownStreamTopologyNodes);
}

View File

@ -0,0 +1,93 @@
package capturemanager.classes;
import capturemanager.interfaces.ISpreaderNodeFactory;
import capturemanager.interfaces.IStreamControl;
final class StreamControl extends StreamControlNative implements IStreamControl {
protected static final String IID = "{E8F25B4A-8C71-4C9E-BD8C-82260DC4C21B}";
StreamControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public String getCollectionOfStreamControlNodeFactories() {
String lresult = "";
do
{
if(mPtr != 0)
break;
lresult = getCollectionOfStreamControlNodeFactories(mPtr);
}
while(false);
return lresult;
}
@Override
public ISpreaderNodeFactory createStreamControlNodeFactory() {
ISpreaderNodeFactory lresult = null;
do
{
if(mPtr != 0)
break;
long lPtr = createStreamControlNodeFactory(
mPtr,
"{85DFAAA1-4CC0-4A88-AE28-8F492E552CCA}");
if(lPtr != 0)
break;
lresult = new SpreaderNodeFactory(lPtr);
}
while(false);
return lresult;
}
@Override
public ISpreaderNodeFactory createStreamControlNodeFactory(String aStringIID) {
ISpreaderNodeFactory lresult = null;
do
{
if(mPtr != 0)
break;
long lPtr = createStreamControlNodeFactory(
mPtr,
aStringIID);
if(lPtr != 0)
break;
lresult = new SpreaderNodeFactory(lPtr);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,11 @@
package capturemanager.classes;
abstract class StreamControlNative {
native protected long createStreamControlNodeFactory(
long aPtr,
String aStringIID);
native protected String getCollectionOfStreamControlNodeFactories(
long aPtr);
}

View File

@ -0,0 +1,23 @@
package capturemanager.classes;
import capturemanager.interfaces.IStreamNode;
final class StreamNode implements IStreamNode {
StreamNode(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable {
super.finalize();
if (mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
}

View File

@ -0,0 +1,49 @@
package capturemanager.classes;
import capturemanager.interfaces.IStrideForBitmap;
class StrideForBitmap extends StrideForBitmapNative implements IStrideForBitmap {
protected static final String IID = "{74D903C9-69E6-4FC7-BF7A-9F47605C52BE}";
StrideForBitmap(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public int getStrideForBitmap(String aStringMFVideoFormat, int aWidthInPixels) {
int lresult = 0;
do
{
if(mPtr == 0)
break;
if(aStringMFVideoFormat == null)
break;
lresult = getStrideForBitmap(
mPtr,
aStringMFVideoFormat,
aWidthInPixels);
}
while(false);
return lresult;
}
}

View File

@ -0,0 +1,8 @@
package capturemanager.classes;
abstract class StrideForBitmapNative {
native protected int getStrideForBitmap(
long aPtr,
String aStringMFVideoFormat,
int aWidthInPixels);
}

View File

@ -0,0 +1,31 @@
package capturemanager.classes;
import capturemanager.interfaces.IVersionControl;
final class VersionControl extends VersionControlNative implements IVersionControl {
protected static final String IID = "{39DC3AEF-3B59-4C0D-A1B2-54BF2653C056}";
VersionControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public String getXMLStringVersion() {
return getXMLStringVersion(mPtr);
}
}

View File

@ -0,0 +1,5 @@
package capturemanager.classes;
abstract class VersionControlNative {
native protected String getXMLStringVersion(long aPtr);
}

View File

@ -0,0 +1,58 @@
package capturemanager.classes;
import capturemanager.interfaces.IWebCamControl;
final class WebCamControl extends WebCamControlNative implements IWebCamControl {
WebCamControl(long aPtr) {
mPtr = aPtr;
}
protected long mPtr = 0;
@Override
protected void finalize() throws Throwable
{
super.finalize();
if(mPtr != 0)
CaptureManagerNativeProxy.getInstance().Release(mPtr);
mPtr = 0;
}
@Override
public String getCamParametrs() {
String lresult = "";
do
{
lresult = getCamParametrs(mPtr);
}
while(false);
return lresult;
}
@Override
public void setCamParametr(
int aParametrIndex,
int aNewValue,
int aFlag) {
do
{
if(mPtr == 0)
break;
setCamParametr(
mPtr,
aParametrIndex,
aNewValue,
aFlag);
}
while(false);
}
}

View File

@ -0,0 +1,11 @@
package capturemanager.classes;
abstract class WebCamControlNative {
native protected String getCamParametrs(
long aPtr);
native protected void setCamParametr(
long aPtr,
int aParametrIndex,
int aNewValue,
int aFlag);
}

View File

@ -0,0 +1,5 @@
package capturemanager.interfaces;
public interface ICallbackListener {
void invoke(byte[] aSampleBuffer, int aSampleSize);
}

View File

@ -0,0 +1,26 @@
package capturemanager.interfaces;
public interface ICaptureManagerControl {
String getCollectionOfSources();
String getCollectionOfSinks();
ISourceControl createSourceControl();
ISessionControl createSessionControl();
ISinkControl createSinkControl();
IStreamControl createStreamControl();
IEncoderControl createEncoderControl();
int getStrideForBitmapInfoHeader(
String aStringMFVideoFormat,
int aWidthInPixels);
IVersionControl getVersionControl();
void release();
}

View File

@ -0,0 +1,10 @@
package capturemanager.interfaces;
public interface ICaptureManagerNativeProxy {
public long explicitGetPtrClass(String aStringFilePath, String aStringCLSID, String aStringGUID);
public void freeLibrary(String aFileName);
public void Release(long aPtr);
}

View File

@ -0,0 +1,7 @@
package capturemanager.interfaces;
import java.awt.Component;
public interface IEVRSinkFactory {
IStreamNode createOutputNode(Component aGraphicComponent);
}

View File

@ -0,0 +1,7 @@
package capturemanager.interfaces;
public interface IEncoderControl {
IEncoderNodeFactory createEncoderNodeFactory(String aEncoderCLSID);
String getCollectionOfEncoders();
String getMediaTypeCollectionOfEncoder(IMediaType aPtrUncompressedMediaType, String aEncoderCLSID);
}

View File

@ -0,0 +1,18 @@
package capturemanager.interfaces;
public interface IEncoderNodeFactory {
IMediaType createCompressedMediaType(
IMediaType aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType);
IStreamNode createEncoderNode(
IMediaType aPtrUncompressedMediaType,
String aStringEncodingModeGUID,
int aEncodingModeValue,
int aIndexCompressedMediaType,
IStreamNode aPtrDownStreamNode);
}

View File

@ -0,0 +1,9 @@
package capturemanager.interfaces;
import java.util.List;
public interface IFileSinkFactory {
List<IStreamNode> createOutputNodes(
List<IMediaType> aArrayPtrCompressedMediaTypes,
String aPtrFileName);
}

View File

@ -0,0 +1,8 @@
package capturemanager.interfaces;
public interface ILogPrintOutControl {
void addPrintOutDestination(int aLevelType, String aFilePath);
void removePrintOutDestination(int aLevelType, String aFilePath);
void setVerbose(int aLevelType, String aFilePath, Boolean aState);
void release();
}

View File

@ -0,0 +1,5 @@
package capturemanager.interfaces;
public interface IMediaType {
}

Some files were not shown because too many files have changed in this diff Show More