Ignore:
Timestamp:
11/20/17 17:42:27 (6 years ago)
Author:
obi
Message:

update libeplayer3 v36

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/libeplayer3/container/container_ffmpeg.c

    r40362 r41219  
    142142static int64_t seek_target_seconds = 0;
    143143static int8_t do_seek_target_seconds = 0;
     144static int64_t prev_seek_time_sec = -1;
    144145
    145146static int32_t seek_target_flag = 0;
     
    198199static int32_t rtmp_proto_impl = 0; // 0 - auto, 1 - native, 2 - librtmp
    199200
     201static int32_t g_sel_program_id = -1;
     202
    200203#ifdef HAVE_FLV2MPEG4_CONVERTER
    201204static int32_t flv2mpeg4_converter = 1;
     
    214217
    215218static int32_t mutexInitialized = 0;
     219
     220void sel_program_id_set(const int32_t val)
     221{
     222    g_sel_program_id = val;
     223}
    216224
    217225void wma_software_decoder_set(const int32_t val)
     
    616624                ffmpeg_printf(10, "seek_target_seconds[%lld]\n", seek_target_seconds);
    617625                uint32_t i = 0;
    618                 for(i=0; i<IPTV_AV_CONTEXT_MAX_NUM; i+=1)
     626                for(; i<IPTV_AV_CONTEXT_MAX_NUM; i+=1)
    619627                {
    620628                    if(NULL != avContextTab[i])
    621629                    {
     630                        if (i == 1)
     631                        {
     632                            prev_seek_time_sec = seek_target_seconds;
     633                        }
    622634                        if (avContextTab[i]->start_time != AV_NOPTS_VALUE)
    623635                        {
     
    654666                if(NULL != avContextTab[i])
    655667                {
    656                     wrapped_avcodec_flush_buffers(i);
     668                    if (i != 1)
     669                    {
     670                        wrapped_avcodec_flush_buffers(i);
     671                    }
    657672                }
    658673                else
     
    680695            {
    681696                cAVIdx = currentVideoPts <= currentAudioPts ? 0 : 1;
     697                if (1 == cAVIdx && prev_seek_time_sec >= 0 )
     698                {
     699                    avformat_seek_file(avContextTab[1], -1, (currentVideoPts / 90000) * AV_TIME_BASE - AV_TIME_BASE, (currentVideoPts / 90000) * AV_TIME_BASE, (currentVideoPts / 90000) * AV_TIME_BASE + AV_TIME_BASE, 0);
     700                    prev_seek_time_sec = -1;
     701                    wrapped_avcodec_flush_buffers(1);
     702                }
    682703            }
    683704            else
     
    18691890    if(ostrstr(tmpstr, "debuglevel=99") != NULL)
    18701891        av_log_set_level( AV_LOG_DEBUG );
    1871         free(tmpstr), tmpstr = NULL;
     1892    else
     1893        av_log_set_callback(ffmpeg_silen_callback);
     1894    free(tmpstr), tmpstr = NULL;
    18721895//obi (end)
    18731896    // SULGE DEBUG ENABLED
    18741897    // make ffmpeg silen
    18751898    //av_log_set_level( AV_LOG_DEBUG );
    1876     av_log_set_callback(ffmpeg_silen_callback);
     1899    //av_log_set_callback(ffmpeg_silen_callback);
    18771900 
    18781901    context->playback->abortRequested = 0;
     
    19501973        }
    19511974        AVFormatContext *avContext = avContextTab[cAVIdx];
     1975        uint32_t *stream_index = NULL;
     1976        uint32_t nb_stream_indexes = 0;
     1977       
    19521978        ffmpeg_printf(1, "cAVIdx[%d]: number of streams: %d\n", cAVIdx, avContext->nb_streams);
     1979       
     1980        if (avContext->nb_programs > 0)
     1981        {
     1982            uint32_t n = 0;
     1983            ffmpeg_printf(1, "cAVIdx[%d]: stream with multi programs: num of programs %d\n", cAVIdx, avContext->nb_programs);
     1984            for (n = 0; n < avContext->nb_programs && (0 == nb_stream_indexes || stream_index == NULL); n++)
     1985            {
     1986                AVProgram *p = avContext->programs[n];
     1987                if (p->nb_stream_indexes)
     1988                {
     1989                    if (g_sel_program_id > 0)
     1990                    {
     1991                        if (g_sel_program_id == p->id)
     1992                        {
     1993                            stream_index = p->stream_index;
     1994                            nb_stream_indexes = p->nb_stream_indexes;
     1995                            ffmpeg_printf(1, "cAVIdx[%d]: select PROGRAM ID: %d\n", cAVIdx, (int32_t)p->id);
     1996                            break;
     1997                        }
     1998                    }
     1999                    else
     2000                    {
     2001                        uint32_t m = 0;
     2002                        for (m = 0; m < p->nb_stream_indexes; m++)
     2003                        {
     2004                            AVStream *s = avContext->streams[p->stream_index[m]];
     2005                            if (get_codecpar(s)->codec_type == AVMEDIA_TYPE_VIDEO && get_codecpar(s)->width > 0)
     2006                            {
     2007                                ffmpeg_printf(1, "cAVIdx[%d]: PROGRAM ID: %d, width [%d]\n", cAVIdx, (int32_t)p->id, (int32_t)get_codecpar(s)->width);
     2008                                stream_index = p->stream_index;
     2009                                nb_stream_indexes = p->nb_stream_indexes;
     2010                                break;
     2011                            }
     2012                        }
     2013                    }
     2014                }
     2015            }
     2016        }
    19532017       
    19542018        int32_t n = 0;
     
    19582022            AVStream *stream = avContext->streams[n];
    19592023            int32_t version = 0;
    1960 
    1961             char *encoding = Codec2Encoding((int32_t)get_codecpar(stream)->codec_id, (int32_t)get_codecpar(stream)->codec_type, \
    1962                                             (uint8_t *)get_codecpar(stream)->extradata, \
    1963                                             (int)get_codecpar(stream)->extradata_size, \
    1964                                             (int)get_codecpar(stream)->profile, &version);
     2024            char *encoding = NULL;
     2025           
     2026            if (nb_stream_indexes > 0 && stream_index != NULL)
     2027            {
     2028                uint32_t isStreamFromSelProg = 0;
     2029                uint32_t m = 0;
     2030                for (m = 0; m < nb_stream_indexes; m++)
     2031                {
     2032                    if (n == stream_index[m])
     2033                    {
     2034                        isStreamFromSelProg = 1;
     2035                        break;
     2036                    }
     2037                }
     2038               
     2039                if (!isStreamFromSelProg)
     2040                    continue; // skip this stream
     2041            }
     2042
     2043            encoding = Codec2Encoding((int32_t)get_codecpar(stream)->codec_id, (int32_t)get_codecpar(stream)->codec_type, \
     2044                                      (uint8_t *)get_codecpar(stream)->extradata, \
     2045                                      (int)get_codecpar(stream)->extradata_size, \
     2046                                      (int)get_codecpar(stream)->profile, &version);
    19652047           
    19662048            if(encoding != NULL && !strncmp(encoding, "A_IPCM", 6) && insert_pcm_as_lpcm)
Note: See TracChangeset for help on using the changeset viewer.