/* tslint:disable */
/* eslint-disable */
/**
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.8.9
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  ProblemDetails,
} from '../models';
import {
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
} from '../models';

export interface GetHlsAudioSegmentLegacyAacRequest {
    itemId: string;
    segmentId: string;
}

export interface GetHlsAudioSegmentLegacyMp3Request {
    itemId: string;
    segmentId: string;
}

export interface GetHlsPlaylistLegacyRequest {
    itemId: string;
    playlistId: string;
}

export interface GetHlsVideoSegmentLegacyRequest {
    itemId: string;
    playlistId: string;
    segmentId: string;
    segmentContainer: string;
}

export interface StopEncodingProcessRequest {
    deviceId: string;
    playSessionId: string;
}

/**
 * 
 */
export class HlsSegmentApi extends runtime.BaseAPI {

    /**
     * Gets the specified audio segment for an audio item.
     */
    async getHlsAudioSegmentLegacyAacRaw(requestParameters: GetHlsAudioSegmentLegacyAacRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getHlsAudioSegmentLegacyAac.');
        }

        if (requestParameters.segmentId === null || requestParameters.segmentId === undefined) {
            throw new runtime.RequiredError('segmentId','Required parameter requestParameters.segmentId was null or undefined when calling getHlsAudioSegmentLegacyAac.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/Audio/{itemId}/hls/{segmentId}/stream.aac`.replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))).replace(`{${"segmentId"}}`, encodeURIComponent(String(requestParameters.segmentId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets the specified audio segment for an audio item.
     */
    async getHlsAudioSegmentLegacyAac(requestParameters: GetHlsAudioSegmentLegacyAacRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getHlsAudioSegmentLegacyAacRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets the specified audio segment for an audio item.
     */
    async getHlsAudioSegmentLegacyMp3Raw(requestParameters: GetHlsAudioSegmentLegacyMp3Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getHlsAudioSegmentLegacyMp3.');
        }

        if (requestParameters.segmentId === null || requestParameters.segmentId === undefined) {
            throw new runtime.RequiredError('segmentId','Required parameter requestParameters.segmentId was null or undefined when calling getHlsAudioSegmentLegacyMp3.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/Audio/{itemId}/hls/{segmentId}/stream.mp3`.replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))).replace(`{${"segmentId"}}`, encodeURIComponent(String(requestParameters.segmentId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets the specified audio segment for an audio item.
     */
    async getHlsAudioSegmentLegacyMp3(requestParameters: GetHlsAudioSegmentLegacyMp3Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getHlsAudioSegmentLegacyMp3Raw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a hls video playlist.
     */
    async getHlsPlaylistLegacyRaw(requestParameters: GetHlsPlaylistLegacyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getHlsPlaylistLegacy.');
        }

        if (requestParameters.playlistId === null || requestParameters.playlistId === undefined) {
            throw new runtime.RequiredError('playlistId','Required parameter requestParameters.playlistId was null or undefined when calling getHlsPlaylistLegacy.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Videos/{itemId}/hls/{playlistId}/stream.m3u8`.replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))).replace(`{${"playlistId"}}`, encodeURIComponent(String(requestParameters.playlistId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets a hls video playlist.
     */
    async getHlsPlaylistLegacy(requestParameters: GetHlsPlaylistLegacyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getHlsPlaylistLegacyRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a hls video segment.
     */
    async getHlsVideoSegmentLegacyRaw(requestParameters: GetHlsVideoSegmentLegacyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getHlsVideoSegmentLegacy.');
        }

        if (requestParameters.playlistId === null || requestParameters.playlistId === undefined) {
            throw new runtime.RequiredError('playlistId','Required parameter requestParameters.playlistId was null or undefined when calling getHlsVideoSegmentLegacy.');
        }

        if (requestParameters.segmentId === null || requestParameters.segmentId === undefined) {
            throw new runtime.RequiredError('segmentId','Required parameter requestParameters.segmentId was null or undefined when calling getHlsVideoSegmentLegacy.');
        }

        if (requestParameters.segmentContainer === null || requestParameters.segmentContainer === undefined) {
            throw new runtime.RequiredError('segmentContainer','Required parameter requestParameters.segmentContainer was null or undefined when calling getHlsVideoSegmentLegacy.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/Videos/{itemId}/hls/{playlistId}/{segmentId}.{segmentContainer}`.replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))).replace(`{${"playlistId"}}`, encodeURIComponent(String(requestParameters.playlistId))).replace(`{${"segmentId"}}`, encodeURIComponent(String(requestParameters.segmentId))).replace(`{${"segmentContainer"}}`, encodeURIComponent(String(requestParameters.segmentContainer))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets a hls video segment.
     */
    async getHlsVideoSegmentLegacy(requestParameters: GetHlsVideoSegmentLegacyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getHlsVideoSegmentLegacyRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Stops an active encoding.
     */
    async stopEncodingProcessRaw(requestParameters: StopEncodingProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.deviceId === null || requestParameters.deviceId === undefined) {
            throw new runtime.RequiredError('deviceId','Required parameter requestParameters.deviceId was null or undefined when calling stopEncodingProcess.');
        }

        if (requestParameters.playSessionId === null || requestParameters.playSessionId === undefined) {
            throw new runtime.RequiredError('playSessionId','Required parameter requestParameters.playSessionId was null or undefined when calling stopEncodingProcess.');
        }

        const queryParameters: any = {};

        if (requestParameters.deviceId !== undefined) {
            queryParameters['deviceId'] = requestParameters.deviceId;
        }

        if (requestParameters.playSessionId !== undefined) {
            queryParameters['playSessionId'] = requestParameters.playSessionId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Videos/ActiveEncodings`,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Stops an active encoding.
     */
    async stopEncodingProcess(requestParameters: StopEncodingProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.stopEncodingProcessRaw(requestParameters, initOverrides);
    }

}
