Add VideoCaptureFactory so that we don't need to expose VideoCaptureImpl.
BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/213002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@727 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
199f4defd3
commit
ea89922b56
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// This file contains interfaces used for creating the VideoCaptureModule
|
||||
// and DeviceInfo.
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_INTERFACE_VIDEO_CAPTURE_FACTORY_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_INTERFACE_VIDEO_CAPTURE_FACTORY_H_
|
||||
|
||||
#include "video_capture.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class VideoCaptureFactory {
|
||||
public:
|
||||
// Create a video capture module object
|
||||
// id - unique identifier of this video capture module object.
|
||||
// deviceUniqueIdUTF8 - name of the device.
|
||||
// Available names can be found by using GetDeviceName
|
||||
static VideoCaptureModule* Create(const WebRtc_Word32 id,
|
||||
const WebRtc_UWord8* deviceUniqueIdUTF8);
|
||||
|
||||
// Create a video capture module object used for external capture.
|
||||
// id - unique identifier of this video capture module object
|
||||
// externalCapture - [out] interface to call when a new frame is captured.
|
||||
static VideoCaptureModule* Create(const WebRtc_Word32 id,
|
||||
VideoCaptureExternal*& externalCapture);
|
||||
|
||||
static VideoCaptureModule::DeviceInfo* CreateDeviceInfo(
|
||||
const WebRtc_Word32 id);
|
||||
static void DestroyDeviceInfo(VideoCaptureModule::DeviceInfo* deviceInfo);
|
||||
|
||||
private:
|
||||
~VideoCaptureFactory();
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_INTERFACE_VIDEO_CAPTURE_FACTORY_H_
|
@ -32,6 +32,7 @@
|
||||
# interfaces
|
||||
'../interface/video_capture.h',
|
||||
'../interface/video_capture_defines.h',
|
||||
'../interface/video_capture_factory.h',
|
||||
# headers
|
||||
'video_capture_config.h',
|
||||
'video_capture_delay.h',
|
||||
@ -40,6 +41,7 @@
|
||||
'device_info_impl.h',
|
||||
|
||||
# DEFINE PLATFORM INDEPENDENT SOURCE FILES
|
||||
'video_capture_factory.cc',
|
||||
'video_capture_impl.cc',
|
||||
'vplib_conversions.cc',
|
||||
'device_info_impl.cc',
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "video_capture_factory.h"
|
||||
#include "video_capture_impl.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
VideoCaptureModule* VideoCaptureFactory::Create(const WebRtc_Word32 id,
|
||||
const WebRtc_UWord8* deviceUniqueIdUTF8) {
|
||||
return videocapturemodule::VideoCaptureImpl::Create(id, deviceUniqueIdUTF8);
|
||||
}
|
||||
|
||||
VideoCaptureModule* VideoCaptureFactory::Create(const WebRtc_Word32 id,
|
||||
VideoCaptureExternal*& externalCapture) {
|
||||
return videocapturemodule::VideoCaptureImpl::Create(id, externalCapture);
|
||||
}
|
||||
|
||||
VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
|
||||
const WebRtc_Word32 id) {
|
||||
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(id);
|
||||
}
|
||||
|
||||
void VideoCaptureFactory::DestroyDeviceInfo(
|
||||
VideoCaptureModule::DeviceInfo* deviceInfo) {
|
||||
videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(deviceInfo);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -12,8 +12,7 @@
|
||||
#include <android/log.h>
|
||||
|
||||
#include "org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest.h"
|
||||
#include "../../../interface/video_capture.h"
|
||||
#include "../../../source/video_capture_impl.h"
|
||||
#include "../../../interface/video_capture_factory.h"
|
||||
#include "../../../../../video_render/main/interface/video_render.h"
|
||||
#include "../../testAPI/testPlatformDependent.h"
|
||||
#include "../../testAPI/testPlatformDependent.h"
|
||||
@ -117,11 +116,11 @@ Java_org_webrtc_capturemoduleandroidtest_VideoCaptureModuleTest_StartCapture(
|
||||
{
|
||||
if (!jniData._captureInfo) {
|
||||
VideoCaptureModule::SetAndroidObjects(jniData.jvm, context);
|
||||
jniData._captureInfo = VideoCaptureImpl::CreateDeviceInfo(5);
|
||||
jniData._captureInfo = VideoCaptureFactory::CreateDeviceInfo(5);
|
||||
WebRtc_UWord8 id[256];
|
||||
WebRtc_UWord8 name[256];
|
||||
jniData._captureInfo->GetDeviceName(0, name, 256, id, 256);
|
||||
jniData._videoCapture = VideoCaptureImpl::Create(0, id);
|
||||
jniData._videoCapture = VideoCaptureFactory::Create(0, id);
|
||||
VideoCaptureCapability capability;
|
||||
|
||||
jniData._captureInfo->GetCapability(id, 0, capability);
|
||||
|
@ -37,7 +37,6 @@
|
||||
'include_dirs': [
|
||||
'../interface',
|
||||
'../../../modules/video_capture/main/interface',
|
||||
'../../../modules/video_capture/main/source',
|
||||
'../../../modules/video_render/main/interface',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
|
@ -18,8 +18,7 @@
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "event_wrapper.h"
|
||||
#include "module_common_types.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_capture_impl.h"
|
||||
#include "video_capture_factory.h"
|
||||
#include "video_processing.h"
|
||||
#include "video_render_defines.h"
|
||||
#include "thread_wrapper.h"
|
||||
@ -208,11 +207,11 @@ WebRtc_Word32 ViECapturer::Init(const WebRtc_UWord8* deviceUniqueIdUTF8,
|
||||
#ifndef WEBRTC_VIDEO_EXTERNAL_CAPTURE_AND_RENDER
|
||||
if (deviceUniqueIdUTF8 == NULL)
|
||||
{
|
||||
_captureModule = videocapturemodule::VideoCaptureImpl::Create(
|
||||
_captureModule = VideoCaptureFactory::Create(
|
||||
ViEModuleId(_engineId, _captureId), _externalCaptureModule);
|
||||
} else
|
||||
{
|
||||
_captureModule = videocapturemodule::VideoCaptureImpl::Create(
|
||||
_captureModule = VideoCaptureFactory::Create(
|
||||
ViEModuleId(_engineId, _captureId), deviceUniqueIdUTF8);
|
||||
}
|
||||
#endif
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#ifdef WEBRTC_ANDROID
|
||||
#include "video_capture.h"
|
||||
#include "video_capture_impl.h"
|
||||
#include "video_render.h"
|
||||
#endif
|
||||
|
||||
|
@ -17,8 +17,7 @@
|
||||
|
||||
#include "common_types.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_capture_impl.h"
|
||||
#include "video_capture_factory.h"
|
||||
#include "video_coding.h"
|
||||
#include "video_coding_defines.h"
|
||||
#include "rw_lock_wrapper.h"
|
||||
@ -59,7 +58,7 @@ ViEInputManager::ViEInputManager(const int engineId)
|
||||
_ptrCaptureDeviceInfo=NULL;
|
||||
#else
|
||||
_ptrCaptureDeviceInfo =
|
||||
videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(
|
||||
VideoCaptureFactory::CreateDeviceInfo(
|
||||
ViEModuleId(_engineId));
|
||||
#endif
|
||||
for (int idx = 0; idx < kViEMaxFilePlayers; idx++)
|
||||
@ -91,7 +90,7 @@ ViEInputManager::~ViEInputManager()
|
||||
#ifndef WEBRTC_VIDEO_EXTERNAL_CAPTURE_AND_RENDER
|
||||
if (_ptrCaptureDeviceInfo)
|
||||
{
|
||||
videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(
|
||||
VideoCaptureFactory::DestroyDeviceInfo(
|
||||
_ptrCaptureDeviceInfo);
|
||||
_ptrCaptureDeviceInfo = NULL;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_CAPTURE_DEVICE_H_
|
||||
|
||||
#include "tb_interfaces.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_capture_factory.h"
|
||||
|
||||
class tbCaptureDevice
|
||||
{
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "tb_capture_device.h"
|
||||
#include "video_capture_impl.h"
|
||||
|
||||
tbCaptureDevice::tbCaptureDevice(tbInterfaces& Engine, int& nrOfErrors) :
|
||||
captureId(-1),
|
||||
@ -28,7 +27,7 @@ tbCaptureDevice::tbCaptureDevice(tbInterfaces& Engine, int& nrOfErrors) :
|
||||
bool captureDeviceSet = false;
|
||||
|
||||
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(0);
|
||||
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
|
||||
for (size_t captureIdx = 0;
|
||||
captureIdx < devInfo->NumberOfDevices();
|
||||
captureIdx++)
|
||||
@ -40,7 +39,7 @@ tbCaptureDevice::tbCaptureDevice(tbInterfaces& Engine, int& nrOfErrors) :
|
||||
"ERROR: %s at line %d",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
vcpm_ = webrtc::videocapturemodule::VideoCaptureImpl::Create(
|
||||
vcpm_ = webrtc::VideoCaptureFactory::Create(
|
||||
captureIdx, uniqueId);
|
||||
if (vcpm_ == NULL) // Failed to open this device. Try next.
|
||||
{
|
||||
@ -57,7 +56,7 @@ tbCaptureDevice::tbCaptureDevice(tbInterfaces& Engine, int& nrOfErrors) :
|
||||
break;
|
||||
}
|
||||
}
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(devInfo);
|
||||
webrtc::VideoCaptureFactory::DestroyDeviceInfo(devInfo);
|
||||
numberOfErrors += ViETest::TestError(
|
||||
captureDeviceSet, "ERROR: %s at line %d - Could not set capture device",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest.h"
|
||||
#include "engine_configurations.h"
|
||||
#include "video_capture_impl.h"
|
||||
#include "video_capture_factory.h"
|
||||
|
||||
int ViEAutoTest::ViEBaseStandardTest()
|
||||
{
|
||||
@ -82,7 +82,7 @@ int ViEAutoTest::ViEBaseStandardTest()
|
||||
bool captureDeviceSet = false;
|
||||
int captureId = 0;
|
||||
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(0);
|
||||
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
|
||||
|
||||
for (unsigned int captureIdx = 0;
|
||||
captureIdx < devInfo->NumberOfDevices();
|
||||
@ -95,7 +95,7 @@ int ViEAutoTest::ViEBaseStandardTest()
|
||||
"ERROR: %s at line %d",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
vcpm = webrtc::videocapturemodule::VideoCaptureImpl::Create(
|
||||
vcpm = webrtc::VideoCaptureFactory::Create(
|
||||
4571, uniqueId);
|
||||
vcpm->AddRef();
|
||||
numberOfErrors += ViETest::TestError(vcpm != NULL,
|
||||
@ -116,7 +116,7 @@ int ViEAutoTest::ViEBaseStandardTest()
|
||||
vcpm = NULL;
|
||||
}
|
||||
}
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(devInfo);
|
||||
webrtc::VideoCaptureFactory::DestroyDeviceInfo(devInfo);
|
||||
|
||||
numberOfErrors+= ViETest::TestError(
|
||||
captureDeviceSet,
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "tb_interfaces.h"
|
||||
#include "tb_video_channel.h"
|
||||
#include "video_capture_impl.h"
|
||||
#include "video_capture_factory.h"
|
||||
|
||||
class CaptureObserver: public webrtc::ViECaptureObserver
|
||||
{
|
||||
@ -138,7 +138,7 @@ int ViEAutoTest::ViECaptureStandardTest()
|
||||
tbInterfaces ViE("WebRTCViECapture_Standard", numberOfErrors);
|
||||
|
||||
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(0);
|
||||
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
|
||||
|
||||
int numberOfCaptureDevices = devInfo->NumberOfDevices();
|
||||
ViETest::Log("Number of capture devices %d", numberOfCaptureDevices);
|
||||
@ -229,7 +229,7 @@ int ViEAutoTest::ViECaptureStandardTest()
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
webrtc::VideoCaptureModule* vcpm =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::Create(
|
||||
webrtc::VideoCaptureFactory::Create(
|
||||
deviceIndex, deviceUniqueName);
|
||||
vcpm->AddRef();
|
||||
numberOfErrors += ViETest::TestError(vcpm != NULL,
|
||||
@ -338,7 +338,7 @@ int ViEAutoTest::ViECaptureStandardTest()
|
||||
ViETest::Log(" ");
|
||||
return numberOfErrors;
|
||||
}
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(devInfo);
|
||||
webrtc::VideoCaptureFactory::DestroyDeviceInfo(devInfo);
|
||||
|
||||
ViETest::Log(" ");
|
||||
ViETest::Log(" ViECapture Standard Test PASSED!");
|
||||
@ -386,7 +386,7 @@ int ViEAutoTest::ViECaptureAPITest()
|
||||
int captureId = 0;
|
||||
|
||||
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(0);
|
||||
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
|
||||
numberOfErrors += ViETest::TestError(devInfo != NULL,
|
||||
"ERROR: %s at line %d", __FUNCTION__,
|
||||
__LINE__);
|
||||
@ -398,7 +398,7 @@ int ViEAutoTest::ViECaptureAPITest()
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
webrtc::VideoCaptureModule* vcpm =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::Create(
|
||||
webrtc::VideoCaptureFactory::Create(
|
||||
0, deviceUniqueName);
|
||||
vcpm->AddRef();
|
||||
numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d",
|
||||
@ -558,7 +558,7 @@ int ViEAutoTest::ViECaptureAPITest()
|
||||
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(devInfo);
|
||||
webrtc::VideoCaptureFactory::DestroyDeviceInfo(devInfo);
|
||||
vcpm->Release();
|
||||
|
||||
//***************************************************************
|
||||
@ -608,7 +608,7 @@ int ViEAutoTest::ViECaptureExternalCaptureTest()
|
||||
|
||||
// Allocate the external capture device
|
||||
webrtc::VideoCaptureModule* vcpm =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::Create(
|
||||
webrtc::VideoCaptureFactory::Create(
|
||||
0, externalCapture);
|
||||
vcpm->AddRef();
|
||||
numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d",
|
||||
|
@ -24,7 +24,6 @@
|
||||
'helpers/',
|
||||
'../../interface',
|
||||
'../../source',
|
||||
'../../../../modules/video_capture/main/source/',
|
||||
'../../../../modules/video_coding/codecs/interface/',
|
||||
'../../../../common_video/interface/',
|
||||
],
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "modules/video_capture/main/source/video_capture_impl.h"
|
||||
#include "modules/video_capture/main/interface/video_capture_factory.h"
|
||||
#include "talk/examples/peerconnection_client/defaults.h"
|
||||
#include "talk/base/common.h"
|
||||
#include "talk/base/logging.h"
|
||||
@ -222,7 +222,7 @@ void Conductor::ConnectToPeer(int peer_id) {
|
||||
|
||||
scoped_refptr<webrtc::VideoCaptureModule> Conductor::OpenVideoCaptureDevice() {
|
||||
webrtc::VideoCaptureModule::DeviceInfo* device_info(
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(0));
|
||||
webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
|
||||
scoped_refptr<webrtc::VideoCaptureModule> video_device;
|
||||
|
||||
const size_t kMaxDeviceNameLength = 128;
|
||||
@ -237,11 +237,11 @@ scoped_refptr<webrtc::VideoCaptureModule> Conductor::OpenVideoCaptureDevice() {
|
||||
kMaxUniqueIdLength);
|
||||
// Try to open this device.
|
||||
video_device =
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::Create(0, unique_id);
|
||||
webrtc::VideoCaptureFactory::Create(0, unique_id);
|
||||
if (video_device.get())
|
||||
break;
|
||||
}
|
||||
webrtc::videocapturemodule::VideoCaptureImpl::DestroyDeviceInfo(device_info);
|
||||
webrtc::VideoCaptureFactory::DestroyDeviceInfo(device_info);
|
||||
return video_device;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user