Refactored ViEChannelManager ViEInputManager.

Pointers/references and types will come in a future CL.

Review URL: http://webrtc-codereview.appspot.com/317012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1202 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2011-12-15 10:19:29 +00:00
parent e0e07bbaa0
commit e8be22c192
4 changed files with 1106 additions and 1433 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,95 +8,106 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
/* #ifndef WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_
* vie_channel_manager.h #define WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_
*/
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_CHANNEL_MANAGER_H_
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_CHANNEL_MANAGER_H_
// Defines
#include "engine_configurations.h" #include "engine_configurations.h"
#include "vie_defines.h" #include "system_wrappers/interface/map_wrapper.h"
#include "typedefs.h" #include "typedefs.h"
#include "map_wrapper.h" #include "video_engine/vie_defines.h"
#include "vie_manager_base.h" #include "video_engine/vie_manager_base.h"
namespace webrtc {
namespace webrtc
{
class CriticalSectionWrapper; class CriticalSectionWrapper;
//class VoiceEngine;
class ProcessThread; class ProcessThread;
class ViEChannel; class ViEChannel;
class VoEVideoSync;
class ViEPerformanceMonitor;
class ViEEncoder; class ViEEncoder;
class ViEPerformanceMonitor;
class VoEVideoSync;
class VoiceEngine; class VoiceEngine;
// ------------------------------------------------------------------ class ViEChannelManager: private ViEManagerBase {
// ViEChannelManager friend class ViEChannelManagerScoped;
// ------------------------------------------------------------------ public:
ViEChannelManager(int engine_id,
int number_of_cores,
ViEPerformanceMonitor& vie_performance_monitor);
~ViEChannelManager();
class ViEChannelManager: private ViEManagerBase void SetModuleProcessThread(ProcessThread& module_process_thread);
{
friend class ViEChannelManagerScoped;
public: // Creates a new channel. 'channelId' will be the id of the created channel.
ViEChannelManager(int engineId, int numberOfCores, int CreateChannel(int& channel_id);
ViEPerformanceMonitor& viePerformanceMonitor);
~ViEChannelManager();
void SetModuleProcessThread(ProcessThread& moduleProcessThread); // Creates a channel and attaches to an already existing ViEEncoder.
int CreateChannel(int& channelId); int CreateChannel(int& channel_id, int original_channel);
int CreateChannel(int& channelId, int originalChannel);
int DeleteChannel(int channelId);
int SetVoiceEngine(VoiceEngine* voiceEngine);
int ConnectVoiceChannel(int channelId, int audioChannelId);
int DisconnectVoiceChannel(int channelId);
VoiceEngine* GetVoiceEngine();
private: // Deletes a channel.
// Used by ViEChannelScoped, forcing a manager user to use scoped int DeleteChannel(int channel_id);
ViEChannel* ViEChannelPtr(int channelId) const;
void GetViEChannels(MapWrapper& channelMap);
// Methods used by ViECaptureScoped and ViEEncoderScoped // Set the voice engine instance to be used by all video channels.
ViEEncoder* ViEEncoderPtr(int videoChannelId) const; int SetVoiceEngine(VoiceEngine* voice_engine);
bool GetFreeChannelId(int& freeChannelId); // Enables lip sync of the channel.
void ReturnChannelId(int channelId); int ConnectVoiceChannel(int channel_id, int audio_channel_id);
// Returns true if at least one other channels uses the same ViEEncoder as channelId // Disables lip sync of the channel.
bool ChannelUsingViEEncoder(int channelId) const; int DisconnectVoiceChannel(int channel_id);
// Members VoiceEngine* GetVoiceEngine();
CriticalSectionWrapper* _ptrChannelIdCritsect; // protecting _channelMap and _freeChannelIds
int _engineId; private:
int _numberOfCores; // Used by ViEChannelScoped, forcing a manager user to use scoped.
ViEPerformanceMonitor& _viePerformanceMonitor; // Returns a pointer to the channel with id 'channelId'.
MapWrapper _channelMap; ViEChannel* ViEChannelPtr(int channel_id) const;
bool* _freeChannelIds;
int _freeChannelIdsSize; // Adds all channels to channel_map.
// Encoder void GetViEChannels(MapWrapper& channel_map);
MapWrapper _vieEncoderMap; // Channel id -> ViEEncoder
VoEVideoSync* _voiceSyncInterface; // Methods used by ViECaptureScoped and ViEEncoderScoped.
VoiceEngine* _voiceEngine; // Gets the ViEEncoder used as input for video_channel_id
ProcessThread* _moduleProcessThread; ViEEncoder* ViEEncoderPtr(int video_channel_id) const;
// Returns true if we found a new channel id, free_channel_id, false
// otherwise.
bool GetFreeChannelId(int& free_channel_id);
// Returns a previously allocated channel id.
void ReturnChannelId(int channel_id);
// Returns true if at least one other channels uses the same ViEEncoder as
// channel_id.
bool ChannelUsingViEEncoder(int channel_id) const;
// Protects channel_map_ and free_channel_ids_.
CriticalSectionWrapper* channel_id_critsect_;
int engine_id_;
int number_of_cores_;
ViEPerformanceMonitor& vie_performance_monitor_;
MapWrapper channel_map_;
bool* free_channel_ids_;
int free_channel_ids_size_;
// Maps Channel id -> ViEEncoder.
MapWrapper vie_encoder_map_;
VoEVideoSync* voice_sync_interface_;
VoiceEngine* voice_engine_;
ProcessThread* module_process_thread_;
}; };
// ------------------------------------------------------------------ class ViEChannelManagerScoped: private ViEManagerScopedBase {
// ViEChannelManagerScoped public:
// ------------------------------------------------------------------ explicit ViEChannelManagerScoped(
class ViEChannelManagerScoped: private ViEManagerScopedBase const ViEChannelManager& vie_channel_manager);
{ ViEChannel* Channel(int vie_channel_id) const;
public: ViEEncoder* Encoder(int vie_channel_id) const;
ViEChannelManagerScoped(const ViEChannelManager& vieChannelManager);
ViEChannel* Channel(int vieChannelId) const;
ViEEncoder* Encoder(int vieChannelId) const;
// Returns true if at lease one other channels uses the same ViEEncoder as channelId // Returns true if at lease one other channels uses the same ViEEncoder as
bool ChannelUsingViEEncoder(int channelId) const; // channel_id.
bool ChannelUsingViEEncoder(int channel_id) const;
}; };
} //namespace webrtc } // namespace webrtc
#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_CHANNEL_MANAGER_H_
#endif // WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_

