blob: 96c8be57eec76363e71c35ce6945901893dac498 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org07c68b92012-02-29 16:09:51 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000011#include "video_engine/vie_network_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +000013#include "engine_configurations.h" // NOLINT
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000014#include "system_wrappers/interface/trace.h"
mflodman@webrtc.orga4863db2011-12-22 08:51:52 +000015#include "video_engine/include/vie_errors.h"
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000016#include "video_engine/vie_channel.h"
17#include "video_engine/vie_channel_manager.h"
18#include "video_engine/vie_defines.h"
19#include "video_engine/vie_encoder.h"
20#include "video_engine/vie_impl.h"
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000021#include "video_engine/vie_shared_data.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000023namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000024
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000025ViENetwork* ViENetwork::GetInterface(VideoEngine* video_engine) {
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000026 if (!video_engine) {
niklase@google.com470e71d2011-07-07 08:21:25 +000027 return NULL;
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000028 }
29 VideoEngineImpl* vie_impl = reinterpret_cast<VideoEngineImpl*>(video_engine);
30 ViENetworkImpl* vie_networkImpl = vie_impl;
31 // Increase ref count.
32 (*vie_networkImpl)++;
33 return vie_networkImpl;
niklase@google.com470e71d2011-07-07 08:21:25 +000034}
35
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000036int ViENetworkImpl::Release() {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000037 WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000038 "ViENetwork::Release()");
39 // Decrease ref count.
40 (*this)--;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000042 WebRtc_Word32 ref_count = GetCount();
43 if (ref_count < 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000044 WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000045 "ViENetwork release too many times");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000046 shared_data_->SetLastError(kViEAPIDoesNotExist);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000047 return -1;
48 }
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000049 WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000050 "ViENetwork reference count: %d", ref_count);
51 return ref_count;
niklase@google.com470e71d2011-07-07 08:21:25 +000052}
53
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000054ViENetworkImpl::ViENetworkImpl(ViESharedData* shared_data)
55 : shared_data_(shared_data) {
56 WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000057 "ViENetworkImpl::ViENetworkImpl() Ctor");
niklase@google.com470e71d2011-07-07 08:21:25 +000058}
59
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000060ViENetworkImpl::~ViENetworkImpl() {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000061 WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000062 "ViENetworkImpl::~ViENetworkImpl() Dtor");
niklase@google.com470e71d2011-07-07 08:21:25 +000063}
64
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000065int ViENetworkImpl::RegisterSendTransport(const int video_channel,
66 Transport& transport) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000067 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
68 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000069 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000070 if (!shared_data_->Initialized()) {
71 shared_data_->SetLastError(kViENotInitialized);
72 WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000073 "%s - ViE instance %d not initialized", __FUNCTION__,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000074 shared_data_->instance_id());
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000075 return -1;
76 }
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000077 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000078 ViEChannel* vie_channel = cs.Channel(video_channel);
79 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000080 WEBRTC_TRACE(kTraceError, kTraceVideo,
81 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000082 "%s Channel doesn't exist", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000083 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000084 return -1;
85 }
86 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000087 WEBRTC_TRACE(kTraceError, kTraceVideo,
88 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000089 "%s Channel already sending.", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000090 shared_data_->SetLastError(kViENetworkAlreadySending);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000091 return -1;
92 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +000093 if (vie_channel->RegisterSendTransport(&transport) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000094 shared_data_->SetLastError(kViENetworkUnknownError);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +000095 return -1;
96 }
97 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000098}
99
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000100int ViENetworkImpl::DeregisterSendTransport(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000101 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
102 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000103 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000104 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000105 ViEChannel* vie_channel = cs.Channel(video_channel);
106 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000107 WEBRTC_TRACE(kTraceError, kTraceVideo,
108 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000109 "%s Channel doesn't exist", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000110 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000111 return -1;
112 }
113 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000114 WEBRTC_TRACE(kTraceError, kTraceVideo,
115 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000116 "%s Channel already sending", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000117 shared_data_->SetLastError(kViENetworkAlreadySending);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000118 return -1;
119 }
120 if (vie_channel->DeregisterSendTransport() != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000121 shared_data_->SetLastError(kViENetworkUnknownError);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000122 return -1;
123 }
124 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000125}
126
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000127int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data,
128 const int length) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000129 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
130 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000131 "%s(channel: %d, data: -, length: %d)", __FUNCTION__,
132 video_channel, length);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000133 if (!shared_data_->Initialized()) {
134 shared_data_->SetLastError(kViENotInitialized);
135 WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000136 "%s - ViE instance %d not initialized", __FUNCTION__,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000137 shared_data_->instance_id());
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000138 return -1;
139 }
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000140 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000141 ViEChannel* vie_channel = cs.Channel(video_channel);
142 if (!vie_channel) {
143 // The channel doesn't exists
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000144 WEBRTC_TRACE(kTraceError, kTraceVideo,
145 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000146 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000147 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000148 return -1;
149 }
150 return vie_channel->ReceivedRTPPacket(data, length);
niklase@google.com470e71d2011-07-07 08:21:25 +0000151}
152
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000153int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel,
154 const void* data, const int length) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000155 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
156 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000157 "%s(channel: %d, data: -, length: %d)", __FUNCTION__,
158 video_channel, length);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000159 if (!shared_data_->Initialized()) {
160 shared_data_->SetLastError(kViENotInitialized);
161 WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000162 "%s - ViE instance %d not initialized", __FUNCTION__,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000163 shared_data_->instance_id());
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000164 return -1;
165 }
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000166 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000167 ViEChannel* vie_channel = cs.Channel(video_channel);
168 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000169 WEBRTC_TRACE(kTraceError, kTraceVideo,
170 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000171 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000172 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000173 return -1;
174 }
175 return vie_channel->ReceivedRTCPPacket(data, length);
niklase@google.com470e71d2011-07-07 08:21:25 +0000176}
177
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000178int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000179 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
180 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000181 "%s(channel: %d, mtu: %u)", __FUNCTION__, video_channel, mtu);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000182 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000183 ViEChannel* vie_channel = cs.Channel(video_channel);
184 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000185 WEBRTC_TRACE(kTraceError, kTraceVideo,
186 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000187 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000188 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000189 return -1;
190 }
191 if (vie_channel->SetMTU(mtu) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000192 shared_data_->SetLastError(kViENetworkUnknownError);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000193 return -1;
194 }
195 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000196}
197
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000198int ViENetworkImpl::SetPacketTimeoutNotification(const int video_channel,
niklase@google.com470e71d2011-07-07 08:21:25 +0000199 bool enable,
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000200 int timeout_seconds) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000201 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
202 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000203 "%s(channel: %d, enable: %d, timeout_seconds: %u)",
204 __FUNCTION__, video_channel, enable, timeout_seconds);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000205 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000206 ViEChannel* vie_channel = cs.Channel(video_channel);
207 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000208 WEBRTC_TRACE(kTraceError, kTraceVideo,
209 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000210 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000211 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000212 return -1;
213 }
214 if (vie_channel->SetPacketTimeoutNotification(enable,
215 timeout_seconds) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000216 shared_data_->SetLastError(kViENetworkUnknownError);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000217 return -1;
218 }
219 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000220}
221
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000222int ViENetworkImpl::RegisterObserver(const int video_channel,
223 ViENetworkObserver& observer) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000224 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
225 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000226 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000227 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000228 ViEChannel* vie_channel = cs.Channel(video_channel);
229 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000230 WEBRTC_TRACE(kTraceError, kTraceVideo,
231 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000232 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000233 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000234 return -1;
235 }
236 if (vie_channel->RegisterNetworkObserver(&observer) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000237 shared_data_->SetLastError(kViENetworkObserverAlreadyRegistered);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000238 return -1;
239 }
240 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000241}
242
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000243int ViENetworkImpl::DeregisterObserver(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000244 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
245 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000246 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000247 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000248 ViEChannel* vie_channel = cs.Channel(video_channel);
249 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000250 WEBRTC_TRACE(kTraceError, kTraceVideo,
251 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000252 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000253 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000254 return -1;
255 }
256 if (!vie_channel->NetworkObserverRegistered()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000257 shared_data_->SetLastError(kViENetworkObserverNotRegistered);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000258 return -1;
259 }
260 return vie_channel->RegisterNetworkObserver(NULL);
niklase@google.com470e71d2011-07-07 08:21:25 +0000261}
262
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000263int ViENetworkImpl::SetPeriodicDeadOrAliveStatus(
264 const int video_channel,
265 bool enable,
266 unsigned int sample_time_seconds) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000267 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
268 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000269 "%s(channel: %d, enable: %d, sample_time_seconds: %ul)",
270 __FUNCTION__, video_channel, enable, sample_time_seconds);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000271 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000272 ViEChannel* vie_channel = cs.Channel(video_channel);
273 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000274 WEBRTC_TRACE(kTraceError, kTraceVideo,
275 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000276 "Channel doesn't exist");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000277 shared_data_->SetLastError(kViENetworkInvalidChannelId);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000278 return -1;
279 }
280 if (!vie_channel->NetworkObserverRegistered()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000281 shared_data_->SetLastError(kViENetworkObserverNotRegistered);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000282 return -1;
283 }
284 if (vie_channel->SetPeriodicDeadOrAliveStatus(enable, sample_time_seconds)
285 != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000286 shared_data_->SetLastError(kViENetworkUnknownError);
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000287 return -1;
288 }
289 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000290}
291
mflodman@webrtc.org1bdf1df2011-12-20 11:57:47 +0000292} // namespace webrtc