[Sumover-dev] [svn commit] r4475 - vic/branches/mpeg4/video
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Thu Jul 9 09:52:11 BST 2009
Author: douglask
Date: Thu Jul 9 09:51:57 2009
New Revision: 4475
Modified:
vic/branches/mpeg4/video/grabber-win32DS.cpp
vic/branches/mpeg4/video/grabber-win32DS.h
Log:
Committed the patch in the following ticket
https://mediatools.cs.ucl.ac.uk/nets/mmedia/ticket/162
Modified: vic/branches/mpeg4/video/grabber-win32DS.cpp
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32DS.cpp (original)
+++ vic/branches/mpeg4/video/grabber-win32DS.cpp Thu Jul 9 09:51:57 2009
@@ -190,8 +190,6 @@
*/
debug_msg("new DirectShowGrabber()\n");
- svideoPort = -1;
- compositePort = -1;
decimate_ = 2; //default
converter_=0;
cb_mutex_=0;
@@ -211,6 +209,12 @@
capturing_=0;
max_fps_ = 30;
+ memset(inputPorts, 0, NUM_PORTS);
+
+ numInputPorts =0;
+ initializedPorts =0;
+ svideoPortNum = compositePortNum =1;
+
if(!strcmp(cformat, "420"))
cformat_ = CF_420;
if(!strcmp(cformat, "422"))
@@ -517,15 +521,40 @@
hr = xb->get_PinCounts(&output, &input);
- for( int i = 0; i < input; ++i ) {
- xb->get_CrossbarPinInfo(TRUE, i, &related, &pinType);
- if( pinType == PhysConn_Video_SVideo ) {
- svideoPort = i;
- }
- if( pinType == PhysConn_Video_Composite ) {
- compositePort = i;
+ hr = xb->get_PinCounts(&output, &input);
+ 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++;
+
+ }
+ 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++;
+ }
}
}
+
for( int i = 0; i < output; ++i ) {
xb->get_CrossbarPinInfo(FALSE, i, &related, &pinType);
if( pinType == PhysConn_Video_VideoDecoder ) {
@@ -533,12 +562,16 @@
break;
}
}
- if(strcmp(input_port_, "S-Video")==0){
- port = svideoPort;
- }else if(strcmp(input_port_, "Composite")==0){
- port = compositePort;
- }else{
- port = 0;
+
+ port = 0;
+ for( int i=0; i<numInputPorts; i++) {
+ 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( xb->CanRoute(videoDecoderPort, port) == S_FALSE )
@@ -549,8 +582,8 @@
//showErrorMessage(hr);
}
- xb->get_IsRoutedTo(0, &input);
- debug_msg("DirectShowGrabber::routeCrossbar(): pin %d is now routed to output pin 0\n", input);
+ xb->get_IsRoutedTo(videoDecoderPort, &input);
+ debug_msg("DirectShowGrabber::routeCrossbar(): pin %d is now routed to output pin %d\n", input, videoDecoderPort);
}
//-----------------------------
@@ -1091,7 +1124,7 @@
DirectShowDevice::DirectShowDevice(char *friendlyName, IBaseFilter *pCapFilt) : InputDevice(friendlyName) {
- attri_ = new char[128];
+ attri_ = new char[255];
attri_[0] = 0;
debug_msg("new DirectShowDevice(): friendlyName=%s\n", friendlyName);
@@ -1109,13 +1142,15 @@
}
strcat(attri_, " } type { pal ntsc } port { ");
- if(o.hasSVideo() || o.hasComposite()){
- if(o.hasSVideo()){
- strcat(attri_, "S-Video ");
- }
- if(o.hasComposite()){
- strcat(attri_, "Composite ");
- }
+
+ Port **inputPorts = o.getInputPorts();
+ if(inputPorts[0] != NULL) {
+ int i=0;
+ while( i < NUM_PORTS && inputPorts[i] != NULL ) {
+ strcat(attri_, inputPorts[i]->name);
+ strcat(attri_, " ");
+ i++;
+ }
}else{
strcat(attri_, "external-in ");
}
Modified: vic/branches/mpeg4/video/grabber-win32DS.h
==============================================================================
--- vic/branches/mpeg4/video/grabber-win32DS.h (original)
+++ vic/branches/mpeg4/video/grabber-win32DS.h Thu Jul 9 09:51:57 2009
@@ -50,6 +50,8 @@
#include "crossbar.h"
#define NUM_DEVS 20 // max number of capture devices we'll support
+#define NUM_PORTS 20 // max number of ports on a capture device
+
//#define showErrorMessage(x) ShowErrorMessage(x, __LINE__, __FILE__)
//extern void ShowErrorMessage(HRESULT, int, char* );
@@ -85,6 +87,11 @@
class Callback;
+struct Port {
+ int id;
+ char name[64];
+};
+
class DirectShowGrabber : public Grabber {
public:
DirectShowGrabber(IBaseFilter *, const char * cformat, const char * nick = 0);
@@ -95,20 +102,12 @@
converter_ = v;
}
- void capture(BYTE *, long);
-
- bool hasComposite(){
- return (compositePort >= 0);
- }
+ void capture(BYTE *, long);
bool hasDV_SD(){
return (have_DVSD_);
}
- bool hasSVideo(){
- return (svideoPort >= 0);
- }
-
int maxWidth(){
return max_width_;
}
@@ -125,6 +124,10 @@
return min_height_;
}
+ Port ** getInputPorts(){
+ return inputPorts;
+ }
+
int capturing_;
HANDLE cb_mutex_;
protected:
@@ -134,35 +137,39 @@
virtual void setsize();
virtual int grab();
void setport(const char *port);
- int getCaptureCapabilities();
+ int getCaptureCapabilities();
virtual void setCaptureOutputFormat();
int useconfig_;
int basewidth_;
int baseheight_;
u_int max_fps_;
- int max_width_;
- int max_height_;
- int min_width_;
- int min_height_;
- int width_;
- int height_;
+ int max_width_;
+ int max_height_;
+ int min_width_;
+ int min_height_;
+ int width_;
+ int height_;
int cformat_;
- int compositePort;
- int svideoPort;
- bool have_I420_; // YUV 4:2:0 planar
- bool have_UYVY_; // YUV 4:2:2 packed
- bool have_YUY2_; // as for UYVY but with different component ordering
- bool have_RGB24_; // RGB 24 bit
- bool have_DVSD_; // DV standard definition
+ Port * inputPorts[NUM_PORTS];
+ int numInputPorts;
+ int initializedPorts;
+ int compositePortNum;
+ int svideoPortNum;
+
+ bool have_I420_; // YUV 4:2:0 planar
+ bool have_UYVY_; // YUV 4:2:2 packed
+ bool have_YUY2_; // as for UYVY but with different component ordering
+ bool have_RGB24_; // RGB 24 bit
+ bool have_DVSD_; // DV standard definition
u_int decimate_; // set in this::command via small/normal/large in vic UI; msp
BYTE *last_frame_;
- Converter *converter_;
+ Converter *converter_;
private:
- IBaseFilter* pFilter_;
+ IBaseFilter* pFilter_;
IBaseFilter* pCaptureFilter_;
ISampleGrabber* pSampleGrabber_;
IBaseFilter* pGrabberBaseFilter_;
@@ -173,17 +180,17 @@
IGraphBuilder* pGraph_;
ICaptureGraphBuilder2* pBuild_;
IMediaControl* pMediaControl_;
- DWORD dwRegister_;
+ DWORD dwRegister_;
AM_MEDIA_TYPE mt_;
Callback *callback_;
- IAMCrossbar *pXBar_;
- Crossbar *crossbar_;
- Crossbar *crossbarCursor_;
- char input_port_[20];
- bool findCrossbar(IBaseFilter *);
- void addCrossbar(IAMCrossbar *);
- void routeCrossbar();
+ IAMCrossbar *pXBar_;
+ Crossbar *crossbar_;
+ Crossbar *crossbarCursor_;
+ char input_port_[20];
+ bool findCrossbar(IBaseFilter *);
+ void addCrossbar(IAMCrossbar *);
+ void routeCrossbar();
};
More information about the Sumover-dev
mailing list