VLCLocalNetworkServiceBrowserPlex.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*****************************************************************************
  2. * VLCLocalNetworkServiceBrowserPlex.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015-2019 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCLocalNetworkServiceBrowserPlex.h"
  13. #import "VLCNetworkServerBrowserPlex.h"
  14. @implementation VLCLocalNetworkServiceBrowserPlex
  15. - (instancetype)init
  16. {
  17. #if TARGET_OS_TV
  18. NSString *name = NSLocalizedString(@"PLEX_SHORT",nil);
  19. #else
  20. NSString *name = NSLocalizedString(@"PLEX_LONG",nil);
  21. #endif
  22. return [super initWithName:name
  23. serviceType:@"_plexmediasvr._tcp."
  24. domain:@""];
  25. }
  26. - (VLCLocalNetworkServiceNetService *)localServiceForNetService:(NSNetService *)netService
  27. {
  28. return [[VLCLocalNetworkServicePlex alloc] initWithNetService:netService serviceName:self.name];
  29. }
  30. @end
  31. NSString *const VLCNetworkServerProtocolIdentifierPlex = @"plex";
  32. @implementation VLCLocalNetworkServicePlex
  33. - (UIImage *)icon
  34. {
  35. return [UIImage imageNamed:@"PlexServerIcon"];
  36. }
  37. #if TARGET_OS_TV
  38. - (nullable id<VLCNetworkServerLoginInformation>)loginInformation
  39. {
  40. VLCNetworkServerLoginInformation *login = [[VLCNetworkServerLoginInformation alloc] init];
  41. login.address = self.netService.hostName;
  42. login.port = [NSNumber numberWithInteger:self.netService.port];
  43. login.protocolIdentifier = VLCNetworkServerProtocolIdentifierPlex;
  44. return login;
  45. }
  46. #else
  47. - (id<VLCNetworkServerBrowser>)serverBrowser
  48. {
  49. NSNetService *service = self.netService;
  50. if (service.hostName == nil || service.port == 0) {
  51. return nil;
  52. }
  53. NSString *name = service.name;
  54. NSString *hostName = service.hostName;
  55. NSUInteger portNum = service.port;
  56. VLCNetworkServerBrowserPlex *serverBrowser = [[VLCNetworkServerBrowserPlex alloc] initWithName:name host:hostName portNumber:@(portNum) path:@"" authentificication:@""];
  57. return serverBrowser;
  58. }
  59. #endif
  60. @end