qutecom (2.2~rc3.hg396~dfsg1-6) force-palette.patch

Summary

 libs/webcam/src/WebcamDriver.cpp |   10 ++++++++++
 1 file changed, 10 insertions(+)

    
download this patch

Patch contents

# HG changeset patch
# User Ludovico Cavedon <ludovico.cavedon@gmail.com>
# Date 1261054231 -3600
# Node ID b98492b2d423bcbcf2729bf345db2c4ce7519dd9
# Parent  bdfc9e3aba4a0dd87eada8d5bc6a377a97560854
Description: add OWWEBCAM_FORCE_PALETTE env variable to force palette on the webcam
Author: Ludovico Cavedon <cavedon@debian.org>
Forwarded: http://trac.qutecom.org/ticket/179

Index: qutecom-2.2~rc3.hg396~dfsg1/libs/webcam/src/WebcamDriver.cpp
===================================================================
--- qutecom-2.2~rc3.hg396~dfsg1.orig/libs/webcam/src/WebcamDriver.cpp	2009-12-21 00:54:09.000000000 +0100
+++ qutecom-2.2~rc3.hg396~dfsg1/libs/webcam/src/WebcamDriver.cpp	2009-12-21 00:55:30.000000000 +0100
@@ -27,6 +27,8 @@
 
 WebcamDriverFactory * WebcamDriver::_factory = NULL;
 
+#include <boost/lexical_cast.hpp>
+
 #include <iostream>
 using namespace std;
 
@@ -192,6 +194,14 @@
 	if (_startCounter == 0) {
 		if (_webcamPrivate->setPalette(palette) == WEBCAM_NOK) {
 			LOG_DEBUG("this webcam does not support palette #" + String::fromNumber(palette));
+			const char *force_palette = getenv("OWWEBCAM_FORCE_PALETTE");
+			if(force_palette) {
+				pixosi forced_palette = pixosi(boost::lexical_cast<int>(force_palette));
+				LOG_DEBUG("trying with palette #" + String::fromNumber(forced_palette));
+				if (_webcamPrivate->setPalette(forced_palette) == WEBCAM_NOK) {
+					LOG_DEBUG("this webcam does not support palette #" + String::fromNumber(palette));
+				}
+			}
 			if (_webcamPrivate->getPalette() != PIX_OSI_UNSUPPORTED &&  isFormatForced()) {
 				LOG_DEBUG("palette conversion will be forced");
 				_desiredPalette = palette;