//
//  BareVideoInfo.m
//

#import "BareVideoInfo.h"

@implementation BareVideoInfo

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:self.fileType forKey:@"FileType"];
    [dict setValue:self.format forKey:@"Format"];
    [dict setValue:self.codec forKey:@"Codec"];
    [dict setValue:self.fileId forKey:@"FileId"];
    [dict setValue:self.md5 forKey:@"Md5"];
    [dict setValue:self.definition forKey:@"Definition"];
    [dict setValue:self.mainPlayUrl forKey:@"MainPlayUrl"];
    [dict setValue:self.mainUrlExpireTime forKey:@"MainUrlExpire"];
    [dict setValue:@(self.bitrate) forKey:@"Bitrate"];
    [dict setValue:@(self.width) forKey:@"Width"];
    [dict setValue:@(self.height) forKey:@"Height"];
    return [dict copy];
}

@end

@implementation BareVideoModel

- (instancetype)init {
    self = [super init];
    if (self) {
        _version = 4;
        _status = 10;
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:self.vid forKey:@"Vid"];
    [dict setValue:@(self.status) forKey:@"Status"];
    [dict setValue:@(self.version) forKey:@"Version"];
    [dict setValue:@(self.duration) forKey:@"Duration"];
    [dict setValue:@(self.enableAdaptive) forKey:@"EnableAdaptive"];

    NSMutableArray *playInfoList = [NSMutableArray array];
    for (BareVideoInfo *info in self.playInfoList) {
        NSDictionary *infoDict = [info dictionaryRepresentation];
        [playInfoList addObject:infoDict];
    }

    [dict setValue:playInfoList forKey:@"PlayInfoList"];
    return dict.copy;
}

- (TTVideoEngineModel *)engineVideoModel {
    return [TTVideoEngineModel videoModelWithDict:[self dictionaryRepresentation]];
}

@end
