Remove ViEShared inheritance for interface impl.

Review URL: https://webrtc-codereview.appspot.com/357002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1545 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2012-01-25 13:42:03 +00:00
parent f4b77fd722
commit b11424bc11
22 changed files with 1509 additions and 1169 deletions

View File

@ -42,145 +42,145 @@ ViEBase* ViEBase::GetInterface(VideoEngine* video_engine) {
}
int ViEBaseImpl::Release() {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_.instance_id(),
"ViEBase::Release()");
(*this)--; // Decrease ref count.
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_.instance_id(),
"ViEBase release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_.SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_.instance_id(),
"ViEBase reference count: %d", ref_count);
return ref_count;
}
ViEBaseImpl::ViEBaseImpl() {
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_.instance_id(),
"ViEBaseImpl::ViEBaseImpl() Ctor");
}
ViEBaseImpl::~ViEBaseImpl() {
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_.instance_id(),
"ViEBaseImpl::ViEBaseImpl() Dtor");
}
int ViEBaseImpl::Init() {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_.instance_id(),
"Init");
if (Initialized()) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, instance_id_,
if (shared_data_.Initialized()) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_.instance_id(),
"Init called twice");
return 0;
}
SetInitialized();
shared_data_.SetInitialized();
return 0;
}
int ViEBaseImpl::SetVoiceEngine(VoiceEngine* voice_engine) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s", __FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
if (channel_manager_.SetVoiceEngine(voice_engine) != 0) {
SetLastError(kViEBaseVoEFailure);
if (shared_data_.channel_manager()->SetVoiceEngine(voice_engine) != 0) {
shared_data_.SetLastError(kViEBaseVoEFailure);
return -1;
}
return 0;
}
int ViEBaseImpl::CreateChannel(int& video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s", __FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
if (channel_manager_.CreateChannel(video_channel) == -1) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (shared_data_.channel_manager()->CreateChannel(video_channel) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: Could not create channel", __FUNCTION__);
video_channel = -1;
SetLastError(kViEBaseChannelCreationFailed);
shared_data_.SetLastError(kViEBaseChannelCreationFailed);
return -1;
}
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: channel created: %d", __FUNCTION__, video_channel);
return 0;
}
int ViEBaseImpl::CreateChannel(int& video_channel, int original_channel) {
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
if (!cs.Channel(original_channel)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - original_channel does not exist.", __FUNCTION__,
instance_id_);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.instance_id());
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
if (channel_manager_.CreateChannel(video_channel,
if (shared_data_.channel_manager()->CreateChannel(video_channel,
original_channel) == -1) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: Could not create channel", __FUNCTION__);
video_channel = -1;
SetLastError(kViEBaseChannelCreationFailed);
shared_data_.SetLastError(kViEBaseChannelCreationFailed);
return -1;
}
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: channel created: %d", __FUNCTION__, video_channel);
return 0;
}
int ViEBaseImpl::DeleteChannel(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s(%d)", __FUNCTION__, video_channel);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
{
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_), "%s: channel %d doesn't exist",
__FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id()),
"%s: channel %d doesn't exist", __FUNCTION__, video_channel);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
// Deregister the ViEEncoder if no other channel is using it.
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (cs.ChannelUsingViEEncoder(video_channel) == false) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_.input_manager()));
ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder);
if (provider) {
provider->DeregisterFrameCallback(vie_encoder);
@ -188,90 +188,92 @@ int ViEBaseImpl::DeleteChannel(const int video_channel) {
}
}
if (channel_manager_.DeleteChannel(video_channel) == -1) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (shared_data_.channel_manager()->DeleteChannel(video_channel) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: Could not delete channel %d", __FUNCTION__,
video_channel);
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: channel deleted: %d", __FUNCTION__, video_channel);
return 0;
}
int ViEBaseImpl::ConnectAudioChannel(const int video_channel,
const int audio_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s(%d)", __FUNCTION__, video_channel);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
if (!cs.Channel(video_channel)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
if (channel_manager_.ConnectVoiceChannel(video_channel, audio_channel) != 0) {
SetLastError(kViEBaseVoEFailure);
if (shared_data_.channel_manager()->ConnectVoiceChannel(video_channel,
audio_channel) != 0) {
shared_data_.SetLastError(kViEBaseVoEFailure);
return -1;
}
return 0;
}
int ViEBaseImpl::DisconnectAudioChannel(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s(%d)", __FUNCTION__, video_channel);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
if (!(shared_data_.Initialized())) {
shared_data_.SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_.instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
if (!cs.Channel(video_channel)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s: channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
if (channel_manager_.DisconnectVoiceChannel(video_channel) != 0) {
SetLastError(kViEBaseVoEFailure);
if (shared_data_.channel_manager()->DisconnectVoiceChannel(
video_channel) != 0) {
shared_data_.SetLastError(kViEBaseVoEFailure);
return -1;
}
return 0;
}
int ViEBaseImpl::StartSend(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel), "%s(channel: %d)",
__FUNCTION__, video_channel);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Channel %d does not exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
assert(false);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Could not find encoder for channel %d", __FUNCTION__,
video_channel);
return -1;
@ -282,14 +284,14 @@ int ViEBaseImpl::StartSend(const int video_channel) {
WebRtc_Word32 error = vie_channel->StartSend();
if (error != 0) {
vie_encoder->Restart();
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Could not start sending on channel %d", __FUNCTION__,
video_channel);
if (error == kViEBaseAlreadySending) {
SetLastError(kViEBaseAlreadySending);
shared_data_.SetLastError(kViEBaseAlreadySending);
}
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
vie_encoder->SendKeyFrame();
@ -298,30 +300,30 @@ int ViEBaseImpl::StartSend(const int video_channel) {
}
int ViEBaseImpl::StopSend(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel), "%s(channel: %d)",
__FUNCTION__, video_channel);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Channel %d does not exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
WebRtc_Word32 error = vie_channel->StopSend();
if (error != 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Could not stop sending on channel %d", __FUNCTION__,
video_channel);
if (error == kViEBaseNotSending) {
SetLastError(kViEBaseNotSending);
shared_data_.SetLastError(kViEBaseNotSending);
} else {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
}
return -1;
}
@ -329,86 +331,86 @@ int ViEBaseImpl::StopSend(const int video_channel) {
}
int ViEBaseImpl::StartReceive(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel), "%s(channel: %d)",
__FUNCTION__, video_channel);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Channel %d does not exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
if (vie_channel->Receiving()) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Channel %d already receive.", __FUNCTION__,
video_channel);
SetLastError(kViEBaseAlreadyReceiving);
shared_data_.SetLastError(kViEBaseAlreadyReceiving);
return -1;
}
if (vie_channel->StartReceive() != 0) {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
return 0;
}
int ViEBaseImpl::StopReceive(const int video_channel) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel), "%s(channel: %d)",
__FUNCTION__, video_channel);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_.instance_id(), video_channel),
"%s: Channel %d does not exist", __FUNCTION__, video_channel);
SetLastError(kViEBaseInvalidChannelId);
shared_data_.SetLastError(kViEBaseInvalidChannelId);
return -1;
}
if (vie_channel->StopReceive() != 0) {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
return 0;
}
int ViEBaseImpl::RegisterObserver(ViEBaseObserver& observer) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s", __FUNCTION__);
if (vie_performance_monitor_.ViEBaseObserverRegistered()) {
SetLastError(kViEBaseObserverAlreadyRegistered);
if (shared_data_.vie_performance_monitor()->ViEBaseObserverRegistered()) {
shared_data_.SetLastError(kViEBaseObserverAlreadyRegistered);
return -1;
}
return vie_performance_monitor_.Init(&observer);
return shared_data_.vie_performance_monitor()->Init(&observer);
}
int ViEBaseImpl::DeregisterObserver() {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"%s", __FUNCTION__);
if (!vie_performance_monitor_.ViEBaseObserverRegistered()) {
SetLastError(kViEBaseObserverNotRegistered);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, instance_id_,
if (!shared_data_.vie_performance_monitor()->ViEBaseObserverRegistered()) {
shared_data_.SetLastError(kViEBaseObserverNotRegistered);
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_.instance_id(),
"%s No observer registered.", __FUNCTION__);
return -1;
}
vie_performance_monitor_.Terminate();
shared_data_.vie_performance_monitor()->Terminate();
return 0;
}
int ViEBaseImpl::GetVersion(char version[1024]) {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
"GetVersion(version=?)");
assert(kViEVersionMaxMessageSize == 1024);
if (!version) {
SetLastError(kViEBaseInvalidArgument);
shared_data_.SetLastError(kViEBaseInvalidArgument);
return -1;
}
@ -420,7 +422,7 @@ int ViEBaseImpl::GetVersion(char version[1024]) {
len = AddViEVersion(version_ptr);
if (len == -1) {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
version_ptr += len;
@ -429,7 +431,7 @@ int ViEBaseImpl::GetVersion(char version[1024]) {
len = AddBuildInfo(version_ptr);
if (len == -1) {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
version_ptr += len;
@ -438,7 +440,7 @@ int ViEBaseImpl::GetVersion(char version[1024]) {
len = AddExternalTransportBuild(version_ptr);
if (len == -1) {
SetLastError(kViEBaseUnknownError);
shared_data_.SetLastError(kViEBaseUnknownError);
return -1;
}
version_ptr += len;
@ -448,13 +450,14 @@ int ViEBaseImpl::GetVersion(char version[1024]) {
memcpy(version, version_buf, acc_len);
version[acc_len] = '\0';
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceVideo,
ViEId(instance_id_), "GetVersion() => %s", version);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo,
ViEId(shared_data_.instance_id()), "GetVersion() => %s",
version);
return 0;
}
int ViEBaseImpl::LastError() {
return LastErrorInternal();
return shared_data_.LastErrorInternal();
}
WebRtc_Word32 ViEBaseImpl::AddBuildInfo(char* str) const {

View File

@ -22,8 +22,7 @@ class Module;
class VoiceEngine;
class ViEBaseImpl
: public virtual ViESharedData,
public ViEBase,
: public ViEBase,
public ViERefCount {
public:
virtual int Release();
@ -70,7 +69,7 @@ class ViEBaseImpl
// Deregisters the observer.
virtual int DeregisterObserver();
// Prints version information into |verson|.
// Prints version information into |version|.
virtual int GetVersion(char version[1024]);
// Returns the error code for the last registered error.
@ -80,11 +79,16 @@ class ViEBaseImpl
ViEBaseImpl();
virtual ~ViEBaseImpl();
ViESharedData* shared_data() { return &shared_data_; }
private:
// Version functions.
WebRtc_Word32 AddViEVersion(char* str) const;
WebRtc_Word32 AddBuildInfo(char* str) const;
WebRtc_Word32 AddExternalTransportBuild(char* str) const;
// ViEBaseImpl owns ViESharedData used by all interface implementations.
ViESharedData shared_data_;
};
} // namespace webrtc

View File

@ -19,6 +19,7 @@
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_input_manager.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -38,44 +39,45 @@ ViECapture* ViECapture::GetInterface(VideoEngine* video_engine) {
}
int ViECaptureImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViECapture::Release()");
// Decrease ref count
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViECapture release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViECapture reference count: %d", ref_count);
return ref_count;
}
ViECaptureImpl::ViECaptureImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViECaptureImpl::ViECaptureImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViECaptureImpl::ViECaptureImpl() Ctor");
}
ViECaptureImpl::~ViECaptureImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViECaptureImpl::~ViECaptureImpl() Dtor");
}
int ViECaptureImpl::NumberOfCaptureDevices() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
return input_manager_.NumberOfCaptureDevices();
return shared_data_->input_manager()->NumberOfCaptureDevices();
}
@ -84,16 +86,16 @@ int ViECaptureImpl::GetCaptureDevice(unsigned int list_number,
unsigned int device_nameUTF8Length,
char* unique_idUTF8,
unsigned int unique_idUTF8Length) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(list_number: %d)", __FUNCTION__, list_number);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
return input_manager_.GetDeviceName(
return shared_data_->input_manager()->GetDeviceName(
list_number,
reinterpret_cast<WebRtc_UWord8*>(device_nameUTF8), device_nameUTF8Length,
reinterpret_cast<WebRtc_UWord8*>(unique_idUTF8), unique_idUTF8Length);
@ -103,20 +105,21 @@ int ViECaptureImpl::AllocateCaptureDevice(
const char* unique_idUTF8,
const unsigned int unique_idUTF8Length,
int& capture_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(unique_idUTF8: %s)", __FUNCTION__, unique_idUTF8);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
const WebRtc_Word32 result = input_manager_.CreateCaptureDevice(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8),
const WebRtc_Word32 result =
shared_data_->input_manager()->CreateCaptureDevice(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8),
static_cast<const WebRtc_UWord32>(unique_idUTF8Length), capture_id);
if (result != 0) {
SetLastError(result);
shared_data_->SetLastError(result);
return -1;
}
return 0;
@ -124,21 +127,22 @@ int ViECaptureImpl::AllocateCaptureDevice(
int ViECaptureImpl::AllocateExternalCaptureDevice(
int& capture_id, ViEExternalCapture*& external_capture) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
const WebRtc_Word32 result = input_manager_.CreateExternalCaptureDevice(
external_capture, capture_id);
const WebRtc_Word32 result =
shared_data_->input_manager()->CreateExternalCaptureDevice(
external_capture, capture_id);
if (result != 0) {
SetLastError(result);
shared_data_->SetLastError(result);
return -1;
}
return 0;
@ -146,20 +150,21 @@ int ViECaptureImpl::AllocateExternalCaptureDevice(
int ViECaptureImpl::AllocateCaptureDevice(VideoCaptureModule& capture_module,
int& capture_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
const WebRtc_Word32 result = input_manager_.CreateCaptureDevice(
capture_module, capture_id);
const WebRtc_Word32 result =
shared_data_->input_manager()->CreateCaptureDevice(capture_module,
capture_id);
if (result != 0) {
SetLastError(result);
shared_data_->SetLastError(result);
return -1;
}
return 0;
@ -167,55 +172,59 @@ int ViECaptureImpl::AllocateCaptureDevice(VideoCaptureModule& capture_module,
int ViECaptureImpl::ReleaseCaptureDevice(const int capture_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
{
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is((*(shared_data_->input_manager())));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
}
// Destroy the capture device.
return input_manager_.DestroyCaptureDevice(capture_id);
return shared_data_->input_manager()->DestroyCaptureDevice(capture_id);
}
int ViECaptureImpl::ConnectCaptureDevice(const int capture_id,
const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(capture_id: %d, video_channel: %d)", __FUNCTION__,
capture_id, video_channel);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__,
video_channel);
SetLastError(kViECaptureDeviceInvalidChannelId);
shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId);
return -1;
}
// Check if the encoder already has a connected frame provider
if (is.FrameProvider(vie_encoder) != NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d already connected to a capture device.",
__FUNCTION__, video_channel);
SetLastError(kViECaptureDeviceAlreadyConnected);
shared_data_->SetLastError(kViECaptureDeviceAlreadyConnected);
return -1;
}
VideoCodec codec;
@ -231,7 +240,7 @@ int ViECaptureImpl::ConnectCaptureDevice(const int capture_id,
// for callbacks.
if (!use_hardware_encoder &&
vie_capture->RegisterFrameCallback(video_channel, vie_encoder) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -239,39 +248,43 @@ int ViECaptureImpl::ConnectCaptureDevice(const int capture_id,
int ViECaptureImpl::DisconnectCaptureDevice(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__,
video_channel);
SetLastError(kViECaptureDeviceInvalidChannelId);
shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId);
return -1;
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* frame_provider = is.FrameProvider(vie_encoder);
if (!frame_provider) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s: No capture device connected to channel %d",
__FUNCTION__, video_channel);
SetLastError(kViECaptureDeviceNotConnected);
shared_data_->SetLastError(kViECaptureDeviceNotConnected);
return -1;
}
if (frame_provider->Id() < kViECaptureIdBase ||
frame_provider->Id() > kViECaptureIdMax) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s: No capture device connected to channel %d",
__FUNCTION__, video_channel);
SetLastError(kViECaptureDeviceNotConnected);
shared_data_->SetLastError(kViECaptureDeviceNotConnected);
return -1;
}
if (frame_provider->DeregisterFrameCallback(vie_encoder) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
@ -280,48 +293,50 @@ int ViECaptureImpl::DisconnectCaptureDevice(const int video_channel) {
int ViECaptureImpl::StartCapture(const int capture_id,
const CaptureCapability& capture_capability) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (vie_capture->Started()) {
SetLastError(kViECaptureDeviceAlreadyStarted);
shared_data_->SetLastError(kViECaptureDeviceAlreadyStarted);
return -1;
}
if (vie_capture->Start(capture_capability) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
}
int ViECaptureImpl::StopCapture(const int capture_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (!vie_capture->Started()) {
SetLastError(kViECaptureDeviceNotStarted);
shared_data_->SetLastError(kViECaptureDeviceNotStarted);
return -1;
}
if (vie_capture->Stop() != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
@ -346,20 +361,21 @@ int ViECaptureImpl::SetRotateCapturedFrames(
i_rotation = 270;
break;
}
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(rotation: %d)", __FUNCTION__, i_rotation);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (vie_capture->SetRotateCapturedFrames(rotation) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -367,22 +383,23 @@ int ViECaptureImpl::SetRotateCapturedFrames(
int ViECaptureImpl::SetCaptureDelay(const int capture_id,
const unsigned int capture_delay_ms) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d, capture_delay_ms %u)", __FUNCTION__,
capture_id, capture_delay_ms);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (vie_capture->SetCaptureDelay(capture_delay_ms) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -391,7 +408,7 @@ int ViECaptureImpl::SetCaptureDelay(const int capture_id,
int ViECaptureImpl::NumberOfCapabilities(
const char* unique_idUTF8,
const unsigned int unique_idUTF8Length) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_device_name: %s)", __FUNCTION__, unique_idUTF8);
#if defined(WEBRTC_MAC_INTEL)
@ -399,21 +416,21 @@ int ViECaptureImpl::NumberOfCapabilities(
// QTKit framework handles all capabilities and capture settings
// automatically (mandatory).
// Thus this function cannot be supported on the Mac platform.
SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s This API is not supported on Mac OS", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
#endif
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
return input_manager_.NumberOfCaptureCapabilities(
return shared_data_->input_manager()->NumberOfCaptureCapabilities(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8));
}
@ -422,7 +439,7 @@ int ViECaptureImpl::GetCaptureCapability(const char* unique_idUTF8,
const unsigned int unique_idUTF8Length,
const unsigned int capability_number,
CaptureCapability& capability) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_device_name: %s)", __FUNCTION__, unique_idUTF8);
#if defined(WEBRTC_MAC_INTEL)
@ -430,23 +447,23 @@ int ViECaptureImpl::GetCaptureCapability(const char* unique_idUTF8,
// QTKit framework handles all capabilities and capture settings
// automatically (mandatory).
// Thus this function cannot be supported on the Mac platform.
SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s This API is not supported on Mac OS", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
#endif
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
if (input_manager_.GetCaptureCapability(
if (shared_data_->input_manager()->GetCaptureCapability(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8),
capability_number, capability) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -464,17 +481,17 @@ int ViECaptureImpl::ShowCaptureSettingsDialogBox(
// QTKit framework handles all capabilities and capture settings
// automatically (mandatory).
// Thus this function cannot be supported on the Mac platform.
SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s This API is not supported on Mac OS", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
#endif
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s capture_id (capture_device_name: %s)", __FUNCTION__,
unique_idUTF8);
return input_manager_.DisplayCaptureSettingsDialogBox(
return shared_data_->input_manager()->DisplayCaptureSettingsDialogBox(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8),
reinterpret_cast<const WebRtc_UWord8*>(dialog_title),
parent_window, x, y);
@ -482,20 +499,20 @@ int ViECaptureImpl::ShowCaptureSettingsDialogBox(
int ViECaptureImpl::GetOrientation(const char* unique_idUTF8,
RotateCapturedFrame& orientation) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s (capture_device_name: %s)", __FUNCTION__, unique_idUTF8);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
if (input_manager_.GetOrientation(
if (shared_data_->input_manager()->GetOrientation(
reinterpret_cast<const WebRtc_UWord8*>(unique_idUTF8),
orientation) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -504,17 +521,18 @@ int ViECaptureImpl::GetOrientation(const char* unique_idUTF8,
int ViECaptureImpl::EnableBrightnessAlarm(const int capture_id,
const bool enable) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (vie_capture->EnableBrightnessAlarm(enable) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
@ -522,45 +540,48 @@ int ViECaptureImpl::EnableBrightnessAlarm(const int capture_id,
int ViECaptureImpl::RegisterObserver(const int capture_id,
ViECaptureObserver& observer) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (vie_capture->IsObserverRegistered()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Observer already registered", __FUNCTION__);
SetLastError(kViECaptureObserverAlreadyRegistered);
shared_data_->SetLastError(kViECaptureObserverAlreadyRegistered);
return -1;
}
if (vie_capture->RegisterObserver(observer) != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;
}
int ViECaptureImpl::DeregisterObserver(const int capture_id) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViECaptureDeviceDoesNotExist);
shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (!vie_capture->IsObserverRegistered()) {
SetLastError(kViECaptureDeviceObserverNotRegistered);
shared_data_->SetLastError(kViECaptureDeviceObserverNotRegistered);
return -1;
}
if (vie_capture->DeRegisterObserver() != 0) {
SetLastError(kViECaptureDeviceUnknownError);
shared_data_->SetLastError(kViECaptureDeviceUnknownError);
return -1;
}
return 0;

View File

@ -15,13 +15,13 @@
#include "video_engine/include/vie_capture.h"
#include "video_engine/vie_defines.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViECaptureImpl
: public virtual ViESharedData,
public ViECapture,
: public ViECapture,
public ViERefCount {
public:
// Implements ViECapture.
@ -69,8 +69,11 @@ class ViECaptureImpl
virtual int DeregisterObserver(const int capture_id);
protected:
ViECaptureImpl();
ViECaptureImpl(ViESharedData* shared_data);
virtual ~ViECaptureImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -21,6 +21,7 @@
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_input_manager.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -40,43 +41,44 @@ ViECodec* ViECodec::GetInterface(VideoEngine* video_engine) {
}
int ViECodecImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViECodecImpl::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViECodec released too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViECodec reference count: %d", ref_count);
return ref_count;
}
ViECodecImpl::ViECodecImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViECodecImpl::ViECodecImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViECodecImpl::ViECodecImpl() Ctor");
}
ViECodecImpl::~ViECodecImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViECodecImpl::~ViECodecImpl() Dtor");
}
int ViECodecImpl::NumberOfCodecs() const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
// +2 because of FEC(RED and ULPFEC)
return static_cast<int>((VideoCodingModule::NumberOfCodecs() + 2));
}
int ViECodecImpl::GetCodec(const unsigned char list_number,
VideoCodec& video_codec) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(list_number: %d, codec_type: %d)", __FUNCTION__,
list_number, video_codec.codecType);
if (list_number == VideoCodingModule::NumberOfCodecs()) {
@ -90,10 +92,10 @@ int ViECodecImpl::GetCodec(const unsigned char list_number,
video_codec.codecType = kVideoCodecULPFEC;
video_codec.plType = VCM_ULPFEC_PAYLOAD_TYPE;
} else if (VideoCodingModule::Codec(list_number, &video_codec) != VCM_OK) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Could not get codec for list_number: %u", __FUNCTION__,
list_number);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
return 0;
@ -101,10 +103,12 @@ int ViECodecImpl::GetCodec(const unsigned char list_number,
int ViECodecImpl::SetSendCodec(const int video_channel,
const VideoCodec& video_codec) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(),video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
video_channel, video_codec.codecType);
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: codec: %d, pl_type: %d, width: %d, height: %d, bitrate: %d"
"maxBr: %d, min_br: %d, frame_rate: %d, qpMax: %u,"
"numberOfSimulcastStreams: %u )", __FUNCTION__,
@ -114,7 +118,8 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
video_codec.maxFramerate, video_codec.qpMax,
video_codec.numberOfSimulcastStreams);
if (video_codec.codecType == kVideoCodecVP8) {
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"pictureLossIndicationOn: %d, feedbackModeOn: %d, "
"complexity: %d, resilience: %d, numberOfTemporalLayers: %u",
video_codec.codecSpecific.VP8.pictureLossIndicationOn,
@ -125,16 +130,17 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
}
if (!CodecValid(video_codec)) {
// Error logged.
SetLastError(kViECodecInvalidCodec);
shared_data_->SetLastError(kViECodecInvalidCodec);
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
@ -151,7 +157,8 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
// Don't limit the set start bitrate.
video_codec_internal.maxBitrate = video_codec_internal.startBitrate;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: New max bitrate set to %d kbps", __FUNCTION__,
video_codec_internal.maxBitrate);
}
@ -159,9 +166,10 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
assert(false);
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder found for channel %d", __FUNCTION__);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
@ -170,10 +178,11 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
if (encoder.codecType != video_codec_internal.codecType &&
cs.ChannelUsingViEEncoder(video_channel)) {
// We don't allow changing codec type when several channels share encoder.
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Settings differs from other channels using encoder",
__FUNCTION__);
SetLastError(kViECodecInUse);
shared_data_->SetLastError(kViECodecInUse);
return -1;
}
// Make sure to generate a new SSRC if the codec type and/or resolution has
@ -187,15 +196,16 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
if (video_codec_internal.numberOfSimulcastStreams > 1) {
if (cs.ChannelUsingViEEncoder(video_channel)) {
// We don't allow simulcast channels to share encoder.
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Can't share simulcast encoder",
__FUNCTION__);
SetLastError(kViECodecInUse);
shared_data_->SetLastError(kViECodecInUse);
return -1;
}
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* frame_provider = NULL;
// Stop the media flow while reconfiguring.
@ -223,10 +233,11 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
// of this codec.
if (!use_capture_device_as_encoder &&
vie_encoder->SetEncoder(video_codec_internal) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not change encoder for channel %d", __FUNCTION__,
video_channel);
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
@ -237,13 +248,14 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
++it) {
bool ret = true;
if ((*it)->SetSendCodec(video_codec_internal, new_rtp_stream) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not set send codec for channel %d", __FUNCTION__,
video_channel);
ret = false;
}
if (!ret) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
}
@ -266,15 +278,17 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
int ViECodecImpl::GetSendCodec(const int video_channel,
VideoCodec& video_codec) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder for channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
return vie_encoder->GetEncoder(video_codec);
@ -282,10 +296,12 @@ int ViECodecImpl::GetSendCodec(const int video_channel,
int ViECodecImpl::SetReceiveCodec(const int video_channel,
const VideoCodec& video_codec) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
video_channel, video_codec.codecType);
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: codec: %d, pl_type: %d, width: %d, height: %d, bitrate: %d,"
"maxBr: %d, min_br: %d, frame_rate: %d", __FUNCTION__,
video_codec.codecType, video_codec.plType, video_codec.width,
@ -295,24 +311,26 @@ int ViECodecImpl::SetReceiveCodec(const int video_channel,
if (CodecValid(video_codec) == false) {
// Error logged.
SetLastError(kViECodecInvalidCodec);
shared_data_->SetLastError(kViECodecInvalidCodec);
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->SetReceiveCodec(video_codec) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not set receive codec for channel %d",
__FUNCTION__, video_channel);
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -320,21 +338,23 @@ int ViECodecImpl::SetReceiveCodec(const int video_channel,
int ViECodecImpl::GetReceiveCodec(const int video_channel,
VideoCodec& video_codec) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
video_channel, video_codec.codecType);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->GetReceiveCodec(video_codec) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -344,21 +364,23 @@ int ViECodecImpl::GetCodecConfigParameters(
const int video_channel,
unsigned char config_parameters[kConfigParameterSize],
unsigned char& config_parameters_size) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder for channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->GetCodecConfigParameters(config_parameters,
config_parameters_size) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -366,21 +388,23 @@ int ViECodecImpl::GetCodecConfigParameters(
int ViECodecImpl::SetImageScaleStatus(const int video_channel,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, enable: %d)", __FUNCTION__, video_channel,
enable);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->ScaleInputImage(enable) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -389,21 +413,23 @@ int ViECodecImpl::SetImageScaleStatus(const int video_channel,
int ViECodecImpl::GetSendCodecStastistics(const int video_channel,
unsigned int& key_frames,
unsigned int& delta_frames) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No send codec for channel %d", __FUNCTION__,
video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->SendCodecStatistics(key_frames, delta_frames) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -412,36 +438,40 @@ int ViECodecImpl::GetSendCodecStastistics(const int video_channel,
int ViECodecImpl::GetReceiveCodecStastistics(const int video_channel,
unsigned int& key_frames,
unsigned int& delta_frames) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->ReceiveCodecStatistics(key_frames, delta_frames) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
}
unsigned int ViECodecImpl::GetDiscardedPackets(const int video_channel) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
return vie_channel->DiscardedPackets();
@ -449,19 +479,21 @@ unsigned int ViECodecImpl::GetDiscardedPackets(const int video_channel) const {
int ViECodecImpl::SetKeyFrameRequestCallbackStatus(const int video_channel,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->EnableKeyFrameRequestCallback(enable) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -470,20 +502,22 @@ int ViECodecImpl::SetKeyFrameRequestCallbackStatus(const int video_channel,
int ViECodecImpl::SetSignalKeyPacketLossStatus(const int video_channel,
const bool enable,
const bool only_key_frames) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, enable: %d, only_key_frames: %d)",
__FUNCTION__, video_channel, enable);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->SetSignalPacketLossStatus(enable, only_key_frames) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -491,41 +525,44 @@ int ViECodecImpl::SetSignalKeyPacketLossStatus(const int video_channel,
int ViECodecImpl::RegisterEncoderObserver(const int video_channel,
ViEEncoderObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder for channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->RegisterCodecObserver(&observer) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not register codec observer at channel",
__FUNCTION__);
SetLastError(kViECodecObserverAlreadyRegistered);
shared_data_->SetLastError(kViECodecObserverAlreadyRegistered);
return -1;
}
return 0;
}
int ViECodecImpl::DeregisterEncoderObserver(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No encoder for channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->RegisterCodecObserver(NULL) != 0) {
SetLastError(kViECodecObserverNotRegistered);
shared_data_->SetLastError(kViECodecObserverNotRegistered);
return -1;
}
return 0;
@ -533,60 +570,65 @@ int ViECodecImpl::DeregisterEncoderObserver(const int video_channel) {
int ViECodecImpl::RegisterDecoderObserver(const int video_channel,
ViEDecoderObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->RegisterCodecObserver(&observer) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not register codec observer at channel",
__FUNCTION__);
SetLastError(kViECodecObserverAlreadyRegistered);
shared_data_->SetLastError(kViECodecObserverAlreadyRegistered);
return -1;
}
return 0;
}
int ViECodecImpl::DeregisterDecoderObserver(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id()), "%s",
__FUNCTION__);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->RegisterCodecObserver(NULL) != 0) {
SetLastError(kViECodecObserverNotRegistered);
shared_data_->SetLastError(kViECodecObserverNotRegistered);
return -1;
}
return 0;
}
int ViECodecImpl::SendKeyFrame(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_encoder->SendKeyFrame() != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -594,20 +636,22 @@ int ViECodecImpl::SendKeyFrame(const int video_channel) {
int ViECodecImpl::WaitForFirstKeyFrame(const int video_channel,
const bool wait) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s(video_channel: %d, wait: %d)", __FUNCTION__, video_channel,
wait);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViECodecInvalidChannelId);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
if (vie_channel->WaitForKeyFrame(wait) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;

View File

@ -15,13 +15,13 @@
#include "video_engine/include/vie_codec.h"
#include "video_engine/vie_defines.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViECodecImpl
: public virtual ViESharedData,
public ViECodec,
: public ViECodec,
public ViERefCount {
public:
virtual int Release();
@ -65,11 +65,13 @@ class ViECodecImpl
virtual int WaitForFirstKeyFrame(const int video_channel, const bool wait);
protected:
ViECodecImpl();
ViECodecImpl(ViESharedData* shared_data);
virtual ~ViECodecImpl();
private:
bool CodecValid(const VideoCodec& video_codec);
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -16,6 +16,7 @@
#include "video_engine/vie_channel_manager.h"
#include "video_engine/vie_defines.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -35,69 +36,73 @@ ViEEncryption* ViEEncryption::GetInterface(VideoEngine* video_engine) {
}
int ViEEncryptionImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViEEncryptionImpl::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViEEncryptionImpl release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViEEncryptionImpl reference count: %d", ref_count);
return ref_count;
}
ViEEncryptionImpl::ViEEncryptionImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViEEncryptionImpl::ViEEncryptionImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEEncryptionImpl::ViEEncryptionImpl() Ctor");
}
ViEEncryptionImpl::~ViEEncryptionImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEEncryptionImpl::~ViEEncryptionImpl() Dtor");
}
int ViEEncryptionImpl::RegisterExternalEncryption(const int video_channel,
Encryption& encryption) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"RegisterExternalEncryption(video_channel=%d)", video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (vie_channel == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, video_channel), "%s: No channel %d",
__FUNCTION__, video_channel);
SetLastError(kViEEncryptionInvalidChannelId);
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
shared_data_->SetLastError(kViEEncryptionInvalidChannelId);
return -1;
}
if (vie_channel->RegisterExternalEncryption(&encryption) != 0) {
SetLastError(kViEEncryptionUnknownError);
shared_data_->SetLastError(kViEEncryptionUnknownError);
return -1;
}
return 0;
}
int ViEEncryptionImpl::DeregisterExternalEncryption(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"RegisterExternalEncryption(video_channel=%d)", video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (vie_channel == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
SetLastError(kViEEncryptionInvalidChannelId);
shared_data_->SetLastError(kViEEncryptionInvalidChannelId);
return -1;
}
if (vie_channel->DeRegisterExternalEncryption() != 0) {
SetLastError(kViEEncryptionUnknownError);
shared_data_->SetLastError(kViEEncryptionUnknownError);
return -1;
}
return 0;

View File

@ -14,13 +14,13 @@
#include "typedefs.h"
#include "video_engine/include/vie_encryption.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViEEncryptionImpl
: public virtual ViESharedData,
public ViEEncryption,
: public ViEEncryption,
public ViERefCount {
public:
virtual int Release();
@ -31,8 +31,11 @@ class ViEEncryptionImpl
virtual int DeregisterExternalEncryption(const int video_channel);
protected:
ViEEncryptionImpl();
ViEEncryptionImpl(ViESharedData* shared_data);
virtual ~ViEEncryptionImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -17,6 +17,7 @@
#include "video_engine/vie_channel_manager.h"
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -36,48 +37,61 @@ ViEExternalCodec* ViEExternalCodec::GetInterface(VideoEngine* video_engine) {
}
int ViEExternalCodecImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViEExternalCodec::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViEExternalCodec release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViEExternalCodec reference count: %d", ref_count);
return ref_count;
}
ViEExternalCodecImpl::ViEExternalCodecImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEExternalCodecImpl::ViEExternalCodecImpl() Ctor");
}
ViEExternalCodecImpl::~ViEExternalCodecImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEExternalCodecImpl::~ViEExternalCodecImpl() Dtor");
}
int ViEExternalCodecImpl::RegisterExternalSendCodec(const int video_channel,
const unsigned char pl_type,
VideoEncoder* encoder) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s channel %d pl_type %d encoder 0x%x", __FUNCTION__,
video_channel, pl_type, encoder);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument video_channel %u. Does it exist?",
__FUNCTION__, video_channel);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (!encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument Encoder 0x%x.", __FUNCTION__, encoder);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (vie_encoder->RegisterExternalEncoder(encoder, pl_type) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -85,22 +99,23 @@ int ViEExternalCodecImpl::RegisterExternalSendCodec(const int video_channel,
int ViEExternalCodecImpl::DeRegisterExternalSendCodec(
const int video_channel, const unsigned char pl_type) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s channel %d pl_type %d", __FUNCTION__, video_channel,
pl_type);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument video_channel %u. Does it exist?",
__FUNCTION__, video_channel);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (vie_encoder->DeRegisterExternalEncoder(pl_type) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -112,30 +127,32 @@ int ViEExternalCodecImpl::RegisterExternalReceiveCodec(
VideoDecoder* decoder,
bool decoder_render,
int render_delay) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s channel %d pl_type %d decoder 0x%x, decoder_render %d, "
"renderDelay %d", __FUNCTION__, video_channel, pl_type, decoder,
decoder_render, render_delay);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument video_channel %u. Does it exist?",
__FUNCTION__, video_channel);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (!decoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument decoder 0x%x.", __FUNCTION__, decoder);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (vie_channel->RegisterExternalDecoder(pl_type, decoder, decoder_render,
render_delay) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;
@ -143,21 +160,22 @@ int ViEExternalCodecImpl::RegisterExternalReceiveCodec(
int ViEExternalCodecImpl::DeRegisterExternalReceiveCodec(
const int video_channel, const unsigned char pl_type) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s channel %d pl_type %u", __FUNCTION__, video_channel,
pl_type);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Invalid argument video_channel %u. Does it exist?",
__FUNCTION__, video_channel);
SetLastError(kViECodecInvalidArgument);
shared_data_->SetLastError(kViECodecInvalidArgument);
return -1;
}
if (vie_channel->DeRegisterExternalDecoder(pl_type) != 0) {
SetLastError(kViECodecUnknownError);
shared_data_->SetLastError(kViECodecUnknownError);
return -1;
}
return 0;

