зеркало из https://github.com/mozilla/gecko-dev.git
Bug 811695: disable internal socket transports for getUserMedia Audio capture r=derf
This commit is contained in:
Родитель
2007d09f19
Коммит
decae3d858
|
@ -41,5 +41,6 @@ include $(topsrcdir)/config/rules.mk
|
|||
ifdef MOZ_WEBRTC
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/media/webrtc/trunk/src \
|
||||
-I$(topsrcdir)/media/webrtc/signaling/src/common \
|
||||
$(NULL)
|
||||
endif
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "voice_engine/include/voe_base.h"
|
||||
#include "voice_engine/include/voe_codec.h"
|
||||
#include "voice_engine/include/voe_hardware.h"
|
||||
#include "voice_engine/include/voe_network.h"
|
||||
#include "voice_engine/include/voe_audio_processing.h"
|
||||
#include "voice_engine/include/voe_volume_control.h"
|
||||
#include "voice_engine/include/voe_external_media.h"
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include "video_engine/include/vie_capture.h"
|
||||
#include "video_engine/include/vie_file.h"
|
||||
|
||||
#include "NullTransport.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -166,7 +168,8 @@ public:
|
|||
, mMonitor("WebRTCMic.Monitor")
|
||||
, mCapIndex(aIndex)
|
||||
, mChannel(-1)
|
||||
, mInitDone(false) {
|
||||
, mInitDone(false)
|
||||
, mNullTransport(nullptr) {
|
||||
mState = kReleased;
|
||||
mDeviceName.Assign(NS_ConvertUTF8toUTF16(name));
|
||||
mDeviceUUID.Assign(NS_ConvertUTF8toUTF16(uuid));
|
||||
|
@ -201,6 +204,7 @@ private:
|
|||
webrtc::VoiceEngine* mVoiceEngine;
|
||||
webrtc::VoEBase* mVoEBase;
|
||||
webrtc::VoEExternalMedia* mVoERender;
|
||||
webrtc::VoENetwork* mVoENetwork;
|
||||
|
||||
mozilla::ReentrantMonitor mMonitor;
|
||||
|
||||
|
@ -213,6 +217,7 @@ private:
|
|||
nsString mDeviceUUID;
|
||||
|
||||
SourceMediaStream* mSource;
|
||||
NullTransport *mNullTransport;
|
||||
};
|
||||
|
||||
class MediaEngineWebRTC : public MediaEngine
|
||||
|
|
|
@ -53,11 +53,6 @@ MediaEngineWebRTCAudioSource::Allocate()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Audio doesn't play through unless we set a receiver and destination, so
|
||||
// we setup a dummy local destination, and do a loopback.
|
||||
mVoEBase->SetLocalReceiver(mChannel, DEFAULT_PORT);
|
||||
mVoEBase->SetSendDestination(mChannel, DEFAULT_PORT, "127.0.0.1");
|
||||
|
||||
mState = kAllocated;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -165,11 +160,19 @@ MediaEngineWebRTCAudioSource::Init()
|
|||
if (!mVoERender) {
|
||||
return;
|
||||
}
|
||||
mVoENetwork = webrtc::VoENetwork::GetInterface(mVoiceEngine);
|
||||
if (!mVoENetwork) {
|
||||
return;
|
||||
}
|
||||
|
||||
mChannel = mVoEBase->CreateChannel();
|
||||
if (mChannel < 0) {
|
||||
return;
|
||||
}
|
||||
mNullTransport = new NullTransport();
|
||||
if (mVoENetwork->RegisterExternalTransport(mChannel, *mNullTransport)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for availability.
|
||||
webrtc::VoEHardware* ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
|
||||
|
@ -209,6 +212,15 @@ void
|
|||
MediaEngineWebRTCAudioSource::Shutdown()
|
||||
{
|
||||
if (!mInitDone) {
|
||||
// duplicate these here in case we failed during Init()
|
||||
if (mChannel != -1) {
|
||||
mVoENetwork->DeRegisterExternalTransport(mChannel);
|
||||
}
|
||||
|
||||
if (mNullTransport) {
|
||||
delete mNullTransport;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,6 +233,14 @@ MediaEngineWebRTCAudioSource::Shutdown()
|
|||
}
|
||||
|
||||
mVoEBase->Terminate();
|
||||
if (mChannel != -1) {
|
||||
mVoENetwork->DeRegisterExternalTransport(mChannel);
|
||||
}
|
||||
|
||||
if (mNullTransport) {
|
||||
delete mNullTransport;
|
||||
}
|
||||
|
||||
mVoERender->Release();
|
||||
mVoEBase->Release();
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ CPPSRCS = \
|
|||
ifdef MOZ_WEBRTC
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/media/webrtc/trunk/src \
|
||||
-I$(topsrcdir)/media/webrtc/signaling/src/common \
|
||||
$(NULL)
|
||||
DIRS += bridge
|
||||
endif
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
'./src/common/csf_common.h',
|
||||
'./src/common/NullDeleter.h',
|
||||
'./src/common/Wrapper.h',
|
||||
'./src/common/NullTransport.h',
|
||||
# Browser Logging
|
||||
'./src/common/browser_logging/CSFLog.cpp',
|
||||
'./src/common/browser_logging/CSFLog.h',
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#ifndef NULL_TRANSPORT_H_
|
||||
#define NULL_TRANSPORT_H_
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include "common_types.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* NullTransport is registered as ExternalTransport to throw away data
|
||||
*/
|
||||
class NullTransport : public webrtc::Transport
|
||||
{
|
||||
public:
|
||||
virtual int SendPacket(int channel, const void *data, int len)
|
||||
{
|
||||
(void) channel; (void) data;
|
||||
return len;
|
||||
}
|
||||
|
||||
virtual int SendRTCPPacket(int channel, const void *data, int len)
|
||||
{
|
||||
(void) channel; (void) data;
|
||||
return len;
|
||||
}
|
||||
|
||||
NullTransport() {}
|
||||
|
||||
virtual ~NullTransport() {};
|
||||
|
||||
private:
|
||||
NullTransport(const NullTransport& other) MOZ_DELETE;
|
||||
void operator=(const NullTransport& other) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif
|
|
@ -38,6 +38,9 @@
|
|||
'include',
|
||||
],
|
||||
},
|
||||
'defines': [
|
||||
'WEBRTC_EXTERNAL_TRANSPORT',
|
||||
],
|
||||
'sources': [
|
||||
'../common_types.h',
|
||||
'../engine_configurations.h',
|
||||
|
|
Загрузка…
Ссылка в новой задаче