Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
murat-dogan committed Aug 11, 2022
2 parents 2bb49ce + 953005d commit 6c4e3d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ export interface RtcConfig {
iceTransportPolicy?: TransportPolicy;
}

// Lowercase to match the description type string from libdatachannel
export const enum DescriptionType {
Unspec = 'Unspec',
Offer = 'Offer',
Answer = 'Answer',
Pranswer = 'Pranswer',
Rollback = 'Rollback',
Unspec = 'unspec',
Offer = 'offer',
Answer = 'answer',
Pranswer = 'pranswer',
Rollback = 'rollback',
}

export const enum ReliabilityType {
Expand Down
13 changes: 9 additions & 4 deletions src/peer-connection-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "media-video-wrapper.h"
#include "media-audio-wrapper.h"

#include <cctype>
#include <sstream>

Napi::FunctionReference PeerConnectionWrapper::constructor;
Expand Down Expand Up @@ -281,13 +282,17 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
}
std::string typeStr = info[0].As<Napi::String>().ToString();

if (typeStr == "Answer")
// Accept uppercase first letter for backward compatibility
if(typeStr.size() > 0)
typeStr[0] = std::tolower(typeStr[0]);

if (typeStr == "answer")
type = rtc::Description::Type::Answer;
if (typeStr == "Offer")
else if (typeStr == "offer")
type = rtc::Description::Type::Offer;
if (typeStr == "Pranswer")
else if (typeStr == "pranswer")
type = rtc::Description::Type::Pranswer;
if (typeStr == "Rollback")
else if (typeStr == "rollback")
type = rtc::Description::Type::Rollback;
}

Expand Down

0 comments on commit 6c4e3d0

Please sign in to comment.