Bug 1494312 - Part 1: Remove unused nsresult returns from MediaTransportHandler. r=mjf

Differential Revision: https://phabricator.services.mozilla.com/D11775

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Byron Campen [:bwc] 2018-11-23 16:46:23 +00:00
Родитель aa56ee0d4c
Коммит 69e7155b3a
9 изменённых файлов: 94 добавлений и 130 удалений

Просмотреть файл

@ -183,11 +183,10 @@ class LoopbackTransport : public MediaTransportBase {
peer_ = nullptr;
}
nsresult SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) override
void SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) override
{
peer_->SignalPacketReceived(aTransportId, aPacket);
return NS_OK;
}
TransportLayer::State GetState(const std::string& aTransportId,

Просмотреть файл

@ -825,21 +825,13 @@ MediaPipeline::CheckTransportStates()
}
}
nsresult
void
MediaPipeline::SendPacket(MediaPacket& packet)
{
ASSERT_ON_THREAD(mStsThread);
MOZ_ASSERT(mRtpState == TransportLayer::TS_OPEN);
MOZ_ASSERT(!mTransportId.empty());
nsresult rv = mTransportHandler->SendPacket(mTransportId, packet);
if (NS_FAILED(rv)) {
MOZ_LOG(gMediaPipelineLog, LogLevel::Error,
("Failed write on stream %s", mDescription.c_str()));
return NS_BASE_STREAM_CLOSED;
}
return NS_OK;
mTransportHandler->SendPacket(mTransportId, packet);
}
void
@ -1450,7 +1442,7 @@ MediaPipeline::PipelineTransport::SendRtpPacket(const uint8_t* aData, size_t aLe
return NS_OK;
}
nsresult
void
MediaPipeline::PipelineTransport::SendRtpRtcpPacket_s(
nsAutoPtr<MediaPacket> aPacket)
{
@ -1458,15 +1450,15 @@ MediaPipeline::PipelineTransport::SendRtpRtcpPacket_s(
ASSERT_ON_THREAD(mStsThread);
if (!mPipeline) {
return NS_OK; // Detached
return; // Detached
}
if (isRtp && mPipeline->mRtpState != TransportLayer::TS_OPEN) {
return NS_OK;
return;
}
if (!isRtp && mPipeline->mRtcpState != TransportLayer::TS_OPEN) {
return NS_OK;
return;
}
MediaPacket packet(std::move(*aPacket));
@ -1497,7 +1489,7 @@ MediaPipeline::PipelineTransport::SendRtpRtcpPacket_s(
mPipeline->mDescription.c_str(),
(isRtp ? "RTP" : "RTCP")));
return mPipeline->SendPacket(packet);
mPipeline->SendPacket(packet);
}
nsresult

Просмотреть файл

@ -189,7 +189,7 @@ public:
virtual nsresult SendRtcpPacket(const uint8_t* aData, size_t aLen) override;
private:
nsresult SendRtpRtcpPacket_s(nsAutoPtr<MediaPacket> aData);
void SendRtpRtcpPacket_s(nsAutoPtr<MediaPacket> aPacket);
// Creates a cycle, which we break with Detach
RefPtr<MediaPipeline> mPipeline;
@ -209,7 +209,7 @@ protected:
virtual void OnRtpPacketReceived() {};
void IncrementRtcpPacketsReceived();
virtual nsresult SendPacket(MediaPacket& packet);
virtual void SendPacket(MediaPacket& packet);
// Process slots on transports
void RtpStateChange(const std::string& aTransportId, TransportLayer::State);

Просмотреть файл

