diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar index 0cb2a2cab..131c40d04 100644 Binary files a/lib/installer-exclude/libjitsi.jar and b/lib/installer-exclude/libjitsi.jar differ diff --git a/lib/native/windows-64/jndirectshow.dll b/lib/native/windows-64/jndirectshow.dll index 9b4318724..56909b7e8 100644 Binary files a/lib/native/windows-64/jndirectshow.dll and b/lib/native/windows-64/jndirectshow.dll differ diff --git a/lib/native/windows/jndirectshow.dll b/lib/native/windows/jndirectshow.dll index 8e7e671f2..e1ed7a899 100644 Binary files a/lib/native/windows/jndirectshow.dll and b/lib/native/windows/jndirectshow.dll differ diff --git a/src/native/build.xml b/src/native/build.xml index 07f4b6fb9..89d7615d1 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -470,26 +470,6 @@ - - - - - - - - - - - - - - - - - - - @@ -828,7 +808,6 @@ - diff --git a/src/native/windows/directshow/Makefile b/src/native/windows/directshow/Makefile deleted file mode 100644 index 67e38d8f3..000000000 --- a/src/native/windows/directshow/Makefile +++ /dev/null @@ -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 - diff --git a/src/native/windows/directshow/README.txt b/src/native/windows/directshow/README.txt deleted file mode 100644 index 393eb5f9d..000000000 --- a/src/native/windows/directshow/README.txt +++ /dev/null @@ -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 - diff --git a/src/native/windows/directshow/ds_capture_device.cpp b/src/native/windows/directshow/ds_capture_device.cpp deleted file mode 100644 index 0464027c2..000000000 --- a/src/native/windows/directshow/ds_capture_device.cpp +++ /dev/null @@ -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(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 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; -} - diff --git a/src/native/windows/directshow/ds_capture_device.h b/src/native/windows/directshow/ds_capture_device.h deleted file mode 100644 index 1777b9b86..000000000 --- a/src/native/windows/directshow/ds_capture_device.h +++ /dev/null @@ -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 - -#define WIN32_LEAN_AND_MEAN -#include -#include -#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 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 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 */ - diff --git a/src/native/windows/directshow/ds_manager.cpp b/src/native/windows/directshow/ds_manager.cpp deleted file mode 100644 index 2b5c6273e..000000000 --- a/src/native/windows/directshow/ds_manager.cpp +++ /dev/null @@ -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 - -#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::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 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::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(); -} - diff --git a/src/native/windows/directshow/ds_manager.h b/src/native/windows/directshow/ds_manager.h deleted file mode 100644 index 85d0ca45b..000000000 --- a/src/native/windows/directshow/ds_manager.h +++ /dev/null @@ -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 - -#include - -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 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 m_devices; - - /** - * \brief Easy use of template-based list iterator. - */ - typedef std::list::iterator DeviceListIterator; - - /** - * If COM backend is initialized. - */ - bool comInited; -}; - -#endif /* DS_MANAGER_H */ - diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp deleted file mode 100644 index 1cc9ffa94..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp +++ /dev/null @@ -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(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(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(ptr); - jstring ret = NULL; - jsize len = static_cast(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(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(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, "", "(IIJ)V"); - - if(initDSFormat == NULL) - { - return NULL; - } - - ret = env->NewObject(clazzDSFormat, initDSFormat, static_cast(fmt.width), - static_cast(fmt.height), static_cast(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(ptr); - std::list 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, "", "(IIJ)V"); - - if(initDSFormat == NULL) - { - return NULL; - } - - formats = dev->getSupportedFormats(); - - ret = env->NewObjectArray(static_cast(formats.size()), clazzDSFormat, NULL); - for(std::list::iterator it = formats.begin() ; it != formats.end() ; ++it) - { - VideoFormat tmp = (*it); - jobject o = env->NewObject(clazzDSFormat, initDSFormat, static_cast(tmp.width), - static_cast(tmp.height), static_cast(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(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 - diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.h b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.h deleted file mode 100644 index 4e9b0bfcf..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.h +++ /dev/null @@ -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 -/* 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 diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.cpp b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.cpp deleted file mode 100644 index 72e54b945..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.cpp +++ /dev/null @@ -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 -#include -#include - -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; -} - diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.h b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.h deleted file mode 100644 index 5d5d8858a..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSFormat.h +++ /dev/null @@ -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 -/* 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 diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.cpp b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.cpp deleted file mode 100644 index 1dffa9d7d..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.cpp +++ /dev/null @@ -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(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(ptr); - std::list devices; - jsize i = 0; - - devices = manager->getDevices(); - - ret = env->NewLongArray(static_cast(devices.size())); - if(!ret) - { - return NULL; - } - - for(std::list::iterator it = devices.begin() ; it != devices.end() ; ++it) - { - jlong dPtr = reinterpret_cast((*it)); - - env->SetLongArrayRegion(ret, i, 1, &dPtr); - i++; - } - - return ret; -} - -#ifdef __cplusplus -} -#endif - diff --git a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.h b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.h deleted file mode 100644 index 4b8245264..000000000 --- a/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSManager.h +++ /dev/null @@ -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 -/* 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 diff --git a/src/native/windows/directshow/qedit.h b/src/native/windows/directshow/qedit.h deleted file mode 100644 index 5c4121176..000000000 --- a/src/native/windows/directshow/qedit.h +++ /dev/null @@ -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 - -/////////////////////////////////////////////////////////////////////////////////// - diff --git a/src/native/windows/directshow/video_format.h b/src/native/windows/directshow/video_format.h deleted file mode 100644 index 1842f95b5..000000000 --- a/src/native/windows/directshow/video_format.h +++ /dev/null @@ -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 */ - diff --git a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java index a58c71ef6..3b51beedb 100755 --- a/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/GeneralDialPanel.java @@ -19,6 +19,7 @@ import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.skin.*; +import org.jitsi.service.resources.*; import org.jitsi.util.*; /** @@ -27,12 +28,18 @@ * * @author Yana Stamcheva * @author Adam Netocny + * @author Lyubomir Marinov */ public class GeneralDialPanel extends TransparentPanel - implements MouseListener, - Skinnable + implements MouseListener, + Skinnable { + /** + * The parent dial pad dialog. + */ + private final GeneralDialPadDialog dialPadDialog; + /** * The dial panel. */ @@ -46,12 +53,7 @@ public class GeneralDialPanel /** * Handles DTMFs. */ - private DTMFHandler dtmfHandler; - - /** - * The parent dial pad dialog. - */ - private final GeneralDialPadDialog dialPadDialog; + private final DTMFHandler dtmfHandler; /** * Creates an instance of DialPanel for a specific call, by @@ -69,20 +71,6 @@ public GeneralDialPanel(GeneralDialPadDialog dialPadDialog, this.init(); } - /** - * Initializes this panel by adding all dial buttons to it. - */ - public void init() - { - this.dialPadPanel.setOpaque(false); - - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - - loadSkin(); - - this.add(dialPadPanel, BorderLayout.CENTER); - } - /** * Creates DTMF button. * @@ -94,8 +82,8 @@ public void init() private JButton createDialButton(Image bgImage, ImageID iconImage, String name) { - JButton button = - new SIPCommButton(bgImage, ImageLoader.getImage(iconImage)); + JButton button + = new SIPCommButton(bgImage, ImageLoader.getImage(iconImage)); button.setAlignmentY(JButton.LEFT_ALIGNMENT); button.setName(name); @@ -105,31 +93,75 @@ private JButton createDialButton(Image bgImage, ImageID iconImage, } /** - * Creates DTMF button. + * Initializes a new dial button which is to be used on Mac OS X. * - * @param bgImage - * @param iconImage + * @param imageID + * @param rolloverImageID * @param name - * @return the created dial button + * @return the newly-initialized dial button */ private JButton createMacOSXDialButton( ImageID imageID, ImageID rolloverImageID, String name) { - JButton button = new SIPCommButton( - ImageLoader.getImage(imageID), - ImageLoader.getImage(rolloverImageID), - ImageLoader.getImage(rolloverImageID), - null, - null, - null); + JButton button + = new SIPCommButton( + ImageLoader.getImage(imageID), + ImageLoader.getImage(rolloverImageID), + ImageLoader.getImage(rolloverImageID), + null, + null, + null); button.setName(name); button.addMouseListener(this); - return button; } + /** + * Initializes this panel by adding all dial buttons to it. + */ + public void init() + { + this.dialPadPanel.setOpaque(false); + + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + + loadSkin(); + + this.add(dialPadPanel, BorderLayout.CENTER); + } + + /** + * Reloads dial buttons. + */ + public void loadSkin() + { + dialPadPanel.removeAll(); + + Image bgImage = ImageLoader.getImage(ImageLoader.DIAL_BUTTON_BG); + + for (DTMFHandler.DTMFToneInfo info : DTMFHandler.AVAILABLE_TONES) + { + // We only add buttons with images. + if (info.imageID == null) + continue; + + JComponent c + = OSUtils.IS_MAC + ? createMacOSXDialButton( + info.macImageID, + info.macImageRolloverID, + info.tone.getValue()) + : createDialButton( + bgImage, + info.imageID, + info.tone.getValue()); + + dialPadPanel.add(c); + } + } + public void mouseClicked(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} @@ -164,83 +196,50 @@ public void mouseReleased(MouseEvent e) * * @param g the Graphics object used for painting */ + @Override public void paintComponent(Graphics g) { - // do the superclass behavior first + // do the superclass behavior first super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; - boolean isTextureBackground - = Boolean.parseBoolean(GuiActivator.getResources() - .getSettingsString("impl.gui.IS_CONTACT_LIST_TEXTURE_BG_ENABLED")); - BufferedImage bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND); // paint the image if (bgImage != null) { + ResourceManagementService r = GuiActivator.getResources(); + boolean isTextureBackground + = Boolean.parseBoolean( + r.getSettingsString( + "impl.gui.IS_CONTACT_LIST_TEXTURE_BG_ENABLED")); + int width = getWidth(); + int height = getHeight(); + if (isTextureBackground) { Rectangle rect = new Rectangle(0, 0, bgImage.getWidth(null), bgImage.getHeight(null)); - TexturePaint texture = new TexturePaint(bgImage, rect); g2.setPaint(texture); - - g2.fillRect(0, 0, this.getWidth(), this.getHeight()); + g2.fillRect(0, 0, width, height); } else { - g.setColor(new Color( - GuiActivator.getResources() - .getColor("contactListBackground"))); - - // paint the background with the choosen color - g.fillRect(0, 0, getWidth(), getHeight()); - - g2.drawImage(bgImage, - this.getWidth() - bgImage.getWidth(), - this.getHeight() - bgImage.getHeight(), + g.setColor(new Color(r.getColor("contactListBackground"))); + // Paint the background with the chosen color. + g.fillRect(0, 0, width, height); + g2.drawImage( + bgImage, + width - bgImage.getWidth(), + height - bgImage.getHeight(), this); } } } - - /** - * Reloads dial buttons. - */ - public void loadSkin() - { - dialPadPanel.removeAll(); - - Image bgImage = ImageLoader.getImage(ImageLoader.DIAL_BUTTON_BG); - DTMFHandler.DTMFToneInfo[] availableTones = DTMFHandler.AVAILABLE_TONES; - - for (int i = 0; i < availableTones.length; i++) - { - DTMFHandler.DTMFToneInfo info = availableTones[i]; - - // we add only buttons having image - if(info.imageID == null) - continue; - - JComponent c - = OSUtils.IS_MAC - ? createMacOSXDialButton( - info.macImageID, - info.macImageRolloverID, - info.tone.getValue()) - : createDialButton( - bgImage, - info.imageID, - info.tone.getValue()); - - dialPadPanel.add(c); - } - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java index f28c6fa3c..334bb801f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -1290,7 +1290,7 @@ private void initializeUserInterfaceHierarchy() * buttons which accept a Call as an argument should be changed to take * into account the whole CallConference. */ - Call aCall = this.callConference.getCalls().get(0); + Call aCall = callConference.getCalls().get(0); chatButton = new CallToolBarButton( @@ -1351,6 +1351,7 @@ private void initializeUserInterfaceHierarchy() false); remoteLevel = new OutputVolumeControlButton( + callConference, ImageLoader.VOLUME_CONTROL_BUTTON, false, true) diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java index a753b17db..120ee2efd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java @@ -361,7 +361,11 @@ private void createSoundLevelIndicators() false, false); remoteLevel - = new OutputVolumeControlButton(ImageLoader.HEADPHONE, false, false) + = new OutputVolumeControlButton( + call.getConference(), + ImageLoader.HEADPHONE, + false, + false) .getComponent(); final SoundLevelIndicator localLevelIndicator diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java b/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java index 1da4869bd..9cf234e94 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OutputVolumeControlButton.java @@ -14,9 +14,12 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.service.resources.*; import org.jitsi.service.neomedia.*; +import org.jitsi.service.resources.*; /** * The VolumeControlButton is the button shown in the call window, @@ -24,84 +27,49 @@ * * @author Yana Stamcheva * @author Damian Minkov + * @author Lyubomir Marinov */ public class OutputVolumeControlButton { /** - * The background image. + * The CallConference (i.e. telephony conference-related state) + * depicted by this instance. */ - private ImageID bgImage; + private final CallConference callConference; /** - * The pressed image. + * The indicator which determines whether the user interface + * (representation) of this instance is (to be) displayed in full-screen + * mode. */ - private ImageID pressedImage; + private final boolean fullScreen; /** * The icon image. */ private ImageID iconImageID; - /** - * Indicates if we're in full screen mode. - */ - private final boolean fullScreen; - - /** - * - */ private final boolean inButtonToolBar; - /** - * Creates not full screen button. - */ - public OutputVolumeControlButton() - { - this(false); - } - - /** - * Creates volume control button. - * - * @param fullScreen is full screen. - */ - public OutputVolumeControlButton(boolean fullScreen) - { - this(ImageLoader.VOLUME_CONTROL_BUTTON, fullScreen, true); - } - /** * Creates volume control button. * + * @param callConference * @param iconImageID the image. * @param fullScreen is full screen. * @param inButtonToolBar indicates if this button is shown in the button * tool bar */ - public OutputVolumeControlButton(ImageID iconImageID, - boolean fullScreen, - boolean inButtonToolBar) + public OutputVolumeControlButton( + CallConference callConference, + ImageID iconImageID, + boolean fullScreen, + boolean inButtonToolBar) { + this.callConference = callConference; + this.iconImageID = iconImageID; this.fullScreen = fullScreen; this.inButtonToolBar = inButtonToolBar; - - this.iconImageID = iconImageID; - } - - /** - * Returns the component associated with this output volume control button. - * - * @return the component associated with this output volume control button - */ - public Component getComponent() - { - if (!fullScreen) - return createVolumeControlButton( - inButtonToolBar, - iconImageID, - "service.gui.VOLUME_CONTROL_TOOL_TIP"); - else - return createSliderComponent(); } /** @@ -111,48 +79,48 @@ public Component getComponent() */ public Component createSliderComponent() { + ResourceManagementService r = GuiActivator.getResources(); final Color bgColor - = new Color(GuiActivator.getResources().getColor( - "service.gui.CALL_TOOL_BAR_SOUND_BG")); + = new Color(r.getColor("service.gui.CALL_TOOL_BAR_SOUND_BG")); @SuppressWarnings("serial") - TransparentPanel soundPanel = new TransparentPanel( - new FlowLayout(FlowLayout.LEFT, 0, 0)) - { - public void paintComponent(Graphics g) + TransparentPanel soundPanel + = new TransparentPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)) { - super.paintComponent(g); - - g = g.create(); - - AntialiasingManager.activateAntialiasing(g); - - try + @Override + public void paintComponent(Graphics g) { - g.setColor(bgColor); - - g.fillRoundRect(0, 0, getWidth()-1, getHeight()-1, 8, 8); - } - finally - { - g.dispose(); + super.paintComponent(g); + + g = g.create(); + try + { + AntialiasingManager.activateAntialiasing(g); + + g.setColor(bgColor); + g.fillRoundRect( + 0, 0, getWidth() - 1, getHeight() - 1, + 8, 8); + } + finally + { + g.dispose(); + } } - } - }; + }; soundPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - final VolumeControl volumeControl - = GuiActivator.getMediaService().getOutputVolumeControl(); + VolumeControl volumeControl = getOutputVolumeControl(); // Creates the menu that would contain the volume control component. VolumeControlSlider slider = new VolumeControlSlider(volumeControl, JSlider.HORIZONTAL); - soundPanel.add(new JLabel(GuiActivator.getResources() - .getImage("service.gui.icons.NO_SOUND_ICON"))); + soundPanel.add( + new JLabel(r.getImage("service.gui.icons.NO_SOUND_ICON"))); soundPanel.add(slider); - soundPanel.add(new JLabel(GuiActivator.getResources() - .getImage("service.gui.icons.SOUND_MENU_ICON"))); + soundPanel.add( + new JLabel(r.getImage("service.gui.icons.SOUND_MENU_ICON"))); return soundPanel; } @@ -180,9 +148,7 @@ public Component createVolumeControlButton( boolean isButtonBar, GuiActivator.getResources().getI18NString(toolTipTextKey)); } - final VolumeControl volumeControl - = GuiActivator.getMediaService().getOutputVolumeControl(); - + VolumeControl volumeControl = getOutputVolumeControl(); // Creates the menu that would contain the volume control component. final JPopupMenu sliderMenu = new VolumeControlSlider(volumeControl, JSlider.VERTICAL) @@ -190,26 +156,71 @@ public Component createVolumeControlButton( boolean isButtonBar, sliderMenu.setInvoker(volumeControlButton); - volumeControlButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent arg0) - { - Point location = new Point( - volumeControlButton.getX(), - volumeControlButton.getY() - + volumeControlButton.getHeight()); + volumeControlButton.addActionListener( + new ActionListener() + { + public void actionPerformed(ActionEvent ev) + { + Point location + = new Point( + volumeControlButton.getX(), + volumeControlButton.getY() + + volumeControlButton.getHeight()); + + SwingUtilities.convertPointToScreen( + location, + volumeControlButton.getParent()); + + sliderMenu.setLocation(location); + sliderMenu.setVisible(!sliderMenu.isVisible()); + } + }); - SwingUtilities.convertPointToScreen( - location, - volumeControlButton.getParent()); + return volumeControlButton; + } - sliderMenu.setLocation(location); + /** + * Returns the component associated with this output volume control button. + * + * @return the component associated with this output volume control button + */ + public Component getComponent() + { + if (fullScreen) + return createSliderComponent(); + else + { + return + createVolumeControlButton( + inButtonToolBar, + iconImageID, + "service.gui.VOLUME_CONTROL_TOOL_TIP"); + } + } - sliderMenu.setVisible(!sliderMenu.isVisible()); - } - }); + /** + * Gets the VolumeControl instance (to be) depicted by this + * instance. + * + * @return the VolumeControl instance (to be) depicted by this + * instance + */ + private VolumeControl getOutputVolumeControl() + { + VolumeControl volumeControl = null; - return volumeControlButton; + if (callConference instanceof MediaAwareCallConference) + { + volumeControl + = ((MediaAwareCallConference) callConference) + .getOutputVolumeControl(); + } + if (volumeControl == null) + { + volumeControl + = GuiActivator.getMediaService().getOutputVolumeControl(); + } + return volumeControl; } /** @@ -219,6 +230,16 @@ public void actionPerformed(ActionEvent arg0) private class VolumeControlButton extends SIPCommButton { + /** + * The background image. + */ + private ImageID bgImage; + + /** + * The pressed image. + */ + private ImageID pressedImage; + public VolumeControlButton(boolean inSettingsPanel) { super( diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java index 2fe14387d..50eea0dc4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java @@ -15,7 +15,6 @@ import javax.swing.event.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.contactlist.addgroup.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java index 5ec55a910..6e48b14d3 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.impl.protocol.dict; -import java.util.*; - import net.java.dict4j.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java index 0dca03bd3..8bae28c03 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.impl.protocol.gibberish; -import java.util.*; - import net.java.sip.communicator.service.protocol.*; /** diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java index fc727fb61..8ff4f4eac 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java @@ -8,7 +8,6 @@ import java.io.*; import java.net.*; -import java.util.*; import net.java.sip.communicator.service.protocol.*; diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java index 8c0e8d33c..2390f463f 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java @@ -7,7 +7,6 @@ package net.java.sip.communicator.impl.protocol.zeroconf; import java.net.*; -import java.util.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; diff --git a/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java b/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java index f134444e3..71dc7befb 100644 --- a/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java +++ b/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java @@ -6,7 +6,6 @@ */ package net.java.sip.communicator.service.gui; -import javax.swing.*; /** * Creates and show authentication window, normally to fill in username and diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallConference.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallConference.java index c89d2253f..6d0369e0a 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallConference.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallConference.java @@ -50,6 +50,15 @@ public class MediaAwareCallConference */ private final MediaDevice[] mixers; + /** + * The VolumeControl implementation which is to control the volume + * (level) of the audio played back the telephony conference represented by + * this instance. + */ + private final VolumeControl outputVolumeControl + = new BasicVolumeControl( + VolumeControl.PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME); + /** * The PropertyChangeListener which listens to sources of * PropertyChangeEvents on behalf of this instance. @@ -188,7 +197,7 @@ protected void callRemoved(Call call) { super.callRemoved(call); - if (getCallCount() == 0 && videoRTPTranslator != null) + if (getCallCount() == 0 && (videoRTPTranslator != null)) { videoRTPTranslator.dispose(); videoRTPTranslator = null; @@ -265,6 +274,20 @@ public MediaDevice getDefaultDevice( return device; } + /** + * Gets the VolumeControl which controls the volume (level) of the + * audio played back in the telephony conference represented by this + * instance. + * + * @return the VolumeControl which controls the volume (level) of + * the audio played back in the telephony conference represented by this + * instance + */ + public VolumeControl getOutputVolumeControl() + { + return outputVolumeControl; + } + /** * Gets the RTPTranslator which forwards RTP and RTCP traffic * between the CallPeers of the Calls participating in diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java index 1ab2f3f96..62ecfa67f 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java @@ -658,7 +658,7 @@ protected MediaStream configureStream( stream.setDirection(direction); stream.setFormat(format); - MediaAwareCall call = callPeerMediaHandler.getPeer().getCall(); + MediaAwareCall call = callPeerMediaHandler.getPeer().getCall(); MediaType mediaType = (stream instanceof AudioMediaStream) ? MediaType.AUDIO @@ -669,7 +669,16 @@ protected MediaStream configureStream( switch (mediaType) { case AUDIO: - setAudioStream((AudioMediaStream) stream); + AudioMediaStream audioStream = (AudioMediaStream) stream; + + /* + * The volume (level) of the audio played back in calls should be + * call-specific i.e. it should be able to change the volume (level) + * of a call without affecting any other simultaneous calls. + */ + setOutputVolumeControl(audioStream, call); + + setAudioStream(audioStream); break; case VIDEO: @@ -1327,6 +1336,43 @@ private void setLocalSSRC(MediaType mediaType, long localSSRC) } } + /** + * Sets the VolumeControl which is to control the volume (level) of + * the audio received in/by a specific AudioMediaStream and played + * back in order to achieve call-specific volume (level). + *

+ * Note: The implementation makes the volume (level) telephony + * conference-specific. + *

+ * + * @param audioStream the AudioMediaStream on which a + * VolumeControl from the specified call is to be set + * @param call the MediaAwareCall which provides the + * VolumeControl to be set on the specified audioStream + */ + private void setOutputVolumeControl( + AudioMediaStream audioStream, + MediaAwareCall call) + { + /* + * The volume (level) of the audio played back in calls should be + * call-specific i.e. it should be able to change the volume (level) of + * a call without affecting any other simultaneous calls. The + * implementation makes the volume (level) telephony + * conference-specific. + */ + MediaAwareCallConference conference = call.getConference(); + + if (conference != null) + { + VolumeControl outputVolumeControl + = conference.getOutputVolumeControl(); + + if (outputVolumeControl != null) + audioStream.setOutputVolumeControl(outputVolumeControl); + } + } + /** * Sets the last-known remote SSRC of the MediaStream of a specific * MediaType.