View File

@ -13,13 +13,13 @@
#include "video_engine/include/vie_external_codec.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViEExternalCodecImpl
: public virtual ViESharedData,
public ViEExternalCodec,
: public ViEExternalCodec,
public ViERefCount {
public:
// Implements ViEExternalCodec.
@ -36,6 +36,13 @@ class ViEExternalCodecImpl
int render_delay = 0);
virtual int DeRegisterExternalReceiveCodec(const int video_channel,
const unsigned char pl_type);
protected:
ViEExternalCodecImpl(ViESharedData* shared_data);
virtual ~ViEExternalCodecImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -52,29 +52,30 @@ ViEFile* ViEFile::GetInterface(VideoEngine* video_engine) {
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
int ViEFileImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViEFile::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViEFile release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViEFile reference count: %d", ref_count);
return ref_count;
}
ViEFileImpl::ViEFileImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViEFileImpl::ViEFileImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEFileImpl::ViEFileImpl() Ctor");
}
ViEFileImpl::~ViEFileImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEFileImpl::~ViEFileImpl() Dtor");
}
@ -82,175 +83,181 @@ int ViEFileImpl::StartPlayFile(const char* file_nameUTF8,
int& file_id,
const bool loop,
const FileFormats file_format) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), "%s",
__FUNCTION__);
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s", __FUNCTION__);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
VoiceEngine* voice = channel_manager_.GetVoiceEngine();
const WebRtc_Word32 result = input_manager_.CreateFilePlayer(file_nameUTF8,
loop,
file_format,
voice, file_id);
VoiceEngine* voice = shared_data_->channel_manager()->GetVoiceEngine();
const WebRtc_Word32 result = shared_data_->input_manager()->CreateFilePlayer(
file_nameUTF8, loop, file_format, voice, file_id);
if (result != 0) {
SetLastError(result);
shared_data_->SetLastError(result);
return -1;
}
return 0;
}
int ViEFileImpl::StopPlayFile(const int file_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(file_id: %d)", __FUNCTION__, file_id);
{
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
}
// Destroy the capture device.
return input_manager_.DestroyFilePlayer(file_id);
return shared_data_->input_manager()->DestroyFilePlayer(file_id);
}
int ViEFileImpl::RegisterObserver(int file_id, ViEFileObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(file_id: %d)", __FUNCTION__, file_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->IsObserverRegistered()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, file_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), file_id),
"%s: Observer already registered", __FUNCTION__);
SetLastError(kViEFileObserverAlreadyRegistered);
shared_data_->SetLastError(kViEFileObserverAlreadyRegistered);
return -1;
}
if (vie_file_player->RegisterObserver(observer) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, file_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), file_id),
"%s: Failed to register observer", __FUNCTION__, file_id);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
return 0;
}
int ViEFileImpl::DeregisterObserver(int file_id, ViEFileObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(file_id: %d)", __FUNCTION__, file_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (!vie_file_player->IsObserverRegistered()) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, file_id), "%s: No Observer registered",
__FUNCTION__);
SetLastError(kViEFileObserverNotRegistered);
ViEId(shared_data_->instance_id(), file_id),
"%s: No Observer registered", __FUNCTION__);
shared_data_->SetLastError(kViEFileObserverNotRegistered);
return -1;
}
if (vie_file_player->DeRegisterObserver() != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, file_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), file_id),
"%s: Failed to deregister observer", __FUNCTION__, file_id);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
return 0;
}
int ViEFileImpl::SendFileOnChannel(const int file_id, const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(file_id: %d)", __FUNCTION__, file_id);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
if (is.FrameProvider(vie_encoder) != NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d already connected to a capture device or "
"file.", __FUNCTION__, video_channel);
SetLastError(kViEFileInputAlreadyConnected);
shared_data_->SetLastError(kViEFileInputAlreadyConnected);
return -1;
}
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->RegisterFrameCallback(video_channel, vie_encoder)
!= 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Failed to register frame callback.", __FUNCTION__,
file_id);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
return 0;
}
int ViEFileImpl::StopSendFileOnChannel(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* frame_provider = is.FrameProvider(vie_encoder);
if (!frame_provider ||
frame_provider->Id() < kViEFileIdBase ||
frame_provider->Id() > kViEFileIdMax) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No file connected to Channel %d", __FUNCTION__,
video_channel);
SetLastError(kViEFileNotConnected);
shared_data_->SetLastError(kViEFileNotConnected);
return -1;
}
if (frame_provider->DeregisterFrameCallback(vie_encoder) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Failed to deregister file from channel %d",
__FUNCTION__, video_channel);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
}
return 0;
}
@ -259,39 +266,39 @@ int ViEFileImpl::StartPlayFileAsMicrophone(const int file_id,
const int audio_channel,
bool mix_microphone,
float volume_scaling) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->SendAudioOnChannel(audio_channel, mix_microphone,
volume_scaling) != 0) {
SetLastError(kViEFileVoEFailure);
shared_data_->SetLastError(kViEFileVoEFailure);
return -1;
}
return 0;
}
int ViEFileImpl::StopPlayFileAsMicrophone(const int file_id,
const int audio_channel) {
ViEInputManagerScoped is(input_manager_);
const int audio_channel) {
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->StopSendAudioOnChannel(audio_channel) != 0) {
SetLastError(kViEFileVoEFailure);
shared_data_->SetLastError(kViEFileVoEFailure);
return -1;
}
return 0;
@ -300,18 +307,18 @@ const int audio_channel) {
int ViEFileImpl::StartPlayAudioLocally(const int file_id,
const int audio_channel,
float volume_scaling) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->PlayAudioLocally(audio_channel, volume_scaling) != 0) {
SetLastError(kViEFileVoEFailure);
shared_data_->SetLastError(kViEFileVoEFailure);
return -1;
}
return 0;
@ -319,18 +326,18 @@ int ViEFileImpl::StartPlayAudioLocally(const int file_id,
int ViEFileImpl::StopPlayAudioLocally(const int file_id,
const int audio_channel) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFilePlayer* vie_file_player = is.FilePlayer(file_id);
if (!vie_file_player) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: File with id %d is not playing.", __FUNCTION__,
file_id);
SetLastError(kViEFileNotPlaying);
shared_data_->SetLastError(kViEFileNotPlaying);
return -1;
}
if (vie_file_player->StopPlayAudioLocally(audio_channel) != 0) {
SetLastError(kViEFileVoEFailure);
shared_data_->SetLastError(kViEFileVoEFailure);
return -1;
}
return 0;
@ -342,23 +349,26 @@ int ViEFileImpl::StartRecordOutgoingVideo(const int video_channel,
const CodecInst& audio_codec,
const VideoCodec& video_codec,
const FileFormats file_format) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEFileRecorder& file_recorder = vie_encoder->GetOutgoingFileRecorder();
if (file_recorder.RecordingStarted()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Already recording outgoing video on channel %d",
__FUNCTION__, video_channel);
SetLastError(kViEFileAlreadyRecording);
shared_data_->SetLastError(kViEFileAlreadyRecording);
return -1;
}
@ -369,22 +379,24 @@ int ViEFileImpl::StartRecordOutgoingVideo(const int video_channel,
// Channel should exists since we have a ViEEncoder.
assert(vie_channel);
ve_channel_id = vie_channel->VoiceChannel();
ve_ptr = channel_manager_.GetVoiceEngine();
ve_ptr = shared_data_->channel_manager()->GetVoiceEngine();
if (!ve_ptr) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Can't access voice engine. Have SetVoiceEngine "
"been called?", __FUNCTION__);
SetLastError(kViEFileVoENotSet);
shared_data_->SetLastError(kViEFileVoENotSet);
return -1;
}
}
if (file_recorder.StartRecording(file_nameUTF8, video_codec, audio_source,
ve_channel_id, audio_codec, ve_ptr,
file_format) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Failed to start recording. Check arguments.",
__FUNCTION__);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
@ -393,61 +405,68 @@ int ViEFileImpl::StartRecordOutgoingVideo(const int video_channel,
int ViEFileImpl::StopRecordOutgoingVideo(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(instance_id_, video_channel), "%s video_channel: %d)",
__FUNCTION__, video_channel);
ViEId(shared_data_->instance_id(), video_channel),
"%s video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEFileRecorder& file_recorder = vie_encoder->GetOutgoingFileRecorder();
if (!file_recorder.RecordingStarted()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d is not recording.", __FUNCTION__,
video_channel);
SetLastError(kViEFileNotRecording);
shared_data_->SetLastError(kViEFileNotRecording);
return -1;
}
if (file_recorder.StopRecording() != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Failed to stop recording of channel %d.", __FUNCTION__,
video_channel);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
return 0;
}
int ViEFileImpl::StopRecordIncomingVideo(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEFileRecorder& file_recorder = vie_channel->GetIncomingFileRecorder();
if (!file_recorder.RecordingStarted()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d is not recording.", __FUNCTION__,
video_channel);
SetLastError(kViEFileNotRecording);
shared_data_->SetLastError(kViEFileNotRecording);
vie_channel->ReleaseIncomingFileRecorder();
return -1;
}
if (file_recorder.StopRecording() != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Failed to stop recording of channel %d.",
__FUNCTION__, video_channel);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
vie_channel->ReleaseIncomingFileRecorder();
return -1;
}
@ -462,24 +481,27 @@ int ViEFileImpl::StartRecordIncomingVideo(const int video_channel,
const CodecInst& audio_codec,
const VideoCodec& video_codec,
const FileFormats file_format) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__,
video_channel);
SetLastError(kViEFileInvalidChannelId);
shared_data_->SetLastError(kViEFileInvalidChannelId);
return -1;
}
ViEFileRecorder& file_recorder = vie_channel->GetIncomingFileRecorder();
if (file_recorder.RecordingStarted()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Already recording outgoing video on channel %d",
__FUNCTION__, video_channel);
SetLastError(kViEFileAlreadyRecording);
shared_data_->SetLastError(kViEFileAlreadyRecording);
return -1;
}
@ -487,23 +509,25 @@ int ViEFileImpl::StartRecordIncomingVideo(const int video_channel,
VoiceEngine* ve_ptr = NULL;
if (audio_source != NO_AUDIO) {
ve_channel_id = vie_channel->VoiceChannel();
ve_ptr = channel_manager_.GetVoiceEngine();
ve_ptr = shared_data_->channel_manager()->GetVoiceEngine();
if (!ve_ptr) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Can't access voice engine. Have SetVoiceEngine "
"been called?", __FUNCTION__);
SetLastError(kViEFileVoENotSet);
shared_data_->SetLastError(kViEFileVoENotSet);
return -1;
}
}
if (file_recorder.StartRecording(file_nameUTF8, video_codec, audio_source,
ve_channel_id, audio_codec, ve_ptr,
file_format) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Failed to start recording. Check arguments.",
__FUNCTION__);
SetLastError(kViEFileUnknownError);
shared_data_->SetLastError(kViEFileUnknownError);
return -1;
}
return 0;
@ -514,7 +538,8 @@ int ViEFileImpl::GetFileInformation(const char* file_name,
CodecInst& audio_codec,
const FileFormats file_format) {
return ViEFilePlayer::GetFileInformation(
instance_id_, static_cast<const WebRtc_Word8*>(file_name),
shared_data_->instance_id(),
static_cast<const WebRtc_Word8*>(file_name),
video_codec, audio_codec, file_format);
}
@ -522,7 +547,7 @@ int ViEFileImpl::GetRenderSnapshot(const int video_channel,
const char* file_nameUTF8) {
// Gain access to the renderer for the specified channel and get it's
// current frame.
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
return -1;
@ -539,7 +564,7 @@ int ViEFileImpl::GetRenderSnapshot(const int video_channel,
JpegEncoder jpeg_encoder;
RawImage input_image;
if (jpeg_encoder.SetFileName(file_nameUTF8) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"\tCould not open output file '%s' for writing!",
file_nameUTF8);
return -1;
@ -551,7 +576,7 @@ int ViEFileImpl::GetRenderSnapshot(const int video_channel,
input_image._size);
if (jpeg_encoder.Encode(input_image) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"\tCould not encode i420 -> jpeg file '%s' for writing!",
file_nameUTF8);
if (input_image._buffer) {
@ -569,7 +594,7 @@ int ViEFileImpl::GetRenderSnapshot(const int video_channel,
ViEPicture& picture) {
// Gain access to the renderer for the specified channel and get it's
// current frame.
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
return -1;
@ -595,7 +620,7 @@ int ViEFileImpl::GetRenderSnapshot(const int video_channel,
int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
const char* file_nameUTF8) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* capturer = is.Capture(capture_id);
if (!capturer) {
return -1;
@ -603,7 +628,7 @@ int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
VideoFrame video_frame;
if (GetNextCapturedFrame(capture_id, video_frame) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"Could not gain acces to capture device %d video frame "
"%s:%d", capture_id, __FUNCTION__);
return -1;
@ -620,7 +645,7 @@ int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
input_image._size);
if (jpeg_encoder.SetFileName(file_nameUTF8) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"\tCould not open output file '%s' for writing!",
file_nameUTF8);
@ -630,7 +655,7 @@ int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
return -1;
}
if (jpeg_encoder.Encode(input_image) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"\tCould not encode i420 -> jpeg file '%s' for "
"writing!", file_nameUTF8);
if (input_image._buffer) {
@ -646,13 +671,13 @@ int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
int ViEFileImpl::GetCaptureDeviceSnapshot(const int capture_id,
ViEPicture& picture) {
VideoFrame video_frame;
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* capturer = is.Capture(capture_id);
if (!capturer) {
return -1;
}
if (GetNextCapturedFrame(capture_id, video_frame) == -1) {
WEBRTC_TRACE(kTraceError, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_->instance_id(),
"Could not gain acces to capture device %d video frame "
"%s:%d", capture_id, __FUNCTION__);
return -1;
@ -685,28 +710,29 @@ int ViEFileImpl::FreePicture(ViEPicture& picture) {
}
int ViEFileImpl::SetCaptureDeviceImage(const int capture_id,
const char* file_nameUTF8) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* capturer = is.Capture(capture_id);
if (!capturer) {
SetLastError(kViEFileInvalidCaptureId);
shared_data_->SetLastError(kViEFileInvalidCaptureId);
return -1;
}
VideoFrame capture_image;
if (ViEFileImage::ConvertJPEGToVideoFrame(
ViEId(instance_id_, capture_id), file_nameUTF8, capture_image) != 0) {
ViEId(shared_data_->instance_id(), capture_id), file_nameUTF8,
capture_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, capture_id),
ViEId(shared_data_->instance_id(), capture_id),
"%s(capture_id: %d) Failed to open file.", __FUNCTION__,
capture_id);
SetLastError(kViEFileInvalidFile);
shared_data_->SetLastError(kViEFileInvalidFile);
return -1;
}
if (capturer->SetCaptureDeviceImage(capture_image)) {
SetLastError(kViEFileSetCaptureImageError);
shared_data_->SetLastError(kViEFileSetCaptureImageError);
return -1;
}
return 0;
@ -714,34 +740,36 @@ int ViEFileImpl::SetCaptureDeviceImage(const int capture_id,
int ViEFileImpl::SetCaptureDeviceImage(const int capture_id,
const ViEPicture& picture) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
if (picture.type != kVideoI420) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s(capture_id: %d) Not a valid picture type.",
__FUNCTION__, capture_id);
SetLastError(kViEFileInvalidArgument);
shared_data_->SetLastError(kViEFileInvalidArgument);
return -1;
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* capturer = is.Capture(capture_id);
if (!capturer) {
SetLastError(kViEFileSetCaptureImageError);
shared_data_->SetLastError(kViEFileSetCaptureImageError);
return -1;
}
VideoFrame capture_image;
if (ViEFileImage::ConvertPictureToVideoFrame(
ViEId(instance_id_, capture_id), picture, capture_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, capture_id),
ViEId(shared_data_->instance_id(), capture_id), picture, capture_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), capture_id),
"%s(capture_id: %d) Failed to use picture.", __FUNCTION__,
capture_id);
SetLastError(kViEFileInvalidFile);
shared_data_->SetLastError(kViEFileInvalidFile);
return -1;
}
if (capturer->SetCaptureDeviceImage(capture_image)) {
SetLastError(kViEFileInvalidCapture);
shared_data_->SetLastError(kViEFileInvalidCapture);
return -1;
}
return 0;
@ -749,27 +777,29 @@ const ViEPicture& picture) {
int ViEFileImpl::SetRenderStartImage(const int video_channel,
const char* file_nameUTF8) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
SetLastError(kViEFileInvalidRenderId);
shared_data_->SetLastError(kViEFileInvalidRenderId);
return -1;
}
VideoFrame start_image;
if (ViEFileImage::ConvertJPEGToVideoFrame(
ViEId(instance_id_, video_channel), file_nameUTF8, start_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel), file_nameUTF8, start_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Failed to open file.", __FUNCTION__,
video_channel);
SetLastError(kViEFileInvalidFile);
shared_data_->SetLastError(kViEFileInvalidFile);
return -1;
}
if (renderer->SetRenderStartImage(start_image) != 0) {
SetLastError(kViEFileSetStartImageError);
shared_data_->SetLastError(kViEFileSetStartImageError);
return -1;
}
return 0;
@ -778,34 +808,36 @@ const char* file_nameUTF8) {
int ViEFileImpl::SetRenderStartImage(const int video_channel,
const ViEPicture& picture) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(instance_id_, video_channel), "%s(video_channel: %d)",
__FUNCTION__, video_channel);
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
if (picture.type != kVideoI420) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Not a valid picture type.",
__FUNCTION__, video_channel);
SetLastError(kViEFileInvalidArgument);
shared_data_->SetLastError(kViEFileInvalidArgument);
return -1;
}
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
SetLastError(kViEFileInvalidRenderId);
shared_data_->SetLastError(kViEFileInvalidRenderId);
return -1;
}
VideoFrame start_image;
if (ViEFileImage::ConvertPictureToVideoFrame(
ViEId(instance_id_, video_channel), picture, start_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel), picture, start_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Failed to use picture.",
__FUNCTION__, video_channel);
SetLastError(kViEFileInvalidCapture);
shared_data_->SetLastError(kViEFileInvalidCapture);
return -1;
}
if (renderer->SetRenderStartImage(start_image) != 0) {
SetLastError(kViEFileSetStartImageError);
shared_data_->SetLastError(kViEFileSetStartImageError);
return -1;
}
return 0;
@ -813,39 +845,44 @@ int ViEFileImpl::SetRenderStartImage(const int video_channel,
int ViEFileImpl::SetRenderTimeoutImage(const int video_channel,
const char* file_nameUTF8,
const unsigned int timeout_ms) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
SetLastError(kViEFileInvalidRenderId);
shared_data_->SetLastError(kViEFileInvalidRenderId);
return -1;
}
VideoFrame timeout_image;
if (ViEFileImage::ConvertJPEGToVideoFrame(
ViEId(instance_id_, video_channel), file_nameUTF8, timeout_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel), file_nameUTF8,
timeout_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Failed to open file.", __FUNCTION__,
video_channel);
SetLastError(kViEFileInvalidFile);
shared_data_->SetLastError(kViEFileInvalidFile);
return -1;
}
WebRtc_Word32 timeout_time = timeout_ms;
if (timeout_ms < kViEMinRenderTimeoutTimeMs) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Invalid timeout_ms, using %d.",
__FUNCTION__, video_channel, kViEMinRenderTimeoutTimeMs);
timeout_time = kViEMinRenderTimeoutTimeMs;
}
if (timeout_ms > kViEMaxRenderTimeoutTimeMs) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Invalid timeout_ms, using %d.",
__FUNCTION__, video_channel, kViEMaxRenderTimeoutTimeMs);
timeout_time = kViEMaxRenderTimeoutTimeMs;
}
if (renderer->SetTimeoutImage(timeout_image, timeout_time) != 0) {
SetLastError(kViEFileSetRenderTimeoutError);
shared_data_->SetLastError(kViEFileSetRenderTimeoutError);
return -1;
}
return 0;
@ -854,47 +891,53 @@ int ViEFileImpl::SetRenderTimeoutImage(const int video_channel,
int ViEFileImpl::SetRenderTimeoutImage(const int video_channel,
const ViEPicture& picture,
const unsigned int timeout_ms) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
if (picture.type != kVideoI420) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Not a valid picture type.",
__FUNCTION__, video_channel);
SetLastError(kViEFileInvalidArgument);
shared_data_->SetLastError(kViEFileInvalidArgument);
return -1;
}
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(video_channel);
if (!renderer) {
SetLastError(kViEFileSetRenderTimeoutError);
shared_data_->SetLastError(kViEFileSetRenderTimeoutError);
return -1;
}
VideoFrame timeout_image;
if (ViEFileImage::ConvertPictureToVideoFrame(
ViEId(instance_id_, video_channel), picture, timeout_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel), picture,
timeout_image) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Failed to use picture.",
__FUNCTION__, video_channel);
SetLastError(kViEFileInvalidCapture);
shared_data_->SetLastError(kViEFileInvalidCapture);
return -1;
}
WebRtc_Word32 timeout_time = timeout_ms;
if (timeout_ms < kViEMinRenderTimeoutTimeMs) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Invalid timeout_ms, using %d.",
__FUNCTION__, video_channel, kViEMinRenderTimeoutTimeMs);
timeout_time = kViEMinRenderTimeoutTimeMs;
}
if (timeout_ms > kViEMaxRenderTimeoutTimeMs) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d) Invalid timeout_ms, using %d.",
__FUNCTION__, video_channel, kViEMaxRenderTimeoutTimeMs);
timeout_time = kViEMaxRenderTimeoutTimeMs;
}
if (renderer->SetTimeoutImage(timeout_image, timeout_time) != 0) {
SetLastError(kViEFileSetRenderTimeoutError);
shared_data_->SetLastError(kViEFileSetRenderTimeoutError);
return -1;
}
return 0;
@ -902,7 +945,7 @@ const unsigned int timeout_ms) {
WebRtc_Word32 ViEFileImpl::GetNextCapturedFrame(WebRtc_Word32 capture_id,
VideoFrame& video_frame) {
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* capturer = is.Capture(capture_id);
if (!capturer) {
return -1;

View File

@ -23,6 +23,7 @@ namespace webrtc {
class ConditionVariableWrapper;
class CriticalSectionWrapper;
class ViESharedData;
class ViECaptureSnapshot : public ViEFrameCallback {
public:
@ -48,8 +49,7 @@ class ViECaptureSnapshot : public ViEFrameCallback {
};
class ViEFileImpl
: public virtual ViESharedData,
public ViEFile,
: public ViEFile,
public ViERefCount {
public:
// Implements ViEFile.
@ -116,12 +116,14 @@ class ViEFileImpl
const unsigned int timeout_ms);
protected:
ViEFileImpl();
ViEFileImpl(ViESharedData* shared_data);
virtual ~ViEFileImpl();
private:
WebRtc_Word32 GetNextCapturedFrame(WebRtc_Word32 capture_id,
VideoFrame& video_frame);
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -19,6 +19,7 @@
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_input_manager.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -38,77 +39,78 @@ ViEImageProcess* ViEImageProcess::GetInterface(VideoEngine* video_engine) {
}
int ViEImageProcessImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViEImageProcess::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViEImageProcess release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViEImageProcess reference count: %d", ref_count);
return ref_count;
}
ViEImageProcessImpl::ViEImageProcessImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViEImageProcessImpl::ViEImageProcessImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEImageProcessImpl::ViEImageProcessImpl() Ctor");
}
ViEImageProcessImpl::~ViEImageProcessImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViEImageProcessImpl::~ViEImageProcessImpl() Dtor");
}
int ViEImageProcessImpl::RegisterCaptureEffectFilter(
const int capture_id,
ViEEffectFilter& capture_filter) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViEImageProcessInvalidCaptureId);
shared_data_->SetLastError(kViEImageProcessInvalidCaptureId);
return -1;
}
if (vie_capture->RegisterEffectFilter(&capture_filter) != 0) {
SetLastError(kViEImageProcessFilterExists);
shared_data_->SetLastError(kViEImageProcessFilterExists);
return -1;
}
return 0;
}
int ViEImageProcessImpl::DeregisterCaptureEffectFilter(const int capture_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d)", __FUNCTION__, capture_id);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViEImageProcessInvalidCaptureId);
shared_data_->SetLastError(kViEImageProcessInvalidCaptureId);
return -1;
}
if (vie_capture->RegisterEffectFilter(NULL) != 0) {
SetLastError(kViEImageProcessFilterDoesNotExist);
shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist);
return -1;
}
return 0;
@ -117,39 +119,39 @@ int ViEImageProcessImpl::DeregisterCaptureEffectFilter(const int capture_id) {
int ViEImageProcessImpl::RegisterSendEffectFilter(
const int video_channel,
ViEEffectFilter& send_filter) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (vie_encoder == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_encoder->RegisterEffectFilter(&send_filter) != 0) {
SetLastError(kViEImageProcessFilterExists);
shared_data_->SetLastError(kViEImageProcessFilterExists);
return -1;
}
return 0;
}
int ViEImageProcessImpl::DeregisterSendEffectFilter(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (vie_encoder == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_encoder->RegisterEffectFilter(NULL) != 0) {
SetLastError(kViEImageProcessFilterDoesNotExist);
shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist);
return -1;
}
return 0;
@ -158,39 +160,39 @@ int ViEImageProcessImpl::DeregisterSendEffectFilter(const int video_channel) {
int ViEImageProcessImpl::RegisterRenderEffectFilter(
const int video_channel,
ViEEffectFilter& render_filter) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_channel->RegisterEffectFilter(&render_filter) != 0) {
SetLastError(kViEImageProcessFilterExists);
shared_data_->SetLastError(kViEImageProcessFilterExists);
return -1;
}
return 0;
}
int ViEImageProcessImpl::DeregisterRenderEffectFilter(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_channel->RegisterEffectFilter(NULL) != 0) {
SetLastError(kViEImageProcessFilterDoesNotExist);
shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist);
return -1;
}
return 0;
@ -198,25 +200,25 @@ int ViEImageProcessImpl::DeregisterRenderEffectFilter(const int video_channel) {
int ViEImageProcessImpl::EnableDeflickering(const int capture_id,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d, enable: %d)", __FUNCTION__, capture_id,
enable);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_capture->EnableDeflickering(enable) != 0) {
if (enable) {
SetLastError(kViEImageProcessAlreadyEnabled);
shared_data_->SetLastError(kViEImageProcessAlreadyEnabled);
} else {
SetLastError(kViEImageProcessAlreadyDisabled);
shared_data_->SetLastError(kViEImageProcessAlreadyDisabled);
}
return -1;
}
@ -225,25 +227,25 @@ int ViEImageProcessImpl::EnableDeflickering(const int capture_id,
int ViEImageProcessImpl::EnableDenoising(const int capture_id,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(capture_id: %d, enable: %d)", __FUNCTION__, capture_id,
enable);
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViECapturer* vie_capture = is.Capture(capture_id);
if (!vie_capture) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Capture device %d doesn't exist", __FUNCTION__,
capture_id);
SetLastError(kViEImageProcessInvalidCaptureId);
shared_data_->SetLastError(kViEImageProcessInvalidCaptureId);
return -1;
}
if (vie_capture->EnableDenoising(enable) != 0) {
if (enable) {
SetLastError(kViEImageProcessAlreadyEnabled);
shared_data_->SetLastError(kViEImageProcessAlreadyEnabled);
} else {
SetLastError(kViEImageProcessAlreadyDisabled);
shared_data_->SetLastError(kViEImageProcessAlreadyDisabled);
}
return -1;
}
@ -252,23 +254,23 @@ int ViEImageProcessImpl::EnableDenoising(const int capture_id,
int ViEImageProcessImpl::EnableColorEnhancement(const int video_channel,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(video_channel: %d, enable: %d)", __FUNCTION__, video_channel,
enable);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViEImageProcessInvalidChannelId);
shared_data_->SetLastError(kViEImageProcessInvalidChannelId);
return -1;
}
if (vie_channel->EnableColorEnhancement(enable) != 0) {
if (enable) {
SetLastError(kViEImageProcessAlreadyEnabled);
shared_data_->SetLastError(kViEImageProcessAlreadyEnabled);
} else {
SetLastError(kViEImageProcessAlreadyDisabled);
shared_data_->SetLastError(kViEImageProcessAlreadyDisabled);
}
return -1;
}