@ -170,14 +170,28 @@ nsresult
MediaTransportHandler::Init(const std::string& aName,
const dom::RTCConfiguration& aConfiguration)
{
bool allowIceLoopback = Preferences::GetBool(
"media.peerconnection.ice.loopback", false);
bool iceTcp = Preferences::GetBool("media.peerconnection.ice.tcp", false);
bool allowIceLinkLocal = Preferences::GetBool(
"media.peerconnection.ice.link_local", false);
std::vector<NrIceStunServer> stunServers;
std::vector<NrIceTurnServer> turnServers;
NrIceCtx::InitializeGlobals(allowIceLoopback, iceTcp, allowIceLinkLocal);
nsresult rv;
if (aConfiguration.mIceServers.WasPassed()) {
for (const auto& iceServer : aConfiguration.mIceServers.Value()) {
NS_ENSURE_STATE(iceServer.mUrls.WasPassed());
NS_ENSURE_STATE(iceServer.mUrls.Value().IsStringSequence());
for (const auto& iceUrl : iceServer.mUrls.Value().GetAsStringSequence()) {
rv = addNrIceServer(iceUrl, iceServer, &stunServers, &turnServers);
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: invalid STUN/TURN server: %s",
__FUNCTION__, NS_ConvertUTF16toUTF8(iceUrl).get());
return rv;
}
}
}
}
// This stuff will probably live on the other side of IPC; errors down here
// will either need to be ignored, or plumbed back in some way other than
// the return.
bool allowLoopback = Preferences::GetBool(
"media.peerconnection.ice.loopback", false);
bool tcpEnabled = Preferences::GetBool(
@ -199,25 +213,6 @@ MediaTransportHandler::Init(const std::string& aName,
mIceCtx->SignalConnectionStateChange.connect(
this, &MediaTransportHandler::OnConnectionStateChange);
std::vector<NrIceStunServer> stunServers;
std::vector<NrIceTurnServer> turnServers;
nsresult rv;
if (aConfiguration.mIceServers.WasPassed()) {
for (const auto& iceServer : aConfiguration.mIceServers.Value()) {
NS_ENSURE_STATE(iceServer.mUrls.WasPassed());
NS_ENSURE_STATE(iceServer.mUrls.Value().IsStringSequence());
for (const auto& iceUrl : iceServer.mUrls.Value().GetAsStringSequence()) {
rv = addNrIceServer(iceUrl, iceServer, &stunServers, &turnServers);
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: invalid STUN/TURN server: %s",
__FUNCTION__, NS_ConvertUTF16toUTF8(iceUrl).get());
return rv;
}
}
}
}
if (NS_FAILED(rv = mIceCtx->SetStunServers(stunServers))) {
CSFLogError(LOGTAG, "%s: Failed to set stun servers", __FUNCTION__);
return rv;
@ -250,26 +245,28 @@ void
MediaTransportHandler::Destroy()
{
disconnect_all();
NrIceStats stats = mIceCtx->Destroy();
CSFLogDebug(LOGTAG, "Ice Telemetry: stun (retransmits: %d)"
" turn (401s: %d 403s: %d 438s: %d)",
stats.stun_retransmits, stats.turn_401s, stats.turn_403s,
stats.turn_438s);
if (mIceCtx) {
NrIceStats stats = mIceCtx->Destroy();
CSFLogDebug(LOGTAG, "Ice Telemetry: stun (retransmits: %d)"
" turn (401s: %d 403s: %d 438s: %d)",
stats.stun_retransmits, stats.turn_401s, stats.turn_403s,
stats.turn_438s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_STUN_RETRANSMITS,
stats.stun_retransmits);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_401S,
stats.turn_401s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_403S,
stats.turn_403s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_438S,
stats.turn_438s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_STUN_RETRANSMITS,
stats.stun_retransmits);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_401S,
stats.turn_401s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_403S,
stats.turn_403s);
Telemetry::ScalarAdd(Telemetry::ScalarID::WEBRTC_NICER_TURN_438S,
stats.turn_438s);
}
}
nsresult
void
MediaTransportHandler::SetProxyServer(NrSocketProxyConfig&& aProxyConfig)
{
return mIceCtx->SetProxyServer(std::move(aProxyConfig));
mIceCtx->SetProxyServer(std::move(aProxyConfig));
}
void
@ -308,7 +305,7 @@ MediaTransportHandler::EnsureProvisionalTransport(
mTransports[aTransportId];
}
nsresult
void
MediaTransportHandler::ActivateTransport(
const std::string& aTransportId,
const std::string& aLocalUfrag,
@ -328,7 +325,7 @@ MediaTransportHandler::ActivateTransport(
RefPtr<NrIceMediaStream> stream(mIceCtx->GetStream(aTransportId));
if (!stream) {
MOZ_ASSERT(false);
return NS_ERROR_FAILURE;
return;
}
CSFLogDebug(LOGTAG, "%s: Activating ICE media stream=%s components=%u",
@ -351,7 +348,7 @@ MediaTransportHandler::ActivateTransport(
CSFLogError(LOGTAG, "Couldn't parse ICE attributes, rv=%u",
static_cast<unsigned>(rv));
MOZ_ASSERT(false);
return rv;
return;
}
Transport transport = mTransports[aTransportId];
@ -359,7 +356,7 @@ MediaTransportHandler::ActivateTransport(
transport.mFlow = CreateTransportFlow(aTransportId, false, aDtlsIdentity,
aDtlsClient, aFingerprints, aPrivacyRequested);
if (!transport.mFlow) {
return NS_ERROR_FAILURE;
return;
}
TransportLayer* dtls = transport.mFlow->GetLayer(TransportLayerDtls::ID());
dtls->SignalStateChange.connect(
@ -375,7 +372,7 @@ MediaTransportHandler::ActivateTransport(
transport.mRtcpFlow = CreateTransportFlow(aTransportId, true,
aDtlsIdentity, aDtlsClient, aFingerprints, aPrivacyRequested);
if (!transport.mRtcpFlow) {
return NS_ERROR_FAILURE;
return;
}
TransportLayer* dtls = transport.mRtcpFlow->GetLayer(
TransportLayerDtls::ID());
@ -389,7 +386,6 @@ MediaTransportHandler::ActivateTransport(
}
mTransports[aTransportId] = transport;
return NS_OK;
}
void
@ -423,7 +419,7 @@ MediaTransportHandler::StartIceGathering(
SignalGatheringStateChange(dom::PCImplIceGatheringState::Complete);
}
nsresult
void
MediaTransportHandler::StartIceChecks(
bool aIsControlling,
bool aIsOfferer,
@ -432,7 +428,7 @@ MediaTransportHandler::StartIceChecks(
nsresult rv = mIceCtx->ParseGlobalAttributes(aIceOptions);
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: couldn't parse global parameters", __FUNCTION__ );
return rv;
return;
}
rv = mIceCtx->SetControlling(aIsControlling ? NrIceCtx::ICE_CONTROLLING :
@ -440,19 +436,17 @@ MediaTransportHandler::StartIceChecks(
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: couldn't set controlling to %d",
__FUNCTION__, aIsControlling);
return rv;
return;
}
rv = mIceCtx->StartChecks(aIsOfferer);
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: couldn't start checks", __FUNCTION__);
return rv;
return;
}
return NS_OK;
}
nsresult
void
MediaTransportHandler::AddIceCandidate(const std::string& aTransportId,
const std::string& aCandidate)
{
@ -460,7 +454,7 @@ MediaTransportHandler::AddIceCandidate(const std::string& aTransportId,
if (!stream) {
CSFLogError(LOGTAG, "No ICE stream for candidate with transport id %s: %s",
aTransportId.c_str(), aCandidate.c_str());
return NS_ERROR_NOT_AVAILABLE;
return;
}
nsresult rv = stream->ParseTrickleCandidate(aCandidate);
@ -468,10 +462,7 @@ MediaTransportHandler::AddIceCandidate(const std::string& aTransportId,
CSFLogError(LOGTAG, "Couldn't process ICE candidate with transport id %s: "
"%s",
aTransportId.c_str(), aCandidate.c_str());
return NS_ERROR_FAILURE;
}
return NS_OK;
}
void
@ -499,7 +490,7 @@ MediaTransportHandler::RemoveTransportsExcept(
}
}
nsresult
void
MediaTransportHandler::SendPacket(const std::string& aTransportId,
MediaPacket& aPacket)
{
@ -511,7 +502,7 @@ MediaTransportHandler::SendPacket(const std::string& aTransportId,
CSFLogError(LOGTAG, "%s: No such transport flow (%s) for outgoing packet",
mIceCtx->name().c_str(), aTransportId.c_str());
MOZ_ASSERT(false);
return NS_ERROR_NOT_AVAILABLE;
return;
}
TransportLayer* layer = nullptr;
@ -527,7 +518,7 @@ MediaTransportHandler::SendPacket(const std::string& aTransportId,
// Maybe it would be useful to allow the injection of other packet types
// for testing?
MOZ_ASSERT(false);
return NS_ERROR_FAILURE;
return;
}
MOZ_ASSERT(layer);
@ -535,10 +526,7 @@ MediaTransportHandler::SendPacket(const std::string& aTransportId,
if (layer->SendPacket(aPacket) < 0) {
CSFLogError(LOGTAG, "%s: Transport flow (%s) failed to send packet",
mIceCtx->name().c_str(), aTransportId.c_str());
return NS_ERROR_FAILURE;
}
return NS_OK;
}
TransportLayer::State
@ -553,24 +541,22 @@ MediaTransportHandler::GetState(const std::string& aTransportId,
}
void
MediaTransportHandler::GetAllIceStats(bool aInternalStats,
DOMHighResTimeStamp aNow,
MediaTransportHandler::GetAllIceStats(DOMHighResTimeStamp aNow,
dom::RTCStatsReportInternal* aReport)
{
for (const auto& stream : mIceCtx->GetStreams()) {
GetIceStats(*stream, aInternalStats, aNow, aReport);
GetIceStats(*stream, aNow, aReport);
}
}
void
MediaTransportHandler::GetIceStats(const std::string& aTransportId,
bool aInternalStats,
DOMHighResTimeStamp aNow,
dom::RTCStatsReportInternal* aReport)
{
auto stream = mIceCtx->GetStream(aTransportId);
if (stream) {
GetIceStats(*stream, aInternalStats, aNow, aReport);
GetIceStats(*stream, aNow, aReport);
}
}
@ -615,7 +601,6 @@ static void ToRTCIceCandidateStats(
void
MediaTransportHandler::GetIceStats(
const NrIceMediaStream& aStream,
bool aInternalStats,
DOMHighResTimeStamp aNow,
dom::RTCStatsReportInternal* aReport) const
{

Просмотреть файл

@ -34,8 +34,8 @@ struct RTCStatsReportInternal;
// Base-class, makes some testing easier
class MediaTransportBase {
public:
virtual nsresult SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) = 0;
virtual void SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) = 0;
virtual TransportLayer::State GetState(const std::string& aTransportId,
bool aRtcp) const = 0;
@ -61,7 +61,7 @@ class MediaTransportHandler : public MediaTransportBase,
// We will probably be able to move the proxy lookup stuff into
// this class once we move mtransport to its own process.
nsresult SetProxyServer(NrSocketProxyConfig&& aProxyConfig);
void SetProxyServer(NrSocketProxyConfig&& aProxyConfig);
void EnsureProvisionalTransport(const std::string& aTransportId,
const std::string& aLocalUfrag,
@ -79,33 +79,33 @@ class MediaTransportHandler : public MediaTransportBase,
const nsTArray<NrIceStunAddr>& aStunAddrs);
nsresult ActivateTransport(const std::string& aTransportId,
const std::string& aLocalUfrag,
const std::string& aLocalPwd,
size_t aComponentCount,
const std::string& aUfrag,
const std::string& aPassword,
const std::vector<std::string>& aCandidateList,
// TODO(bug 1494311): Use an IPC type.
RefPtr<DtlsIdentity> aDtlsIdentity,
bool aDtlsClient,
// TODO(bug 1494311): Use IPC type
const SdpFingerprintAttributeList& aFingerprints,
bool aPrivacyRequested);
void ActivateTransport(const std::string& aTransportId,
const std::string& aLocalUfrag,
const std::string& aLocalPwd,
size_t aComponentCount,
const std::string& aUfrag,
const std::string& aPassword,
const std::vector<std::string>& aCandidateList,
// TODO(bug 1494311): Use an IPC type.
RefPtr<DtlsIdentity> aDtlsIdentity,
bool aDtlsClient,
// TODO(bug 1494311): Use IPC type
const SdpFingerprintAttributeList& aFingerprints,
bool aPrivacyRequested);
void RemoveTransportsExcept(const std::set<std::string>& aTransportIds);
nsresult StartIceChecks(bool aIsControlling,
bool aIsOfferer,
const std::vector<std::string>& aIceOptions);
void StartIceChecks(bool aIsControlling,
bool aIsOfferer,
const std::vector<std::string>& aIceOptions);
nsresult AddIceCandidate(const std::string& aTransportId,
const std::string& aCandidate);
void AddIceCandidate(const std::string& aTransportId,
const std::string& aCandidate);
void UpdateNetworkState(bool aOnline);
nsresult SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) override;
void SendPacket(const std::string& aTransportId,
MediaPacket& aPacket) override;
// TODO(bug 1494312): Figure out how this fits with an async API. Maybe we
// cache on the content process.
@ -113,13 +113,11 @@ class MediaTransportHandler : public MediaTransportBase,
bool aRtcp) const override;
// TODO(bug 1494312): Stats stuff needs to be async.
void GetAllIceStats(bool internalStats,
DOMHighResTimeStamp now,
void GetAllIceStats(DOMHighResTimeStamp now,
dom::RTCStatsReportInternal* report);
// TODO(bug 1494312): Stats stuff needs to be async.
void GetIceStats(const std::string& aTransportId,
bool internalStats,
DOMHighResTimeStamp now,
dom::RTCStatsReportInternal* report);
@ -165,7 +163,6 @@ class MediaTransportHandler : public MediaTransportBase,
RefPtr<TransportFlow> GetTransportFlow(const std::string& aId,
bool aIsRtcp) const;
void GetIceStats(const NrIceMediaStream& aStream,
bool aInternalStats,
DOMHighResTimeStamp aNow,
dom::RTCStatsReportInternal* aReport) const;

Просмотреть файл

@ -3188,12 +3188,10 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) {
if (query->media->mTransportHandler) {
if (query->grabAllLevels) {
query->media->mTransportHandler->GetAllIceStats(query->internalStats,
query->now,
query->media->mTransportHandler->GetAllIceStats(query->now,
query->report);
} else {
query->media->mTransportHandler->GetIceStats(query->transportId,
query->internalStats,
query->now,
query->report);
}

Просмотреть файл

@ -378,12 +378,7 @@ PeerConnectionMedia::StartIceChecks_s(
}
}
nsresult rv = mTransportHandler->StartIceChecks(aIsControlling,
aIsOfferer,
attributes);
if (NS_FAILED(rv)) {
CSFLogError(LOGTAG, "%s: couldn't start ICE", __FUNCTION__ );
}
mTransportHandler->StartIceChecks(aIsControlling, aIsOfferer, attributes);
}
bool

Просмотреть файл

@ -869,15 +869,13 @@ DataChannelConnection::SctpDtlsInput(const std::string& aTransportId,
usrsctp_conninput(static_cast<void *>(this), packet.data(), packet.len(), 0);
}
int
void
DataChannelConnection::SendPacket(nsAutoPtr<MediaPacket> packet)
{
//LOG(("%p: SCTP/DTLS sent %ld bytes", this, len));
if (!mTransportId.empty()) {
nsresult rv = mTransportHandler->SendPacket(mTransportId, *packet);
return NS_FAILED(rv) ? 1 : 0;
mTransportHandler->SendPacket(mTransportId, *packet);
}
return 0;
}
/* static */

Просмотреть файл

@ -247,7 +247,7 @@ private:
#ifdef SCTP_DTLS_SUPPORTED
static void DTLSConnectThread(void *data);
int SendPacket(nsAutoPtr<MediaPacket> packet);
void SendPacket(nsAutoPtr<MediaPacket> packet);
void SctpDtlsInput(const std::string& aTransportId, MediaPacket& packet);
static int SctpDtlsOutput(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df);
#endif