/*****************************************************************************
 * VLCMLCacher.h
 * VLCMediaLibraryKit
 *****************************************************************************
 * Copyright (C) 2026 VLC authors and VideoLAN
 *
 * Authors: Felix Paul Kühne <fkuehne # videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
 * @brief The VLCMLCacherDelegate protocol lets an application provide the
 * download implementation used to cache subscription media (e.g. podcast
 * episodes).
 *
 * The media library owns all caching policy — which media to cache, quota
 * enforcement and eviction, and the destination path. The delegate only has to
 * fetch a given MRL and write it to a given local path.
 *
 * @warning Both methods are invoked on a media library background thread, never
 * on the main thread.
 */
@protocol VLCMLCacherDelegate <NSObject>

@required

/**
 * @brief cacheMRL Synchronously fetches a media and writes it to a local file.
 * @param mrl  The MRL to fetch.
 * @param path The local filesystem path the complete media must be written to.
 * @return YES only if the file at path is complete and usable.
 *
 * This is a blocking call: it must not return until the download either
 * completes, fails, or is interrupted via \c interruptCaching.
 */
- (BOOL)cacheMRL:(NSURL *)mrl toPath:(NSString *)path;

/**
 * @brief interruptCaching Aborts any in-flight caching operation promptly.
 *
 * This is invoked from a different thread than \c cacheMRL:toPath: (typically
 * on media library shutdown) and must cause an in-progress call to return.
 */
- (void)interruptCaching;

@end

NS_ASSUME_NONNULL_END
