Allow passing network config constraint as base64 encoded string to preserve values of serialized protos. The values are a serialized byte stream packed into a std::string. To be represented as a NSString they must be base64 encoded or bytes outside of the ASCII range will be encoded into multi byte UTF8 sequences by default.
BUG=0 Review-Url: https://codereview.webrtc.org/2650343006 Cr-Commit-Position: refs/heads/master@{#16435}
This commit is contained in:
parent
390e64d7eb
commit
98c437458a
@ -32,6 +32,8 @@ NSString * const kRTCMediaConstraintsMaxFrameRate =
|
||||
@(webrtc::MediaConstraintsInterface::kMaxFrameRate);
|
||||
NSString * const kRTCMediaConstraintsLevelControl =
|
||||
@(webrtc::MediaConstraintsInterface::kLevelControl);
|
||||
NSString * const kRTCMediaConstraintsAudioNetworkAdaptorConfig =
|
||||
@(webrtc::MediaConstraintsInterface::kAudioNetworkAdaptorConfig);
|
||||
|
||||
NSString * const kRTCMediaConstraintsValueTrue =
|
||||
@(webrtc::MediaConstraintsInterface::kValueTrue);
|
||||
@ -109,8 +111,17 @@ MediaConstraints::GetOptional() const {
|
||||
NSString *value = [constraints objectForKey:key];
|
||||
NSAssert([value isKindOfClass:[NSString class]],
|
||||
@"%@ is not an NSString.", value);
|
||||
nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
|
||||
key.stdString, value.stdString));
|
||||
if ([kRTCMediaConstraintsAudioNetworkAdaptorConfig isEqualToString:key]) {
|
||||
// This value is base64 encoded.
|
||||
NSData *charData = [[NSData alloc] initWithBase64EncodedString:value options:0];
|
||||
std::string configValue =
|
||||
std::string(reinterpret_cast<const char *>(charData.bytes), charData.length);
|
||||
nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
|
||||
key.stdString, configValue));
|
||||
} else {
|
||||
nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
|
||||
key.stdString, value.stdString));
|
||||
}
|
||||
}
|
||||
return nativeConstraints;
|
||||
}
|
||||
|
||||
@ -23,6 +23,10 @@ RTC_EXTERN NSString * const kRTCMediaConstraintsMinHeight;
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsMaxFrameRate;
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsMinFrameRate;
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsLevelControl;
|
||||
/** The value for this key should be a base64 encoded string containing
|
||||
* the data from the serialized configuration proto.
|
||||
*/
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsAudioNetworkAdaptorConfig;
|
||||
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsValueTrue;
|
||||
RTC_EXTERN NSString * const kRTCMediaConstraintsValueFalse;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user