Commit be256141 authored by Michael Niedermayer's avatar Michael Niedermayer

mmsh: reimplement seeking

Fixes Ticket2682
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c7cfd4cc
...@@ -309,16 +309,14 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim ...@@ -309,16 +309,14 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
return 0; return 0;
fail: fail:
av_freep(&stream_selection); av_freep(&stream_selection);
mmsh_close(h);
av_dlog(NULL, "Connection failed with error %d\n", err); av_dlog(NULL, "Connection failed with error %d\n", err);
return err; return err;
} }
static int mmsh_open(URLContext *h, const char *uri, int flags) static int mmsh_open(URLContext *h, const char *uri, int flags)
{ {
int ret = mmsh_open_internal(h, uri, flags, 0, 0); return mmsh_open_internal(h, uri, flags, 0, 0);
if (ret < 0)
mmsh_close(h);
return ret;
} }
static int handle_chunk_type(MMSHContext *mmsh) static int handle_chunk_type(MMSHContext *mmsh)
...@@ -370,23 +368,26 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size) ...@@ -370,23 +368,26 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size)
static int64_t mmsh_read_seek(URLContext *h, int stream_index, static int64_t mmsh_read_seek(URLContext *h, int stream_index,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
MMSHContext *mmsh = h->priv_data; MMSHContext *mmsh_old = h->priv_data;
MMSContext *mms = &mmsh->mms; MMSHContext *mmsh = av_mallocz(sizeof(*mmsh));
int ret; int ret;
ret= mmsh_open_internal(h, mmsh->location, 0, FFMAX(timestamp, 0), 0); if (!mmsh)
return AVERROR(ENOMEM);
h->priv_data = mmsh;
ret= mmsh_open_internal(h, mmsh_old->location, 0, FFMAX(timestamp, 0), 0);
if(ret>=0){ if(ret>=0){
if (mms->mms_hd) h->priv_data = mmsh_old;
ffurl_close(mms->mms_hd); mmsh_close(h);
av_freep(&mms->streams); h->priv_data = mmsh;
av_freep(&mms->asf_header); av_free(mmsh_old);
mmsh->mms.asf_header_read_size = mmsh->mms.asf_header_size;
}else {
h->priv_data = mmsh_old;
av_free(mmsh); av_free(mmsh);
mmsh = h->priv_data; }
mms = &mmsh->mms;
mms->asf_header_read_size= mms->asf_header_size;
}else
h->priv_data= mmsh;
return ret; return ret;
} }
......
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