View File

@ -14,13 +14,13 @@
#include "typedefs.h"
#include "video_engine/include/vie_image_process.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViEImageProcessImpl
: public virtual ViESharedData,
public ViEImageProcess,
: public ViEImageProcess,
public ViERefCount {
public:
// Implements ViEImageProcess.
@ -40,8 +40,11 @@ class ViEImageProcessImpl
const bool enable);
protected:
ViEImageProcessImpl();
ViEImageProcessImpl(ViESharedData* shared_data);
virtual ~ViEImageProcessImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -77,7 +77,36 @@ class VideoEngineImpl
#endif
{ // NOLINT
public:
VideoEngineImpl() {}
VideoEngineImpl()
:
#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API
ViECodecImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
, ViECaptureImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
, ViEEncryptionImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
, ViEFileImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API
, ViEImageProcessImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_NETWORK_API
, ViENetworkImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
, ViERenderImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API
, ViERTP_RTCPImpl(ViEBaseImpl::shared_data())
#endif
#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API
, ViEExternalCodecImpl(ViEBaseImpl::shared_data())
#endif
{}
virtual ~VideoEngineImpl() {}
};

View File

@ -23,6 +23,7 @@
#include "video_engine/vie_defines.h"
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -42,30 +43,31 @@ ViENetwork* ViENetwork::GetInterface(VideoEngine* video_engine) {
}
int ViENetworkImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViENetwork::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViENetwork release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViENetwork reference count: %d", ref_count);
return ref_count;
}
ViENetworkImpl::ViENetworkImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViENetworkImpl::ViENetworkImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViENetworkImpl::ViENetworkImpl() Ctor");
}
ViENetworkImpl::~ViENetworkImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViENetworkImpl::~ViENetworkImpl() Dtor");
}
@ -73,33 +75,35 @@ int ViENetworkImpl::SetLocalReceiver(const int video_channel,
const unsigned short rtp_port,
const unsigned short rtcp_port,
const char* ip_address) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, rtp_port: %u, rtcp_port: %u, ip_address: %s)",
__FUNCTION__, video_channel, rtp_port, rtcp_port, ip_address);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
// The channel doesn't exists.
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->Receiving()) {
SetLastError(kViENetworkAlreadyReceiving);
shared_data_->SetLastError(kViENetworkAlreadyReceiving);
return -1;
}
if (vie_channel->SetLocalReceiver(rtp_port, rtcp_port, ip_address) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -109,19 +113,21 @@ int ViENetworkImpl::GetLocalReceiver(const int video_channel,
unsigned short& rtp_port,
unsigned short& rtcp_port,
char* ip_address) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetLocalReceiver(rtp_port, rtcp_port, ip_address) != 0) {
SetLastError(kViENetworkLocalReceiverNotSet);
shared_data_->SetLastError(kViENetworkLocalReceiverNotSet);
return -1;
}
return 0;
@ -133,37 +139,40 @@ int ViENetworkImpl::SetSendDestination(const int video_channel,
const unsigned short rtcp_port,
const unsigned short source_rtp_port,
const unsigned short source_rtcp_port) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, ip_address: %s, rtp_port: %u, rtcp_port: %u, "
"sourceRtpPort: %u, source_rtcp_port: %u)",
__FUNCTION__, video_channel, ip_address, rtp_port, rtcp_port,
source_rtp_port, source_rtcp_port);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel doesn't exist", __FUNCTION__);
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel already sending.", __FUNCTION__);
SetLastError(kViENetworkAlreadySending);
shared_data_->SetLastError(kViENetworkAlreadySending);
return -1;
}
if (vie_channel->SetSendDestination(ip_address, rtp_port, rtcp_port,
source_rtp_port,
source_rtcp_port) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -175,20 +184,22 @@ int ViENetworkImpl::GetSendDestination(const int video_channel,
unsigned short& rtcp_port,
unsigned short& source_rtp_port,
unsigned short& source_rtcp_port) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, video_channel), "Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetSendDestination(ip_address, rtp_port, rtcp_port,
source_rtp_port,
source_rtcp_port) != 0) {
SetLastError(kViENetworkDestinationNotSet);
shared_data_->SetLastError(kViENetworkDestinationNotSet);
return -1;
}
return 0;
@ -196,55 +207,61 @@ int ViENetworkImpl::GetSendDestination(const int video_channel,
int ViENetworkImpl::RegisterSendTransport(const int video_channel,
Transport& transport) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel doesn't exist", __FUNCTION__);
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel already sending.", __FUNCTION__);
SetLastError(kViENetworkAlreadySending);
shared_data_->SetLastError(kViENetworkAlreadySending);
return -1;
}
if (vie_channel->RegisterSendTransport(transport) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
}
int ViENetworkImpl::DeregisterSendTransport(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel doesn't exist", __FUNCTION__);
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s Channel already sending", __FUNCTION__);
SetLastError(kViENetworkAlreadySending);
shared_data_->SetLastError(kViENetworkAlreadySending);
return -1;
}
if (vie_channel->DeregisterSendTransport() != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -252,23 +269,25 @@ int ViENetworkImpl::DeregisterSendTransport(const int video_channel) {
int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data,
const int length) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, data: -, length: %d)", __FUNCTION__,
video_channel, length);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
// The channel doesn't exists
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
return vie_channel->ReceivedRTPPacket(data, length);
@ -276,22 +295,24 @@ int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data,
int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel,
const void* data, const int length) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, data: -, length: %d)", __FUNCTION__,
video_channel, length);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
return vie_channel->ReceivedRTCPPacket(data, length);
@ -301,52 +322,54 @@ int ViENetworkImpl::GetSourceInfo(const int video_channel,
unsigned short& rtp_port,
unsigned short& rtcp_port, char* ip_address,
unsigned int ip_address_length) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetSourceInfo(rtp_port, rtcp_port, ip_address,
ip_address_length) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
}
int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s( ip_address, ipV6: %d)", __FUNCTION__, ipv6);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
if (!ip_address) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: No argument", __FUNCTION__);
SetLastError(kViENetworkInvalidArgument);
shared_data_->SetLastError(kViENetworkInvalidArgument);
return -1;
}
WebRtc_UWord8 num_socket_threads = 1;
UdpTransport* socket_transport = UdpTransport::Create(
ViEModuleId(instance_id_, -1), num_socket_threads);
ViEModuleId(shared_data_->instance_id(), -1), num_socket_threads);
if (!socket_transport) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Could not create socket module", __FUNCTION__);
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
@ -355,9 +378,9 @@ int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) {
WebRtc_UWord8 local_ip[16];
if (socket_transport->LocalHostAddressIPV6(local_ip) != 0) {
UdpTransport::Destroy(socket_transport);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Could not get local IP", __FUNCTION__);
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
// Convert 128-bit address to character string (a:b:c:d:e:f:g:h).
@ -372,9 +395,9 @@ int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) {
WebRtc_UWord32 local_ip = 0;
if (socket_transport->LocalHostAddress(local_ip) != 0) {
UdpTransport::Destroy(socket_transport);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: Could not get local IP", __FUNCTION__);
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
// Convert 32-bit address to character string (x.y.z.w).
@ -386,11 +409,11 @@ int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) {
}
strcpy(ip_address, local_ip_address);
UdpTransport::Destroy(socket_transport);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: local ip = %s", __FUNCTION__, local_ip_address);
return 0;
#else
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: not available for external transport", __FUNCTION__);
return -1;
@ -398,32 +421,36 @@ int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) {
}
int ViENetworkImpl::EnableIPv6(int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->EnableIPv6() != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
}
bool ViENetworkImpl::IsIPv6Enabled(int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return false;
}
return vie_channel->IsIPv6Enabled();
@ -433,19 +460,21 @@ int ViENetworkImpl::SetSourceFilter(const int video_channel,
const unsigned short rtp_port,
const unsigned short rtcp_port,
const char* ip_address) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, rtp_port: %u, rtcp_port: %u, ip_address: %s)",
__FUNCTION__, video_channel, rtp_port, rtcp_port, ip_address);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->SetSourceFilter(rtp_port, rtcp_port, ip_address) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -455,18 +484,20 @@ int ViENetworkImpl::GetSourceFilter(const int video_channel,
unsigned short& rtp_port,
unsigned short& rtcp_port,
char* ip_address) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetSourceFilter(rtp_port, rtcp_port, ip_address) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -474,27 +505,30 @@ int ViENetworkImpl::GetSourceFilter(const int video_channel,
int ViENetworkImpl::SetSendToS(const int video_channel, const int DSCP,
const bool use_set_sockOpt = false) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, DSCP: %d, use_set_sockOpt: %d)", __FUNCTION__,
video_channel, DSCP, use_set_sockOpt);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
#if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
" force use_set_sockopt=true since there is no alternative"
" implementation");
if (vie_channel->SetToS(DSCP, true) != 0) {
#else
if (vie_channel->SetToS(DSCP, use_set_sockOpt) != 0) {
#endif
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -502,18 +536,20 @@ int ViENetworkImpl::SetSendToS(const int video_channel, const int DSCP,
int ViENetworkImpl::GetSendToS(const int video_channel, int& DSCP,
bool& use_set_sockOpt) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetToS((WebRtc_Word32&) DSCP, use_set_sockOpt) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -522,15 +558,16 @@ int ViENetworkImpl::GetSendToS(const int video_channel, int& DSCP,
int ViENetworkImpl::SetSendGQoS(const int video_channel, const bool enable,
const int service_type,
const int overrideDSCP) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, service_type: %d, "
"overrideDSCP: %d)", __FUNCTION__, video_channel, enable,
service_type, overrideDSCP);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
@ -541,81 +578,90 @@ int ViENetworkImpl::SetSendGQoS(const int video_channel, const bool enable,
(service_type != SERVICETYPE_CONTROLLEDLOAD) &&
(service_type != SERVICETYPE_GUARANTEED) &&
(service_type != SERVICETYPE_QUALITATIVE)) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: service type %d not supported", __FUNCTION__,
video_channel, service_type);
SetLastError(kViENetworkServiceTypeNotSupported);
shared_data_->SetLastError(kViENetworkServiceTypeNotSupported);
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
VideoCodec video_codec;
if (vie_encoder->GetEncoder(video_codec) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not get max bitrate for the channel",
__FUNCTION__);
SetLastError(kViENetworkSendCodecNotSet);
shared_data_->SetLastError(kViENetworkSendCodecNotSet);
return -1;
}
if (vie_channel->SetSendGQoS(enable, service_type, video_codec.maxBitrate,
overrideDSCP) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
#else
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Not supported", __FUNCTION__);
SetLastError(kViENetworkNotSupported);
shared_data_->SetLastError(kViENetworkNotSupported);
return -1;
#endif
}
int ViENetworkImpl::GetSendGQoS(const int video_channel, bool& enabled,
int& service_type, int& overrideDSCP) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->GetSendGQoS(enabled, service_type, overrideDSCP) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
}
int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, mtu: %u)", __FUNCTION__, video_channel, mtu);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->SetMTU(mtu) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -624,20 +670,22 @@ int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) {
int ViENetworkImpl::SetPacketTimeoutNotification(const int video_channel,
bool enable,
int timeout_seconds) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, timeout_seconds: %u)",
__FUNCTION__, video_channel, enable, timeout_seconds);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->SetPacketTimeoutNotification(enable,
timeout_seconds) != 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -645,36 +693,40 @@ int ViENetworkImpl::SetPacketTimeoutNotification(const int video_channel,
int ViENetworkImpl::RegisterObserver(const int video_channel,
ViENetworkObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->RegisterNetworkObserver(&observer) != 0) {
SetLastError(kViENetworkObserverAlreadyRegistered);
shared_data_->SetLastError(kViENetworkObserverAlreadyRegistered);
return -1;
}
return 0;
}
int ViENetworkImpl::DeregisterObserver(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (!vie_channel->NetworkObserverRegistered()) {
SetLastError(kViENetworkObserverNotRegistered);
shared_data_->SetLastError(kViENetworkObserverNotRegistered);
return -1;
}
return vie_channel->RegisterNetworkObserver(NULL);
@ -684,24 +736,26 @@ int ViENetworkImpl::SetPeriodicDeadOrAliveStatus(
const int video_channel,
bool enable,
unsigned int sample_time_seconds) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, sample_time_seconds: %ul)",
__FUNCTION__, video_channel, enable, sample_time_seconds);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (!vie_channel->NetworkObserverRegistered()) {
SetLastError(kViENetworkObserverNotRegistered);
shared_data_->SetLastError(kViENetworkObserverNotRegistered);
return -1;
}
if (vie_channel->SetPeriodicDeadOrAliveStatus(enable, sample_time_seconds)
!= 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;
@ -711,29 +765,31 @@ int ViENetworkImpl::SendUDPPacket(const int video_channel, const void* data,
const unsigned int length,
int& transmitted_bytes,
bool use_rtcp_socket = false) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, data: -, length: %d, transmitter_bytes: -, "
"useRtcpSocket: %d)", __FUNCTION__, video_channel, length,
use_rtcp_socket);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"Channel doesn't exist");
SetLastError(kViENetworkInvalidChannelId);
shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1;
}
if (vie_channel->SendUDPPacket((const WebRtc_Word8*) data, length,
(WebRtc_Word32&) transmitted_bytes,
use_rtcp_socket) < 0) {
SetLastError(kViENetworkUnknownError);
shared_data_->SetLastError(kViENetworkUnknownError);
return -1;
}
return 0;

