VLCRendererItem.m 2.55 KB
Newer Older
1
/*****************************************************************************
2
 * VLCRendererItem.m: Wrapper class for vlc_renderer_item_t
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *****************************************************************************
 * Copyright (C) 2016 VLC authors and VideoLAN
 * $Id$
 *
 * Authors: Marvin Scholz <epirat07 at gmail dot com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 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 General Public License for more details.
 *
 * You should have received a copy of the GNU 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 "VLCRendererItem.h"
25
#import "VLCStringUtility.h"
26 27 28 29 30 31

#include <vlc_common.h>
#include <vlc_renderer_discovery.h>

@implementation VLCRendererItem

32
- (instancetype)initWithRendererItem:(vlc_renderer_item_t*)item
33 34 35 36 37 38 39 40 41 42 43 44 45 46
{
    self = [super init];
    if (self) {
        if (!item)
            [NSException raise:NSInvalidArgumentException
                        format:@"item must not be nil"];
        _rendererItem = vlc_renderer_item_hold(item);
    }
    return self;
}

- (void)dealloc
{
    vlc_renderer_item_release(_rendererItem);
47
    _rendererItem = nil;
48 49 50 51 52 53 54 55 56 57
}

- (NSString*)name
{
    const char *name = vlc_renderer_item_name(_rendererItem);
    if (!name)
        return nil;
    return [NSString stringWithUTF8String:name];
}

58 59 60 61 62 63 64 65
- (NSString*)identifier
{
    const char *sout = vlc_renderer_item_sout(_rendererItem);
    if (!sout)
        return nil;
    return [NSString stringWithUTF8String:sout];
}

66 67 68 69 70 71 72 73 74 75 76 77 78
- (NSString*)iconURI
{
    const char *uri = vlc_renderer_item_icon_uri(_rendererItem);
    if (!uri)
        return nil;
    return [NSString stringWithUTF8String:uri];
}

- (int)capabilityFlags
{
    return vlc_renderer_item_flags(_rendererItem);
}

79
- (void)setRendererForPlaylist:(playlist_t*)playlist
80
{
81
    playlist_SetRenderer(playlist, _rendererItem);
82 83
}

84 85 86 87 88 89 90 91 92
- (BOOL)isEqual:(id)object
{
    if (![object isKindOfClass:[VLCRendererItem class]]) {
        return NO;
    }
    VLCRendererItem *other = object;
    return (other.rendererItem == self.rendererItem);
}

93
@end