2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 06:50:15 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_
|
|
|
|
#define WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-01-03 13:46:49 +00:00
|
|
|
#include <list>
|
2012-01-24 06:50:15 +00:00
|
|
|
#include <map>
|
2012-01-03 13:46:49 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#include "engine_configurations.h"
|
2011-12-22 10:26:13 +00:00
|
|
|
#include "system_wrappers/interface/scoped_ptr.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
#include "typedefs.h"
|
2012-03-05 17:12:41 +00:00
|
|
|
#include "video_engine/vie_channel_group.h"
|
2011-12-15 10:19:29 +00:00
|
|
|
#include "video_engine/vie_defines.h"
|
|
|
|
#include "video_engine/vie_manager_base.h"
|
2012-03-05 17:12:41 +00:00
|
|
|
#include "video_engine/vie_remb.h"
|
2011-12-15 10:19:29 +00:00
|
|
|
|
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
class CriticalSectionWrapper;
|
2012-01-24 06:50:15 +00:00
|
|
|
class MapWrapper;
|
2011-07-07 08:21:25 +00:00
|
|
|
class ProcessThread;
|
|
|
|
class ViEChannel;
|
|
|
|
class ViEEncoder;
|
2011-12-15 10:19:29 +00:00
|
|
|
class ViEPerformanceMonitor;
|
|
|
|
class VoEVideoSync;
|
2011-07-07 08:21:25 +00:00
|
|
|
class VoiceEngine;
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
typedef std::list<ChannelGroup*> ChannelGroups;
|
2012-01-03 13:46:49 +00:00
|
|
|
typedef std::list<ViEChannel*> ChannelList;
|
2012-01-24 06:50:15 +00:00
|
|
|
typedef std::map<int, ViEChannel*> ChannelMap;
|
|
|
|
typedef std::map<int, ViEEncoder*> EncoderMap;
|
2012-01-03 13:46:49 +00:00
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
class ViEChannelManager: private ViEManagerBase {
|
|
|
|
friend class ViEChannelManagerScoped;
|
|
|
|
public:
|
|
|
|
ViEChannelManager(int engine_id,
|
|
|
|
int number_of_cores,
|
|
|
|
ViEPerformanceMonitor& vie_performance_monitor);
|
|
|
|
~ViEChannelManager();
|
|
|
|
|
|
|
|
void SetModuleProcessThread(ProcessThread& module_process_thread);
|
|
|
|
|
|
|
|
// Creates a new channel. 'channelId' will be the id of the created channel.
|
|
|
|
int CreateChannel(int& channel_id);
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
// Creates a new channel grouped with |original_channel|. The new channel
|
|
|
|
// will get its own |ViEEncoder| if |sender| is set to true. It will be a
|
|
|
|
// receive only channel, without an own |ViEEncoder| if |sender| is false.
|
|
|
|
int CreateChannel(int& channel_id, int original_channel, bool sender);
|
2011-12-15 10:19:29 +00:00
|
|
|
|
|
|
|
// Deletes a channel.
|
|
|
|
int DeleteChannel(int channel_id);
|
|
|
|
|
|
|
|
// Set the voice engine instance to be used by all video channels.
|
|
|
|
int SetVoiceEngine(VoiceEngine* voice_engine);
|
|
|
|
|
|
|
|
// Enables lip sync of the channel.
|
|
|
|
int ConnectVoiceChannel(int channel_id, int audio_channel_id);
|
|
|
|
|
|
|
|
// Disables lip sync of the channel.
|
|
|
|
int DisconnectVoiceChannel(int channel_id);
|
|
|
|
|
|
|
|
VoiceEngine* GetVoiceEngine();
|
|
|
|
|
2011-12-22 10:26:13 +00:00
|
|
|
// Adds a channel to include when sending REMB.
|
|
|
|
bool SetRembStatus(int channel_id, bool sender, bool receiver);
|
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
private:
|
2012-03-05 17:12:41 +00:00
|
|
|
// Creates a channel object connected to |vie_encoder|. Assumed to be called
|
|
|
|
// protected.
|
2012-04-27 05:25:53 +00:00
|
|
|
bool CreateChannelObject(int channel_id, ViEEncoder* vie_encoder,
|
|
|
|
RtcpBandwidthObserver* bandwidth_observer);
|
2012-03-05 17:12:41 +00:00
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
// 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;
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
// Returns a free channel id, -1 if failing.
|
|
|
|
int FreeChannelId();
|
2011-12-15 10:19:29 +00:00
|
|
|
|
|
|
|
// Returns a previously allocated channel id.
|
|
|
|
void ReturnChannelId(int channel_id);
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
// Returns the iterator to the ChannelGroup containing |channel_id|.
|
|
|
|
ChannelGroup* FindGroup(int channel_id);
|
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
// Returns true if at least one other channels uses the same ViEEncoder as
|
|
|
|
// channel_id.
|
|
|
|
bool ChannelUsingViEEncoder(int channel_id) const;
|
2012-01-03 13:46:49 +00:00
|
|
|
void ChannelsUsingViEEncoder(int channel_id, ChannelList* channels) const;
|
2011-12-15 10:19:29 +00:00
|
|
|
|
|
|
|
// Protects channel_map_ and free_channel_ids_.
|
|
|
|
CriticalSectionWrapper* channel_id_critsect_;
|
|
|
|
int engine_id_;
|
|
|
|
int number_of_cores_;
|
|
|
|
ViEPerformanceMonitor& vie_performance_monitor_;
|
2012-03-05 17:12:41 +00:00
|
|
|
|
|
|
|
// TODO(mflodman) Make part of channel group.
|
2012-01-24 06:50:15 +00:00
|
|
|
ChannelMap channel_map_;
|
2011-12-15 10:19:29 +00:00
|
|
|
bool* free_channel_ids_;
|
|
|
|
int free_channel_ids_size_;
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
// List with all channel groups.
|
|
|
|
std::list<ChannelGroup*> channel_groups_;
|
|
|
|
|
|
|
|
// TODO(mflodman) Make part of channel group.
|
2011-12-15 10:19:29 +00:00
|
|
|
// Maps Channel id -> ViEEncoder.
|
2012-01-24 06:50:15 +00:00
|
|
|
EncoderMap vie_encoder_map_;
|
2011-12-15 10:19:29 +00:00
|
|
|
VoEVideoSync* voice_sync_interface_;
|
2012-03-05 17:12:41 +00:00
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
VoiceEngine* voice_engine_;
|
|
|
|
ProcessThread* module_process_thread_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
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;
|
|
|
|
|
2012-01-03 13:46:49 +00:00
|
|
|
// Returns true if at least one other channels uses the same ViEEncoder as
|
2011-12-15 10:19:29 +00:00
|
|
|
// channel_id.
|
|
|
|
bool ChannelUsingViEEncoder(int channel_id) const;
|
2012-01-03 13:46:49 +00:00
|
|
|
|
|
|
|
// Returns a list with pointers to all channels using the same encoder as the
|
|
|
|
// channel with |channel_id|, including the one with the specified id.
|
|
|
|
void ChannelsUsingViEEncoder(int channel_id, ChannelList* channels) const;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
2011-12-15 10:19:29 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
#endif // WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_
|