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:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -8,95 +8,106 @@ | ||||
|  *  be found in the AUTHORS file in the root of the source tree. | ||||
|  */ | ||||
|  | ||||
| /* | ||||
|  * vie_channel_manager.h | ||||
|  */ | ||||
| #ifndef WEBRTC_VIDEO_ENGINE_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 "vie_defines.h" | ||||
| #include "system_wrappers/interface/map_wrapper.h" | ||||
| #include "typedefs.h" | ||||
| #include "map_wrapper.h" | ||||
| #include "vie_manager_base.h" | ||||
| #include "video_engine/vie_defines.h" | ||||
| #include "video_engine/vie_manager_base.h" | ||||
|  | ||||
| namespace webrtc { | ||||
|  | ||||
| namespace webrtc | ||||
| { | ||||
| class CriticalSectionWrapper; | ||||
| //class VoiceEngine; | ||||
| class ProcessThread; | ||||
| class ViEChannel; | ||||
| class VoEVideoSync; | ||||
| class ViEPerformanceMonitor; | ||||
| class ViEEncoder; | ||||
| class ViEPerformanceMonitor; | ||||
| class VoEVideoSync; | ||||
| class VoiceEngine; | ||||
|  | ||||
| // ------------------------------------------------------------------ | ||||
| // ViEChannelManager | ||||
| // ------------------------------------------------------------------ | ||||
| class ViEChannelManager: private ViEManagerBase { | ||||
|   friend class ViEChannelManagerScoped; | ||||
|  public: | ||||
|   ViEChannelManager(int engine_id, | ||||
|                     int number_of_cores, | ||||
|                     ViEPerformanceMonitor& vie_performance_monitor); | ||||
|   ~ViEChannelManager(); | ||||
|  | ||||
| class ViEChannelManager: private ViEManagerBase | ||||
| { | ||||
|     friend class ViEChannelManagerScoped; | ||||
|   void SetModuleProcessThread(ProcessThread& module_process_thread); | ||||
|  | ||||
| public: | ||||
|     ViEChannelManager(int engineId, int numberOfCores, | ||||
|                       ViEPerformanceMonitor& viePerformanceMonitor); | ||||
|     ~ViEChannelManager(); | ||||
|   // Creates a new channel. 'channelId' will be the id of the created channel. | ||||
|   int CreateChannel(int& channel_id); | ||||
|  | ||||
|     void SetModuleProcessThread(ProcessThread& moduleProcessThread); | ||||
|     int CreateChannel(int& channelId); | ||||
|     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(); | ||||
|   // Creates a channel and attaches to an already existing ViEEncoder. | ||||
|   int CreateChannel(int& channel_id, int original_channel); | ||||
|  | ||||
| private: | ||||
|     // Used by ViEChannelScoped, forcing a manager user to use scoped | ||||
|     ViEChannel* ViEChannelPtr(int channelId) const; | ||||
|     void GetViEChannels(MapWrapper& channelMap); | ||||
|   // Deletes a channel. | ||||
|   int DeleteChannel(int channel_id); | ||||
|  | ||||
|     // Methods used by ViECaptureScoped and ViEEncoderScoped | ||||
|     ViEEncoder* ViEEncoderPtr(int videoChannelId) const; | ||||
|   // Set the voice engine instance to be used by all video channels. | ||||
|   int SetVoiceEngine(VoiceEngine* voice_engine); | ||||
|  | ||||
|     bool GetFreeChannelId(int& freeChannelId); | ||||
|     void ReturnChannelId(int channelId); | ||||
|   // Enables lip sync of the channel. | ||||
|   int ConnectVoiceChannel(int channel_id, int audio_channel_id); | ||||
|  | ||||
|     // Returns true if at least one other channels uses the same ViEEncoder as channelId | ||||
|     bool ChannelUsingViEEncoder(int channelId) const; | ||||
|   // Disables lip sync of the channel. | ||||
|   int DisconnectVoiceChannel(int channel_id); | ||||
|  | ||||
|     // Members | ||||
|     CriticalSectionWrapper* _ptrChannelIdCritsect; // protecting _channelMap and _freeChannelIds | ||||
|     int _engineId; | ||||
|     int _numberOfCores; | ||||
|     ViEPerformanceMonitor& _viePerformanceMonitor; | ||||
|     MapWrapper _channelMap; | ||||
|     bool* _freeChannelIds; | ||||
|     int _freeChannelIdsSize; | ||||
|     // Encoder | ||||
|     MapWrapper _vieEncoderMap; // Channel id -> ViEEncoder | ||||
|     VoEVideoSync* _voiceSyncInterface; | ||||
|     VoiceEngine* _voiceEngine; | ||||
|     ProcessThread* _moduleProcessThread; | ||||
|   VoiceEngine* GetVoiceEngine(); | ||||
|  | ||||
|  private: | ||||
|   // Used by ViEChannelScoped, forcing a manager user to use scoped. | ||||
|   // Returns a pointer to the channel with id 'channelId'. | ||||
|   ViEChannel* ViEChannelPtr(int channel_id) const; | ||||
|  | ||||
|   // Adds all channels to channel_map. | ||||
|   void GetViEChannels(MapWrapper& channel_map); | ||||
|  | ||||
|   // Methods used by ViECaptureScoped and ViEEncoderScoped. | ||||
|   // Gets the ViEEncoder used as input for video_channel_id | ||||
|   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_; | ||||
| }; | ||||
|  | ||||
| // ------------------------------------------------------------------ | ||||
| // ViEChannelManagerScoped | ||||
| // ------------------------------------------------------------------ | ||||
| class ViEChannelManagerScoped: private ViEManagerScopedBase | ||||
| { | ||||
| public: | ||||
|     ViEChannelManagerScoped(const ViEChannelManager& vieChannelManager); | ||||
|     ViEChannel* Channel(int vieChannelId) const; | ||||
|     ViEEncoder* Encoder(int vieChannelId) const; | ||||
| class ViEChannelManagerScoped: private ViEManagerScopedBase { | ||||
|  public: | ||||
|   explicit ViEChannelManagerScoped( | ||||
|       const ViEChannelManager& vie_channel_manager); | ||||
|   ViEChannel* Channel(int vie_channel_id) const; | ||||
|   ViEEncoder* Encoder(int vie_channel_id) const; | ||||
|  | ||||
|     // Returns true if at lease one other channels uses the same ViEEncoder as channelId | ||||
|     bool ChannelUsingViEEncoder(int channelId) const; | ||||
|   // Returns true if at lease one other channels uses the same ViEEncoder as | ||||
|   // channel_id. | ||||
|   bool ChannelUsingViEEncoder(int channel_id) const; | ||||
| }; | ||||
|  | ||||
| } //namespace webrtc | ||||
| #endif    // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_CHANNEL_MANAGER_H_ | ||||
| }  // namespace webrtc | ||||
|  | ||||
| #endif  // WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_ | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -8,114 +8,135 @@ | ||||
|  *  be found in the AUTHORS file in the root of the source tree. | ||||
|  */ | ||||
|  | ||||
| /* | ||||
|  * vie_input_manager.h | ||||
|  */ | ||||
| #ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ | ||||
| #define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ | ||||
|  | ||||
| #ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_INPUT_MANAGER_H_ | ||||
| #define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_INPUT_MANAGER_H_ | ||||
|  | ||||
| #include "vie_defines.h" | ||||
| #include "modules/video_capture/main/interface/video_capture.h" | ||||
| #include "system_wrappers/interface/map_wrapper.h" | ||||
| #include "typedefs.h" | ||||
| #include "map_wrapper.h" | ||||
| #include "video_capture.h" | ||||
| #include "vie_manager_base.h" | ||||
| #include "vie_frame_provider_base.h" | ||||
| #include "vie_capture.h" | ||||
|  | ||||
| class ViEExternalCapture; | ||||
| #include "video_engine/main/interface/vie_capture.h" | ||||
| #include "video_engine/vie_defines.h" | ||||
| #include "video_engine/vie_frame_provider_base.h" | ||||
| #include "video_engine/vie_manager_base.h" | ||||
|  | ||||
| namespace webrtc { | ||||
|  | ||||
| class CriticalSectionWrapper; | ||||
| class ProcessThread; | ||||
| class RWLockWrapper; | ||||
| class ViECapturer; | ||||
| class ViEExternalCapture; | ||||
| class ViEFilePlayer; | ||||
| class VoiceEngine; | ||||
|  | ||||
| class ViEInputManager: private ViEManagerBase | ||||
| { | ||||
|     friend class ViEInputManagerScoped; | ||||
| public: | ||||
|     ViEInputManager(int engineId); | ||||
|     ~ViEInputManager(); | ||||
| class ViEInputManager : private ViEManagerBase { | ||||
|   friend class ViEInputManagerScoped; | ||||
|  public: | ||||
|   explicit ViEInputManager(int engine_id); | ||||
|   ~ViEInputManager(); | ||||
|  | ||||
|     void SetModuleProcessThread(ProcessThread& moduleProcessThread); | ||||
|   void SetModuleProcessThread(ProcessThread& module_process_thread); | ||||
|  | ||||
|     // Capture device information | ||||
|     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); | ||||
|   // Returns number of capture devices. | ||||
|   int NumberOfCaptureDevices(); | ||||
|  | ||||
|     // Create/delete Capture device settings | ||||
|     // Return zero on success. A ViEError on failure. | ||||
|     int CreateCaptureDevice(const WebRtc_UWord8* deviceUniqueIdUTF8, | ||||
|                             const WebRtc_UWord32 deviceUniqueIdUTF8Length, | ||||
|                             int& captureId); | ||||
|     int CreateCaptureDevice(VideoCaptureModule& captureModule, | ||||
|                             int& captureId); | ||||
|     int CreateExternalCaptureDevice(ViEExternalCapture*& externalCapture, | ||||
|                                     int& captureId); | ||||
|     int DestroyCaptureDevice(int captureId); | ||||
|   // Gets name and id for a capture device. | ||||
|   int GetDeviceName(WebRtc_UWord32 device_number, | ||||
|                     WebRtc_UWord8* device_nameUTF8, | ||||
|                     WebRtc_UWord32 device_name_length, | ||||
|                     WebRtc_UWord8* device_unique_idUTF8, | ||||
|                     WebRtc_UWord32 device_unique_idUTF8Length); | ||||
|  | ||||
|     int CreateFilePlayer(const WebRtc_Word8* fileNameUTF8, const bool loop, | ||||
|                          const webrtc::FileFormats fileFormat, VoiceEngine* vePtr, | ||||
|                          int& fileId); | ||||
|     int DestroyFilePlayer(int fileId); | ||||
|   // Returns the number of capture capabilities for a specified device. | ||||
|   int NumberOfCaptureCapabilities(const WebRtc_UWord8* device_unique_idUTF8); | ||||
|  | ||||
| private: | ||||
|     bool GetFreeCaptureId(int& freecaptureId); | ||||
|     void ReturnCaptureId(int captureId); | ||||
|     bool GetFreeFileId(int& freeFileId); | ||||
|     void ReturnFileId(int fileId); | ||||
|   // Gets a specific capability for a capture device. | ||||
|   int GetCaptureCapability(const WebRtc_UWord8* device_unique_idUTF8, | ||||
|                            const WebRtc_UWord32 device_capability_number, | ||||
|                            CaptureCapability& capability); | ||||
|  | ||||
|     ViEFrameProviderBase* ViEFrameProvider(const ViEFrameCallback* | ||||
|                                                        captureObserver) const; | ||||
|     ViEFrameProviderBase* ViEFrameProvider(int providerId) const; | ||||
|   // Show OS specific Capture settings. | ||||
|   int DisplayCaptureSettingsDialogBox(const WebRtc_UWord8* device_unique_idUTF8, | ||||
|                                       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; | ||||
|     void GetViECaptures(MapWrapper& vieCaptureMap); | ||||
|   // Creates a capture module for the specified capture device and assigns | ||||
|   // 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 | ||||
|     int _engineId; | ||||
|     CriticalSectionWrapper& _mapCritsect; | ||||
|     MapWrapper _vieFrameProviderMap; | ||||
|  private: | ||||
|   // Gets and allocates a free capture device id. Assumed protected by caller. | ||||
|   bool GetFreeCaptureId(int& freecapture_id); | ||||
|  | ||||
|     // Capture devices | ||||
|     VideoCaptureModule::DeviceInfo* _ptrCaptureDeviceInfo; | ||||
|     int _freeCaptureDeviceId[kViEMaxCaptureDevices]; | ||||
|     //File Players | ||||
|     int _freeFileId[kViEMaxFilePlayers]; | ||||
|     //uses | ||||
|     ProcessThread* _moduleProcessThread; | ||||
|   // Frees a capture id assigned in GetFreeCaptureId. | ||||
|   void ReturnCaptureId(int capture_id); | ||||
|  | ||||
|   // Gets and allocates a free file id. Assumed protected by caller. | ||||
|   bool GetFreeFileId(int& free_file_id); | ||||
|  | ||||
|   // 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 | ||||
| { | ||||
| public: | ||||
|     ViEInputManagerScoped(const ViEInputManager& vieInputManager); | ||||
| // Provides protected access to ViEInputManater. | ||||
| class ViEInputManagerScoped: private ViEManagerScopedBase { | ||||
|  public: | ||||
|   explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager); | ||||
|  | ||||
|     ViECapturer* Capture(int captureId) const; | ||||
|     ViEFilePlayer* FilePlayer(int fileId) const; | ||||
|     ViEFrameProviderBase* FrameProvider(int providerId) const; | ||||
|     ViEFrameProviderBase* FrameProvider(const ViEFrameCallback* | ||||
|                                                         captureObserver) const; | ||||
|   ViECapturer* Capture(int capture_id) const; | ||||
|   ViEFilePlayer* FilePlayer(int file_id) const; | ||||
|   ViEFrameProviderBase* FrameProvider(int provider_id) const; | ||||
|   ViEFrameProviderBase* FrameProvider(const ViEFrameCallback* | ||||
|                                       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_ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 mflodman@webrtc.org
					mflodman@webrtc.org