Bug 805533 Patch 2 - Pass SDP parsing errors up to PeerConnection r=jesup

This commit is contained in:
Ethan Hugg 2012-11-15 10:38:27 -08:00
parent 2f241cd167
commit 53f76a2172
7 changed files with 106 additions and 9 deletions
media/webrtc/signaling/src

@ -2700,3 +2700,22 @@ vcmCreateTransportFlow(sipcc::PeerConnectionImpl *pc, int level, bool rtcp,
}
return flow;
}
/**
* vcmOnSdpParseError
*
* This method is called for each parsing error of SDP. It does not necessarily
* mean the SDP read was fatal and can be called many times for the same SDP.
*
*/
int vcmOnSdpParseError(const char *peerconnection, const char *message) {
sipcc::PeerConnectionWrapper pc(peerconnection);
ENSURE_PC(pc, VCM_ERROR);
pc.impl()->OnSdpParseError(message);
return 0;
}

@ -160,18 +160,30 @@ public:
break;
case SETLOCALDESC:
// TODO: The SDP Parse error list should be copied out and sent up
// to the Javascript layer before being cleared here.
mPC->ClearSdpParseErrorMessages();
mObserver->OnSetLocalDescriptionSuccess(mCode);
break;
case SETREMOTEDESC:
// TODO: The SDP Parse error list should be copied out and sent up
// to the Javascript layer before being cleared here.
mPC->ClearSdpParseErrorMessages();
mObserver->OnSetRemoteDescriptionSuccess(mCode);
break;
case SETLOCALDESCERROR:
// TODO: The SDP Parse error list should be copied out and sent up
// to the Javascript layer before being cleared here.
mPC->ClearSdpParseErrorMessages();
mObserver->OnSetLocalDescriptionError(mCode);
break;
case SETREMOTEDESCERROR:
// TODO: The SDP Parse error list should be copied out and sent up
// to the Javascript layer before being cleared here.
mPC->ClearSdpParseErrorMessages();
mObserver->OnSetRemoteDescriptionError(mCode);
break;
@ -1388,6 +1400,18 @@ PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream)
CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str());
}
void
PeerConnectionImpl::OnSdpParseError(const char *message) {
CSFLogError(logTag, "%s SDP Parse Error: %s", __FUNCTION__, message);
// Save the parsing errors in the PC to be delivered with OnSuccess or OnError
mSDPParseErrorMessages.push_back(message);
}
void
PeerConnectionImpl::ClearSdpParseErrorMessages() {
mSDPParseErrorMessages.clear();
}
#ifdef MOZILLA_INTERNAL_API
static nsresult

@ -222,6 +222,15 @@ public:
NS_IMETHODIMP CreateOffer(MediaConstraints& aConstraints);
NS_IMETHODIMP CreateAnswer(MediaConstraints& aConstraints);
// Called whenever something is unrecognized by the parser
// May be called more than once and does not necessarily mean
// that parsing was stopped, only that something was unrecognized.
void OnSdpParseError(const char* errorMessage);
// Called when OnLocal/RemoteDescriptionSuccess/Error
// is called to start the list over.
void ClearSdpParseErrorMessages();
private:
PeerConnectionImpl(const PeerConnectionImpl&rhs);
PeerConnectionImpl& operator=(PeerConnectionImpl);
@ -313,6 +322,9 @@ private:
int mNumAudioStreams;
int mNumVideoStreams;
// Holder for error messages from parsing SDP
std::vector<std::string> mSDPParseErrorMessages;
public:
//these are temporary until the DataChannel Listen/Connect API is removed
unsigned short listenPort;

@ -1453,11 +1453,17 @@ sdp_result_e sdp_free_description (sdp_t *sdp_p)
* Send SDP parsing errors to log and up to peerconnection
*/
void sdp_parse_error(const char *peerconnection, const char *format, ...) {
flex_string fs;
va_list ap;
/* TODO - report error up to PeerConnection here */
flex_string_init(&fs);
va_start(ap, format);
CSFLogErrorV("SDP Parse", format, ap);
flex_string_vsprintf(&fs, format, ap);
va_end(ap);
CSFLogError("SDP Parse", "SDP Parse Error %s, pc %s", fs.buffer, peerconnection);
vcmOnSdpParseError(peerconnection, fs.buffer);
flex_string_free(&fs);
}

@ -2,7 +2,6 @@
* 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/. */
#include <stdio.h>
#include <stdarg.h>
#include "mozilla/Assertions.h"
@ -166,22 +165,29 @@ void flex_string_append(flex_string *fs, const char *more) {
}
/*
* flex_string_sprintf
* va_copy is part of the C99 spec but MSVC doesn't have it.
*/
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
/*
* flex_string_vsprintf
*
* Not thread-safe
*/
void flex_string_sprintf(flex_string *fs, const char *format, ...) {
void flex_string_vsprintf(flex_string *fs, const char *format, va_list original_ap) {
va_list ap;
int vsnprintf_result;
va_start(ap, format);
va_copy(ap, original_ap);
vsnprintf_result = vsnprintf(fs->buffer + fs->string_length, fs->buffer_length - fs->string_length, format, ap);
va_end(ap);
/* Special case just for Windows where vsnprintf is broken
and returns -1 if buffer too large unless you size it 0. */
if (vsnprintf_result < 0) {
va_start(ap, format);
va_copy(ap, original_ap);
vsnprintf_result = vsnprintf(NULL, 0, format, ap);
va_end(ap);
}
@ -191,10 +197,10 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
flex_string_check_alloc(fs, fs->string_length + vsnprintf_result + 1);
/* Try again with new buffer */
va_start(ap, format);
va_copy(ap, original_ap);
vsnprintf_result = vsnprintf(fs->buffer + fs->string_length, fs->buffer_length - fs->string_length, format, ap);
MOZ_ASSERT(vsnprintf_result > 0 && vsnprintf_result < (fs->buffer_length - fs->string_length));
va_end(ap);
MOZ_ASSERT(vsnprintf_result > 0 && vsnprintf_result < (fs->buffer_length - fs->string_length));
}
if (vsnprintf_result > 0) {
@ -202,4 +208,16 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
}
}
/*
* flex_string_sprintf
*
* Not thread-safe
*/
void flex_string_sprintf(flex_string *fs, const char *format, ...) {
va_list ap;
va_start(ap, format);
flex_string_vsprintf(fs, format, ap);
va_end(ap);
}

@ -5,6 +5,8 @@
#ifndef _CPR_STRING_H_
#define _CPR_STRING_H_
#include <stdarg.h>
#include "cpr_types.h"
#include "cpr_strings.h"
@ -104,6 +106,13 @@ void flex_string_check_alloc(flex_string *fs, size_t new_min_length);
*/
void flex_string_append(flex_string *fs, const char *more);
/*
* flex_string_sprintf
*
* Not thread-safe
*/
void flex_string_vsprintf(flex_string *fs, const char *format, va_list original_ap);
/*
* flex_string_sprintf
*

@ -1003,6 +1003,15 @@ int vcmDtmfBurst(int digit, int duration, int direction);
*/
int vcmGetILBCMode();
/**
* vcmOnSdpParseError
*
* This method is called for each parsing error of SDP. It does not necessarily
* mean the SDP read was fatal and can be called many times for the same SDP.
*
*/
int vcmOnSdpParseError(const char *peercconnection, const char *message);
//Using C++ for gips. This is the end of extern "C" above.
#ifdef __cplusplus
}