#include <map>
#include <vector>
-#include "talk/base/scoped_ptr.h"
#include "talk/media/base/codec.h"
#include "talk/media/base/videocommon.h"
#include "talk/media/webrtc/webrtccommon.h"
#include "talk/media/webrtc/webrtcexport.h"
#include "talk/media/webrtc/webrtcvideoencoderfactory.h"
#include "talk/session/media/channel.h"
+#include "webrtc/base/scoped_ptr.h"
#include "webrtc/video_engine/include/vie_base.h"
#if !defined(LIBPEERCONNECTION_LIB) && \
#error "Bogus include."
#endif
-
namespace webrtc {
class VideoCaptureModule;
class VideoDecoder;
class ViERTP_RTCP;
}
-namespace talk_base {
+namespace rtc {
class CpuMonitor;
-} // namespace talk_base
+} // namespace rtc
namespace cricket {
// TODO(juberti): Remove the 3-arg ctor once fake tracing is implemented.
WebRtcVideoEngine(WebRtcVoiceEngine* voice_engine,
ViEWrapper* vie_wrapper,
- talk_base::CpuMonitor* cpu_monitor);
+ rtc::CpuMonitor* cpu_monitor);
WebRtcVideoEngine(WebRtcVoiceEngine* voice_engine,
ViEWrapper* vie_wrapper,
ViETraceWrapper* tracing,
- talk_base::CpuMonitor* cpu_monitor);
+ rtc::CpuMonitor* cpu_monitor);
~WebRtcVideoEngine();
// Basic video engine implementation.
- bool Init(talk_base::Thread* worker_thread);
+ bool Init(rtc::Thread* worker_thread);
void Terminate();
int GetCapabilities();
bool IsExternalEncoderCodecType(webrtc::VideoCodecType type) const;
// Functions called by WebRtcVideoMediaChannel.
- talk_base::Thread* worker_thread() { return worker_thread_; }
+ rtc::Thread* worker_thread() { return worker_thread_; }
ViEWrapper* vie() { return vie_wrapper_.get(); }
const VideoFormat& default_codec_format() const {
return default_codec_format_;
VideoFormat GetStartCaptureFormat() const { return default_codec_format_; }
- talk_base::CpuMonitor* cpu_monitor() { return cpu_monitor_.get(); }
+ rtc::CpuMonitor* cpu_monitor() { return cpu_monitor_.get(); }
protected:
// When a video processor registers with the engine.
static const VideoCodecPref kVideoCodecPrefs[];
static const VideoFormatPod kVideoFormats[];
- static const VideoFormatPod kDefaultVideoFormat;
+ static const VideoFormatPod kDefaultMaxVideoFormat;
void Construct(ViEWrapper* vie_wrapper,
ViETraceWrapper* tracing,
WebRtcVoiceEngine* voice_engine,
- talk_base::CpuMonitor* cpu_monitor);
+ rtc::CpuMonitor* cpu_monitor);
bool SetDefaultCodec(const VideoCodec& codec);
bool RebuildCodecList(const VideoCodec& max_codec);
void SetTraceFilter(int filter);
// WebRtcVideoEncoderFactory::Observer implementation.
virtual void OnCodecsAvailable();
- talk_base::Thread* worker_thread_;
- talk_base::scoped_ptr<ViEWrapper> vie_wrapper_;
+ rtc::Thread* worker_thread_;
+ rtc::scoped_ptr<ViEWrapper> vie_wrapper_;
bool vie_wrapper_base_initialized_;
- talk_base::scoped_ptr<ViETraceWrapper> tracing_;
+ rtc::scoped_ptr<ViETraceWrapper> tracing_;
WebRtcVoiceEngine* voice_engine_;
- talk_base::scoped_ptr<webrtc::VideoRender> render_module_;
+ rtc::scoped_ptr<webrtc::VideoRender> render_module_;
WebRtcVideoEncoderFactory* encoder_factory_;
WebRtcVideoDecoderFactory* decoder_factory_;
std::vector<VideoCodec> video_codecs_;
VideoFormat default_codec_format_;
bool initialized_;
- talk_base::CriticalSection channels_crit_;
+ rtc::CriticalSection channels_crit_;
VideoChannels channels_;
bool capture_started_;
int local_renderer_h_;
VideoRenderer* local_renderer_;
- talk_base::scoped_ptr<talk_base::CpuMonitor> cpu_monitor_;
+ rtc::scoped_ptr<rtc::CpuMonitor> cpu_monitor_;
};
-class WebRtcVideoMediaChannel : public talk_base::MessageHandler,
+class WebRtcVideoMediaChannel : public rtc::MessageHandler,
public VideoMediaChannel,
public webrtc::Transport {
public:
WebRtcVideoEngine* engine() { return engine_; }
VoiceMediaChannel* voice_channel() { return voice_channel_; }
- int video_channel() const { return vie_channel_; }
bool sending() const { return sending_; }
// Public for testing purpose.
- uint32 GetDefaultChannelSsrc();
+ uint32 GetDefaultSendChannelSsrc();
+ int GetDefaultChannelId() const { return default_channel_id_; }
// VideoMediaChannel implementation
virtual bool SetRecvCodecs(const std::vector<VideoCodec> &codecs);
virtual bool SendIntraFrame();
virtual bool RequestIntraFrame();
- virtual void OnPacketReceived(talk_base::Buffer* packet,
- const talk_base::PacketTime& packet_time);
- virtual void OnRtcpReceived(talk_base::Buffer* packet,
- const talk_base::PacketTime& packet_time);
+ virtual void OnPacketReceived(rtc::Buffer* packet,
+ const rtc::PacketTime& packet_time);
+ virtual void OnRtcpReceived(rtc::Buffer* packet,
+ const rtc::PacketTime& packet_time);
virtual void OnReadyToSend(bool ready);
virtual bool MuteStream(uint32 ssrc, bool on);
virtual bool SetRecvRtpHeaderExtensions(
void OnLocalFrameFormat(VideoCapturer* capturer, const VideoFormat* format) {
}
- virtual void OnMessage(talk_base::Message* msg);
+ virtual void OnMessage(rtc::Message* msg);
protected:
int GetLastEngineError() { return engine()->GetLastEngineError(); }
enum MediaDirection { MD_RECV, MD_SEND, MD_SENDRECV };
- // Creates and initializes a ViE channel. When successful |channel_id| will
- // contain the new channel's ID. If |receiving| is true |ssrc| is the
- // remote ssrc. If |sending| is true the ssrc is local ssrc. If both
- // |receiving| and |sending| is true the ssrc must be 0 and the channel will
- // be created as a default channel. The ssrc must be different for receive
- // channels and it must be different for send channels. If the same SSRC is
- // being used for creating channel more than once, this function will fail
- // returning false.
+ // Creates and initializes a ViE channel. When successful
+ // |channel_id| will contain the new channel's ID. If |receiving| is
+ // true |ssrc| is the remote ssrc. If |sending| is true the ssrc is
+ // local ssrc. If both |receiving| and |sending| is true the ssrc
+ // must be kDefaultChannelSsrcKey and the channel will be created as
+ // a default channel. The ssrc must be different for receive
+ // channels and it must be different for send channels. If the same
+ // SSRC is being used for creating channel more than once, this
+ // function will fail returning false.
bool CreateChannel(uint32 ssrc_key, MediaDirection direction,
int* channel_id);
bool CreateUnsignalledRecvChannel(uint32 ssrc_key, int* channel_id);
// Prepares the channel with channel id |info->channel_id()| to receive all
// codecs in |receive_codecs_| and start receive packets.
bool SetReceiveCodecs(WebRtcVideoChannelRecvInfo* info);
- // Returns the channel number that receives the stream with SSRC |ssrc|.
- int GetRecvChannelNum(uint32 ssrc);
+ // Returns the channel ID that receives the stream with SSRC |ssrc|.
+ int GetRecvChannelId(uint32 ssrc);
bool MaybeSetRtxSsrc(const StreamParams& sp, int channel_id);
// Given captured video frame size, checks if we need to reset vie send codec.
// |reset| is set to whether resetting has happened on vie or not.
bool SendIntraFrame(int channel_id);
bool HasReadySendChannels();
-
- // Send channel key returns the key corresponding to the provided local SSRC
- // in |key|. The return value is true upon success.
- // If the local ssrc correspond to that of the default channel the key is 0.
- // For all other channels the returned key will be the same as the local ssrc.
- bool GetSendChannelKey(uint32 local_ssrc, uint32* key);
- WebRtcVideoChannelSendInfo* GetSendChannel(uint32 local_ssrc);
- // Creates a new unique key that can be used for inserting a new send channel
- // into |send_channels_|
- bool CreateSendChannelKey(uint32 local_ssrc, uint32* key);
+ bool DefaultSendChannelInUse();
+
+ // Returns the ssrc key corresponding to the provided local SSRC in
+ // |ssrc_key|. The return value is true upon success. If the local
+ // ssrc correspond to that of the default channel the key is
+ // kDefaultChannelSsrcKey.
+ // For all other channels the returned ssrc key will be the same as
+ // the local ssrc.
+ bool GetSendChannelSsrcKey(uint32 local_ssrc, uint32* ssrc_key);
+ WebRtcVideoChannelSendInfo* GetDefaultSendChannel();
+ WebRtcVideoChannelSendInfo* GetSendChannelBySsrcKey(uint32 ssrc_key);
+ WebRtcVideoChannelSendInfo* GetSendChannelBySsrc(uint32 local_ssrc);
+ // Creates a new unique ssrc key that can be used for inserting a
+ // new send channel into |send_channels_|
+ bool CreateSendChannelSsrcKey(uint32 local_ssrc, uint32* ssrc_key);
// Get the number of the send channels |capturer| registered with.
int GetSendChannelNum(VideoCapturer* capturer);
- bool IsDefaultChannel(int channel_id) const {
- return channel_id == vie_channel_;
+ bool IsDefaultChannelId(int channel_id) const {
+ return channel_id == default_channel_id_;
}
+ bool GetDefaultRenderer(VideoRenderer** renderer);
bool DeleteSendChannel(uint32 ssrc_key);
+ WebRtcVideoChannelRecvInfo* GetDefaultRecvChannel();
+ WebRtcVideoChannelRecvInfo* GetRecvChannelBySsrc(uint32 ssrc);
+
bool InConferenceMode() const {
return options_.conference_mode.GetWithDefaultIfUnset(false);
}
bool RemoveCapturer(uint32 ssrc);
-
- talk_base::MessageQueue* worker_thread() { return engine_->worker_thread(); }
+ rtc::MessageQueue* worker_thread() { return engine_->worker_thread(); }
void QueueBlackFrame(uint32 ssrc, int64 timestamp, int framerate);
void FlushBlackFrame(uint32 ssrc, int64 timestamp);
// Global state.
WebRtcVideoEngine* engine_;
VoiceMediaChannel* voice_channel_;
- int vie_channel_;
+ int default_channel_id_;
bool nack_enabled_;
// Receiver Estimated Max Bitrate
bool remb_enabled_;
VideoOptions options_;
// Global recv side state.
- // Note the default channel (vie_channel_), i.e. the send channel
+ // Note the default channel (default_channel_id_), i.e. the send channel
// corresponding to all the receive channels (this must be done for REMB to
// work properly), resides in both recv_channels_ and send_channels_ with the
- // ssrc key 0.
+ // ssrc key kDefaultChannelSsrcKey.
RecvChannelMap recv_channels_; // Contains all receive channels.
// A map from the SSRCs on which RTX packets are received to the media SSRCs
// the RTX packets are associated with. RTX packets will be delivered to the
// Global send side state.
SendChannelMap send_channels_;
- talk_base::scoped_ptr<webrtc::VideoCodec> send_codec_;
+ rtc::scoped_ptr<webrtc::VideoCodec> send_codec_;
int send_rtx_type_;
int send_red_type_;
int send_fec_type_;