View File

@ -14,13 +14,13 @@
#include "typedefs.h"
#include "video_engine/include/vie_network.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViENetworkImpl
: public virtual ViESharedData,
public ViENetwork,
: public ViENetwork,
public ViERefCount {
public:
// Implements ViENetwork.
@ -102,8 +102,11 @@ class ViENetworkImpl
bool use_rtcp_socket);
protected:
ViENetworkImpl();
ViENetworkImpl(ViESharedData* shared_data);
virtual ~ViENetworkImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -24,6 +24,7 @@
#include "video_engine/vie_input_manager.h"
#include "video_engine/vie_render_manager.h"
#include "video_engine/vie_renderer.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -43,37 +44,39 @@ ViERender* ViERender::GetInterface(VideoEngine* video_engine) {
}
int ViERenderImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViERender::Release()");
// Decrease ref count
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViERender release too many times");
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViERender reference count: %d", ref_count);
return ref_count;
}
ViERenderImpl::ViERenderImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViERenderImpl::ViERenderImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViERenderImpl::ViERenderImpl() Ctor");
}
ViERenderImpl::~ViERenderImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViERenderImpl::~ViERenderImpl() Dtor");
}
int ViERenderImpl::RegisterVideoRenderModule(
VideoRender& render_module) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s (&render_module: %p)", __FUNCTION__, &render_module);
if (render_manager_.RegisterVideoRenderModule(render_module) != 0) {
SetLastError(kViERenderUnknownError);
if (shared_data_->render_manager()->RegisterVideoRenderModule(
render_module) != 0) {
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
@ -81,11 +84,12 @@ int ViERenderImpl::RegisterVideoRenderModule(
int ViERenderImpl::DeRegisterVideoRenderModule(
VideoRender& render_module) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s (&render_module: %p)", __FUNCTION__, &render_module);
if (render_manager_.DeRegisterVideoRenderModule(render_module) != 0) {
if (shared_data_->render_manager()->DeRegisterVideoRenderModule(
render_module) != 0) {
// Error logging is done in ViERenderManager::DeRegisterVideoRenderModule.
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
@ -95,65 +99,61 @@ int ViERenderImpl::AddRenderer(const int render_id, void* window,
const unsigned int z_order, const float left,
const float top, const float right,
const float bottom) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s (render_id: %d, window: 0x%p, z_order: %u, left: %f, "
"top: %f, right: %f, bottom: %f)",
__FUNCTION__, render_id, window, z_order, left, top, right,
bottom);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
{
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
if (rs.Renderer(render_id)) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - Renderer already exist %d.", __FUNCTION__,
render_id);
SetLastError(kViERenderAlreadyExists);
shared_data_->SetLastError(kViERenderAlreadyExists);
return -1;
}
}
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
// This is a channel.
ViEChannelManagerScoped cm(channel_manager_);
ViEChannelManagerScoped cm(*(shared_data_->channel_manager()));
ViEFrameProviderBase* frame_provider = cm.Channel(render_id);
if (!frame_provider) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
ViERenderer* renderer = render_manager_.AddRenderStream(render_id,
window, z_order,
left, top,
right, bottom);
ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream(
render_id, window, z_order, left, top, right, bottom);
if (!renderer) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return frame_provider->RegisterFrameCallback(render_id, renderer);
} else {
// Camera or file.
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id);
if (!frame_provider) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
ViERenderer* renderer = render_manager_.AddRenderStream(render_id,
window, z_order,
left, top,
right, bottom);
ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream(
render_id, window, z_order, left, top, right, bottom);
if (!renderer) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return frame_provider->RegisterFrameCallback(render_id, renderer);
@ -161,25 +161,26 @@ int ViERenderImpl::AddRenderer(const int render_id, void* window,
}
int ViERenderImpl::RemoveRenderer(const int render_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s(render_id: %d)", __FUNCTION__, render_id);
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
ViERenderer* renderer = NULL;
{
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
renderer = rs.Renderer(render_id);
if (!renderer) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s No render exist with render_id: %d", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
// Leave the scope lock since we don't want to lock two managers
@ -187,69 +188,75 @@ int ViERenderImpl::RemoveRenderer(const int render_id) {
}
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
// This is a channel.
ViEChannelManagerScoped cm(channel_manager_);
ViEChannelManagerScoped cm(*(shared_data_->channel_manager()));
ViEChannel* channel = cm.Channel(render_id);
if (!channel) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s: no channel with id %d exists ", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
channel->DeregisterFrameCallback(renderer);
} else {
// Provider owned by inputmanager, i.e. file or capture device.
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* provider = is.FrameProvider(render_id);
if (!provider) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceWarning, kTraceVideo,
ViEId(shared_data_->instance_id()),
"%s: no provider with id %d exists ", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
provider->DeregisterFrameCallback(renderer);
}
if (render_manager_.RemoveRenderStream(render_id) != 0) {
SetLastError(kViERenderUnknownError);
if (shared_data_->render_manager()->RemoveRenderStream(render_id) != 0) {
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
}
int ViERenderImpl::StartRender(const int render_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s(channel: %d)", __FUNCTION__, render_id);
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(render_id);
if (!renderer) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s: No renderer with render Id %d exist.", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
if (renderer->StartRender() != 0) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
}
int ViERenderImpl::StopRender(const int render_id) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s(channel: %d)", __FUNCTION__, render_id);
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(render_id);
if (!renderer) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s: No renderer with render_id %d exist.", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
if (renderer->StopRender() != 0) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
@ -258,20 +265,22 @@ int ViERenderImpl::StopRender(const int render_id) {
int ViERenderImpl::ConfigureRender(int render_id, const unsigned int z_order,
const float left, const float top,
const float right, const float bottom) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s(channel: %d)", __FUNCTION__, render_id);
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(render_id);
if (!renderer) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s: No renderer with render_id %d exist.", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
if (renderer->ConfigureRenderer(z_order, left, top, right, bottom) != 0) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
@ -280,18 +289,19 @@ int ViERenderImpl::ConfigureRender(int render_id, const unsigned int z_order,
int ViERenderImpl::MirrorRenderStream(const int render_id, const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis) {
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(render_id);
if (!renderer) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s: No renderer with render_id %d exist.", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
if (renderer->EnableMirroring(render_id, enable, mirror_xaxis, mirror_yaxis)
!= 0) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
@ -310,76 +320,75 @@ int ViERenderImpl::AddRenderer(const int render_id,
video_input_format != kVideoRGB565 &&
video_input_format != kVideoARGB4444 &&
video_input_format != kVideoARGB1555) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), render_id),
"%s: Unsupported video frame format requested",
__FUNCTION__, render_id);
SetLastError(kViERenderInvalidFrameFormat);
shared_data_->SetLastError(kViERenderInvalidFrameFormat);
return -1;
}
if (!Initialized()) {
SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
if (!shared_data_->Initialized()) {
shared_data_->SetLastError(kViENotInitialized);
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - ViE instance %d not initialized", __FUNCTION__,
instance_id_);
shared_data_->instance_id());
return -1;
}
{
// Verify the renderer doesn't exist.
ViERenderManagerScoped rs(render_manager_);
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
if (rs.Renderer(render_id)) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s - Renderer already exist %d.", __FUNCTION__,
render_id);
SetLastError(kViERenderAlreadyExists);
shared_data_->SetLastError(kViERenderAlreadyExists);
return -1;
}
}
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
// This is a channel.
ViEChannelManagerScoped cm(channel_manager_);
ViEChannelManagerScoped cm(*(shared_data_->channel_manager()));
ViEFrameProviderBase* frame_provider = cm.Channel(render_id);
if (!frame_provider) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
ViERenderer* renderer = render_manager_.AddRenderStream(render_id, NULL,
0, 0.0f, 0.0f,
1.0f, 1.0f);
ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream(
render_id, NULL, 0, 0.0f, 0.0f, 1.0f, 1.0f);
if (!renderer) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
if (renderer->SetExternalRenderer(render_id, video_input_format,
external_renderer) == -1) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return frame_provider->RegisterFrameCallback(render_id, renderer);
} else {
// Camera or file.
ViEInputManagerScoped is(input_manager_);
ViEInputManagerScoped is(*(shared_data_->input_manager()));
ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id);
if (!frame_provider) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
render_id);
SetLastError(kViERenderInvalidRenderId);
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
ViERenderer* renderer = render_manager_.AddRenderStream(render_id, NULL,
0, 0.0f, 0.0f,
1.0f, 1.0f);
ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream(
render_id, NULL, 0, 0.0f, 0.0f, 1.0f, 1.0f);
if (!renderer) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
if (renderer->SetExternalRenderer(render_id, video_input_format,
external_renderer) == -1) {
SetLastError(kViERenderUnknownError);
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return frame_provider->RegisterFrameCallback(render_id, renderer);

View File

@ -15,13 +15,13 @@
#include "typedefs.h"
#include "video_engine/include/vie_render.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViERenderImpl
: public virtual ViESharedData,
public ViERender,
: public ViERender,
public ViERefCount {
public:
// Implements ViERender
@ -45,9 +45,13 @@ class ViERenderImpl
ExternalRenderer* renderer);
protected:
ViERenderImpl();
ViERenderImpl(ViESharedData* shared_data);
virtual ~ViERenderImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc
#endif // WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_

View File

@ -19,6 +19,7 @@
#include "video_engine/vie_defines.h"
#include "video_engine/vie_encoder.h"
#include "video_engine/vie_impl.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
@ -95,30 +96,31 @@ ViERTP_RTCP* ViERTP_RTCP::GetInterface(VideoEngine* video_engine) {
}
int ViERTP_RTCPImpl::Release() {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
"ViERTP_RTCP::Release()");
// Decrease ref count.
(*this)--;
WebRtc_Word32 ref_count = GetCount();
if (ref_count < 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
"ViERTP_RTCP release too many times");
SetLastError(kViEAPIDoesNotExist);
shared_data_->SetLastError(kViEAPIDoesNotExist);
return -1;
}
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
"ViERTP_RTCP reference count: %d", ref_count);
return ref_count;
}
ViERTP_RTCPImpl::ViERTP_RTCPImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
ViERTP_RTCPImpl::ViERTP_RTCPImpl(ViESharedData* shared_data)
: shared_data_(shared_data) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViERTP_RTCPImpl::ViERTP_RTCPImpl() Ctor");
}
ViERTP_RTCPImpl::~ViERTP_RTCPImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
"ViERTP_RTCPImpl::~ViERTP_RTCPImpl() Dtor");
}
@ -126,19 +128,21 @@ int ViERTP_RTCPImpl::SetLocalSSRC(const int video_channel,
const unsigned int SSRC,
const StreamType usage,
const unsigned char simulcast_idx) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
// The channel doesn't exists
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->SetSSRC(SSRC, usage, simulcast_idx) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -148,24 +152,24 @@ int ViERTP_RTCPImpl::SetRemoteSSRCType(const int videoChannel,
const StreamType usage,
const unsigned int SSRC) const {
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
ViEId(instance_id_, videoChannel),
ViEId(shared_data_->instance_id(), videoChannel),
"%s(channel: %d, usage:%d SSRC: 0x%x)",
__FUNCTION__, usage, videoChannel, SSRC);
// Get the channel
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* ptrViEChannel = cs.Channel(videoChannel);
if (ptrViEChannel == NULL) {
// The channel doesn't exists
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(instance_id_, videoChannel),
ViEId(shared_data_->instance_id(), videoChannel),
"%s: Channel %d doesn't exist",
__FUNCTION__, videoChannel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (ptrViEChannel->SetRemoteSSRCType(usage, SSRC) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -173,18 +177,20 @@ int ViERTP_RTCPImpl::SetRemoteSSRCType(const int videoChannel,
int ViERTP_RTCPImpl::GetLocalSSRC(const int video_channel,
unsigned int& SSRC) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetLocalSSRC((WebRtc_UWord32&) SSRC) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -192,18 +198,20 @@ int ViERTP_RTCPImpl::GetLocalSSRC(const int video_channel,
int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel,
unsigned int& SSRC) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel, SSRC);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetRemoteSSRC(SSRC) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -211,18 +219,20 @@ int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel,
int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel,
unsigned int CSRCs[kRtpCsrcSize]) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetRemoteCSRC(CSRCs) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -230,26 +240,29 @@ int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel,
int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel,
unsigned short sequence_number) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, sequence_number: %u)", __FUNCTION__,
video_channel, sequence_number);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d already sending.", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpAlreadySending);
shared_data_->SetLastError(kViERtpRtcpAlreadySending);
return -1;
}
if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -257,21 +270,23 @@ int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel,
int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel,
const ViERTCPMode rtcp_mode) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, mode: %d)", __FUNCTION__, video_channel,
rtcp_mode);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode);
if (vie_channel->SetRTCPMode(module_mode) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -279,21 +294,24 @@ int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel,
int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel,
ViERTCPMode& rtcp_mode) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel, rtcp_mode);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
RTCPMethod module_mode = kRtcpOff;
if (vie_channel->GetRTCPMode(module_mode) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: could not get current RTCP mode", __FUNCTION__);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
rtcp_mode = RTCPMethodToViERTCPMode(module_mode);
@ -302,26 +320,29 @@ int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel,
int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel,
const char rtcp_cname[KMaxRTCPCNameLength]) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, name: %s)", __FUNCTION__, video_channel,
rtcp_cname);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d already sending.", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpAlreadySending);
shared_data_->SetLastError(kViERtpRtcpAlreadySending);
return -1;
}
if (vie_channel->SetRTCPCName(rtcp_cname) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -329,18 +350,20 @@ int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel,
int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel,
char rtcp_cname[KMaxRTCPCNameLength]) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetRTCPCName(rtcp_cname) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -349,18 +372,20 @@ int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel,
int ViERTP_RTCPImpl::GetRemoteRTCPCName(
const int video_channel,
char rtcp_cname[KMaxRTCPCNameLength]) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -372,67 +397,75 @@ int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
unsigned int name,
const char* data,
unsigned short data_length_in_bytes) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, sub_type: %c, name: %d, data: x, length: %u)",
__FUNCTION__, video_channel, sub_type, name,
data_length_in_bytes);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (!vie_channel->Sending()) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d not sending", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpNotSending);
shared_data_->SetLastError(kViERtpRtcpNotSending);
return -1;
}
RTCPMethod method;
if (vie_channel->GetRTCPMode(method) != 0 || method == kRtcpOff) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: RTCP disabled on channel %d.", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpRtcpDisabled);
shared_data_->SetLastError(kViERtpRtcpRtcpDisabled);
return -1;
}
if (vie_channel->SendApplicationDefinedRTCPPacket(
sub_type, name, reinterpret_cast<const WebRtc_UWord8*>(data),
data_length_in_bytes) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
}
int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
enable);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->SetNACKStatus(enable) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: failed for channel %d", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
// Update the encoder
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not get encoder for channel %d", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
vie_encoder->UpdateProtectionMethod();
@ -442,34 +475,38 @@ int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) {
int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable,
const unsigned char payload_typeRED,
const unsigned char payload_typeFEC) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, payload_typeRED: %u, "
"payloadTypeFEC: %u)",
__FUNCTION__, video_channel, enable, payload_typeRED,
payload_typeFEC);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->SetFECStatus(enable, payload_typeRED,
payload_typeFEC) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: failed for channel %d", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
// Update the encoder.
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not get encoder for channel %d", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
vie_encoder->UpdateProtectionMethod();
@ -481,36 +518,40 @@ int ViERTP_RTCPImpl::SetHybridNACKFECStatus(
const bool enable,
const unsigned char payload_typeRED,
const unsigned char payload_typeFEC) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, payload_typeRED: %u, "
"payloadTypeFEC: %u)",
__FUNCTION__, video_channel, enable, payload_typeRED,
payload_typeFEC);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
// Update the channel status with hybrid NACK FEC mode.
if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED,
payload_typeFEC) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: failed for channel %d", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
// Update the encoder.
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not get encoder for channel %d", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
vie_encoder->UpdateProtectionMethod();
@ -520,22 +561,24 @@ int ViERTP_RTCPImpl::SetHybridNACKFECStatus(
int ViERTP_RTCPImpl::SetKeyFrameRequestMethod(
const int video_channel,
const ViEKeyFrameRequestMethod method) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, method: %d)", __FUNCTION__, video_channel,
method);
// Get the channel.
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method);
if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -543,19 +586,21 @@ int ViERTP_RTCPImpl::SetKeyFrameRequestMethod(
int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel,
const bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
enable);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->EnableTMMBR(enable) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -563,10 +608,12 @@ int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel,
int ViERTP_RTCPImpl::SetRembStatus(int video_channel, bool sender,
bool receiver) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"ViERTP_RTCPImpl::SetRembStatus(%d, %d, %d)", video_channel,
sender, receiver);
if (!channel_manager_.SetRembStatus(video_channel, sender, receiver)) {
if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender,
receiver)) {
return -1;
}
return 0;
@ -578,14 +625,16 @@ int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel,
unsigned int& extended_max,
unsigned int& jitter,
int& rtt_ms) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetReceivedRtcpStatistics(
@ -594,7 +643,7 @@ int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel,
static_cast<WebRtc_UWord32&>(extended_max),
static_cast<WebRtc_UWord32&>(jitter),
static_cast<WebRtc_Word32&>(rtt_ms)) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -606,14 +655,16 @@ int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel,
unsigned int& extended_max,
unsigned int& jitter,
int& rtt_ms) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
@ -623,7 +674,7 @@ int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel,
static_cast<WebRtc_UWord32&>(extended_max),
static_cast<WebRtc_UWord32&>(jitter),
static_cast<WebRtc_Word32&>(rtt_ms)) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -634,14 +685,16 @@ int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel,
unsigned int& packets_sent,
unsigned int& bytes_received,
unsigned int& packets_received) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->GetRtpStatistics(
@ -649,7 +702,7 @@ int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel,
static_cast<WebRtc_UWord32&>(packets_sent),
static_cast<WebRtc_UWord32&>(bytes_received),
static_cast<WebRtc_UWord32&>(packets_received)) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -660,14 +713,16 @@ int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel,
unsigned int& video_bitrate_sent,
unsigned int& fec_bitrate_sent,
unsigned int& nackBitrateSent) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
vie_channel->GetBandwidthUsage(
@ -683,26 +738,27 @@ int ViERTP_RTCPImpl::SetRTPKeepAliveStatus(
bool enable,
const char unknown_payload_type,
const unsigned int delta_transmit_time_seconds) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, enable: %d, unknown_payload_type: %d, "
"deltaTransmitTimeMS: %ul)",
__FUNCTION__, video_channel, enable,
static_cast<int>(unknown_payload_type),
delta_transmit_time_seconds);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__,
video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
WebRtc_UWord16 delta_transmit_time_ms = 1000 * delta_transmit_time_seconds;
if (vie_channel->SetKeepAliveStatus(enable, unknown_payload_type,
delta_transmit_time_ms) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -713,14 +769,16 @@ int ViERTP_RTCPImpl::GetRTPKeepAliveStatus(
bool& enabled,
char& unknown_payload_type,
unsigned int& delta_transmit_time_seconds) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
@ -729,7 +787,7 @@ int ViERTP_RTCPImpl::GetRTPKeepAliveStatus(
delta_time_ms);
delta_transmit_time_seconds = delta_time_ms / 1000;
if (ret_val != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
}
return ret_val;
}
@ -737,20 +795,22 @@ int ViERTP_RTCPImpl::GetRTPKeepAliveStatus(
int ViERTP_RTCPImpl::StartRTPDump(const int video_channel,
const char file_nameUTF8[1024],
RTPDirections direction) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__,
video_channel, file_nameUTF8, direction);
assert(FileWrapper::kMaxFileNameSize == 1024);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -758,19 +818,21 @@ int ViERTP_RTCPImpl::StartRTPDump(const int video_channel,
int ViERTP_RTCPImpl::StopRTPDump(const int video_channel,
RTPDirections direction) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, direction: %d)", __FUNCTION__, video_channel,
direction);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->StopRTPDump(direction) != 0) {
SetLastError(kViERtpRtcpUnknownError);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0;
@ -778,37 +840,40 @@ int ViERTP_RTCPImpl::StopRTPDump(const int video_channel,
int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel,
ViERTPObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->RegisterRtpObserver(&observer) != 0) {
SetLastError(kViERtpRtcpObserverAlreadyRegistered);
shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
return -1;
}
return 0;
}
int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(instance_id_, video_channel),
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->RegisterRtpObserver(NULL) != 0) {
SetLastError(kViERtpRtcpObserverNotRegistered);
shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
return -1;
}
return 0;
@ -816,36 +881,40 @@ int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) {
int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel,
ViERTCPObserver& observer) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->RegisterRtcpObserver(&observer) != 0) {
SetLastError(kViERtpRtcpObserverAlreadyRegistered);
shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
return -1;
}
return 0;
}
int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(channel_manager_);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel),
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
SetLastError(kViERtpRtcpInvalidChannelId);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
if (vie_channel->RegisterRtcpObserver(NULL) != 0) {
SetLastError(kViERtpRtcpObserverNotRegistered);
shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
return -1;
}
return 0;

