[Sumover-dev] [svn commit] r4761 - in vic/branches/mpeg4: video

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Tue Apr 6 21:06:53 BST 2010


Author: turam
Date: Tue Apr  6 21:06:53 2010
New Revision: 4761

Modified:
   vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
   vic/branches/mpeg4/video/grabber-win32DS.cpp
   vic/branches/mpeg4/video/grabber-win32DS.h

Log:
Properly map input pins to output pins (e.g. Winnov Videum); Select currently selected port in Port menu; Sort Device menu

Modified: vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl	(original)
+++ vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl	Tue Apr  6 21:06:53 2010
@@ -798,6 +798,30 @@
 	}
 }
 
+proc compare {a b} {
+
+	return [string compare [$a nickname] [$b nickname]]
+
+    set a0 [$a nickname]
+
+    set b0 [$b nickname]
+
+    if {$a0 < $b0} {
+
+        return -1
+
+    } elseif {$a0 > $b0} {
+
+        return 1
+
+    }
+
+    return 0
+
+}
+
+
+
 proc build.device w {
 	set f [smallfont]
 
@@ -832,7 +856,9 @@
 		$w configure -state disabled
 		return
 	}
-	foreach d $inputDeviceList {
+	
+    set inputDeviceListSorted [lsort -command compare $inputDeviceList]
+	foreach d $inputDeviceListSorted {
 		if { [$d nickname] == "still" && ![yesno stillGrabber] } {
 			set defaultFormat($d) $videoFormat
 			continue
@@ -1086,7 +1112,13 @@
 			if { $s != "" } {
 				set defaultPort($device) $s
 			} else {
-				set defaultPort($device) [lindex $portnames 0]
+				# use current port setting
+				set s [string trim [attribute_class [$device attributes] selected_port]]
+				if { $s != "" } {
+					set defaultPort($device) $s
+				} else {
+					set defaultPort($device) [lindex $portnames 0]
+				}
 			}
 		}
 	}
@@ -1927,4 +1959,3 @@
 	set V(dither) gray
 	set_dither
 }
-

Modified: vic/branches/mpeg4/video/grabber-win32DS.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32DS.cpp	(original)
+++ vic/branches/mpeg4/video/grabber-win32DS.cpp	Tue Apr  6 21:06:53 2010
@@ -212,7 +212,6 @@
    pFilter_ = NULL;
    capturing_=0;
    max_fps_ = 30;
-
    memset(inputPorts, 0, NUM_PORTS);
        
    numInputPorts = 0;
@@ -521,72 +520,90 @@
     long        pinType;
     IAMCrossbar *xb;
 
+	long tmp_input_port;
+
     if( crossbar_ == NULL ) return;
 
     xb = crossbar_->getXBar();
 
-    xb->get_IsRoutedTo(0, &input);
-    debug_msg("DirectShowGrabber::routeCrossbar():  pin %d is routed to output pin 0\n", input);
 
     hr = xb->get_PinCounts(&output, &input);
