//
//  RCDataBuffer.m
//  RCOperation
//
//  Created by YHW on 2024/10/8.
//

#import "RCDataBuffer.h"

#pragma mark - RCDataBuffer
@interface RCDataBuffer ()

/** 内部存储的 `NSData` 和 `isBinary` 属性 */
@property (nonatomic, strong) NSData *data;
@property (nonatomic, assign) BOOL isBinary;

@end

@implementation RCDataBuffer

// 自定义的初始化方法
- (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary {
    self = [super init];
    if (self) {
        _data = data;
        _isBinary = isBinary;
    }
    return self;
}

@end



#pragma mark - RCStatistics
@interface RCStatistics ()

/** 可读写属性，用于内部赋值 */
@property(nonatomic, strong) NSString *id;
@property(nonatomic, assign) CFTimeInterval timestamp_us;
@property(nonatomic, strong) NSString *type;
@property(nonatomic, strong) NSDictionary<NSString *, NSObject *> *values;

@end

@implementation RCStatistics

// 自定义的初始化方法
- (instancetype)initWithId:(NSString *)id
                 timestamp:(CFTimeInterval)timestamp_us
                      type:(NSString *)type
                    values:(NSDictionary<NSString *, NSObject *> *)values {
    self = [super init];
    if (self) {
        _id = [id copy];  // 深拷贝保证唯一标识符安全
        _timestamp_us = timestamp_us;  // 赋值时间戳
        _type = [type copy];  // 深拷贝类型
        _values = [values copy];  // 深拷贝字典确保数据安全
    }
    return self;
}

@end



#pragma mark - RCStatisticsReport
@interface RCStatisticsReport ()

/** 可读写属性，用于内部设置 */
@property(nonatomic, assign) CFTimeInterval timestamp_us;
@property(nonatomic, strong) NSDictionary<NSString *, RCStatistics *> *statistics;

@end

@implementation RCStatisticsReport

// 自定义的初始化方法
- (instancetype)initWithTimestamp:(CFTimeInterval)timestamp_us
                       statistics:(NSDictionary<NSString *, RCStatistics *> *)statistics {
    self = [super init];
    if (self) {
        _timestamp_us = timestamp_us;
        _statistics = [statistics copy];  // 深拷贝以保证数据安全
    }
    return self;
}

@end


@interface RCIceCandidate ()

/** 可读写属性，用于内部设置 */
@property(nonatomic, copy, nullable) NSString *sdpMid;
@property(nonatomic, assign) int sdpMLineIndex;
@property(nonatomic, copy) NSString *sdp;

@end

@implementation RCIceCandidate

// 自定义的初始化方法
- (instancetype)initWithSdp:(NSString *)sdp
              sdpMLineIndex:(int)sdpMLineIndex
                     sdpMid:(nullable NSString *)sdpMid {
    self = [super init];
    if (self) {
        _sdp = sdp;
        _sdpMLineIndex = sdpMLineIndex;
        _sdpMid = sdpMid;
    }
    return self;
}

@end
