Page 1 of 1

tvOS TVVLCKit problem with NSURL

Posted: 14 Nov 2015 18:05
by Airrud
Hi all,
I am developing a Apple TV 4 app for streaming from Enigma 2 receivers. Life TV streaming to Apple TV works fine. But I run in problems with recorded movies on the receiver. Here my code:

Code: Select all

VLCMediaPlayer *mediaplayer; mediaplayer = [[VLCMediaPlayer alloc] init]; mediaplayer.delegate = self; mediaplayer.drawable = movieView; NSString *path = @"http://bm750.local/hdd/movie/20151023 2030 - ZDF HD - Der Alte.ts"; NSString *encodedPath = [path stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet]; NSURL *url = [NSURL URLWithString:encodedPath]; mediaplayer.media = [VLCMedia mediaWithURL:url]; [mediaplayer play]; NSLog(@"URL: %@", url); // Output: URL: http://bm750.local/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts
The stream does not start and I got VLCMediaPlayerStateError.

It seems the encoding/encapsulation is the problem. If I try to access a movie w/o spaces in the path it works fine.
It works also fine when I open the encoded URL in VLC on OS X.

I tried different character sets w/o success:
- URLFragmentAllowedCharacterSet
- URLHostAllowedCharacterSet
- URLPasswordAllowedCharacterSet
- URLPathAllowedCharacterSet
- URLQueryAllowedCharacterSet
- URLUserAllowedCharacterSet

Thanks, Matthias

Re: tvOS TVVLCKit problem with NSURL

Posted: 14 Nov 2015 19:14
by matrog
I should not help you since you are developing my same app... :D but.....

try this

Code: Select all

URLHostAllowedCharacterSet
instead of

Code: Select all

URLQueryAllowedCharacterSet

Re: tvOS TVVLCKit problem with NSURL

Posted: 14 Nov 2015 19:24
by matrog
try also something like that

Code: Select all

http://bm750.local/web/ts.m3u?file=/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts

Re: tvOS TVVLCKit problem with NSURL

Posted: 14 Nov 2015 19:37
by Airrud
Thanks for your help - but it does not work.
Tried:

Code: Select all

NSURL *url = [NSURL URLWithString: @"http://bm750.local/web/ts.m3u?file=/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts"]; mediaplayer.media = [VLCMedia mediaWithURL:url];
No success.

For testing I have created two files on the receiver:
- Film.ts
- Fi lm.ts

Does not work:

Code: Select all

