Ticket #649: phmi-20111114T1820-ffmpeg-applehttplive-seek_fix.diff

File phmi-20111114T1820-ffmpeg-applehttplive-seek_fix.diff, 1.5 KB (added by takis, 15 years ago)
  • libavformat/applehttp.c

    diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
    index 97bd74a..07a5ea2 100644
    a b typedef struct AppleHTTPContext {  
    9999    int cur_seq_no;
    100100    int end_of_segment;
    101101    int first_packet;
     102    int64_t first_timestamp;
    102103    AVIOInterruptCB *interrupt_callback;
    103104} AppleHTTPContext;
    104105
    … … static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)  
    527528    }
    528529
    529530    c->first_packet = 1;
     531    c->first_timestamp = -1;
    530532
    531533    return 0;
    532534fail:
    … … start:  
    591593                if (!url_feof(&var->pb))
    592594                    return ret;
    593595                reset_packet(&var->pkt);
     596            } else {
     597                if (c->first_timestamp == -1)
     598                    c->first_timestamp = var->pkt.dts;
    594599            }
    595600        }
    596601        /* Check if this stream has the packet with the lowest dts */
    … … static int applehttp_read_seek(AVFormatContext *s, int stream_index,  
    639644    for (i = 0; i < c->n_variants; i++) {
    640645        /* Reset reading */
    641646        struct variant *var = c->variants[i];
    642         int64_t pos = 0;
    643         if (var->input) {
     647        int64_t pos = av_rescale_rnd(c->first_timestamp, 1, stream_index >= 0 ?
     648                               s->streams[stream_index]->time_base.den :
     649                               AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ?
     650                               AV_ROUND_DOWN : AV_ROUND_UP);
     651         if (var->input) {
    644652            ffurl_close(var->input);
    645653            var->input = NULL;
    646654        }