mirror of https://github.com/sipwise/jitsi.git
parent
910e37f3e7
commit
5a6dd7a37f
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,24 +0,0 @@
|
||||
##
|
||||
# \file Makefile
|
||||
# \brief Windows (Visual C++) makefile for jdirectshow DLL.
|
||||
# \author Sebastien Vincent
|
||||
|
||||
CC = cl /W4 /wd4996 /EHsc /O2
|
||||
JNI_HEADERS = /I%JAVA_HOME%\include /I%JAVA_HOME%\include\win32
|
||||
LIBS = /link /out:jdirectshow.dll
|
||||
CFLAGS = $(JNI_HEADERS)
|
||||
|
||||
OBJS = net_java_sip_communicator_impl_neomedia_directshow_DSManager.cpp net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp net_java_sip_communicator_impl_neomedia_directshow_DSFormat.cpp ds_manager.cpp ds_capture_device.cpp
|
||||
|
||||
jdirectshow.dll: clean
|
||||
$(CC) $(CFLAGS) /LD $(OBJS) $(LIBS) ole32.lib oleaut32.lib user32.lib
|
||||
|
||||
install64: jdirectshow.dll
|
||||
copy jdirectshow.dll ..\..\..\..\lib\native\windows-64\
|
||||
|
||||
install32: jdirectshow.dll
|
||||
copy jdirectshow.dll ..\..\..\..\lib\native\windows\
|
||||
|
||||
clean:
|
||||
del *.exp *.lib *.dll *.obj *.manifest
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
JDirectShow
|
||||
============
|
||||
|
||||
1. Requirements
|
||||
|
||||
- Microsoft C++ compiler from Microsoft Platform SDK or Visual Studio (express or not);
|
||||
|
||||
Open Visual C++ command line,
|
||||
|
||||
for 32-bit compilation with Visual Studio:
|
||||
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat
|
||||
|
||||
for 64-bit compilation with Visual Studio:
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat
|
||||
|
||||
Set environment variable with Java SDK path:
|
||||
set JAVA_HOME=C:\Progra~1\Java\jdk1.6.0_20
|
||||
|
||||
2. Build instructions
|
||||
|
||||
Go to jdirectshow native source directory:
|
||||
cd \Path\to\sip-communicator\src\native\windows\directshow
|
||||
|
||||
Build and install:
|
||||
for 32-bit:
|
||||
nmake install32
|
||||
|
||||
for 64-bit:
|
||||
nmake install64
|
||||
|
||||
@ -1,522 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file ds_capture_device.cpp
|
||||
* \brief DirectShow capture device.
|
||||
* \author Sebastien Vincent
|
||||
* \date 2010
|
||||
*/
|
||||
|
||||
#include "ds_capture_device.h"
|
||||
|
||||
/* implementation of ISampleGrabber */
|
||||
DSGrabberCallback::DSGrabberCallback()
|
||||
{
|
||||
}
|
||||
|
||||
DSGrabberCallback::~DSGrabberCallback()
|
||||
{
|
||||
}
|
||||
|
||||
STDMETHODIMP DSGrabberCallback::SampleCB(double time, IMediaSample* sample)
|
||||
{
|
||||
BYTE* data = NULL;
|
||||
ULONG length = 0;
|
||||
|
||||
if(FAILED(sample->GetPointer(&data)))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
length = sample->GetActualDataLength();
|
||||
|
||||
printf("Sample received: %p %u\n", data, length);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP DSGrabberCallback::BufferCB(double time, BYTE* buffer, long len)
|
||||
{
|
||||
/* do nothing */
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DSGrabberCallback::QueryInterface(const IID& iid, void** ptr)
|
||||
{
|
||||
if(iid == IID_ISampleGrabberCB || iid == IID_IUnknown)
|
||||
{
|
||||
*ptr = (void*)reinterpret_cast<ISampleGrabberCB*>(this);
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) DSGrabberCallback::AddRef()
|
||||
{
|
||||
/* fake reference counting */
|
||||
return 1;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) DSGrabberCallback::Release()
|
||||
{
|
||||
/* fake reference counting */
|
||||
return 1;
|
||||
}
|
||||
|
||||
DSCaptureDevice::DSCaptureDevice(const WCHAR* name)
|
||||
{
|
||||
if(name)
|
||||
{
|
||||
m_name = wcsdup(name);
|
||||
}
|
||||
|
||||
m_flip = false;
|
||||
m_callback = NULL;
|
||||
|
||||
m_filterGraph = NULL;
|
||||
m_captureGraphBuilder = NULL;
|
||||
m_graphController = NULL;
|
||||
|
||||
m_srcFilter = NULL;
|
||||
m_sampleGrabberFilter = NULL;
|
||||
m_sampleGrabber = NULL;
|
||||
m_renderer = NULL;
|
||||
}
|
||||
|
||||
DSCaptureDevice::~DSCaptureDevice()
|
||||
{
|
||||
if(m_filterGraph)
|
||||
{
|
||||
/* remove all added filters from filter graph */
|
||||
if(m_srcFilter)
|
||||
{
|
||||
m_filterGraph->RemoveFilter(m_srcFilter);
|
||||
}
|
||||
|
||||
if(m_renderer)
|
||||
{
|
||||
m_filterGraph->RemoveFilter(m_renderer);
|
||||
}
|
||||
|
||||
if(m_sampleGrabberFilter)
|
||||
{
|
||||
m_filterGraph->RemoveFilter(m_sampleGrabberFilter);
|
||||
}
|
||||
}
|
||||
|
||||
/* clean up COM stuff */
|
||||
if(m_renderer)
|
||||
{
|
||||
m_renderer->Release();
|
||||
}
|
||||
|
||||
if(m_sampleGrabber)
|
||||
{
|
||||
m_sampleGrabber->Release();
|
||||
}
|
||||
|
||||
if(m_sampleGrabberFilter)
|
||||
{
|
||||
m_sampleGrabberFilter->Release();
|
||||
}
|
||||
|
||||
if(m_srcFilter)
|
||||
{
|
||||
m_srcFilter->Release();
|
||||
}
|
||||
|
||||
if(m_captureGraphBuilder)
|
||||
{
|
||||
m_captureGraphBuilder->Release();
|
||||
}
|
||||
|
||||
if(m_filterGraph)
|
||||
{
|
||||
m_filterGraph->Release();
|
||||
}
|
||||
|
||||
if(m_name)
|
||||
{
|
||||
free(m_name);
|
||||
}
|
||||
}
|
||||
|
||||
const WCHAR* DSCaptureDevice::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::setFormat(const VideoFormat& format)
|
||||
{
|
||||
HRESULT ret;
|
||||
IAMStreamConfig* streamConfig = NULL;
|
||||
AM_MEDIA_TYPE* mediaType = NULL;
|
||||
|
||||
/* force to stop */
|
||||
stop();
|
||||
|
||||
/* get the right interface to change capture settings */
|
||||
ret = m_captureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
|
||||
m_srcFilter, IID_IAMStreamConfig, (void**)&streamConfig);
|
||||
|
||||
if(!FAILED(ret))
|
||||
{
|
||||
size_t bitCount = 0;
|
||||
int nb = 0;
|
||||
int size = 0;
|
||||
BYTE* allocBytes = NULL;
|
||||
AM_MEDIA_TYPE* mt;
|
||||
bool found = false;
|
||||
|
||||
streamConfig->GetNumberOfCapabilities(&nb, &size);
|
||||
allocBytes = new BYTE[size];
|
||||
|
||||
for(int i = 0 ; i < nb ; i++)
|
||||
{
|
||||
if(streamConfig->GetStreamCaps(i, &mt, allocBytes) == S_OK)
|
||||
{
|
||||
VIDEOINFOHEADER* hdr = (VIDEOINFOHEADER*)mt->pbFormat;
|
||||
|
||||
if(hdr)
|
||||
{
|
||||
if((long)format.height == hdr->bmiHeader.biHeight &&
|
||||
(long)format.width == hdr->bmiHeader.biWidth)
|
||||
{
|
||||
mediaType = mt;
|
||||
if(format.pixelFormat == MEDIASUBTYPE_ARGB32.Data1 ||
|
||||
format.pixelFormat == MEDIASUBTYPE_RGB32.Data1)
|
||||
{
|
||||
bitCount = 32;
|
||||
}
|
||||
else if(format.pixelFormat == MEDIASUBTYPE_RGB24.Data1)
|
||||
{
|
||||
bitCount = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitCount = hdr->bmiHeader.biBitCount;
|
||||
}
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(found)
|
||||
{
|
||||
ret = streamConfig->SetFormat(mediaType);
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
fprintf(stderr, "Failed to set format\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bitPerPixel = bitCount;
|
||||
m_format = format;
|
||||
m_format.mediaType = mediaType->subtype;
|
||||
}
|
||||
}
|
||||
|
||||
delete allocBytes;
|
||||
|
||||
streamConfig->Release();
|
||||
}
|
||||
|
||||
return !FAILED(ret);
|
||||
}
|
||||
|
||||
DSGrabberCallback* DSCaptureDevice::getCallback()
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
void DSCaptureDevice::setCallback(DSGrabberCallback* callback)
|
||||
{
|
||||
m_callback = callback;
|
||||
m_sampleGrabber->SetCallback(callback, 0);
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::initDevice(IMoniker* moniker)
|
||||
{
|
||||
HRESULT ret = 0;
|
||||
|
||||
if(!m_name || !moniker)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_filterGraph)
|
||||
{
|
||||
/* already initialized */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create the filter and capture graph */
|
||||
ret = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IFilterGraph2, (void**)&m_filterGraph);
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
|
||||
CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,
|
||||
(void**)&m_captureGraphBuilder);
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_captureGraphBuilder->SetFiltergraph(m_filterGraph);
|
||||
|
||||
/* get graph controller */
|
||||
ret = m_filterGraph->QueryInterface(IID_IMediaControl, (void**)&m_graphController);
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* add source filter to the filter graph */
|
||||
ret = moniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&m_srcFilter);
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
WCHAR* name = wcsdup(m_name);
|
||||
ret = m_filterGraph->AddFilter(m_srcFilter, name);
|
||||
free(name);
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,
|
||||
(void**)&m_sampleGrabberFilter);
|
||||
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get sample grabber */
|
||||
ret = m_sampleGrabberFilter->QueryInterface(IID_ISampleGrabber, (void**)&m_sampleGrabber);
|
||||
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* and sample grabber to the filter graph */
|
||||
ret = m_filterGraph->AddFilter(m_sampleGrabberFilter, L"SampleGrabberFilter");
|
||||
|
||||
/* set media type */
|
||||
/*
|
||||
AM_MEDIA_TYPE mediaType;
|
||||
memset(&mediaType, 0x00, sizeof(AM_MEDIA_TYPE));
|
||||
mediaType.majortype = MEDIATYPE_Video;
|
||||
mediaType.subtype = MEDIASUBTYPE_RGB24;
|
||||
ret = m_sampleGrabber->SetMediaType(&mediaType);
|
||||
*/
|
||||
/* set the callback handler */
|
||||
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* set renderer */
|
||||
ret = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IBaseFilter, (void**)&m_renderer);
|
||||
|
||||
if(ret != S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* add renderer to the filter graph */
|
||||
m_filterGraph->AddFilter(m_renderer, L"NullRenderer");
|
||||
|
||||
/* initialize the list of formats this device supports */
|
||||
initSupportedFormats();
|
||||
|
||||
/* see if camera support flipping */
|
||||
IAMVideoControl* videoControl = NULL;
|
||||
long caps = 0;
|
||||
|
||||
ret = m_captureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
|
||||
m_srcFilter, IID_IAMVideoControl, (void**)&videoControl);
|
||||
|
||||
if(!FAILED(ret))
|
||||
{
|
||||
IPin* pin = NULL;
|
||||
|
||||
ret = m_captureGraphBuilder->FindPin(
|
||||
m_srcFilter, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, NULL, FALSE, 0, &pin);
|
||||
|
||||
if(!FAILED(ret))
|
||||
{
|
||||
if(!FAILED(videoControl->GetCaps(pin, &caps)))
|
||||
{
|
||||
if((caps & VideoControlFlag_FlipVertical) > 0)
|
||||
{
|
||||
m_flip = false;
|
||||
caps = caps & ~(VideoControlFlag_FlipVertical);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flip = false;
|
||||
}
|
||||
|
||||
if((caps & VideoControlFlag_FlipHorizontal) != 0)
|
||||
{
|
||||
caps = caps & ~(VideoControlFlag_FlipHorizontal);
|
||||
}
|
||||
|
||||
videoControl->SetMode(pin, caps);
|
||||
}
|
||||
pin->Release();
|
||||
}
|
||||
|
||||
videoControl->Release();
|
||||
}
|
||||
|
||||
return setFormat(m_formats.front());
|
||||
}
|
||||
|
||||
void DSCaptureDevice::initSupportedFormats()
|
||||
{
|
||||
HRESULT ret;
|
||||
IAMStreamConfig* streamConfig = NULL;
|
||||
AM_MEDIA_TYPE* mediaType = NULL;
|
||||
|
||||
ret = m_captureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
|
||||
m_srcFilter, IID_IAMStreamConfig, (void**)&streamConfig);
|
||||
|
||||
/* get to find all supported formats */
|
||||
if(!FAILED(ret))
|
||||
{
|
||||
int nb = 0;
|
||||
int size = 0;
|
||||
BYTE* allocBytes = NULL;
|
||||
|
||||
streamConfig->GetNumberOfCapabilities(&nb, &size);
|
||||
allocBytes = new BYTE[size];
|
||||
|
||||
for(int i = 0 ; i < nb ; i++)
|
||||
{
|
||||
if(streamConfig->GetStreamCaps(i, &mediaType, allocBytes) == S_OK)
|
||||
{
|
||||
struct VideoFormat format;
|
||||
VIDEOINFOHEADER* hdr = (VIDEOINFOHEADER*)mediaType->pbFormat;
|
||||
|
||||
if(hdr)
|
||||
{
|
||||
format.height = hdr->bmiHeader.biHeight;
|
||||
format.width = hdr->bmiHeader.biWidth;
|
||||
format.pixelFormat = mediaType->subtype.Data1;
|
||||
format.mediaType = mediaType->subtype;
|
||||
|
||||
m_formats.push_back(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete allocBytes;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<VideoFormat> DSCaptureDevice::getSupportedFormats() const
|
||||
{
|
||||
return m_formats;
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::buildGraph()
|
||||
{
|
||||
REFERENCE_TIME start = 0;
|
||||
REFERENCE_TIME stop = MAXLONGLONG;
|
||||
HRESULT ret = 0;
|
||||
|
||||
#ifndef RENDERER_DEBUG
|
||||
ret = m_captureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
|
||||
m_srcFilter, m_sampleGrabberFilter,
|
||||
m_renderer);
|
||||
#else
|
||||
ret = m_captureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
|
||||
m_srcFilter, m_sampleGrabberFilter,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
/* fprintf(stderr, "problem render stream\n"); */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* start capture */
|
||||
ret = m_captureGraphBuilder->ControlStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
|
||||
m_srcFilter, &start, &stop, 1, 2);
|
||||
|
||||
/* we need this to finalize graph (maybe other filter will be added) */
|
||||
//m_graphController->Run();
|
||||
//this->stop();
|
||||
|
||||
return !FAILED(ret);
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::start()
|
||||
{
|
||||
if(!m_renderer || !m_sampleGrabberFilter || !m_srcFilter || !m_graphController)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_graphController->Run();
|
||||
m_renderer->Run(0);
|
||||
m_sampleGrabberFilter->Run(0);
|
||||
m_srcFilter->Run(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::stop()
|
||||
{
|
||||
if(!m_renderer || !m_sampleGrabberFilter || !m_srcFilter || !m_graphController)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_srcFilter->Stop();
|
||||
m_sampleGrabberFilter->Stop();
|
||||
m_renderer->Stop();
|
||||
m_graphController->Stop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
VideoFormat DSCaptureDevice::getFormat() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
size_t DSCaptureDevice::getBitPerPixel()
|
||||
{
|
||||
return m_bitPerPixel;
|
||||
}
|
||||
|
||||
bool DSCaptureDevice::isFlip()
|
||||
{
|
||||
return m_flip;
|
||||
}
|
||||
|
||||
@ -1,253 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file ds_capture_device.h
|
||||
* \brief DirectShow capture device.
|
||||
* \author Sebastien Vincent
|
||||
* \date 2010
|
||||
*/
|
||||
|
||||
#ifndef DS_CAPTURE_DEVICE_H
|
||||
#define DS_CAPTURE_DEVICE_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <dshow.h>
|
||||
#include "qedit.h"
|
||||
|
||||
#include "video_format.h"
|
||||
|
||||
/**
|
||||
* \class DSGrabberCallback
|
||||
* \brief Callback when DirectShow device capture frames.
|
||||
*/
|
||||
class DSGrabberCallback : public ISampleGrabberCB
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
DSGrabberCallback();
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~DSGrabberCallback();
|
||||
|
||||
/**
|
||||
* \brief Method callback when device capture a frame.
|
||||
* \param time time when frame was received
|
||||
* \param sample media sample
|
||||
* \see ISampleGrabberCB
|
||||
*/
|
||||
virtual STDMETHODIMP SampleCB(double time, IMediaSample* sample);
|
||||
|
||||
/**
|
||||
* \brief Method callback when device buffer a frame.
|
||||
* \param time time when frame was received
|
||||
* \param buffer raw buffer
|
||||
* \param len length of buffer
|
||||
* \see ISampleGrabberCB
|
||||
*/
|
||||
virtual STDMETHODIMP BufferCB(double time, BYTE* buffer, long len);
|
||||
|
||||
/**
|
||||
* \brief Query if this COM object has the interface iid.
|
||||
* \param iid interface requested
|
||||
* \param ptr if method succeed, an object corresponding
|
||||
* to the interface requested will be copied in this pointer
|
||||
*/
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(const IID& iid, void** ptr);
|
||||
|
||||
/**
|
||||
* \brief Adding a reference.
|
||||
* \return number of reference hold
|
||||
*/
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
|
||||
/**
|
||||
* \brief Release a reference.
|
||||
* \return number of reference hold
|
||||
*/
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
};
|
||||
|
||||
/**
|
||||
* \class DSCaptureDevice
|
||||
* \brief DirectShow capture device.
|
||||
*
|
||||
* Once a DSCapture has been obtained by DSManager, do not
|
||||
* forget to build the graph and optionally set a format.
|
||||
*/
|
||||
class DSCaptureDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor.
|
||||
* \param name name of the capture device
|
||||
*/
|
||||
DSCaptureDevice(const WCHAR* name);
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~DSCaptureDevice();
|
||||
|
||||
/**
|
||||
* \brief Get name of the capture device.
|
||||
* \return name of the capture device
|
||||
*/
|
||||
const WCHAR* getName() const;
|
||||
|
||||
/**
|
||||
* \brief Initialize the device.
|
||||
* \param moniker moniker of the capture device
|
||||
* \return true if initialization succeed, false otherwise (in this
|
||||
* case the capture device have to be deleted)
|
||||
*/
|
||||
bool initDevice(IMoniker* moniker);
|
||||
|
||||
/**
|
||||
* \brief Set video format.
|
||||
* \param format video format
|
||||
* \return true if change is successful, false otherwise (format unsupported, ...)
|
||||
* \note This method stop stream so you have to call start() after.
|
||||
*/
|
||||
bool setFormat(const VideoFormat& format);
|
||||
|
||||
/**
|
||||
* \brief Get list of supported formats.
|
||||
* \return list of supported formats.
|
||||
*/
|
||||
std::list<VideoFormat> getSupportedFormats() const;
|
||||
|
||||
/**
|
||||
* \brief Build the filter graph for this capture device.
|
||||
* \return true if success, false otherwise
|
||||
* \note Call this method before start().
|
||||
*/
|
||||
bool buildGraph();
|
||||
|
||||
/**
|
||||
* \brief get callback object.
|
||||
* \return callback
|
||||
*/
|
||||
DSGrabberCallback* getCallback();
|
||||
|
||||
/**
|
||||
* \brief Set callback object when receiving new frames.
|
||||
* \param callback callback object to set
|
||||
*/
|
||||
void setCallback(DSGrabberCallback* callback);
|
||||
|
||||
/**
|
||||
* \brief Start capture device.
|
||||
* \return false if problem, true otherwise
|
||||
*/
|
||||
bool start();
|
||||
|
||||
/**
|
||||
* \brief Stop capture device.
|
||||
* \return false if problem, true otherwise
|
||||
*/
|
||||
bool stop();
|
||||
|
||||
/**
|
||||
* \brief Get current format.
|
||||
* \return current format
|
||||
*/
|
||||
VideoFormat getFormat() const;
|
||||
|
||||
/**
|
||||
* \brief Get current bit per pixel.
|
||||
* \return bit per pixel of images
|
||||
*/
|
||||
size_t getBitPerPixel();
|
||||
|
||||
/**
|
||||
* \brief If the image is flipped vertically.
|
||||
* \return true if image is flipped vertically, false otherwise
|
||||
*/
|
||||
bool isFlip();
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief Initialize list of supported size.
|
||||
*/
|
||||
void initSupportedFormats();
|
||||
|
||||
/**
|
||||
* \brief Name of the capture device.
|
||||
*/
|
||||
WCHAR* m_name;
|
||||
|
||||
/**
|
||||
* \brief Callback.
|
||||
*/
|
||||
DSGrabberCallback* m_callback;
|
||||
|
||||
/**
|
||||
* \brief List of VideoFormat.
|
||||
*/
|
||||
std::list<VideoFormat> m_formats;
|
||||
|
||||
/**
|
||||
* \brief Reference of the filter graph.
|
||||
*/
|
||||
IFilterGraph2* m_filterGraph;
|
||||
|
||||
/**
|
||||
* \brief Reference of the capture graph builder.
|
||||
*/
|
||||
ICaptureGraphBuilder2* m_captureGraphBuilder;
|
||||
|
||||
/**
|
||||
* \brief Controller of the graph.
|
||||
*/
|
||||
IMediaControl* m_graphController;
|
||||
|
||||
/**
|
||||
* \brief Source filter.
|
||||
*/
|
||||
IBaseFilter* m_srcFilter;
|
||||
|
||||
/**
|
||||
* \brief Sample grabber filter.
|
||||
*/
|
||||
IBaseFilter* m_sampleGrabberFilter;
|
||||
|
||||
/**
|
||||
* \brief The null renderer.
|
||||
*/
|
||||
IBaseFilter* m_renderer;
|
||||
|
||||
/**
|
||||
* \brief The sample grabber.
|
||||
*/
|
||||
ISampleGrabber* m_sampleGrabber;
|
||||
|
||||
/**
|
||||
* \brief Current format.
|
||||
*/
|
||||
VideoFormat m_format;
|
||||
|
||||
/**
|
||||
* \brief Current bit per pixel.
|
||||
*/
|
||||
size_t m_bitPerPixel;
|
||||
|
||||
/**
|
||||
* \brief If the video is already flipped.
|
||||
*/
|
||||
bool m_flip;
|
||||
};
|
||||
|
||||
#endif /* DS_CAPTURE_DEVICE_H */
|
||||
|
||||
@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file ds_manager.cpp
|
||||
* \brief DirectShow capture devices manager.
|
||||
* \author Sebastien Vincent
|
||||
* \date 2010
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ds_manager.h"
|
||||
#include "ds_capture_device.h"
|
||||
#include "qedit.h"
|
||||
|
||||
/* initialization of static member variables */
|
||||
DSManager* DSManager::m_instance = NULL;
|
||||
|
||||
DSManager* DSManager::getInstance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
DSManager::DSManager()
|
||||
{
|
||||
DWORD ret = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
if(ret != S_OK && ret != S_FALSE)
|
||||
{
|
||||
//seems to be a problem with COM initialization
|
||||
/*
|
||||
printf("problem\n");fflush(stdout);
|
||||
if(ret == RPC_E_CHANGED_MODE)
|
||||
{
|
||||
printf("rpc\n");fflush(stdout);
|
||||
}
|
||||
else if(ret == E_INVALIDARG)
|
||||
{
|
||||
printf("invalid arg\n");fflush(stdout);
|
||||
}
|
||||
else if(ret == E_OUTOFMEMORY)
|
||||
{
|
||||
printf("outofmemory\n");fflush(stdout);
|
||||
}
|
||||
else if(ret == E_UNEXPECTED)
|
||||
{
|
||||
printf("unexpected\n");fflush(stdout);
|
||||
}
|
||||
*/
|
||||
|
||||
comInited = false;
|
||||
return;
|
||||
}
|
||||
|
||||
comInited = true;
|
||||
initCaptureDevices();
|
||||
}
|
||||
|
||||
DSManager::~DSManager()
|
||||
{
|
||||
for(std::list<DSCaptureDevice*>::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
m_devices.clear();
|
||||
|
||||
/* one CoUninitialize per CoInitialize */
|
||||
if(comInited)
|
||||
{
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
bool DSManager::initialize()
|
||||
{
|
||||
if(!m_instance)
|
||||
{
|
||||
m_instance = new DSManager();
|
||||
}
|
||||
|
||||
return m_instance != NULL;
|
||||
}
|
||||
|
||||
void DSManager::destroy()
|
||||
{
|
||||
if(m_instance)
|
||||
{
|
||||
delete m_instance;
|
||||
m_instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<DSCaptureDevice*> DSManager::getDevices() const
|
||||
{
|
||||
return m_devices;
|
||||
}
|
||||
|
||||
size_t DSManager::getDevicesCount()
|
||||
{
|
||||
return m_devices.size();
|
||||
}
|
||||
|
||||
void DSManager::initCaptureDevices()
|
||||
{
|
||||
HRESULT ret = 0;
|
||||
VARIANT name;
|
||||
ICreateDevEnum* devEnum = NULL;
|
||||
IEnumMoniker* monikerEnum = NULL;
|
||||
IMoniker* moniker = NULL;
|
||||
|
||||
if(m_devices.size() > 0)
|
||||
{
|
||||
/* clean up our list in case of reinitialization */
|
||||
for(std::list<DSCaptureDevice*>::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
m_devices.clear();
|
||||
}
|
||||
|
||||
/* get the available devices list */
|
||||
ret = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_ICreateDevEnum, (void**)&devEnum);
|
||||
|
||||
if(FAILED(ret))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ret = devEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
|
||||
&monikerEnum, NULL);
|
||||
|
||||
/* error or no devices */
|
||||
if(FAILED(ret) || ret == S_FALSE)
|
||||
{
|
||||
devEnum->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
/* loop and initialize all available capture devices */
|
||||
while(monikerEnum->Next(1, &moniker, 0) == S_OK)
|
||||
{
|
||||
DSCaptureDevice* captureDevice = NULL;
|
||||
IPropertyBag* propertyBag = NULL;
|
||||
|
||||
{
|
||||
IBaseFilter* cp = NULL;
|
||||
if(!FAILED(moniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&cp)))
|
||||
{
|
||||
IAMVfwCaptureDialogs* vfw = NULL;
|
||||
if(!FAILED(
|
||||
cp->QueryInterface(IID_IAMVfwCaptureDialogs, (void**)&vfw)))
|
||||
{
|
||||
if(vfw)
|
||||
{
|
||||
vfw->Release();
|
||||
cp->Release();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* get properties of the device */
|
||||
ret = moniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&propertyBag);
|
||||
if(!FAILED(ret))
|
||||
{
|
||||
VariantInit(&name);
|
||||
|
||||
ret = propertyBag->Read(L"FriendlyName", &name, 0);
|
||||
if(FAILED(ret))
|
||||
{
|
||||
VariantClear(&name);
|
||||
propertyBag->Release();
|
||||
moniker->Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* create a new capture device */
|
||||
captureDevice = new DSCaptureDevice(name.bstrVal);
|
||||
/* wprintf(L"%ws\n", name.bstrVal); */
|
||||
|
||||
if(captureDevice && captureDevice->initDevice(moniker))
|
||||
{
|
||||
/* initialization success, add to the list */
|
||||
m_devices.push_back(captureDevice);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* printf("failed to initialize device\n"); */
|
||||
delete captureDevice;
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
VariantClear(&name);
|
||||
propertyBag->Release();
|
||||
}
|
||||
moniker->Release();
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
monikerEnum->Release();
|
||||
devEnum->Release();
|
||||
}
|
||||
|
||||
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file ds_manager.h
|
||||
* \brief DirectShow capture devices manager.
|
||||
* \author Sebastien Vincent
|
||||
* \date 2010
|
||||
*/
|
||||
|
||||
#ifndef DS_MANAGER_H
|
||||
#define DS_MANAGER_H
|
||||
|
||||
#pragma comment(lib, "strmiids")
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <dshow.h>
|
||||
|
||||
class DSCaptureDevice;
|
||||
|
||||
/**
|
||||
* \class DSManager
|
||||
* \brief DirectShow capture device manager (singleton).
|
||||
*/
|
||||
class DSManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~DSManager();
|
||||
|
||||
/**
|
||||
* \brief Initialize DirectShow manager.
|
||||
*
|
||||
* Call this method to initialize DirectShow capture devices.
|
||||
* It can also be used to reinitialize and update list of current
|
||||
* devices but be sure to not use any of previous DSCaptureDevice after.
|
||||
*
|
||||
* \return true if initialize succeed, false otherwise
|
||||
* \note You MUST call before any use of DirectShow.
|
||||
*/
|
||||
static bool initialize();
|
||||
|
||||
/**
|
||||
* \brief Destroy DirectShow manager.
|
||||
* \note You MUST call this method when you have finished
|
||||
* using DirectShow.
|
||||
*/
|
||||
static void destroy();
|
||||
|
||||
/**
|
||||
* \brief Get unique instance.
|
||||
* \return DirectShow manager instance
|
||||
* \note You MUST call DSManager::initialize before
|
||||
* any use of this method or you will get NULL as return value.
|
||||
*/
|
||||
static DSManager* getInstance();
|
||||
|
||||
/**
|
||||
* \brief Get all available capture video devices.
|
||||
* \return devices list
|
||||
*/
|
||||
std::list<DSCaptureDevice*> getDevices() const;
|
||||
|
||||
/**
|
||||
* \brief Get number of devices.
|
||||
* \return number of available devices
|
||||
*/
|
||||
size_t getDevicesCount();
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief Unique instance of DirectShow manager.
|
||||
*/
|
||||
static DSManager* m_instance;
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
*/
|
||||
DSManager();
|
||||
|
||||
/**
|
||||
* \brief Get and initialize video capture devices.
|
||||
*/
|
||||
void initCaptureDevices();
|
||||
|
||||
/**
|
||||
* \brief Available devices list.
|
||||
*/
|
||||
std::list<DSCaptureDevice*> m_devices;
|
||||
|
||||
/**
|
||||
* \brief Easy use of template-based list iterator.
|
||||
*/
|
||||
typedef std::list<DSCaptureDevice*>::iterator DeviceListIterator;
|
||||
|
||||
/**
|
||||
* If COM backend is initialized.
|
||||
*/
|
||||
bool comInited;
|
||||
};
|
||||
|
||||
#endif /* DS_MANAGER_H */
|
||||
|
||||
@ -1,400 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp
|
||||
* \brief JNI part of DSCaptureDevice.
|
||||
* \author Sebastien Vincent
|
||||
*/
|
||||
|
||||
#include "ds_capture_device.h"
|
||||
#include "video_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* } */
|
||||
#endif
|
||||
|
||||
#include "net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.h"
|
||||
|
||||
/**
|
||||
* \class Grabber.
|
||||
* \brief Frame grabber.
|
||||
*/
|
||||
class Grabber : public DSGrabberCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor.
|
||||
* \param vm Java Virtual Machine
|
||||
* \param delegate delegate Java object
|
||||
*/
|
||||
Grabber(JavaVM* vm, jobject delegate, DSCaptureDevice* dev)
|
||||
{
|
||||
this->m_vm = vm;
|
||||
this->m_delegate = delegate;
|
||||
this->m_dev = dev;
|
||||
m_bytes = NULL;
|
||||
m_bytesLength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~Grabber()
|
||||
{
|
||||
m_vm = NULL;
|
||||
m_delegate = NULL;
|
||||
m_dev = NULL;
|
||||
|
||||
if(m_bytes != NULL)
|
||||
{
|
||||
delete[] m_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Method callback when device capture a frame.
|
||||
* \param time time when frame was received
|
||||
* \param sample media sample
|
||||
* \see ISampleGrabberCB
|
||||
*/
|
||||
virtual STDMETHODIMP SampleCB(double time, IMediaSample* sample)
|
||||
{
|
||||
jclass delegateClass = NULL;
|
||||
JNIEnv* env = NULL;
|
||||
|
||||
if(m_vm->AttachCurrentThreadAsDaemon((void**)&env, NULL) != 0)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
delegateClass = env->GetObjectClass(m_delegate);
|
||||
if(delegateClass)
|
||||
{
|
||||
jmethodID methodid = NULL;
|
||||
|
||||
methodid = env->GetMethodID(delegateClass,"frameReceived",
|
||||
"(JI)V");
|
||||
if(methodid)
|
||||
{
|
||||
BYTE* data = NULL;
|
||||
size_t length = 0;
|
||||
bool flipImage = false;
|
||||
size_t width = 0;
|
||||
size_t height = 0;
|
||||
size_t bytesPerPixel = 0;
|
||||
VideoFormat format = m_dev->getFormat();
|
||||
/* get width and height */
|
||||
width = format.width;
|
||||
height = format.height;
|
||||
bytesPerPixel = m_dev->getBitPerPixel() / 8;
|
||||
|
||||
/* flip image for RGB content */
|
||||
flipImage = !m_dev->isFlip() &&
|
||||
(format.mediaType == MEDIASUBTYPE_ARGB32 ||
|
||||
format.mediaType == MEDIASUBTYPE_RGB32 ||
|
||||
format.mediaType == MEDIASUBTYPE_RGB24);
|
||||
|
||||
sample->GetPointer(&data);
|
||||
length = sample->GetActualDataLength();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(!m_bytes || m_bytesLength < length)
|
||||
{
|
||||
if(m_bytes)
|
||||
{
|
||||
delete[] m_bytes;
|
||||
}
|
||||
|
||||
m_bytes = new BYTE[length];
|
||||
m_bytesLength = length;
|
||||
}
|
||||
|
||||
/* it seems that images is always inversed,
|
||||
* the following code from lti-civil is always used to flip
|
||||
* images
|
||||
*/
|
||||
if(flipImage)
|
||||
{
|
||||
for(size_t row = 0 ; row < height ; row++)
|
||||
{
|
||||
memcpy((m_bytes + row * width * bytesPerPixel), data + (height - 1 - row) * width * bytesPerPixel,
|
||||
width * bytesPerPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(m_bytes, data, length);
|
||||
}
|
||||
|
||||
env->CallVoidMethod(m_delegate, methodid, (jlong)m_bytes, (jlong)length);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Java VM.
|
||||
*/
|
||||
JavaVM* m_vm;
|
||||
|
||||
/**
|
||||
* \brief Delegate Java object.
|
||||
*/
|
||||
jobject m_delegate;
|
||||
|
||||
/**
|
||||
* \brief Internal buffer.
|
||||
*/
|
||||
BYTE* m_bytes;
|
||||
|
||||
/**
|
||||
* \brief Length of internal buffer.
|
||||
*/
|
||||
size_t m_bytesLength;
|
||||
|
||||
/**
|
||||
* \brief DirectShow device.
|
||||
*/
|
||||
DSCaptureDevice* m_dev;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Open native capture device.
|
||||
* \param env JNI environment
|
||||
* \param obj DSCaptureDevice object
|
||||
* \param ptr native pointer of DSCaptureDevice
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_open
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
|
||||
dev->buildGraph();
|
||||
dev->start();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Close native capture device.
|
||||
* \param env JNI environment
|
||||
* \param obj DSCaptureDevice object
|
||||
* \param ptr native pointer of DSCaptureDevice
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_close
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
dev->stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get name of native capture device.
|
||||
* \param env JNI environment
|
||||
* \param obj DSCaptureDevice object
|
||||
* \param ptr native pointer of DSCaptureDevice
|
||||
* \return name of the native capture device
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getName
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
jstring ret = NULL;
|
||||
jsize len = static_cast<jsize>(wcslen(dev->getName()));
|
||||
jchar* name = new jchar[len];
|
||||
|
||||
/* jchar is two bytes! */
|
||||
memcpy((void*)name, (void*)dev->getName(), len * 2);
|
||||
|
||||
ret = env->NewString(name, len);
|
||||
delete[] name;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set format of native capture device.
|
||||
* \param env JNI environment
|
||||
* \param obj DSCaptureDevice object
|
||||
* \param ptr native pointer of DSCaptureDevice
|
||||
* \param format DSFormat to set
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_setFormat
|
||||
(JNIEnv* env, jobject obj, jlong ptr, jobject format)
|
||||
{
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
VideoFormat fmt;
|
||||
jclass clazz = env->GetObjectClass(format);
|
||||
|
||||
if(clazz)
|
||||
{
|
||||
jfieldID fieldH = env->GetFieldID(clazz, "height", "I");
|
||||
jfieldID fieldW = env->GetFieldID(clazz, "width", "I");
|
||||
jfieldID fieldF = env->GetFieldID(clazz, "pixelFormat", "J");
|
||||
jlong f = env->GetLongField(format, fieldF);
|
||||
jint w = env->GetIntField(format, fieldW);
|
||||
jint h = env->GetIntField(format, fieldH);
|
||||
|
||||
fmt.width = w;
|
||||
fmt.height = h;
|
||||
fmt.pixelFormat = (unsigned long)f;
|
||||
|
||||
dev->setFormat(fmt);
|
||||
dev->start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get current format.
|
||||
* \param env JNI environment
|
||||
* \param obj object
|
||||
* \param native pointer
|
||||
* \return current format
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getFormat
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
VideoFormat fmt = dev->getFormat();
|
||||
jclass clazzDSFormat = NULL;
|
||||
jmethodID initDSFormat = NULL;
|
||||
jobject ret = NULL;
|
||||
|
||||
/* get DSFormat class to instantiate some object */
|
||||
clazzDSFormat = env->FindClass("net/java/sip/communicator/impl/neomedia/directshow/DSFormat");
|
||||
if(clazzDSFormat == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
initDSFormat = env->GetMethodID(clazzDSFormat, "<init>", "(IIJ)V");
|
||||
|
||||
if(initDSFormat == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = env->NewObject(clazzDSFormat, initDSFormat, static_cast<size_t>(fmt.width),
|
||||
static_cast<size_t>(fmt.height), static_cast<jlong>(fmt.pixelFormat));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get formats supported by native capture device.
|
||||
* \param env JNI environment
|
||||
* \param obj DSCaptureDevice object
|
||||
* \param ptr native pointer of DSCaptureDevice
|
||||
* \return array of DSFormat object
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getSupportedFormats
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
jobjectArray ret = NULL;
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
std::list<VideoFormat> formats;
|
||||
jclass clazzDSFormat = NULL;
|
||||
jmethodID initDSFormat = NULL;
|
||||
jsize i = 0;
|
||||
|
||||
/* get DSFormat class to instantiate some object */
|
||||
clazzDSFormat = env->FindClass("net/java/sip/communicator/impl/neomedia/directshow/DSFormat");
|
||||
if(clazzDSFormat == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
initDSFormat = env->GetMethodID(clazzDSFormat, "<init>", "(IIJ)V");
|
||||
|
||||
if(initDSFormat == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
formats = dev->getSupportedFormats();
|
||||
|
||||
ret = env->NewObjectArray(static_cast<jsize>(formats.size()), clazzDSFormat, NULL);
|
||||
for(std::list<VideoFormat>::iterator it = formats.begin() ; it != formats.end() ; ++it)
|
||||
{
|
||||
VideoFormat tmp = (*it);
|
||||
jobject o = env->NewObject(clazzDSFormat, initDSFormat, static_cast<size_t>(tmp.width),
|
||||
static_cast<size_t>(tmp.height), static_cast<jlong>(tmp.pixelFormat));
|
||||
|
||||
if(o == NULL)
|
||||
{
|
||||
fprintf(stderr, "failed!!\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
env->SetObjectArrayElement(ret, i, o);
|
||||
env->DeleteLocalRef(o);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set delegate.
|
||||
* \param env JNI environment
|
||||
* \param obj object
|
||||
* \param ptr native pointer on DSCaptureDevice
|
||||
* \param delegate delegate object
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_setDelegate
|
||||
(JNIEnv* env, jobject obj, jlong ptr, jobject delegate)
|
||||
{
|
||||
Grabber* grab = NULL;
|
||||
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
|
||||
DSGrabberCallback* prev = dev->getCallback();
|
||||
|
||||
if(delegate != NULL)
|
||||
{
|
||||
delegate = env->NewGlobalRef(delegate);
|
||||
if(delegate)
|
||||
{
|
||||
JavaVM* vm = NULL;
|
||||
/* get JavaVM */
|
||||
env->GetJavaVM(&vm);
|
||||
grab = new Grabber(vm, delegate, dev);
|
||||
dev->setCallback(grab);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dev->setCallback(NULL);
|
||||
}
|
||||
|
||||
if(prev)
|
||||
{
|
||||
jobject tmp_delegate = ((Grabber*)prev)->m_delegate;
|
||||
if(tmp_delegate)
|
||||
{
|
||||
env->DeleteGlobalRef(tmp_delegate);
|
||||
}
|
||||
delete prev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getBytes
|
||||
(JNIEnv* env, jclass clazz, jlong ptr, jlong buf, jint len)
|
||||
{
|
||||
/* copy data */
|
||||
memcpy((void*)buf, (void*)ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice */
|
||||
|
||||
#ifndef _Included_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
#define _Included_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: open
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_open
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: close
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_close
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: getName
|
||||
* Signature: (J)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getName
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: setFormat
|
||||
* Signature: (JLnet/java/sip/communicator/impl/neomedia/directshow/DSFormat;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_setFormat
|
||||
(JNIEnv *, jobject, jlong, jobject);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: getFormat
|
||||
* Signature: (J)Lnet/java/sip/communicator/impl/neomedia/directshow/DSFormat;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getFormat
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: getSupportedFormats
|
||||
* Signature: (J)[Lnet/java/sip/communicator/impl/neomedia/directshow/DSFormat;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getSupportedFormats
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: setDelegate
|
||||
* Signature: (JLnet/java/sip/communicator/impl/neomedia/directshow/DSCaptureDevice/GrabberDelegate;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_setDelegate
|
||||
(JNIEnv *, jobject, jlong, jobject);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice
|
||||
* Method: getBytes
|
||||
* Signature: (JJI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice_getBytes
|
||||
(JNIEnv *, jclass, jlong, jlong, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
#include "net_java_sip_communicator_impl_neomedia_directshow_DSFormat.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dshow.h>
|
||||
#include <uuids.h>
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getRGB24PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_RGB24.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getRGB32PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_RGB32.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getARGBPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_ARGB32.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getAYUVPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_AYUV.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYUY2PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_YUY2.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getUYVYPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_UYVY.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC1PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IMC1.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC2PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IMC2.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC3PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IMC3.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC4PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IMC4.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYV12PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_YV12.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getNV12PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_NV12.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIF09PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IF09.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIYUVPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_IYUV.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY211PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_Y211.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY411PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_Y411.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY41PPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_Y41P.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYVU9PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_YVU9.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYVYUPixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return MEDIASUBTYPE_YVYU.Data1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getI420PixelFormat
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return 0x30323449; //MEDIASUBTYPE_I420.Data1;
|
||||
}
|
||||
|
||||
@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class net_java_sip_communicator_impl_neomedia_directshow_DSFormat */
|
||||
|
||||
#ifndef _Included_net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
#define _Included_net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getRGB24PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getRGB24PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getRGB32PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getRGB32PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getARGBPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getARGBPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getAYUVPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getAYUVPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getYUY2PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYUY2PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getUYVYPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getUYVYPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIMC1PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC1PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIMC2PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC2PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIMC3PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC3PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIMC4PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIMC4PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getYV12PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYV12PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getNV12PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getNV12PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIF09PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIF09PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getIYUVPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getIYUVPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getY211PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY211PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getY411PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY411PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getY41PPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getY41PPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getYVU9PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYVU9PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getYVYUPixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getYVYUPixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSFormat
|
||||
* Method: getI420PixelFormat
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSFormat_getI420PixelFormat
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file net_java_sip_communicator_impl_neomedia_directshow_DSManager.cpp
|
||||
* \brief JNI part of DSManager.
|
||||
* \author Sebastien Vincent
|
||||
*/
|
||||
|
||||
#include "ds_manager.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* } */
|
||||
#endif
|
||||
|
||||
#include "net_java_sip_communicator_impl_neomedia_directshow_DSManager.h"
|
||||
|
||||
/**
|
||||
* \brief Initialize DSManager singleton.
|
||||
* \param env JNI environment
|
||||
* \param clazz DSManager class
|
||||
* \return native pointer on DSManager singleton instance
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_init
|
||||
(JNIEnv* env, jclass clazz)
|
||||
{
|
||||
if(DSManager::initialize())
|
||||
{
|
||||
DSManager* manager = DSManager::getInstance();
|
||||
return reinterpret_cast<long>(manager);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Initialize DSManager singleton.
|
||||
* \param env JNI environment
|
||||
* \param clazz DSManager class
|
||||
* \return native pointer on DSManager singleton instance
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_destroy
|
||||
(JNIEnv* env, jclass clazz, jlong ptr)
|
||||
{
|
||||
DSManager::destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get all capture devices.
|
||||
* \param env JNI environment
|
||||
* \param obj DSManager object
|
||||
* \param jlong native pointer of DSManager
|
||||
* \return array of native DSCaptureDevice pointers
|
||||
*/
|
||||
JNIEXPORT jlongArray JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_getCaptureDevices
|
||||
(JNIEnv* env, jobject obj, jlong ptr)
|
||||
{
|
||||
jlongArray ret = NULL;
|
||||
DSManager* manager = reinterpret_cast<DSManager*>(ptr);
|
||||
std::list<DSCaptureDevice*> devices;
|
||||
jsize i = 0;
|
||||
|
||||
devices = manager->getDevices();
|
||||
|
||||
ret = env->NewLongArray(static_cast<jsize>(devices.size()));
|
||||
if(!ret)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(std::list<DSCaptureDevice*>::iterator it = devices.begin() ; it != devices.end() ; ++it)
|
||||
{
|
||||
jlong dPtr = reinterpret_cast<jlong>((*it));
|
||||
|
||||
env->SetLongArrayRegion(ret, i, 1, &dPtr);
|
||||
i++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class net_java_sip_communicator_impl_neomedia_directshow_DSManager */
|
||||
|
||||
#ifndef _Included_net_java_sip_communicator_impl_neomedia_directshow_DSManager
|
||||
#define _Included_net_java_sip_communicator_impl_neomedia_directshow_DSManager
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSManager
|
||||
* Method: init
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_init
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSManager
|
||||
* Method: destroy
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_destroy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: net_java_sip_communicator_impl_neomedia_directshow_DSManager
|
||||
* Method: getCaptureDevices
|
||||
* Signature: (J)[J
|
||||
*/
|
||||
JNIEXPORT jlongArray JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_DSManager_getCaptureDevices
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1,95 +0,0 @@
|
||||
/* as qedit.h has been removed from recent Microsoft Platform SDK,
|
||||
* we add it here. This code comes from the following web page:
|
||||
* http://social.msdn.microsoft.com/Forums/en/windowsdirectshowdevelopment/thread/2ab5c212-5824-419d-b5d9-7f5db82f57cd
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __qedit_h__
|
||||
#define __qedit_h__
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
interface
|
||||
ISampleGrabberCB
|
||||
:
|
||||
public IUnknown
|
||||
{
|
||||
virtual STDMETHODIMP SampleCB( double SampleTime, IMediaSample *pSample ) = 0;
|
||||
virtual STDMETHODIMP BufferCB( double SampleTime, BYTE *pBuffer, long BufferLen ) = 0;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
IID IID_ISampleGrabberCB = { 0x0579154A, 0x2B53, 0x4994, { 0xB0, 0xD0, 0xE7, 0x73, 0x14, 0x8E, 0xFF, 0x85 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
interface
|
||||
ISampleGrabber
|
||||
:
|
||||
public IUnknown
|
||||
{
|
||||
virtual HRESULT STDMETHODCALLTYPE SetOneShot( BOOL OneShot ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetMediaType( const AM_MEDIA_TYPE *pType ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType( AM_MEDIA_TYPE *pType ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetBufferSamples( BOOL BufferThem ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentBuffer( long *pBufferSize, long *pBuffer ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentSample( IMediaSample **ppSample ) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetCallback( ISampleGrabberCB *pCallback, long WhichMethodToCallback ) = 0;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
IID IID_ISampleGrabber = { 0x6B652FFF, 0x11FE, 0x4fce, { 0x92, 0xAD, 0x02, 0x66, 0xB5, 0xD7, 0xC7, 0x8F } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_SampleGrabber = { 0xC1F400A0, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_NullRenderer = { 0xC1F400A4, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_VideoEffects1Category = { 0xcc7bfb42, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_VideoEffects2Category = { 0xcc7bfb43, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_AudioEffects1Category = { 0xcc7bfb44, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static
|
||||
const
|
||||
CLSID CLSID_AudioEffects2Category = { 0xcc7bfb45, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file video_format.h
|
||||
* \brief Useful structures and enumerations for video format.
|
||||
* \author Sebastien Vincent
|
||||
*/
|
||||
|
||||
#ifndef VIDEO_FORMAT_H
|
||||
#define VIDEO_FORMAT_H
|
||||
|
||||
/**
|
||||
* \struct VideoFormat
|
||||
* \brief Information about video format
|
||||
*/
|
||||
struct VideoFormat
|
||||
{
|
||||
size_t width; /**< Video width */
|
||||
size_t height; /**< Video height */
|
||||
unsigned long pixelFormat; /**< Pixel format */
|
||||
GUID mediaType; /**< Media type */
|
||||
};
|
||||
|
||||
#endif /* VIDEO_FORMAT_H */
|
||||
|
||||
Loading…
Reference in new issue