Commit 53695abf authored by Amir Abbas Mousavian's avatar Amir Abbas Mousavian Committed by Carola Nitz

Fixed issue of initializing VLCMedia with already opened stream

parent 21114d62
......@@ -168,7 +168,6 @@ typedef NS_ENUM(NSInteger, VLCMediaState) {
* This subclass must allow setting NSStreamFileCurrentOffsetKey property.
* \note VLCMedia will open stream if it is not already opened, and will close eventually.
* You can't pass an already closed input stream.
* \note VLCHTTPInputStream instance can be passed in order to stream remote media.
* \param stream Input stream for media to be accessed.
* \return A new VLCMedia object, only if there were no errors.
*/
......
......@@ -70,14 +70,16 @@ NSString *const VLCMediaMetaChanged = @"VLCMediaMetaChanged";
int open_cb(void *opaque, void **datap, uint64_t *sizep) {
NSInputStream *stream = (__bridge NSInputStream *)(opaque);
*datap = opaque;
*sizep = UINT64_MAX;
// Once a stream is closed, it cannot be reopened.
if (stream && stream.streamStatus == NSStreamStatusNotOpen) {
[stream open];
*datap = opaque;
*sizep = UINT64_MAX;
return 0;
} else {
return stream.streamStatus == NSStreamStatusOpen ? 0 : -1;
}
return stream.streamStatus == NSStreamStatusOpen ? 0 : -1;
}
ssize_t read_cb(void *opaque, unsigned char *buf, size_t len) {
......
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