aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/windows
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2011-03-03 16:16:28 +0000
committerSebastien Vincent <seb@jitsi.org>2011-03-03 16:16:28 +0000
commitb83c3f9ac77f344d9fd2746acaf84375a7ccc060 (patch)
treeeac482dd3c9b24280f101414c458fe2604d19970 /src/native/windows
parentf42a63045bb6ebc54d3baaf46f3142027ea7b9ad (diff)
downloadjitsi-b83c3f9ac77f344d9fd2746acaf84375a7ccc060.zip
jitsi-b83c3f9ac77f344d9fd2746acaf84375a7ccc060.tar.gz
jitsi-b83c3f9ac77f344d9fd2746acaf84375a7ccc060.tar.bz2
Attempt to fix upside-down webcam problems on some computers.
Diffstat (limited to 'src/native/windows')
-rw-r--r--src/native/windows/directshow/ds_capture_device.cpp41
-rw-r--r--src/native/windows/directshow/ds_capture_device.h11
-rw-r--r--src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp33
3 files changed, 69 insertions, 16 deletions
diff --git a/src/native/windows/directshow/ds_capture_device.cpp b/src/native/windows/directshow/ds_capture_device.cpp
index b4fcb4d..8671a53 100644
--- a/src/native/windows/directshow/ds_capture_device.cpp
+++ b/src/native/windows/directshow/ds_capture_device.cpp
@@ -112,6 +112,7 @@ DSCaptureDevice::DSCaptureDevice(const WCHAR* name)
m_name = wcsdup(name);
}
+ m_flip = false;
m_callback = NULL;
m_filterGraph = NULL;
@@ -376,6 +377,41 @@ bool DSCaptureDevice::initDevice(IMoniker* moniker)
/* 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;
+ }
+ videoControl->SetMode(pin, caps);
+ }
+ pin->Release();
+ }
+
+ videoControl->Release();
+ }
+
return setFormat(m_formats.front());
}
@@ -498,3 +534,8 @@ 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
index 78db67d..a8393ab 100644
--- a/src/native/windows/directshow/ds_capture_device.h
+++ b/src/native/windows/directshow/ds_capture_device.h
@@ -171,6 +171,12 @@ public:
*/
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.
@@ -236,6 +242,11 @@ private:
* \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/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp b/src/native/windows/directshow/net_java_sip_communicator_impl_neomedia_directshow_DSCaptureDevice.cpp
index 8272340..66dd0de 100644
--- 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
@@ -94,8 +94,9 @@ public:
bytesPerPixel = m_dev->getBitPerPixel() / 8;
/* flip image for RGB content */
- flipImage = (format.mediaType == MEDIASUBTYPE_ARGB32 ||
- format.mediaType == MEDIASUBTYPE_RGB32 ||
+ flipImage = !m_dev->isFlip() &&
+ (format.mediaType == MEDIASUBTYPE_ARGB32 ||
+ format.mediaType == MEDIASUBTYPE_RGB32 ||
format.mediaType == MEDIASUBTYPE_RGB24);
sample->GetPointer(&data);
@@ -117,7 +118,7 @@ public:
m_bytesLength = length;
}
- /* it seems that images is always inversed,
+ /* it seems that images is always inversed,
* the following code from lti-civil is always used to flip
* images
*/
@@ -139,7 +140,7 @@ public:
}
return S_OK;
}
-
+
/**
* \brief Java VM.
*/
@@ -153,7 +154,7 @@ public:
/**
* \brief Internal buffer.
*/
- BYTE* m_bytes;
+ BYTE* m_bytes;
/**
* \brief Length of internal buffer.
@@ -171,7 +172,7 @@ public:
* \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)
{
@@ -186,21 +187,21 @@ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_D
* \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)
{
@@ -224,14 +225,14 @@ JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_impl_neomedia_directsho
* \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");
@@ -240,11 +241,11 @@ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_D
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();
}
@@ -291,7 +292,7 @@ JNIEXPORT jobject JNICALL Java_net_java_sip_communicator_impl_neomedia_directsho
* \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)
{
@@ -355,7 +356,7 @@ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_D
Grabber* grab = NULL;
DSCaptureDevice* dev = reinterpret_cast<DSCaptureDevice*>(ptr);
DSGrabberCallback* prev = dev->getCallback();
-
+
if(delegate != NULL)
{
delegate = env->NewGlobalRef(delegate);
@@ -372,7 +373,7 @@ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_neomedia_directshow_D
{
dev->setCallback(NULL);
}
-
+
if(prev)
{
jobject tmp_delegate = ((Grabber*)prev)->m_delegate;