//
//  EZStreamConfigLoader.m
//  EZOpenSDKDemo
//
//  Created by JuneCheng on 2026/3/12.
//  Copyright © 2026 hikvision. All rights reserved.
//

#import "EZStreamConfigLoader.h"
#import "EZPlayer.h"
#import "EZDeviceRecordDownloadTask.h"

NS_ASSUME_NONNULL_BEGIN

@implementation EZStreamConfigLoader

+ (void)loadRealPlaySpecialConfigToPlayer:(EZPlayer *)realPlayPlayer {
    // 国内 & 小权限token模式下，设置自己服务器生成的tkToken
    if ([EZOpenSDK isEnableSDKWithTKToken]) {
        [realPlayPlayer setStreamToken:[GlobalKit shareKit].previewStreamToken];
    }
    // 播放器禁用P2P
    if ([GlobalKit shareKit].isPlayerP2PDisable) {
        [realPlayPlayer setPlayerDisableP2P];
    }
    // 取流前要切换清晰度，会增加出画面的耗时；一般不用设置，如果业务需要选择设置
    [realPlayPlayer setVideoQuality:[GlobalKit shareKit].videoQuality];
}

+ (void)loadPlaybackSpecialConfigToPlayer:(EZPlayer *)playbackPlayer {
    // 国内 & 小权限token模式下，设置自己服务器生成的tkToken
    if ([EZOpenSDK isEnableSDKWithTKToken]) {
        [playbackPlayer setStreamToken:[GlobalKit shareKit].playbackStreamToken];
    }
    // 播放器禁用P2P
    if ([GlobalKit shareKit].isPlayerP2PDisable) {
        [playbackPlayer setPlayerDisableP2P];
    }
    // 纯音频播放
    if ([GlobalKit shareKit].enablePureAudio) {
        [playbackPlayer enablePureAudio];
    }
}

+ (void)loadVoicetalkSpecialConfigToPlayer:(EZPlayer *)voiceTalkPlayer {
    // 国内 & 小权限token模式下，设置自己服务器生成的tkToken
    if ([EZOpenSDK isEnableSDKWithTKToken]) {
        [voiceTalkPlayer setStreamToken:[GlobalKit shareKit].talkStreamToken];
    }
}

+ (void)loadDownloadDeviceVideoSpecialConfigToStreamDownload:(EZDeviceRecordDownloadTask *)deviceRecordDownloadTask {
    // 国内 & 小权限token模式下，设置自己服务器生成的tkToken
    if ([EZOpenSDK isEnableSDKWithTKToken]) {
        [deviceRecordDownloadTask setStreamToken:[GlobalKit shareKit].playbackStreamToken];
    }
}

@end

NS_ASSUME_NONNULL_END