File diff suppressed because it is too large Load Diff

View File

@ -8,114 +8,135 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
/* #ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
* vie_input_manager.h #define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
*/
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_INPUT_MANAGER_H_ #include "modules/video_capture/main/interface/video_capture.h"
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_INPUT_MANAGER_H_ #include "system_wrappers/interface/map_wrapper.h"
#include "vie_defines.h"
#include "typedefs.h" #include "typedefs.h"
#include "map_wrapper.h" #include "video_engine/main/interface/vie_capture.h"
#include "video_capture.h" #include "video_engine/vie_defines.h"
#include "vie_manager_base.h" #include "video_engine/vie_frame_provider_base.h"
#include "vie_frame_provider_base.h" #include "video_engine/vie_manager_base.h"
#include "vie_capture.h"
class ViEExternalCapture;
namespace webrtc { namespace webrtc {
class CriticalSectionWrapper; class CriticalSectionWrapper;
class ProcessThread; class ProcessThread;
class RWLockWrapper; class RWLockWrapper;
class ViECapturer; class ViECapturer;
class ViEExternalCapture;
class ViEFilePlayer; class ViEFilePlayer;
class VoiceEngine; class VoiceEngine;
class ViEInputManager: private ViEManagerBase class ViEInputManager : private ViEManagerBase {
{ friend class ViEInputManagerScoped;
friend class ViEInputManagerScoped; public:
public: explicit ViEInputManager(int engine_id);
ViEInputManager(int engineId); ~ViEInputManager();
~ViEInputManager();
void SetModuleProcessThread(ProcessThread& moduleProcessThread); void SetModuleProcessThread(ProcessThread& module_process_thread);
// Capture device information // Returns number of capture devices.
int NumberOfCaptureDevices(); int NumberOfCaptureDevices();
int GetDeviceName(WebRtc_UWord32 deviceNumber,
WebRtc_UWord8* deviceNameUTF8,
WebRtc_UWord32 deviceNameLength,
WebRtc_UWord8* deviceUniqueIdUTF8,
WebRtc_UWord32 deviceUniqueIdUTF8Length);
int NumberOfCaptureCapabilities(const WebRtc_UWord8* deviceUniqueIdUTF8);
int GetCaptureCapability(const WebRtc_UWord8* deviceUniqueIdUTF8,
const WebRtc_UWord32 deviceCapabilityNumber,
CaptureCapability& capability);
int DisplayCaptureSettingsDialogBox(const WebRtc_UWord8* deviceUniqueIdUTF8,
const WebRtc_UWord8* dialogTitleUTF8,
void* parentWindow,
WebRtc_UWord32 positionX,
WebRtc_UWord32 positionY);
int GetOrientation(const WebRtc_UWord8* deviceUniqueIdUTF8,
RotateCapturedFrame &orientation);
// Create/delete Capture device settings // Gets name and id for a capture device.
// Return zero on success. A ViEError on failure. int GetDeviceName(WebRtc_UWord32 device_number,
int CreateCaptureDevice(const WebRtc_UWord8* deviceUniqueIdUTF8, WebRtc_UWord8* device_nameUTF8,
const WebRtc_UWord32 deviceUniqueIdUTF8Length, WebRtc_UWord32 device_name_length,
int& captureId); WebRtc_UWord8* device_unique_idUTF8,
int CreateCaptureDevice(VideoCaptureModule& captureModule, WebRtc_UWord32 device_unique_idUTF8Length);
int& captureId);
int CreateExternalCaptureDevice(ViEExternalCapture*& externalCapture,
int& captureId);
int DestroyCaptureDevice(int captureId);
int CreateFilePlayer(const WebRtc_Word8* fileNameUTF8, const bool loop, // Returns the number of capture capabilities for a specified device.
const webrtc::FileFormats fileFormat, VoiceEngine* vePtr, int NumberOfCaptureCapabilities(const WebRtc_UWord8* device_unique_idUTF8);
int& fileId);
int DestroyFilePlayer(int fileId);
private: // Gets a specific capability for a capture device.
bool GetFreeCaptureId(int& freecaptureId); int GetCaptureCapability(const WebRtc_UWord8* device_unique_idUTF8,
void ReturnCaptureId(int captureId); const WebRtc_UWord32 device_capability_number,
bool GetFreeFileId(int& freeFileId); CaptureCapability& capability);
void ReturnFileId(int fileId);
ViEFrameProviderBase* ViEFrameProvider(const ViEFrameCallback* // Show OS specific Capture settings.
captureObserver) const; int DisplayCaptureSettingsDialogBox(const WebRtc_UWord8* device_unique_idUTF8,
ViEFrameProviderBase* ViEFrameProvider(int providerId) const; const WebRtc_UWord8* dialog_titleUTF8,
void* parent_window,
WebRtc_UWord32 positionX,
WebRtc_UWord32 positionY);
int GetOrientation(const WebRtc_UWord8* device_unique_idUTF8,
RotateCapturedFrame& orientation);
ViECapturer* ViECapturePtr(int captureId) const; // Creates a capture module for the specified capture device and assigns
void GetViECaptures(MapWrapper& vieCaptureMap); // a capture device id for the device.
// Return zero on success, ViEError on failure.
int CreateCaptureDevice(const WebRtc_UWord8* device_unique_idUTF8,
const WebRtc_UWord32 device_unique_idUTF8Length,
int& capture_id);
int CreateCaptureDevice(VideoCaptureModule& capture_module,
int& capture_id);
int CreateExternalCaptureDevice(ViEExternalCapture*& external_capture,
int& capture_id);
int DestroyCaptureDevice(int capture_id);
ViEFilePlayer* ViEFilePlayerPtr(int fileId) const; int CreateFilePlayer(const WebRtc_Word8* file_nameUTF8, const bool loop,
const FileFormats file_format,
VoiceEngine* voe_ptr,
int& file_id);
int DestroyFilePlayer(int file_id);
// Members private:
int _engineId; // Gets and allocates a free capture device id. Assumed protected by caller.
CriticalSectionWrapper& _mapCritsect; bool GetFreeCaptureId(int& freecapture_id);
MapWrapper _vieFrameProviderMap;
// Capture devices // Frees a capture id assigned in GetFreeCaptureId.
VideoCaptureModule::DeviceInfo* _ptrCaptureDeviceInfo; void ReturnCaptureId(int capture_id);
int _freeCaptureDeviceId[kViEMaxCaptureDevices];
//File Players // Gets and allocates a free file id. Assumed protected by caller.
int _freeFileId[kViEMaxFilePlayers]; bool GetFreeFileId(int& free_file_id);
//uses
ProcessThread* _moduleProcessThread; // Frees a file id assigned in GetFreeFileId.
void ReturnFileId(int file_id);
// Gets the ViEFrameProvider for this capture observer.
ViEFrameProviderBase* ViEFrameProvider(
const ViEFrameCallback* capture_observer) const;
// Gets the ViEFrameProvider for this capture observer.
ViEFrameProviderBase* ViEFrameProvider(int provider_id) const;
// Gets the ViECapturer for the capture device id.
ViECapturer* ViECapturePtr(int capture_id) const;
// Gets the the entire map with GetViECaptures.
void GetViECaptures(MapWrapper& vie_capture_map);
// Gets the ViEFilePlayer for this file_id.
ViEFilePlayer* ViEFilePlayerPtr(int file_id) const;
int engine_id_;
CriticalSectionWrapper& map_cs_;
MapWrapper vie_frame_provider_map_;
// Capture devices.
VideoCaptureModule::DeviceInfo* capture_device_info_;
int free_capture_device_id_[kViEMaxCaptureDevices];
// File Players.
int free_file_id_[kViEMaxFilePlayers];
ProcessThread* module_process_thread_;
}; };
class ViEInputManagerScoped: private ViEManagerScopedBase // Provides protected access to ViEInputManater.
{ class ViEInputManagerScoped: private ViEManagerScopedBase {
public: public:
ViEInputManagerScoped(const ViEInputManager& vieInputManager); explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager);
ViECapturer* Capture(int captureId) const; ViECapturer* Capture(int capture_id) const;
ViEFilePlayer* FilePlayer(int fileId) const; ViEFilePlayer* FilePlayer(int file_id) const;
ViEFrameProviderBase* FrameProvider(int providerId) const; ViEFrameProviderBase* FrameProvider(int provider_id) const;
ViEFrameProviderBase* FrameProvider(const ViEFrameCallback* ViEFrameProviderBase* FrameProvider(const ViEFrameCallback*
captureObserver) const; capture_observer) const;
}; };
} // namespace webrtc
#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_INPUT_MANAGER_H_ } // namespace webrtc
#endif // WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_