Commit 0f26d4b0 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Implement UPNP item listing

no downloading or streaming yet
parent 85da8de6
//
// VLCLocalServerFolderListViewController.h
// VLC for iOS
//
// Created by Felix Paul Kühne on 10.08.13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
// Refer to the COPYING file of the official project for license.
//
#import <UIKit/UIKit.h>
@class MediaServer1Device;
@interface VLCLocalServerFolderListViewController : UIViewController
@property (nonatomic, strong) UITableView *tableView;
- (id)initWithDevice:(MediaServer1Device*)device header:(NSString*)header andRootID:(NSString*)rootID;
@end
//
// VLCLocalServerFolderListViewController.m
// VLC for iOS
//
// Created by Felix Paul Kühne on 10.08.13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
// Refer to the COPYING file of the official project for license.
//
#import "VLCLocalServerFolderListViewController.h"
#import "MediaServerBasicObjectParser.h"
#import "MediaServer1ItemObject.h"
#import "MediaServer1ContainerObject.h"
#import "MediaServer1Device.h"
#import "VLCLocalNetworkListCell.h"
@interface VLCLocalServerFolderListViewController () <UITableViewDataSource, UITableViewDelegate>
{
UIBarButtonItem *_backButton;
MediaServer1Device *_device;
NSString *_header;
NSString *_rootID;
NSMutableArray *_objectList;
}
@end
@implementation VLCLocalServerFolderListViewController
- (void)loadView
{
_tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_tableView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
_tableView.delegate = self;
_tableView.dataSource = self;
self.view = _tableView;
}
- (id)initWithDevice:(MediaServer1Device*)device header:(NSString*)header andRootID:(NSString*)rootID
{
self = [super init];
if (self) {
_device = device;
_header = header;
_rootID = rootID;
_objectList = [[NSMutableArray alloc] init];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableString *outResult = [[NSMutableString alloc] init];
NSMutableString *outNumberReturned = [[NSMutableString alloc] init];
NSMutableString *outTotalMatches = [[NSMutableString alloc] init];
NSMutableString *outUpdateID = [[NSMutableString alloc] init];
[[_device contentDirectory] BrowseWithObjectID:_rootID BrowseFlag:@"BrowseDirectChildren" Filter:@"*" StartingIndex:@"0" RequestedCount:@"0" SortCriteria:@"+dc:title" OutResult:outResult OutNumberReturned:outNumberReturned OutTotalMatches:outTotalMatches OutUpdateID:outUpdateID];
[_objectList removeAllObjects];
NSData *didl = [outResult dataUsingEncoding:NSUTF8StringEncoding];
MediaServerBasicObjectParser *parser = [[MediaServerBasicObjectParser alloc] initWithMediaObjectArray:_objectList itemsOnly:NO];
[parser parseFromData:didl];
self.tableView.separatorColor = [UIColor colorWithWhite:.122 alpha:1.];
self.view.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
self.title = _header;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
return YES;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _objectList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"LocalNetworkCellDetail";
VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [VLCLocalNetworkListCell cellWithReuseIdentifier:CellIdentifier];
MediaServer1BasicObject *item = _objectList[indexPath.row];
if (![item isContainer]) {
MediaServer1ItemObject *mediaItem = _objectList[indexPath.row];
[cell setSubtitle:[NSString stringWithFormat:@"%@ - %@", mediaItem.size, mediaItem.duration]];
[cell setIsDirectory:NO];
} else
[cell setIsDirectory:YES];
[cell setTitle:[item title]];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MediaServer1BasicObject *item = _objectList[indexPath.row];
if ([item isContainer]) {
MediaServer1ContainerObject *container = _objectList[indexPath.row];
VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithDevice:_device header:[container title] andRootID:[container objectID]];
[[self navigationController] pushViewController:targetViewController animated:YES];
} else {
MediaServer1ItemObject *item = _objectList[indexPath.row];
MediaServer1ItemRes *resource = nil;
NSEnumerator *e = [[item resources] objectEnumerator];
while((resource = (MediaServer1ItemRes*)[e nextObject])){
NSLog(@"%@ - %d, %@, %d, %d, %d, %@", [item title], [resource bitrate], [resource duration], [resource nrAudioChannels], [resource size], [resource durationInSeconds], [resource protocolInfo] );
NSLog(@"URI is %@", [item uri]);
}
//TODO DO SOMETHING USEFUL!
}
}
@end
......@@ -13,12 +13,11 @@
#import "VLCAppDelegate.h"
#import "UPnPManager.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCLocalServerFolderListViewController.h"
@interface VLCLocalServerListViewController () <UITableViewDataSource, UITableViewDelegate>
{
UIBarButtonItem *_backButton;
UIBarButtonItem *_backToMenuButton;
UILabel *_titleLabel;
NSArray *_devices;
}
......@@ -51,7 +50,6 @@
//Search for UPnP Devices
[[[UPnPManager GetInstance] SSDP] searchSSDP];
_backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
_backToMenuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
self.navigationItem.leftBarButtonItem = _backToMenuButton;
......@@ -59,8 +57,6 @@
self.view.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
self.title = @"Local Servers";
self.navigationItem.titleView = _titleLabel;
}
- (IBAction)goBack:(id)sender
......@@ -101,7 +97,7 @@
BasicUPnPDevice *device = _devices[indexPath.row];
[cell setTitle:[device friendlyName]];
if([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"])
if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"])
[cell setIsDirectory:YES];
return cell;
......@@ -109,18 +105,14 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
/*
BasicUPnPDevice *device = _devices[indexPath.row];
if([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"]){
if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"]) {
MediaServer1Device *server = (MediaServer1Device*)device;
FolderViewController *targetViewController = [[FolderViewController alloc] initWithMediaDevice:server andHeader:@"root" andRootId:@"0"];
VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithDevice:server header:@"root" andRootID:@"0"];
[[self navigationController] pushViewController:targetViewController animated:YES];
[[PlayBack GetInstance] setServer:server];
}else if([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaRenderer:1"]){
[self.titleLabel setText:[device friendlyName]];
MediaRenderer1Device *render = (MediaRenderer1Device*)device;
[[PlayBack GetInstance] setRenderer:render];
}*/
} else if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaRenderer:1"]) {
//FIXME: euh, we don't do rendering atm, at least not here.
}
}
//protocol UPnPDBObserver
......
......@@ -44,6 +44,7 @@
7AC862A81765E9510011611A /* jquery.iframe-transport.js in Resources */ = {isa = PBXBuildFile; fileRef = 7AC862A01765E90C0011611A /* jquery.iframe-transport.js */; };
7AC862A91765E9510011611A /* jquery.ui.widget.js in Resources */ = {isa = PBXBuildFile; fileRef = 7AC862A11765E90C0011611A /* jquery.ui.widget.js */; };
7D00161C177056B700649F27 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 7D00161A17704DAC00649F27 /* main.js */; };
7D02B0D217B6BE850099030D /* VLCLocalServerFolderListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D02B0D117B6BE850099030D /* VLCLocalServerFolderListViewController.m */; };
7D07A4E9174EA47800759D10 /* VLCSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D07A4E7174EA47800759D10 /* VLCSettingsController.m */; };
7D07A4ED174EB81200759D10 /* VLCDropboxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D07A4EC174EB81200759D10 /* VLCDropboxController.m */; };
7D07F708175665ED00CDE21C /* navBarBackground@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D07F706175665ED00CDE21C /* navBarBackground@2x.png */; };
......@@ -345,6 +346,8 @@
7AC862A01765E90C0011611A /* jquery.iframe-transport.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jquery.iframe-transport.js"; sourceTree = "<group>"; };
7AC862A11765E90C0011611A /* jquery.ui.widget.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.ui.widget.js; sourceTree = "<group>"; };
7D00161A17704DAC00649F27 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = main.js; sourceTree = "<group>"; };
7D02B0D017B6BE850099030D /* VLCLocalServerFolderListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLocalServerFolderListViewController.h; sourceTree = "<group>"; };
7D02B0D117B6BE850099030D /* VLCLocalServerFolderListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLocalServerFolderListViewController.m; sourceTree = "<group>"; };
7D05ADEA174945CE0087550C /* DropboxSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DropboxSDK.framework; path = ImportedSources/Dropbox/DropboxSDK.framework; sourceTree = "<group>"; };
7D07A4E6174EA47800759D10 /* VLCSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSettingsController.h; sourceTree = "<group>"; };
7D07A4E7174EA47800759D10 /* VLCSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCSettingsController.m; sourceTree = "<group>"; };
......@@ -1024,6 +1027,8 @@
children = (
7D93043E17B67C4F0054EAC6 /* VLCLocalServerListViewController.h */,
7D93043F17B67C4F0054EAC6 /* VLCLocalServerListViewController.m */,
7D02B0D017B6BE850099030D /* VLCLocalServerFolderListViewController.h */,
7D02B0D117B6BE850099030D /* VLCLocalServerFolderListViewController.m */,
7D93044317B684CE0054EAC6 /* VLCLocalNetworkListCell.h */,
7D93044417B684CF0054EAC6 /* VLCLocalNetworkListCell.m */,
);
......@@ -1824,6 +1829,7 @@
7D93045317B6A0DF0054EAC6 /* VLCMenuTableViewController.m in Sources */,
7D93045617B6A5C00054EAC6 /* GHMenuCell.m in Sources */,
7D93045917B6ACA10054EAC6 /* VLCWiFiUploadTableViewCell.m in Sources */,
7D02B0D217B6BE850099030D /* VLCLocalServerFolderListViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment