2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-31 12:22:14 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-02 15:28:02 +00:00
|
|
|
#include "webrtc/voice_engine/voe_network_impl.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-05-06 15:04:22 +02:00
|
|
|
#include "webrtc/base/checks.h"
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
#include "webrtc/base/format_macros.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
|
|
|
|
#include "webrtc/system_wrappers/include/logging.h"
|
|
|
|
|
#include "webrtc/system_wrappers/include/trace.h"
|
2013-05-02 15:28:02 +00:00
|
|
|
#include "webrtc/voice_engine/channel.h"
|
|
|
|
|
#include "webrtc/voice_engine/include/voe_errors.h"
|
|
|
|
|
#include "webrtc/voice_engine/voice_engine_impl.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-05-04 14:15:32 +02:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-05-04 14:15:32 +02:00
|
|
|
VoENetwork* VoENetwork::GetInterface(VoiceEngine* voiceEngine) {
|
2015-05-06 15:04:22 +02:00
|
|
|
if (!voiceEngine) {
|
|
|
|
|
return nullptr;
|
2015-05-04 14:15:32 +02:00
|
|
|
}
|
|
|
|
|
VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
|
|
|
|
|
s->AddRef();
|
|
|
|
|
return s;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-04 14:15:32 +02:00
|
|
|
VoENetworkImpl::VoENetworkImpl(voe::SharedData* shared) : _shared(shared) {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-06 15:04:22 +02:00
|
|
|
VoENetworkImpl::~VoENetworkImpl() = default;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
int VoENetworkImpl::RegisterExternalTransport(int channel,
|
2015-05-04 14:15:32 +02:00
|
|
|
Transport& transport) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(_shared->statistics().Initialized());
|
2015-05-04 14:15:32 +02:00
|
|
|
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
|
|
|
|
voe::Channel* channelPtr = ch.channel();
|
2015-05-06 15:04:22 +02:00
|
|
|
if (!channelPtr) {
|
|
|
|
|
LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return channelPtr->RegisterExternalTransport(transport);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-04 14:15:32 +02:00
|
|
|
int VoENetworkImpl::DeRegisterExternalTransport(int channel) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_CHECK(_shared->statistics().Initialized());
|
2015-05-04 14:15:32 +02:00
|
|
|
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
|
|
|
|
voe::Channel* channelPtr = ch.channel();
|
2015-05-06 15:04:22 +02:00
|
|
|
if (!channelPtr) {
|
|
|
|
|
LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return channelPtr->DeRegisterExternalTransport();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VoENetworkImpl::ReceivedRTPPacket(int channel,
|
|
|
|
|
const void* data,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t length) {
|
2014-03-24 10:38:25 +00:00
|
|
|
return ReceivedRTPPacket(channel, data, length, webrtc::PacketTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VoENetworkImpl::ReceivedRTPPacket(int channel,
|
|
|
|
|
const void* data,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t length,
|
2015-05-04 14:15:32 +02:00
|
|
|
const PacketTime& packet_time) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_CHECK(_shared->statistics().Initialized());
|
|
|
|
|
RTC_CHECK(data);
|
2015-05-04 14:15:32 +02:00
|
|
|
// L16 at 32 kHz, stereo, 10 ms frames (+12 byte RTP header) -> 1292 bytes
|
|
|
|
|
if ((length < 12) || (length > 1292)) {
|
2015-05-06 15:04:22 +02:00
|
|
|
LOG_F(LS_ERROR) << "Invalid packet length: " << length;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
|
|
|
|
voe::Channel* channelPtr = ch.channel();
|
2015-05-06 15:04:22 +02:00
|
|
|
if (!channelPtr) {
|
|
|
|
|
LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!channelPtr->ExternalTransport()) {
|
2015-05-06 15:04:22 +02:00
|
|
|
LOG_F(LS_ERROR) << "No external transport for channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return channelPtr->ReceivedRTPPacket((const int8_t*)data, length,
|
|
|
|
|
packet_time);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-04 14:15:32 +02:00
|
|
|
int VoENetworkImpl::ReceivedRTCPPacket(int channel,
|
|
|
|
|
const void* data,
|
|
|
|
|
size_t length) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_CHECK(_shared->statistics().Initialized());
|
|
|
|
|
RTC_CHECK(data);
|
2015-05-04 14:15:32 +02:00
|
|
|
if (length < 4) {
|
2015-05-06 15:04:22 +02:00
|
|
|
LOG_F(LS_ERROR) << "Invalid packet length: " << length;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
|
|
|
|
|
voe::Channel* channelPtr = ch.channel();
|
2015-05-06 15:04:22 +02:00
|
|
|
if (!channelPtr) {
|
|
|
|
|
LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!channelPtr->ExternalTransport()) {
|
2015-05-06 15:04:22 +02:00
|
|
|
LOG_F(LS_ERROR) << "No external transport for channel: " << channel;
|
2015-05-04 14:15:32 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return channelPtr->ReceivedRTCPPacket((const int8_t*)data, length);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-05-06 15:04:22 +02:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|