//
// © 2018-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

#import "IoTPlayer+CategoriesHeader.h"
#import "IoTTypes.h"

@implementation IoTPlayer (HomeTheater)

- (void)updateHomeTheaterRatioVolumesForPlayerVolume:(double)volume
                                          completion:(nullable IoTCompletionHandler)completion
                                     completionQueue:(nullable dispatch_queue_t)queue
{
    /*

    if (!self.isSoundBar) {
        if (completion && queue) {
            dispatch_async(queue, ^{
                completion(YES, nil);
            });
        }
        return;
    }

    NSArray<NSNumber *> *channels = @[@(IoTHomeTheaterChannelSubwoofer),
                                      @(IoTHomeTheaterChannelLeftSurround),
                                      @(IoTHomeTheaterChannelRightSurround),
                                      @(IoTHomeTheaterChannelLeftRearSurround),
                                      @(IoTHomeTheaterChannelRightRearSurround),
                                      @(IoTHomeTheaterChannelLeftUpfiringSurround),
                                      @(IoTHomeTheaterChannelRightUpfiringSurround),
                                      @(IoTHomeTheaterChannelLeftRearUpfiringSurround),
                                      @(IoTHomeTheaterChannelRightRearUpfiringSurround)];

    for (NSNumber *number in channels) {
        IoTHomeTheaterChannel channel = [number integerValue];
        if ([self haveHomeTheaterChannel:channel]) {
            double currentRatio = [self homeTheaterChannelVolumeRatio:channel];
            // We assume the max ratio is 100?
			if (currentRatio >= 0)

                int ratioVolume = std::min(roundedDiv(volume * (ratio * m_homeTheaterSystemStatePtr->getMaxVolume(channel)), MAX_MASTER_VOLUME),
                                           m_homeTheaterSystemStatePtr->getMaxVolume(channel));
        }
    }


    for (unsigned int i = 0; i < channels.size(); i++) {
        HomeTheaterChannel::Enum channel = channels.at(i);

        if (m_homeTheaterSystemStatePtr->havePlayerInfo(channel)) {
            double ratio = m_multichannelZoneStatePtr->getLocalRatio(channel);
            if (ratio >= 0) {
                int ratioVolume = std::min(roundedDiv(volume * (ratio * m_homeTheaterSystemStatePtr->getMaxVolume(channel)),
                                                      MAX_MASTER_VOLUME), m_homeTheaterSystemStatePtr->getMaxVolume(channel));
                m_homeTheaterSystemStatePtr->setVolume(channel, ratioVolume);
                PlayerManagerImpl::getInstance()->onPlayerHomeTheaterChannelVolumeChanged(shared_from_this(),
                                                                                          channel, ratioVolume, true);
            }
        }
    }
     */
}

- (NSArray<NSString *> *)allRemovableHomeTheaterPlayerIDs
{
    return [self.state.multiChannelState playerIDsForAllChannelsRemovable];
}

@end
