rtmp、rtc推拉流支持加密
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
@property (nonatomic, strong) UITextField *fpsField;
|
||||
@property (nonatomic, strong) UITextField *maxBitrateField;
|
||||
@property (nonatomic, strong) UITextField *minBitrateField;
|
||||
@property (nonatomic, strong) UITextField *xorKeyField;
|
||||
|
||||
@property (nonatomic, strong) NSLayoutConstraint *containerCenterYConstraint;
|
||||
@property (nonatomic, weak) UITextField *activeTextField; // 当前激活的输入框
|
||||
@@ -194,6 +195,37 @@
|
||||
topOffset += 40 + spacing;
|
||||
}
|
||||
|
||||
// XOR Key (after nickname, before video params)
|
||||
if (self.fieldsMask & AVSettingsFieldXorKey) {
|
||||
UILabel *xorKeyLabel = [[UILabel alloc] init];
|
||||
xorKeyLabel.text = @"加密密钥 (Hex)";
|
||||
xorKeyLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
||||
[contentView addSubview:xorKeyLabel];
|
||||
xorKeyLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[xorKeyLabel.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor constant:20],
|
||||
[xorKeyLabel.topAnchor constraintEqualToAnchor:contentView.topAnchor constant:topOffset]
|
||||
]];
|
||||
topOffset += 20;
|
||||
|
||||
_xorKeyField = [[UITextField alloc] init];
|
||||
_xorKeyField.placeholder = @"如 AABBCCDD(留空不加密)";
|
||||
_xorKeyField.borderStyle = UITextBorderStyleRoundedRect;
|
||||
_xorKeyField.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||
_xorKeyField.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||
_xorKeyField.delegate = self;
|
||||
_xorKeyField.returnKeyType = UIReturnKeyDone;
|
||||
[contentView addSubview:_xorKeyField];
|
||||
_xorKeyField.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_xorKeyField.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor constant:20],
|
||||
[_xorKeyField.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:-20],
|
||||
[_xorKeyField.topAnchor constraintEqualToAnchor:contentView.topAnchor constant:topOffset],
|
||||
[_xorKeyField.heightAnchor constraintEqualToConstant:40]
|
||||
]];
|
||||
topOffset += 40 + spacing;
|
||||
}
|
||||
|
||||
// Video parameters (conditional)
|
||||
if (self.fieldsMask & AVSettingsFieldVideoParams) {
|
||||
// Resolution
|
||||
@@ -373,6 +405,14 @@
|
||||
if (_minBitrateField) {
|
||||
_minBitrateField.text = [NSString stringWithFormat:@"%ld", (long)(config.videoMinBitRate / 1000)];
|
||||
}
|
||||
if (_xorKeyField) {
|
||||
// Load from config first, fallback to cached value
|
||||
NSString *key = config.xorKey;
|
||||
if (key.length == 0) {
|
||||
key = [[NSUserDefaults standardUserDefaults] stringForKey:@"selly_xor_key_cache"];
|
||||
}
|
||||
_xorKeyField.text = key ?: @"";
|
||||
}
|
||||
|
||||
self.frame = viewController.view.bounds;
|
||||
self.alpha = 0;
|
||||
@@ -428,6 +468,17 @@
|
||||
self.tempConfig.videoMinBitRate = minBitrate * 1000; // Convert kbps to bps
|
||||
}
|
||||
|
||||
if (_xorKeyField) {
|
||||
NSString *key = [_xorKeyField.text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
||||
self.tempConfig.xorKey = key.length > 0 ? key : nil;
|
||||
// Cache for next time
|
||||
if (key.length > 0) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:key forKey:@"selly_xor_key_cache"];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"selly_xor_key_cache"];
|
||||
}
|
||||
}
|
||||
|
||||
if (self.callback) {
|
||||
self.callback(self.tempConfig);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user