Prepared for MJPG capture without using MJPG DirectShow filter. MJPG is temporarily disabled and will enabled as soon as MJPG->I420 conversion is available.

Review URL: https://webrtc-codereview.appspot.com/397011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1761 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2012-02-24 10:06:30 +00:00
parent 05f0d578e0
commit 8df260023b
4 changed files with 44 additions and 40 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -18,6 +18,9 @@
#define DELETE_RESET(p) { delete (p) ; (p) = NULL ;}
// TODO(mflodman) Remove WEBRTC_MJPEG when MJPG->I420 conversion is available.
// #define WEBRTC_MJPEG
namespace webrtc
{
namespace videocapturemodule
@ -136,6 +139,19 @@ CaptureInputPin::GetMediaType (IN int iPosition, OUT CMediaType * pmt)
pmt->SetSubtype(&MEDIASUBTYPE_UYVY);
}
break;
#ifdef WEBRTC_MJPEG
case 4:
{
pvi->bmiHeader.biCompression = MAKEFOURCC('M','J','P','G');
pvi->bmiHeader.biBitCount = 12; //bit per pixel
pvi->bmiHeader.biWidth = _requestedCapability.width;
pvi->bmiHeader.biHeight = _requestedCapability.height;
pvi->bmiHeader.biSizeImage = 3*_requestedCapability.height
*_requestedCapability.width/2;
pmt->SetSubtype(&MEDIASUBTYPE_MJPG);
}
break;
#endif
default :
return VFW_S_NO_MORE_ITEMS;
}
@ -182,6 +198,14 @@ CaptureInputPin::CheckMediaType ( IN const CMediaType * pMediaType)
pvi->bmiHeader.biWidth,pvi->bmiHeader.biHeight,
pvi->bmiHeader.biCompression);
#ifdef WEBRTC_MJPEG
if(*SubType == MEDIASUBTYPE_MJPG
&& pvi->bmiHeader.biCompression == MAKEFOURCC('M','J','P','G'))
{
_resultingCapability.rawType = kVideoMJPEG;
return S_OK; // This format is acceptable.
}
#endif
if(*SubType == MEDIASUBTYPE_I420
&& pvi->bmiHeader.biCompression == MAKEFOURCC('I','4','2','0'))
{
@ -232,6 +256,14 @@ CaptureInputPin::CheckMediaType ( IN const CMediaType * pMediaType)
_resultingCapability.width = pvi->bmiHeader.biWidth;
_resultingCapability.height = abs(pvi->bmiHeader.biHeight);
#ifdef WEBRTC_MJPEG
if(*SubType == MEDIASUBTYPE_MJPG
&& pvi->bmiHeader.biCompression == MAKEFOURCC('M','J','P','G'))
{
_resultingCapability.rawType = kVideoMJPEG;
return S_OK; // This format is acceptable.
}
#endif
if(*SubType == MEDIASUBTYPE_I420
&& pvi->bmiHeader.biCompression == MAKEFOURCC('I','4','2','0'))
{

View File

@ -25,8 +25,7 @@ namespace videocapturemodule
VideoCaptureDS::VideoCaptureDS(const WebRtc_Word32 id)
: VideoCaptureImpl(id), _dsInfo(id), _captureFilter(NULL),
_graphBuilder(NULL), _mediaControl(NULL), _sinkFilter(NULL),
_inputSendPin(NULL), _outputCapturePin(NULL), _mjpgJPGFilter(NULL),
_inputMjpgPin(NULL), _outputMjpgPin(NULL), _dvFilter(NULL),
_inputSendPin(NULL), _outputCapturePin(NULL), _dvFilter(NULL),
_inputDvPin(NULL), _outputDvPin(NULL)
{
}
@ -43,23 +42,17 @@ VideoCaptureDS::~VideoCaptureDS()
_graphBuilder->RemoveFilter(_sinkFilter);
if (_captureFilter)
_graphBuilder->RemoveFilter(_captureFilter);
if (_mjpgJPGFilter)
_graphBuilder->RemoveFilter(_mjpgJPGFilter);
if (_dvFilter)
_graphBuilder->RemoveFilter(_dvFilter);
}
RELEASE_AND_CLEAR(_captureFilter); // release the capture device
RELEASE_AND_CLEAR(_sinkFilter);
RELEASE_AND_CLEAR(_mjpgJPGFilter);
RELEASE_AND_CLEAR(_dvFilter);
RELEASE_AND_CLEAR(_mediaControl);
RELEASE_AND_CLEAR(_inputSendPin);
RELEASE_AND_CLEAR(_outputCapturePin);
RELEASE_AND_CLEAR(_inputMjpgPin);
RELEASE_AND_CLEAR(_outputMjpgPin);
RELEASE_AND_CLEAR(_inputDvPin);
RELEASE_AND_CLEAR(_outputDvPin);
@ -140,15 +133,6 @@ WebRtc_Word32 VideoCaptureDS::Init(const WebRtc_Word32 id,
}
_inputSendPin = GetInputPin(_sinkFilter);
// Create MJPG filter
hr = CoCreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC, IID_IBaseFilter,
(void **) &_mjpgJPGFilter);
if (hr == S_OK)
{
_inputMjpgPin = GetInputPin(_mjpgJPGFilter);
_outputMjpgPin = GetOutputPin(_mjpgJPGFilter);
_graphBuilder->AddFilter(_mjpgJPGFilter, NULL);
}
// Temporary connect here.
// This is done so that no one else can use the capture device.
if (SetCameraOutput(_requestedCapability) != 0)
@ -323,15 +307,7 @@ WebRtc_Word32 VideoCaptureDS::SetCameraOutput(
return -1;
}
if (capability.rawType == kVideoMJPEG && _mjpgJPGFilter)
{
// Connect the camera to the MJPEG decoder
hr = _graphBuilder->ConnectDirect(_outputCapturePin, _inputMjpgPin,
NULL);
// Connect the MJPEG filter to the Capture filter
hr += _graphBuilder->ConnectDirect(_outputMjpgPin, _inputSendPin, NULL);
}
else if (isDVCamera)
if (isDVCamera)
{
hr = ConnectDVCamera();
}
@ -355,13 +331,6 @@ WebRtc_Word32 VideoCaptureDS::DisconnectGraph()
hr += _graphBuilder->Disconnect(_outputCapturePin);
hr += _graphBuilder->Disconnect(_inputSendPin);
// If the _mjpg filter exist
if (_mjpgJPGFilter)
{
_graphBuilder->Disconnect(_inputMjpgPin);
_graphBuilder->Disconnect(_outputMjpgPin);
}
//if the DV camera filter exist
if (_dvFilter)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -75,11 +75,6 @@ protected:
IPin* _inputSendPin;
IPin* _outputCapturePin;
// used when using a MJPEG decoder
IBaseFilter* _mjpgJPGFilter;
IPin* _inputMjpgPin;
IPin* _outputMjpgPin;
// Microsoft DV interface (external DV cameras)
IBaseFilter* _dvFilter;
IPin* _inputDvPin;

View File

@ -17,6 +17,9 @@
#define abs(a) (a>=0?a:-a)
#endif
// TODO(mflodman) Remove WEBRTC_MJPEG when MJPG->I420 conversion is available.
// #define WEBRTC_MJPEG
namespace webrtc
{
namespace videocapturemodule
@ -193,6 +196,11 @@ WebRtc_Word32 DeviceInfoImpl::GetBestMatchedCapability(
VideoCaptureCapability& capability = *static_cast<VideoCaptureCapability*>
(item->GetItem());
//#ifndef WEBRTC_MJPEG
// if (capability.rawType == kVideoMJPEG)
// continue;
//#endif
const WebRtc_Word32 diffWidth = capability.width - requested.width;
const WebRtc_Word32 diffHeight = capability.height - requested.height;
const WebRtc_Word32 diffFrameRate = capability.maxFPS - requested.maxFPS;