+	debug_msg("num input %d num output %d", input, output);
+
+
+	long selectedPort = -1;
+	long inport = -1;
+    for( int i = 0; i < output; ++i ) {
+		xb->get_IsRoutedTo(i, &inport);
+		debug_msg("DirectShowGrabber::routeCrossbar():  input pin %d is mapped to output pin %d\n", inport, i);
+		if( inport >= 0 )
+			selectedPort = inport;
+    }
+
+
     if(initializedPorts == 0) {
-	initializedPorts=1;
-	svideoPortNum = 1;
-	compositePortNum = 1;
-	numInputPorts = 0;
-	for( int i = 0; i < input; ++i ) {
-	    xb->get_CrossbarPinInfo(TRUE, i, &related, &pinType);
-	    if( pinType == PhysConn_Video_SVideo ) {
-		debug_msg("Found svideo port %d\n", svideoPortNum);
-		inputPorts[numInputPorts] = new Port();
-		inputPorts[numInputPorts]->id = i;
-		if( svideoPortNum > 1 )
-		    sprintf(inputPorts[numInputPorts]->name,"S-Video%d", svideoPortNum );
-		else
-		    strcpy(inputPorts[numInputPorts]->name,"S-Video");
-		numInputPorts++;
-		svideoPortNum++;
+		initializedPorts=1;
+		svideoPortNum = 1;
+		compositePortNum = 1;
+		numInputPorts = 0;
+		for( int i = 0; i < input; ++i ) {
+			xb->get_CrossbarPinInfo(TRUE, i, &related, &pinType);
+			if( pinType == PhysConn_Video_SVideo ) {
+				debug_msg("Found svideo port %d\n", svideoPortNum);
+				inputPorts[numInputPorts] = new Port();
+				inputPorts[numInputPorts]->id = i;
+				if( svideoPortNum > 1 )
+					sprintf(inputPorts[numInputPorts]->name,"S-Video%d", svideoPortNum );
+				else
+					strcpy(inputPorts[numInputPorts]->name,"S-Video");
+				if( selectedPort == i )
+					strcpy(input_port_, inputPorts[numInputPorts]->name);
+				numInputPorts++;
+				svideoPortNum++;
 
-	    }
-	    if( pinType == PhysConn_Video_Composite ) {
-		debug_msg("Found composite port %d\n", compositePortNum);
-		inputPorts[numInputPorts] = new Port();
-		inputPorts[numInputPorts]->id = i;
-		if(compositePortNum > 1 )
-		    sprintf(inputPorts[numInputPorts]->name,"Composite%d", compositePortNum);
-		else
-		    strcpy(inputPorts[numInputPorts]->name,"Composite");
-		numInputPorts++;
-		compositePortNum++;
-	    }
+			}
+			if( pinType == PhysConn_Video_Composite ) {
+				debug_msg("Found composite port %d\n", compositePortNum);
+				inputPorts[numInputPorts] = new Port();
+				inputPorts[numInputPorts]->id = i;
+				if(compositePortNum > 1 )
+					sprintf(inputPorts[numInputPorts]->name,"Composite%d", compositePortNum);
+				else
+					strcpy(inputPorts[numInputPorts]->name,"Composite");
+				if( selectedPort == i )
+					strcpy(input_port_, inputPorts[numInputPorts]->name);
+				numInputPorts++;
+				compositePortNum++;
+			}
+		}
 	}
-    }
 
     for( int i = 0; i < output; ++i ) {
-	xb->get_CrossbarPinInfo(FALSE, i, &related, &pinType);
-	if( pinType == PhysConn_Video_VideoDecoder ) {
-	    videoDecoderPort = i;
-	    break;
-	}
+		xb->get_CrossbarPinInfo(FALSE, i, &related, &pinType);
+		if( pinType == PhysConn_Video_VideoDecoder ) {
+			videoDecoderPort = i;
+			break;
+		}
     }
 
-    port = 0;
+    port = -1;
     for( int i=0; i<numInputPorts; i++) {
-	if (strcmp(input_port_,inputPorts[i]->name) == 0) {
-	    port = inputPorts[i]->id;
-	    break;
-	}
+		if (strcmp(input_port_,inputPorts[i]->name) == 0) {
+			port = inputPorts[i]->id;
+			break;
+		}
     }
-    if( port == 0 ) { 
-	debug_msg("**** Failed to find port for %s\n", input_port_);
+    if( port == -1 ) { 
+		debug_msg("**** Failed to find port for %s\n", input_port_);
+		return;
     }
 
     if( xb->CanRoute(videoDecoderPort, port) == S_FALSE )
-	debug_msg("DirectShowGrabber::routeCrossbar():  cannot route input pin %d to output pin %d\n", port, videoDecoderPort);
+		debug_msg("DirectShowGrabber::routeCrossbar():  cannot route input pin %d to output pin %d\n", port, videoDecoderPort);
     else {
-	debug_msg("DirectShowGrabber::routeCrossbar() routing pin %d to pin %d\n", port, videoDecoderPort);
-	hr = xb->Route(videoDecoderPort, port);
-	//showErrorMessage(hr);
+		debug_msg("DirectShowGrabber::routeCrossbar() routing pin %d to pin %d\n", port, videoDecoderPort);
+		hr = xb->Route(videoDecoderPort, port);
+		//showErrorMessage(hr);
     }
 
     xb->get_IsRoutedTo(videoDecoderPort, &input);
@@ -1170,9 +1187,15 @@
    }else{
        strcat(attri_, "external-in ");
    }
+   debug_msg("new DirectShowDevice():  after appending ports\n");
 
    strcat(attri_, "} ");
+
+   char *inport = o.getInputPort();
+   sprintf(attri_, "%s selected_port { %s }", attri_, inport );
+   free(inport);
    attributes_ = attri_;
+   debug_msg("attributes: %s", attributes_);
 }
 
 DirectShowDevice::~DirectShowDevice(){

Modified: vic/branches/mpeg4/video/grabber-win32DS.h
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32DS.h	(original)
+++ vic/branches/mpeg4/video/grabber-win32DS.h	Tue Apr  6 21:06:53 2010
@@ -86,7 +86,6 @@
 //#########################################################################
 
 class Callback;
-
 struct Port {
        int id;
        char name[64];
@@ -127,7 +126,9 @@
 	  Port **	   getInputPorts(){
 		  return inputPorts;
 	  }
-
+	  char *		getInputPort(){
+		  return strdup(input_port_);
+	  }
       int          capturing_;
       HANDLE       cb_mutex_;
    protected:
@@ -254,3 +255,5 @@
       IMoniker*     pMoniker_;
 
 };
+
+



More information about the Sumover-dev mailing list