NSString *escapedAdresse = [@"Fi lm.ts" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://bm750.local/hdd/movie/%@", escapedAdresse]]; mediaplayer.media = [VLCMedia mediaWithURL:url];
Works fine:

Code: Select all

NSString *escapedAdresse = [@"Film.ts" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://bm750.local/hdd/movie/%@", escapedAdresse]]; mediaplayer.media = [VLCMedia mediaWithURL:url];

Re: tvOS TVVLCKit problem with NSURL

Posted: 15 Nov 2015 09:25
by matrog
enable debugging to see what's wrong

Code: Select all

mediaplayer.libraryInstance.debugLogging = YES;

Re: tvOS TVVLCKit problem with NSURL

Posted: 15 Nov 2015 12:33
by Airrud
I have enabled the debug mode.

Here the output if I try to open "Fi lm.ts":

Code: Select all

2015-11-15 12:23:47.900 VU Plus[4886:2409431] Creating an input for 'Fi lm.ts' 2015-11-15 12:23:47.900 VU Plus[4886:2410142] using timeshift granularity of 50 MiB 2015-11-15 12:23:47.900 VU Plus[4886:2410142] using default timeshift path 2015-11-15 12:23:47.901 VU Plus[4886:2410142] `http://10.0.1.23/hdd/movie/Fi lm.ts' gives access `http' demux `' path `10.0.1.23/hdd/movie/Fi lm.ts' 2015-11-15 12:23:47.901 VU Plus[4886:2410142] specified demux: any 2015-11-15 12:23:47.901 VU Plus[4886:2410142] creating demux: access='http' demux='any' location='10.0.1.23/hdd/movie/Fi lm.ts' file='(null)' 2015-11-15 12:23:47.901 VU Plus[4886:2410142] looking for access_demux module matching "http": 3 candidates 2015-11-15 12:23:47.901 VU Plus[4886:2410142] no access_demux modules matched 2015-11-15 12:23:47.901 VU Plus[4886:2410142] creating access: http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.901 VU Plus[4886:2410142] looking for access module matching "http": 17 candidates 2015-11-15 12:23:47.902 VU Plus[4886:2410142] querying proxy for http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.903 VU Plus[4886:2410142] no proxy 2015-11-15 12:23:47.903 VU Plus[4886:2410142] http: server='10.0.1.23' port=80 file='/hdd/movie/Fi lm.ts' 2015-11-15 12:23:47.903 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.906 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.919 VU Plus[4886:2410142] protocol 'HTTP' answer code 400 2015-11-15 12:23:47.919 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.919 VU Plus[4886:2410142] switching to HTTP version 1.0 2015-11-15 12:23:47.919 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.922 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.933 VU Plus[4886:2410142] protocol 'HTTP' answer code 400 2015-11-15 12:23:47.934 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.934 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.936 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.949 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.950 VU Plus[4886:2410142] no access modules matched 2015-11-15 12:23:47.950 VU Plus[4886:2410142] cannot access http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.950 VU Plus[4886:2410142] Your input can't be opened 2015-11-15 12:23:47.950 VU Plus[4886:2410142] VLC is unable to open the MRL 'http://10.0.1.23/hdd/movie/Fi lm.ts'. Check the log for details.
And here the output for video file w/o spaces ("Film.ts"):

Code: Select all

2015-11-15 12:25:27.905 VU Plus[4933:2425443] Creating an input for 'Film.ts' 2015-11-15 12:25:27.905 VU Plus[4933:2426073] using timeshift granularity of 50 MiB 2015-11-15 12:25:27.905 VU Plus[4933:2426073] using default timeshift path 2015-11-15 12:25:27.905 VU Plus[4933:2426073] `http://10.0.1.23/hdd/movie/Film.ts' gives access `http' demux `' path `10.0.1.23/hdd/movie/Film.ts' 2015-11-15 12:25:27.905 VU Plus[4933:2426073] specified demux: any 2015-11-15 12:25:27.906 VU Plus[4933:2426073] creating demux: access='http' demux='any' location='10.0.1.23/hdd/movie/Film.ts' file='(null)' 2015-11-15 12:25:27.906 VU Plus[4933:2426073] looking for access_demux module matching "http": 3 candidates 2015-11-15 12:25:27.906 VU Plus[4933:2426073] no access_demux modules matched 2015-11-15 12:25:27.906 VU Plus[4933:2426073] creating access: http://10.0.1.23/hdd/movie/Film.ts 2015-11-15 12:25:27.906 VU Plus[4933:2426073] looking for access module matching "http": 17 candidates 2015-11-15 12:25:27.906 VU Plus[4933:2426073] querying proxy for http://10.0.1.23/hdd/movie/Film.ts 2015-11-15 12:25:27.907 VU Plus[4933:2426073] no proxy 2015-11-15 12:25:27.907 VU Plus[4933:2426073] http: server='10.0.1.23' port=80 file='/hdd/movie/Film.ts' 2015-11-15 12:25:27.907 VU Plus[4933:2426073] net: connecting to 10.0.1.23 port 80 2015-11-15 12:25:27.911 VU Plus[4933:2426073] connection succeeded (socket = 12) 2015-11-15 12:25:27.944 VU Plus[4933:2426073] protocol 'HTTP' answer code 206 2015-11-15 12:25:27.944 VU Plus[4933:2426073] this frame size=8148078672 2015-11-15 12:25:27.944 VU Plus[4933:2426073] stream size=8148078672,pos=0,remaining=8148078672 2015-11-15 12:25:27.944 VU Plus[4933:2426073] Server: TwistedWeb/12.0.0
The differences:
Not working: protocol 'HTTP' answer code 400 - error: HTTP/1.1 400 Bad Request
Working: protocol 'HTTP' answer code 206

It seems, VLC removes the escaped encoding.....

Re: tvOS TVVLCKit problem with NSURL

Posted: 15 Nov 2015 15:27
by matrog
not sure...could be only the display on logs.

You should check receiver's log as well to see the actual url request received by the decoder

Re: tvOS TVVLCKit problem with NSURL

Posted: 17 Nov 2015 14:42
by Airrud
Hi,
the receiver does not log any problems in /var/log/messages. But I have copied the TS file to my Mac and enabled a HTTP server:

$ python -m SimpleHTTPServer 9001

Streaming with "Film.ts" in Apple TV Simulator works fine. But if I try to access to "Fi lm.ts" the HTTP server logs:

127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.1')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.1" 400 -
127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.0')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.0" 400 -
127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.0')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.0" 400 -

As you can see, the VLCKit ignores/deletes the escapes in NSURL.

Re: tvOS TVVLCKit problem with NSURL

Posted: 17 Nov 2015 15:09
by Airrud
I believe I have solved the problem.

In "MobileVLCKit - Sources - VLCMedia" I found:

Code: Select all

- (instancetype)initWithURL:(NSURL *)anURL { if (self = [super init]) { VLCLibrary *library = [VLCLibrary sharedLibrary]; NSAssert(library.instance, @"no library instance when creating media"); p_md = libvlc_media_new_location(library.instance, [[[anURL absoluteString] stringByRemovingPercentEncoding] UTF8String]); _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3]; [self initInternalMediaDescriptor]; } return self; }
I changed it to:

Code: Select all

- (instancetype)initWithURL:(NSURL *)anURL { if (self = [super init]) { VLCLibrary *library = [VLCLibrary sharedLibrary]; NSAssert(library.instance, @"no library instance when creating media"); p_md = libvlc_media_new_location(library.instance, [[anURL absoluteString] UTF8String]); _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3]; [self initInternalMediaDescriptor]; } return self; }
No it works fine.....

Re: tvOS TVVLCKit problem with NSURL

Posted: 18 Nov 2015 16:10
by Vibou
Thank you very much it works !!

Re: tvOS TVVLCKit problem with NSURL

Posted: 18 Nov 2015 17:59
by Vibou
I thinks you fixed one issue but there are others...

It is not working anymore. It worked only once ! Very weird !

My player is not playing it s like it is blocked on a thread (I m not using a multi-threaded environment no dispatch_async or whatever). :(

Re: tvOS TVVLCKit problem with NSURL

Posted: 24 Nov 2015 10:20
by OlivierAubert
The python SimpleHTTPServer is not up to the task of serving videos, it does not even support range requests. For this kind of task (video server launched from the command line for quick tests), I tend to use alternatives such as

Code: Select all

gatling
from fefe.de

Re: tvOS TVVLCKit problem with NSURL

Posted: 26 Nov 2015 17:18
by ssbmaccom
While I tried to build the TVVLCKit on my Mac I saw, that this issue might have been fixed in the meantime by Felix.