Currently working on UpnP project. I want to turn my iPod touch into Media Server (For ex: https://itunes.apple.com/in/app/arkmc-lite-dlna-upnp-media/id640095560?mt=8). So I have used the following SDK (link).I have integrated successfully and it is showing in the Media Servers list but when I click on the server it is unable to browse the media files. Could any one please let me know what my issue is? Thanks for your time
Here is some brief code
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
upnp = [[PLT_UPnPObject alloc] init];
// create server and add ourselves as the delegate
PLT_MediaServerObject* server = [[PLT_MediaServerObject alloc] init];
[server setDelegate:self];
[upnp addDevice:server];
}
- (IBAction)performUPnPStarStop:(id)sender {
if ([upnp isRunning]) {
[upnp stop];
[mainButton setTitle:@"Start" forState:UIControlStateNormal];
} else {
[upnp start];
[mainButton setTitle:@"Stop" forState:UIControlStateNormal];
}
}
#pragma mark PLT_MediaServerDelegateObject
- (NPT_Result)onBrowseMetadata:(PLT_MediaServerBrowseCapsule*)info
{
return NPT_FAILURE;
}
- (NPT_Result)onBrowseDirectChildren:(PLT_MediaServerBrowseCapsule*)info
{
return NPT_FAILURE;
}
- (NPT_Result)onSearchContainer:(PLT_MediaServerSearchCapsule*)info
{
return NPT_FAILURE;
}
- (NPT_Result)onFileRequest:(PLT_MediaServerFileRequestCapsule*)info
{
return NPT_FAILURE;
}
Also I am getting one message in log is NEPTUNE_LOG_CONFIG not found in 'Info.plist'
Sorry I'm late to the thread. I took a look at the SDK source you supplied. I tried to hunt down what might cause this "800 Internal error". Here's what I found:
In PltMediaServer.cpp
down around line 434 there is this bit:
if (NPT_FAILED(res) && (action->GetErrorCode() == 0)) {
action->SetError(800, "Internal error");
}
so then what causes NPT_FAILED(res)
to be true
? I looked back in the source and found out that on line 424
res = OnBrowseDirectChildren(
action,
object_id,
filter,
starting_index,
requested_count,
sort,
context);
but your code (and the default test code too!) has
- (NPT_Result)onBrowseDirectChildren:(PLT_MediaServerBrowseCapsule*)info
{
return NPT_FAILURE;
}
and no other variant of OnBrowseDirectChildren
that I can see from your code.
The default implementation of this is in PltMediaServerObject.mm
on line 44:
NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
const char* object_id,
const char* filter,
NPT_UInt32 starting_index,
NPT_UInt32 requested_count,
const char* sort_criteria,
const PLT_HttpRequestContext& context) {
if (![[m_Target delegate] respondsToSelector:@selector(onBrowseDirectChildren:)])
return NPT_FAILURE;
...
So you avoid the failure condition there, but then this bit comes up on line 62:
NPT_Result result = [[m_Target delegate] onBrowseDirectChildren:capsule];
and that is where your NPT_FAILURE
will be returned which will bollocks up the media browse.
There's another way this error could occur, on line 415 of PltMediaServer.cpp
there is
res = OnBrowseMetadata(...);
but your code again is like this with no other variants.
- (NPT_Result)onBrowseMetadata:(PLT_MediaServerBrowseCapsule*)info
{
return NPT_FAILURE;
}
and this will lead to a similar error condition.
So voilà, an explanation to why you are getting 800 Internal errors. My recommendation, implement them.
Here are sample implementations of said methods you can borrow or reverse engineer:
https://searchcode.com/codesearch/view/65353293/#l-1057
https://searchcode.com/codesearch/view/65652226/#l-1066
https://searchcode.com/codesearch/view/81801836/#l-1068
https://searchcode.com/codesearch/view/8307271/#l-1066
https://searchcode.com/codesearch/view/84764059/#l-556
You should definitely implement your delegate methods (onBrowseDirectChildren:
, etc.) in some useful way. E.g., for onBrowseDirectChildren
, you should identify all the items that need to be returned in the response and build the response (a list of urls) with them.
Now, this goes well beyond what can be accomplished in an answer because of the many variables that are involved.
A good starting point for you would be adding the following log trace to, e.g., onBrowseDirectChildren
:
NSLog(@"UPnP: Received Browse DirectChildren request for object %@, with sort criteria %s - count %d", info.objectId, info.sort, info.count);
Possibly, the best thing you could do is give a look at how XBMC implements its own media server on top of platinum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With