View File

@ -15,16 +15,16 @@
#include "typedefs.h"
#include "video_engine/include/vie_rtp_rtcp.h"
#include "video_engine/vie_ref_count.h"
#include "video_engine/vie_shared_data.h"
namespace webrtc {
class ViESharedData;
class ViERTP_RTCPImpl
: public virtual ViESharedData,
public ViERTP_RTCP,
: public ViERTP_RTCP,
public ViERefCount {
public:
// Implements ViERTP_RTCP
// Implements ViERTP_RTCP.
virtual int Release();
virtual int SetLocalSSRC(const int video_channel,
const unsigned int SSRC,
@ -87,8 +87,9 @@ class ViERTP_RTCPImpl
unsigned int& video_bitrate_sent,
unsigned int& fec_bitrate_sent,
unsigned int& nackBitrateSent) const;
virtual int SetRTPKeepAliveStatus(
const int video_channel, bool enable, const char unknown_payload_type,
virtual int SetRTPKeepAliveStatus(const int video_channel,
bool enable,
const char unknown_payload_type,
const unsigned int delta_transmit_time_seconds);
virtual int GetRTPKeepAliveStatus(
const int video_channel,
@ -107,8 +108,11 @@ class ViERTP_RTCPImpl
virtual int DeregisterRTCPObserver(const int video_channel);
protected:
ViERTP_RTCPImpl();
ViERTP_RTCPImpl(ViESharedData* shared_data);
virtual ~ViERTP_RTCPImpl();
private:
ViESharedData* shared_data_;
};
} // namespace webrtc

View File

@ -14,8 +14,8 @@
#ifndef WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_
#define WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_
#include "vie_defines.h"
#include "vie_performance_monitor.h"
#include "video_engine/vie_defines.h"
#include "video_engine/vie_performance_monitor.h"
namespace webrtc {
@ -25,7 +25,7 @@ class ViEInputManager;
class ViERenderManager;
class ViESharedData {
protected:
public:
ViESharedData();
~ViESharedData();
@ -37,6 +37,14 @@ class ViESharedData {
int NumberOfCores() const;
int instance_id() { return instance_id_;}
ViEPerformanceMonitor* vie_performance_monitor() {
return &vie_performance_monitor_; }
ViEChannelManager* channel_manager() { return &channel_manager_; }
ViEInputManager* input_manager() { return &input_manager_; }
ViERenderManager* render_manager() { return &render_manager_; }
private:
static int instance_counter_;
const int instance_id_;
bool initialized_;
@ -47,8 +55,6 @@ class ViESharedData {
ViEInputManager& input_manager_;
ViERenderManager& render_manager_;
ProcessThread* module_process_thread_;
private:
mutable int last_error_;
};