Changeset 42177


Ignore:
Timestamp:
04/14/18 13:20:15 (6 years ago)
Author:
obi
Message:

reset libeplayer3 to v36

Location:
titan/libeplayer3
Files:
33 edited

Legend:

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

    r42162 r42177  
    146146static int32_t seek_target_flag = 0;
    147147
    148 static int32_t mutexInitialized = 0;
    149 
    150148/* ***************************** */
    151149/* Prototypes                    */
     
    166164    progressive_playback = val;
    167165}
    168 
    169 static void initMutex(void)
    170 {
    171     pthread_mutex_init(&mutex, NULL);
    172     mutexInitialized = 1;
    173 }
    174 
    175 static void getMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int32_t line)
    176 {
    177     ffmpeg_printf(100, "::%d requesting mutex\n", line);
    178 
    179     if (!mutexInitialized)
    180     {
    181         initMutex();
    182     }
    183 
    184     pthread_mutex_lock(&mutex);
    185 
    186     ffmpeg_printf(100, "::%d received mutex\n", line);
    187 }
    188 
    189 static void releaseMutex(const char *filename __attribute__((unused)), const const char *function __attribute__((unused)), int32_t line)
    190 {
    191     pthread_mutex_unlock(&mutex);
    192 
    193     ffmpeg_printf(100, "::%d released mutex\n", line);
    194 }
    195 
    196 typedef int32_t (* Write_FN) (void  *, void *);
    197 
    198 static int32_t Write(Write_FN WriteFun, void *context, void *privateData, int64_t pts)
    199 {
    200     /* Because Write is blocking we will release mutex which protect
    201      * avformat structures, during write time
    202      */
    203     int32_t ret = 0;
    204     releaseMutex(__FILE__, __FUNCTION__,__LINE__);
    205     ret = WriteFun(context, privateData);
    206     getMutex(__FILE__, __FUNCTION__,__LINE__);
    207     return ret;
    208 }
    209 
    210166
    211167#include "buff_ffmpeg.c"
     
    470426}
    471427
    472 //static int32_t mutexInitialized = 0;
     428static int32_t mutexInitialized = 0;
    473429
    474430void sel_program_id_set(const int32_t val)
     
    540496{
    541497    return av_dict_set(&avio_opts, key, value, flags);
     498}
     499
     500static void initMutex(void)
     501{
     502    pthread_mutex_init(&mutex, NULL);
     503    mutexInitialized = 1;
     504}
     505
     506static void getMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int32_t line)
     507{
     508    ffmpeg_printf(100, "::%d requesting mutex\n", line);
     509
     510    if (!mutexInitialized)
     511    {
     512        initMutex();
     513    }
     514
     515    pthread_mutex_lock(&mutex);
     516
     517    ffmpeg_printf(100, "::%d received mutex\n", line);
     518}
     519
     520static void releaseMutex(const char *filename __attribute__((unused)), const const char *function __attribute__((unused)), int32_t line)
     521{
     522    pthread_mutex_unlock(&mutex);
     523
     524    ffmpeg_printf(100, "::%d released mutex\n", line);
    542525}
    543526
     
    720703        pts = INVALID_PTS_VALUE;
    721704    }
    722     else
    723     {
    724         pts &= 0x01FFFFFFFF; // PES header can handle only 33 bit PTS
    725     }
    726705
    727706    return pts;
     
    819798    while ( context && context->playback && context->playback->isPlaying )
    820799    {
    821         /* When user press PAUSE we call pause on AUDIO and VIDEO decoders,
    822          * we will not wait here because we can still fill
    823          * DVB drivers buffers at PAUSE time
    824          *
    825          * In the future we can add buffering queue before injection in to
    826          * AUDIO, VIDEO decoders, so we can not wait here
    827          */
    828 #ifdef __sh__
    829800        //IF MOVIE IS PAUSED, WAIT
    830801        if (context->playback->isPaused)
     
    835806            continue;
    836807        }
    837 #endif
    838808
    839809        if (context->playback->isSeeking)
     
    959929           
    960930            reset_finish_timeout();
    961             if(avContextTab[cAVIdx]->streams[packet.stream_index]->discard != AVDISCARD_ALL)
    962             {
    963                 if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0)
    964                 {
    965                     ffmpeg_err("error getting video track\n");
    966                 }
    967                
    968                 if (context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack) < 0)
    969                 {
    970                     ffmpeg_err("error getting audio track\n");
    971                 }
    972                
    973                 if (context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &subtitleTrack) < 0)
    974                 {
    975                     ffmpeg_err("error getting subtitle track\n");
    976                 }
    977             }
    978             else
    979             {
    980                 ffmpeg_printf(1, "SKIP DISCARDED PACKET stream_index[%d] pid[%d]\n", packet.size, (int)packet.stream_index, pid);
     931
     932            if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0)
     933            {
     934                ffmpeg_err("error getting video track\n");
    981935            }
    982936           
     937            if (context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack) < 0)
     938            {
     939                ffmpeg_err("error getting audio track\n");
     940            }
     941           
     942            if (context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &subtitleTrack) < 0)
     943            {
     944                ffmpeg_err("error getting subtitle track\n");
     945            }
     946
    983947            ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, pid);
    984948
     
    10731037                    }
    10741038
    1075                     if (Write(context->output->video->Write, context, &avOut, pts) < 0)
     1039                    if (context->output->video->Write(context, &avOut) < 0)
    10761040                    {
    10771041                        ffmpeg_err("writing data to video device failed\n");
     
    11491113                    avOut.type       = "audio";
    11501114
    1151                     if (Write(context->output->audio->Write, context, &avOut, pts) < 0)
     1115                    if (context->output->audio->Write(context, &avOut) < 0)
    11521116                    {
    11531117                        ffmpeg_err("(raw pcm) writing data to audio device failed\n");
     
    13441308                        avOut.type       = "audio";
    13451309
    1346                         if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
     1310                        if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)
    13471311                        {
    13481312                            ffmpeg_err("writing data to audio device failed\n");
     
    13671331                    avOut.type       = "audio";
    13681332
    1369                     if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
     1333                    if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)
    13701334                    {
    13711335                        ffmpeg_err("(aac) writing data to audio device failed\n");
     
    13851349                    avOut.type       = "audio";
    13861350
    1387                     if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
     1351                    if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)
    13881352                    {
    13891353                        ffmpeg_err("writing data to audio device failed\n");
     
    14331397                    //obi (end)
    14341398
    1435                     if (Write(context->output->subtitle->Write, context, &subOut, pts) < 0)
     1399                    if (context->output->subtitle->Write(context, &subOut) < 0)
    14361400                    {
    14371401                        ffmpeg_err("writing data to teletext fifo failed\n");
     
    15811545
    15821546#ifdef SAM_CUSTOM_IO
    1583 typedef struct CustomIOCtx_t
    1584 {
    1585     FILE *pFile;
    1586     FILE *pMoovFile;
    1587     int64_t iOffset;
    1588    
    1589     char *szFile;
    1590     uint64_t iFileSize;
    1591     char *szMoovAtomFile;
    1592     uint64_t iMoovAtomOffset;
    1593 } CustomIOCtx_t;
    1594 
    1595 CustomIOCtx_t* custom_io_tab[IPTV_AV_CONTEXT_MAX_NUM] = {NULL, NULL};
    1596 
    15971547int SAM_ReadFunc(void *ptr, uint8_t *buffer, int lSize)
    15981548{
    1599     CustomIOCtx_t *io = (CustomIOCtx_t *)ptr;
    1600     int ret = 0;
    1601    
    1602     if (!io->pMoovFile)
    1603     {
    1604         ret = (int)fread( (void *) buffer, (size_t) 1, (size_t) lSize, io->pFile );
    1605     }
    1606     else
    1607     {
    1608         if (io->iOffset < io->iMoovAtomOffset)
    1609         {
    1610             ret = (int)fread( (void *) buffer, (size_t) 1, (size_t) lSize, io->pFile );
    1611             buffer += ret;
    1612             lSize -= ret;
     1549    size_t ret = fread ( (void *) buffer, (size_t) 1, (size_t) lSize, (FILE *)ptr );
     1550    return (int)ret;
     1551}
     1552
     1553// whence: SEEK_SET, SEEK_CUR, SEEK_END (like fseek) and AVSEEK_SIZE
     1554int64_t SAM_SeekFunc(void* ptr, int64_t pos, int whence)
     1555{   
     1556    if( AVSEEK_SIZE == whence )
     1557    {
     1558        return -1;
     1559    }
     1560    int ret = fseeko((FILE *)ptr, (off_t)pos, whence);
     1561    if(0 == ret)
     1562    {
     1563        return (off_t)ftello((FILE *)ptr);
     1564    }
     1565    return ret;
     1566}
     1567
     1568AVIOContext* container_ffmpeg_get_avio_context(char *filename, size_t avio_ctx_buffer_size)
     1569{
     1570        if(strstr(filename, "file://") == filename)
     1571        {
     1572            filename += 7;
    16131573        }
    16141574       
    1615         if (io->iOffset + ret >= io->iMoovAtomOffset)
    1616         {
    1617             if (ret)
    1618             {
    1619                 if (fseeko(io->pMoovFile, io->iOffset + ret - io->iMoovAtomOffset, SEEK_SET))
    1620                 {
    1621                     // something goes wrong
    1622                     ffmpeg_err("fseeko on moov atom file fail \n");
    1623                     lSize = 0;
    1624                 }
    1625             }
    1626            
    1627             ret += (int)fread( (void *) buffer, (size_t) 1, (size_t) lSize, io->pMoovFile );
     1575        FILE *pFile = fopen(filename, "rb");
     1576        if(NULL == pFile)
     1577        {
     1578            return NULL;
    16281579        }
    16291580       
    1630         io->iOffset += ret;
    1631     }
    1632     return ret;
    1633 }
    1634 
    1635 // whence: SEEK_SET, SEEK_CUR, SEEK_END (like fseek) and AVSEEK_SIZE
    1636 int64_t SAM_SeekFunc(void *ptr, int64_t pos, int whence)
    1637 {   
    1638     CustomIOCtx_t *io = (CustomIOCtx_t *)ptr;
    1639     int64_t ret = -1;
    1640     if (!io->pMoovFile)
    1641     {
    1642         if( AVSEEK_SIZE != whence )
    1643         {
    1644             ret = (int64_t)fseeko(io->pFile, (off_t)pos, whence);
    1645             if(0 == ret)
    1646             {
    1647                 ret = (int64_t)ftello(io->pFile);
    1648             }
    1649         }
    1650     }
    1651     else
    1652     {
    1653         switch(whence)
    1654         {
    1655             case SEEK_SET:
    1656                 ret = pos;
    1657                 break;
    1658             case SEEK_CUR:
    1659                 ret += pos;
    1660                 break;
    1661             case SEEK_END:
    1662                 ret = io->iFileSize + pos;
    1663                 break;
    1664             case AVSEEK_SIZE:
    1665                 return io->iFileSize;
    1666             default:
    1667                 return -1;
    1668         }
     1581        AVIOContext *avio_ctx = NULL;
     1582        uint8_t *avio_ctx_buffer = NULL;
    16691583       
    1670         if (ret >= 0 && ret <= io->iFileSize)
    1671         {
    1672             if (ret < io->iMoovAtomOffset)
    1673             {
    1674                 if(!fseeko(io->pFile, (off_t)ret, SEEK_SET))
    1675                     io->iOffset = ret;
    1676                 else
    1677                     ret = -1;
    1678             }
    1679             else
    1680             {
    1681                 if(!fseeko(io->pMoovFile, (off_t)(ret - io->iMoovAtomOffset), SEEK_SET))
    1682                     io->iOffset = ret;
    1683                 else
    1684                     ret = -1;
    1685             }
    1686         }
    1687         else
    1688         {
    1689             ret = -1;
    1690         }
    1691     }
    1692     return ret;
    1693 }
    1694 
    1695 AVIOContext* container_ffmpeg_get_avio_context(CustomIOCtx_t *custom_io, size_t avio_ctx_buffer_size)
    1696 {
    1697     if(strstr(custom_io->szFile, "file://") == custom_io->szFile)
    1698         custom_io->szFile += 7;
    1699    
    1700     custom_io->pFile = fopen(custom_io->szFile, "rb");
    1701     if(NULL == custom_io->pFile)
    1702     {
    1703         return NULL;
    1704     }
    1705    
    1706     if (custom_io->szMoovAtomFile && custom_io->szMoovAtomFile[0] != '\0')
    1707     {
    1708         if(strstr(custom_io->szMoovAtomFile, "file://") == custom_io->szMoovAtomFile)
    1709             custom_io->szMoovAtomFile += 7;
    1710        
    1711         custom_io->pMoovFile = fopen(custom_io->szMoovAtomFile, "rb");
    1712         if(NULL == custom_io->pMoovFile)
    1713         {
    1714             fclose(custom_io->pFile);
     1584        avio_ctx_buffer = av_malloc(avio_ctx_buffer_size);
     1585        if (!avio_ctx_buffer)
     1586        {
    17151587            return NULL;
    17161588        }
    1717     }
    1718    
    1719     AVIOContext *avio_ctx = NULL;
    1720     uint8_t *avio_ctx_buffer = NULL;
    1721    
    1722     avio_ctx_buffer = av_malloc(avio_ctx_buffer_size);
    1723     if (!avio_ctx_buffer)
    1724     {
    1725         return NULL;
    1726     }
    1727     avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size, 0, custom_io, &SAM_ReadFunc, NULL, &SAM_SeekFunc);
    1728     if (!avio_ctx)
    1729     {
    1730         return NULL;
    1731     }
    1732     return avio_ctx;
     1589        avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size, 0, pFile, &SAM_ReadFunc, NULL, &SAM_SeekFunc);
     1590        if (!avio_ctx)
     1591        {
     1592            return NULL;
     1593        }
     1594        return avio_ctx;
    17331595}
    17341596#endif
    17351597
    1736 int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uint64_t fileSize, char *moovAtomFile, uint64_t moovAtomOffset, int32_t AVIdx)
     1598int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int32_t AVIdx)
    17371599{
    17381600    int32_t err = 0;
     
    17461608       0 == strncmp(filename, "file://", 7))
    17471609    {
    1748         AVIOContext *avio_ctx = NULL;
    1749         custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t));
    1750         sizeof(custom_io_tab[AVIdx], 0x00, sizeof(CustomIOCtx_t));
    1751        
    1752         custom_io_tab[AVIdx]->szFile = filename;
    1753         custom_io_tab[AVIdx]->iFileSize = fileSize;
    1754         custom_io_tab[AVIdx]->szMoovAtomFile = moovAtomFile;
    1755         custom_io_tab[AVIdx]->iMoovAtomOffset = moovAtomOffset;
    1756        
    1757         avio_ctx = container_ffmpeg_get_avio_context(custom_io_tab[AVIdx], 4096);
     1610        AVIOContext *avio_ctx = container_ffmpeg_get_avio_context(filename, 4096);
    17581611        if(avio_ctx)
    17591612        {
     
    17631616        else
    17641617        {
    1765             free(custom_io_tab[AVIdx]);
    1766             custom_io_tab[AVIdx] = NULL;
    17671618            return cERR_CONTAINER_FFMPEG_OPEN;
    17681619        }
     
    23032154 
    23042155    context->playback->abortRequested = 0;
    2305     int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \
    2306                                                    playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0);
     2156    int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, 0);
    23072157    if(0 != res)
    23082158    {
     
    23102160    }
    23112161
    2312     if(playFilesNames->szSecondFile && playFilesNames->szSecondFile[0] != '\0')
    2313     {
    2314         res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, playFilesNames->iSecondFileSize, \
    2315                                                playFilesNames->szSecondMoovAtomFile, playFilesNames->iSecondMoovAtomOffset, 1);
     2162    if(playFilesNames->szSecondFile)
     2163    {
     2164        res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, 1);
    23162165    }
    23172166   
     
    23342183int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32_t initial)
    23352184{
    2336     Track_t *currAudioTrack = NULL;
    2337     Track_t *currSubtitleTrack = NULL;
    2338     uint32_t addedVideoTracksCount = 0;
     2185    Track_t *audioTrack = NULL;
     2186    Track_t *subtitleTrack = NULL;
    23392187   
    23402188    if (terminating)
     
    23432191    }
    23442192   
    2345     getMutex(__FILE__, __FUNCTION__,__LINE__);
    2346    
    23472193    if (initial && context->manager->subtitle)
    23482194    {
    2349         context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &currSubtitleTrack);
     2195        context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &subtitleTrack);
    23502196    }
    23512197
    23522198    if (context->manager->audio)
    23532199    {
    2354         context->manager->audio->Command(context, MANAGER_GET_TRACK, &currAudioTrack);
     2200        context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack);
    23552201    }
    23562202
     
    23712217    }
    23722218#endif
     2219
    23732220
    23742221    ffmpeg_printf(20, "dump format\n");
     
    24482295                }
    24492296               
    2450                 if (!isStreamFromSelProg) {
    2451                     stream->discard = AVDISCARD_ALL;
    2452                     ffmpeg_printf(1, "cAVIdx[%d]: add DISCARD flag to  stream index[%d]\n", cAVIdx, stream->index);
     2297                if (!isStreamFromSelProg)
    24532298                    continue; // skip this stream
    2454                 }
    24552299            }
    24562300
     
    24852329            case AVMEDIA_TYPE_VIDEO:
    24862330                ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type);
    2487                 stream->discard = AVDISCARD_ALL; /* by default we discard all video streams */
     2331
    24882332                if (encoding != NULL)
    24892333                {
     
    25652409                            ffmpeg_err("failed to add track %d\n", n);
    25662410                        }
    2567                         else
    2568                         {
    2569                             if (addedVideoTracksCount == 0) /* at now we can handle only first video track */
    2570                             {
    2571                                 stream->discard = AVDISCARD_DEFAULT;
    2572                             }
    2573                             addedVideoTracksCount += 1;
    2574                         }
    25752411                    }
    25762412                }
     
    25822418            case AVMEDIA_TYPE_AUDIO:
    25832419                ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n",get_codecpar(stream)->codec_type);
    2584                 stream->discard = AVDISCARD_ALL;
     2420
    25852421                if (encoding != NULL)
    25862422                {
     
    29542790            case AVMEDIA_TYPE_NB:
    29552791            default:
    2956                 stream->discard = AVDISCARD_ALL;
    29572792                ffmpeg_err("not handled or unknown codec_type %d\n", get_codecpar(stream)->codec_type);
    29582793             break;
     
    29612796   
    29622797    }
    2963    
    2964     if (context->manager->audio)
    2965     {
    2966         Track_t *Tracks = NULL;
    2967         int32_t TrackCount = 0;
    2968         int32_t selTrackIdx = -1;
    2969        
    2970         context->manager->audio->Command(context, MANAGER_REF_LIST, &Tracks);
    2971         context->manager->audio->Command(context, MANAGER_REF_LIST_SIZE, &TrackCount);
    2972         if (Tracks && TrackCount)
    2973         {
    2974             int32_t i;
    2975             for (i=0; i < TrackCount; ++i)
    2976             {
    2977                 if (Tracks[i].pending || Tracks[i].Id < 0)
    2978                     continue;
    2979                
    2980                 if (selTrackIdx == -1)
    2981                     selTrackIdx = i;
    2982                    
    2983                 if (currAudioTrack && currAudioTrack->Id == Tracks[i].Id)
    2984                 {
    2985                     selTrackIdx = i;
    2986                     break;
    2987                 }
    2988             }
    2989            
    2990             if (selTrackIdx > -1)
    2991             {
    2992                 ((AVStream*)Tracks[selTrackIdx].stream)->discard = AVDISCARD_DEFAULT;
    2993                 if (!currAudioTrack || currAudioTrack->Id != Tracks[selTrackIdx].Id )
    2994                 {
    2995                     context->manager->audio->Command(context, MANAGER_SET, &Tracks[selTrackIdx].Id);
    2996                 }
    2997             }
    2998         }
    2999     }
    3000    
    3001     releaseMutex(__FILE__, __FUNCTION__,__LINE__);
     2798
    30022799    return cERR_CONTAINER_FFMPEG_NO_ERROR;
    30032800}
     
    33223119    }
    33233120
    3324 //    getMutex(__FILE__, __FUNCTION__,__LINE__);
     3121    getMutex(__FILE__, __FUNCTION__,__LINE__);
    33253122
    33263123    if (!context->playback || !context->playback->isPlaying)
     
    33413138        */
    33423139
    3343         getMutex(__FILE__, __FUNCTION__,__LINE__);
    33443140        off_t pos = avio_tell(avContextTab[0]->pb);
    3345         releaseMutex(__FILE__, __FUNCTION__,__LINE__);
    33463141
    33473142        ffmpeg_printf(10, "pos %lld %d\n", pos, avContextTab[0]->bit_rate);
     
    33773172    }
    33783173
    3379 //    releaseMutex(__FILE__, __FUNCTION__,__LINE__);
     3174    releaseMutex(__FILE__, __FUNCTION__,__LINE__);
    33803175    return cERR_CONTAINER_FFMPEG_NO_ERROR;
    33813176}
     
    34383233{
    34393234    ffmpeg_printf(10, "track %d\n", *arg);
    3440     getMutex(__FILE__, __FUNCTION__,__LINE__);
    3441     if (context->manager->audio)
    3442     {
    3443         Track_t *Tracks = NULL;
    3444         int32_t TrackCount = 0;
    3445        
    3446         context->manager->audio->Command(context, MANAGER_REF_LIST, &Tracks);
    3447         context->manager->audio->Command(context, MANAGER_REF_LIST_SIZE, &TrackCount);
    3448         if (Tracks && TrackCount)
    3449         {
    3450             int32_t i;
    3451             for (i=0; i < TrackCount; ++i)
    3452             {
    3453                 ((AVStream*)Tracks[i].stream)->discard = Tracks[i].Id == *arg ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
    3454             }
    3455         }
    3456     }
    3457     releaseMutex(__FILE__, __FUNCTION__,__LINE__);
    34583235   
    34593236    /* Hellmaster1024: nothing to do here!*/
    3460     int64_t sec = -1;
     3237    int64_t sec = -5;
    34613238    context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec);
    34623239    return cERR_CONTAINER_FFMPEG_NO_ERROR;
     
    34723249     * but now we will not ignore subtitle frame
    34733250     */
    3474     int64_t sec = -1;
     3251    int64_t sec = -5;
    34753252    context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec);
    34763253    //obi
  • titan/libeplayer3/container/flv2mpeg4_ffmpeg.c

    r42162 r42177  
    3939    avOut.type       = "video";
    4040
    41     if (Write(ctx->out_ctx->output->video->Write, ctx->out_ctx, &avOut, avOut.pts) < 0)
     41    if (ctx->out_ctx->output->video->Write(ctx->out_ctx, &avOut) < 0)
    4242    {
    4343        ffmpeg_err("writing data to video device failed\n");
  • titan/libeplayer3/container/mpeg4p2_ffmpeg.c

    r42162 r42177  
    112112    avOut.type       = "video";
    113113
    114     if (Write(ctx->output->video->Write, ctx, &avOut, avOut.pts) < 0)
     114    if (ctx->output->video->Write(ctx, &avOut) < 0)
    115115    {
    116116        ffmpeg_err("writing data to video device failed\n");
  • titan/libeplayer3/include/common.h

    r42162 r42177  
    1010#include <pthread.h>
    1111
    12 //typedef char PlayFilesTab_t[2];
     12typedef char PlayFilesTab_t[2];
    1313
    1414typedef struct PlayFiles_t
     
    1616    char *szFirstFile;
    1717    char *szSecondFile;
    18     char *szFirstMoovAtomFile;
    19     char *szSecondMoovAtomFile;
    20     uint64_t iFirstFileSize;
    21     uint64_t iSecondFileSize;
    22     uint64_t iFirstMoovAtomOffset;
    23     uint64_t iSecondMoovAtomOffset;
    2418} PlayFiles_t;
    2519
  • titan/libeplayer3/include/manager.h

    r42162 r42177  
    1818    MANAGER_UPDATED_TRACK_INFO,
    1919    MANAGER_REGISTER_UPDATED_TRACK_INFO,
    20     MANAGER_REF_LIST,
    21     MANAGER_REF_LIST_SIZE,
    2220} ManagerCmd_t;
    2321
  • titan/libeplayer3/include/output.h

    r42162 r42177  
    2727    OUTPUT_GET_FRAME_COUNT,
    2828    OUTPUT_GET_PROGRESSIVE,
    29     OUTPUT_SET_BUFFER_SIZE,
    3029} OutputCmd_t;
    3130
     
    6968    char * Name;
    7069    int32_t (* Command) (/*Context_t*/void  *, OutputCmd_t, void *);
    71     int32_t (* Write) (/*Context_t*/void  *, void *);
     70    int32_t (* Write) (/*Context_t*/void  *, void* privateData);
    7271    char ** Capabilities;
    7372
  • titan/libeplayer3/include/playback.h

    r42162 r42177  
    33#include <sys/types.h>
    44#include <stdint.h>
    5 #include <stdbool.h>
    6 
    7 typedef void( * PlaybackDieNowCallback )();
    8 bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback);
    95
    106typedef enum {PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS, PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO, PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION, PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT} PlaybackCmd_t;
  • titan/libeplayer3/include/writer.h

    r42162 r42177  
    55#include <stdio.h>
    66#include <stdint.h>
    7 #include "common.h"
    87
    98typedef enum { eNone, eAudio, eVideo} eWriterType_t;
     
    2322    unsigned char          Version;
    2423    unsigned int           InfoFlags;
    25     ssize_t                (* WriteV) (int, const struct iovec *, size_t);
    2624} WriterAVCallData_t;
    2725
     
    8987ssize_t write_with_retry(int fd, const void *buf, size_t size);
    9088ssize_t writev_with_retry(int fd, const struct iovec *iov, size_t ic);
    91 
    92 ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, const void *buf, size_t size);
    9389#endif
  • titan/libeplayer3/main/exteplayer.c

    r42162 r42177  
    8585}
    8686
    87 static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread and kbhit */
     87static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread */
    8888static int isPlaybackStarted = 0;
    8989static pthread_mutex_t playbackStartMtx;
    90 
    91 static void TerminateWakeUp()
    92 {
    93     write(g_pfd[1], "x", 1);
    94 }
    9590
    9691static void *TermThreadFun(void *arg)
     
    141136    if (FD_ISSET(fd, &readfds))
    142137    {
     138        /*
     139        if ( (cl = accept(fd, NULL, NULL)) == -1)
     140        {
     141            perror("TermThreadFun accept error");
     142            goto finish;
     143        }
     144        */
     145       
    143146        pthread_mutex_lock(&playbackStartMtx);
    144147        PlaybackDieNow(1);
     
    181184{
    182185    struct timeval tv;
    183     fd_set readfds;
    184 
    185     tv.tv_sec = 1;
    186     tv.tv_usec = 0;
    187 
    188     FD_ZERO(&readfds);
    189     FD_SET(0,&readfds);
    190     FD_SET(g_pfd[0], &readfds);
    191 
    192     if(-1 == select(g_pfd[0] + 1, &readfds, NULL, NULL, &tv))
     186    fd_set read_fd;
     187
     188    tv.tv_sec=1;
     189    tv.tv_usec=0;
     190
     191    FD_ZERO(&read_fd);
     192    FD_SET(0,&read_fd);
     193
     194    if(-1 == select(1, &read_fd, NULL, NULL, &tv))
    193195    {
    194196        return 0;
    195197    }
    196198
    197     if(FD_ISSET(0, &readfds))
     199    if(FD_ISSET(0,&read_fd))
    198200    {
    199201        return 1;
     
    367369}
    368370
    369 static int ParseParams(int argc,char* argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB)
     371static int ParseParams(int argc,char* argv[], char *file, char *audioFile, int *pAudioTrackIdx, int *subtitleTrackIdx)
    370372{   
    371373    int ret = 0;
     
    374376    int aopt = 0, bopt = 0;
    375377    char *copt = 0, *dopt = 0;
    376     while ( (c = getopt(argc, argv, "we3dlsrimva:n:x:u:c:h:o:p:P:t:9:0:1:4:f:b:F:S:O:")) != -1)
     378    while ( (c = getopt(argc, argv, "we3dlsrimva:n:x:u:c:h:o:p:P:t:9:0:1:4:f:")) != -1)
    377379    {
    378380        switch (c)
     
    435437            break;
    436438        case 'x':
    437             if (optarg[0] != '\0')
    438             {
    439                 playbackFiles->szSecondFile = malloc(IPTV_MAX_FILE_PATH);
    440                 playbackFiles->szSecondFile[0] = '\0';
    441                 strncpy(playbackFiles->szSecondFile, optarg, IPTV_MAX_FILE_PATH-1);
    442                 playbackFiles->szSecondFile[IPTV_MAX_FILE_PATH] = '\0';
    443                 map_inter_file_path(playbackFiles->szSecondFile);
    444             }
     439            strncpy(audioFile, optarg, IPTV_MAX_FILE_PATH-1);
     440            map_inter_file_path(audioFile);
    445441            break;
    446442        case 'h':
     
    490486            break;
    491487        }
    492         case 'b':
    493             *linuxDvbBufferSizeMB = 1024 * 1024 * atoi(optarg);
    494             break;
    495         case 'S':
    496             playbackFiles->iFirstFileSize = (uint64_t) strtoull(optarg, (char **)NULL, 10);
    497             break;
    498         case 'O':
    499             playbackFiles->iFirstMoovAtomOffset = (uint64_t) strtoull(optarg, (char **)NULL, 10);
    500             break;
    501         case 'F':
    502             if (optarg[0] != '\0')
    503             {
    504                 playbackFiles->szFirstMoovAtomFile = malloc(IPTV_MAX_FILE_PATH);
    505                 playbackFiles->szFirstMoovAtomFile[0] = '\0';
    506                 strncpy(playbackFiles->szFirstMoovAtomFile, optarg, IPTV_MAX_FILE_PATH-1);
    507                 playbackFiles->szFirstMoovAtomFile[IPTV_MAX_FILE_PATH] = '\0';
    508                 map_inter_file_path(playbackFiles->szFirstMoovAtomFile);
    509             }
    510             break;
    511488        default:
    512489            printf ("?? getopt returned character code 0%o ??\n", c);
     
    518495    {
    519496        ret = 0;
    520         playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH);
    521         playbackFiles->szFirstFile[0] = '\0';
     497       
    522498        if(NULL == strstr(argv[optind], "://"))
    523499        {
    524             strcpy(playbackFiles->szFirstFile, "file://");
    525         }
    526         strcat(playbackFiles->szFirstFile, argv[optind]);
    527         playbackFiles->szFirstFile[IPTV_MAX_FILE_PATH] = '\0';
    528         map_inter_file_path(playbackFiles->szFirstFile);
    529         printf("file: [%s]\n", playbackFiles->szFirstFile);
     500            strcpy(file, "file://");
     501        }
     502        strcat(file, argv[optind]);
     503        map_inter_file_path(file);
     504        printf("file: [%s]\n", file);
    530505        ++optind;
    531506    }
     
    541516    pthread_t termThread;
    542517    int isTermThreadStarted = 0;
     518    char file[IPTV_MAX_FILE_PATH];
     519    memset(file, '\0', sizeof(file));
     520   
     521    char audioFile[IPTV_MAX_FILE_PATH];
     522    memset(audioFile, '\0', sizeof(audioFile));
    543523   
    544524    int audioTrackIdx = -1;
    545525    int subtitleTrackIdx = -1;
    546    
    547     uint32_t linuxDvbBufferSizeMB = 0;
    548526   
    549527    char argvBuff[256];
     
    551529    int commandRetVal = -1;
    552530    /* inform client that we can handle additional commands */
    553     fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 47);
    554 
    555     PlayFiles_t playbackFiles;
    556     memset(&playbackFiles, 0x00, sizeof(playbackFiles));
    557     if (0 != ParseParams(argc, argv, &playbackFiles, &audioTrackIdx, &subtitleTrackIdx, &linuxDvbBufferSizeMB))
     531    fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 36);
     532
     533    if (0 != ParseParams(argc, argv, file, audioFile, &audioTrackIdx, &subtitleTrackIdx))
    558534    {
    559535        printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n");
    560         printf("[-b size] Linux DVB output buffer size in MB\n");
    561536        printf("[-a 0|1|2|3] AAC software decoding - 1 bit - AAC ADTS, 2 - bit AAC LATM\n");
    562537        printf("[-e] EAC3 software decoding\n");
     
    585560        printf("[-1 idx] audio MPEG-DASH representation index\n");
    586561        printf("[-f ffopt=ffval] any other ffmpeg option\n");
    587         printf("[-F path to additional file with moov atom data (used for mp4 playback in progressive download mode)\n");
    588         printf("[-O moov atom offset in the original file (used for mp4 playback in progressive download mode)\n");
    589         printf("[-S remote file size (used for mp4 playback in progressive download mode)\n");
     562       
    590563        exit(1);
    591564    }
     
    626599            isTermThreadStarted = 1;
    627600    } while(0);
    628    
     601
    629602    g_player->playback    = &PlaybackHandler;
    630603    g_player->output      = &OutputHandler;
     
    641614    g_player->output->Command(g_player, OUTPUT_ADD, "video");
    642615    g_player->output->Command(g_player, OUTPUT_ADD, "subtitle");
    643    
    644     //Set LINUX DVB additional write buffer size
    645     if (linuxDvbBufferSizeMB)
    646         g_player->output->Command(g_player, OUTPUT_SET_BUFFER_SIZE, &linuxDvbBufferSizeMB);
    647    
    648616
    649617    g_player->manager->video->Command(g_player, MANAGER_REGISTER_UPDATED_TRACK_INFO, UpdateVideoTrack);
    650     if (strncmp(playbackFiles.szFirstFile, "rtmp", 4) && strncmp(playbackFiles.szFirstFile, "ffrtmp", 4))
     618    if (strncmp(file, "rtmp", 4) && strncmp(file, "ffrtmp", 4))
    651619    {
    652620        g_player->playback->noprobe = 1;
    653621    }
    654622
     623    PlayFiles_t playbackFiles = {file, NULL};
     624    if('\0' != audioFile[0])
     625    {
     626        playbackFiles.szSecondFile = audioFile;
     627    }
     628   
    655629    commandRetVal = g_player->playback->Command(g_player, PLAYBACK_OPEN, &playbackFiles);
    656     fprintf(stderr, "{\"PLAYBACK_OPEN\":{\"OutputName\":\"%s\", \"file\":\"%s\", \"sts\":%d}}\n", g_player->output->Name, playbackFiles.szFirstFile, commandRetVal);
     630    fprintf(stderr, "{\"PLAYBACK_OPEN\":{\"OutputName\":\"%s\", \"file\":\"%s\", \"sts\":%d}}\n", g_player->output->Name, file, commandRetVal);
    657631    if(commandRetVal < 0)
    658632    {
     
    676650        if (g_player->playback->isPlaying)
    677651        {
    678             PlaybackDieNowRegisterCallback(TerminateWakeUp);
    679            
    680652            HandleTracks(g_player->manager->video, (PlaybackCmd_t)-1, "vc");
    681653            HandleTracks(g_player->manager->audio, (PlaybackCmd_t)-1, "al");
     
    698670        }
    699671
    700         while(g_player->playback->isPlaying && 0 == PlaybackDieNow(0))
     672        while(g_player->playback->isPlaying)
    701673        {
    702674            /* we made fgets non blocking */
     
    876848                if (0 == commandRetVal)
    877849                {
    878                     int64_t lastPts = 0;
    879                     commandRetVal = 1;
    880                     if (g_player->container && g_player->container->selectedContainer)
    881                     {
    882                         commandRetVal = g_player->container->selectedContainer->Command(g_player->container, CONTAINER_LAST_PTS, &lastPts);
    883                     }
    884                    
    885                     if (0 == commandRetVal && lastPts != INVALID_PTS_VALUE)
    886                     {
    887                         fprintf(stderr, "{\"J\":{\"ms\":%lld,\"lms\":%lld}}\n", pts / 90, lastPts / 90);
    888                     }
    889                     else
    890                     {
    891                         fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90);
    892                     }
     850                    fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90, commandRetVal);
    893851                }
    894852                break;
     
    947905    close(g_pfd[0]);
    948906    close(g_pfd[1]);
    949    
     907
     908    //printOutputCapabilities();
     909
    950910    exit(0);
    951911}
  • titan/libeplayer3/manager/audio.c

    r42162 r42177  
    220220        break;
    221221    }
    222     case MANAGER_REF_LIST:
    223     {
    224         *((Track_t **)argument) = Tracks;
    225         break;
    226     }
    227     case MANAGER_REF_LIST_SIZE:
    228     {
    229         *((int*)argument) = TrackCount;
    230         break;
    231     }
    232    
    233222    case MANAGER_GET:
    234223    {
  • titan/libeplayer3/output/linuxdvb_mipsel.c

    r42162 r42177  
    2626#include <stdlib.h>
    2727#include <unistd.h>
    28 #include <stdbool.h>
    2928#include <fcntl.h>
    3029#include <sys/types.h>
     
    5453#define LINUXDVB_SILENT
    5554
    56 static uint16_t debug_level = 0;
     55static unsigned short debug_level = 0;
    5756
    5857static const char FILENAME[] = __FILE__;
     
    7473#define cERR_LINUXDVB_ERROR        -1
    7574
    76 static const char VIDEODEV[] = "/dev/dvb/adapter0/video0";
    77 static const char AUDIODEV[] = "/dev/dvb/adapter0/audio0";
     75static const char VIDEODEV[]    = "/dev/dvb/adapter0/video0";
     76static const char AUDIODEV[]    = "/dev/dvb/adapter0/audio0";
    7877
    7978static int videofd      = -1;
     
    9089
    9190unsigned long long int sCURRENT_PTS = 0;
    92 bool isBufferedOutput = false;
    9391
    9492pthread_mutex_t LinuxDVBmutex;
     
    9795/* Prototypes                    */
    9896/* ***************************** */
    99 int32_t LinuxDvbBuffOpen(Context_t *context, char *type, int outfd);
    100 int32_t LinuxDvbBuffClose(Context_t *context);
    101 int32_t LinuxDvbBuffFlush(Context_t *context);
    102 int32_t LinuxDvbBuffResume(Context_t *context);
    103 
    104 ssize_t BufferingWriteV(int fd, const struct iovec *iov, size_t ic);
    105 int32_t WriteSetBufferingSize(const uint32_t bufferSize);
    106 
    10797int LinuxDvbStop(Context_t  *context, char * type);
    10898
     
    111101/* ***************************** */
    112102
    113 void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused)))
    114 {
     103void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) {
     104
     105    linuxdvb_printf(250, "requesting mutex\n");
     106
    115107    pthread_mutex_lock(&LinuxDVBmutex);
     108
     109    linuxdvb_printf(250, "received mutex\n");
    116110}
    117111
    118112void releaseLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) {
    119113    pthread_mutex_unlock(&LinuxDVBmutex);
     114
     115    linuxdvb_printf(250, "released mutex\n");
     116
    120117}
    121118
    122119static int LinuxDvbMapBypassMode(int bypass)
    123120{
    124     if (0x30 == bypass && IsDreambox())
     121    if( 0x30 == bypass && IsDreambox() )
    125122    {
    126123        return 0x0f;
     
    129126}
    130127
    131 int LinuxDvbOpen(Context_t  *context __attribute__((unused)), char *type)
    132 {
    133     uint8_t video = !strcmp("video", type);
    134     uint8_t audio = !strcmp("audio", type);
     128int LinuxDvbOpen(Context_t  *context __attribute__((unused)), char * type) {
     129    unsigned char video = !strcmp("video", type);
     130    unsigned char audio = !strcmp("audio", type);
    135131
    136132    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     
    142138        if (videofd < 0)
    143139        {
    144             linuxdvb_err("failed to open %s - errno %d, %s\n", VIDEODEV, errno, strerror(errno));
    145             linuxdvb_err("%s\n", );
     140            linuxdvb_err("failed to open %s - errno %d\n", VIDEODEV, errno);
     141            linuxdvb_err("%s\n", strerror(errno));
    146142            return cERR_LINUXDVB_ERROR;
    147143        }
     
    149145        if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1)
    150146        {
    151             linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     147            linuxdvb_err("ioctl failed with errno %d\n", errno);
     148            linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno));
    152149        }
    153150
    154151        if (ioctl( videofd, VIDEO_SELECT_SOURCE, (void*)VIDEO_SOURCE_MEMORY) == -1)
    155152        {
    156             linuxdvb_err("VIDEO_SELECT_SOURCE: ERROR %d, %s\n", errno, strerror(errno));
     153            linuxdvb_err("ioctl failed with errno %d\n", errno);
     154            linuxdvb_err("VIDEO_SELECT_SOURCE: %s\n", strerror(errno));
    157155        }
    158156       
    159157        if (ioctl(videofd, VIDEO_FREEZE) == -1)
    160158        {
    161             linuxdvb_err("VIDEO_FREEZE: ERROR %d, %s\n", errno, strerror(errno));
    162         }
    163 
    164         if (isBufferedOutput)
    165             LinuxDvbBuffOpen(context, type, videofd);
     159            linuxdvb_err("ioctl failed with errno %d\n", errno);
     160            linuxdvb_err("VIDEO_FREEZE: %s\n", strerror(errno));
     161        }
     162
    166163    }
    167164    if (audio && audiofd < 0)
     
    171168        if (audiofd < 0)
    172169        {
    173             linuxdvb_err("failed to open %s - errno %d, %s\n", AUDIODEV, errno, strerror(errno));
     170            linuxdvb_err("failed to open %s - errno %d\n", AUDIODEV, errno);
     171            linuxdvb_err("%s\n", strerror(errno));
     172           
    174173            return cERR_LINUXDVB_ERROR;
    175174        }
     
    177176        if (ioctl( audiofd, AUDIO_CLEAR_BUFFER) == -1)
    178177        {
    179             linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     178            linuxdvb_err("ioctl failed with errno %d\n", errno);
     179            linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno));
    180180        }
    181181
    182182        if (ioctl( audiofd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) == -1)
    183183        {
    184             linuxdvb_err("AUDIO_SELECT_SOURCE: ERROR %d, %s\n", errno, strerror(errno));
     184            linuxdvb_err("ioctl failed with errno %d\n", errno);
     185            linuxdvb_err("AUDIO_SELECT_SOURCE: %s\n", strerror(errno));
    185186        }
    186187       
    187188        if (ioctl( audiofd, AUDIO_PAUSE) == -1)
    188189        {
    189             linuxdvb_err("AUDIO_PAUSE: ERROR %d, %s\n", errno, strerror(errno));
     190            linuxdvb_err("ioctl failed with errno %d\n", errno);
     191            linuxdvb_err("AUDIO_PAUSE: %s\n", strerror(errno));
    190192        }
    191193       
    192         if (isBufferedOutput)
    193             LinuxDvbBuffOpen(context, type, audiofd);
    194194    }
    195195
     
    197197}
    198198
    199 int LinuxDvbClose(Context_t  *context, char *type)
     199int LinuxDvbClose(Context_t  *context, char * type)
    200200{
    201     uint8_t video = !strcmp("video", type);
    202     uint8_t audio = !strcmp("audio", type);
     201    unsigned char video = !strcmp("video", type);
     202    unsigned char audio = !strcmp("audio", type);
    203203
    204204    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     
    211211
    212212    getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
    213    
    214     if (isBufferedOutput)
    215         LinuxDvbBuffClose(context);
    216213
    217214    if (video && videofd != -1)
     
    226223    }
    227224
    228     releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);
     225    releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
    229226    return cERR_LINUXDVB_NO_ERROR;
    230227}
    231228
    232 int LinuxDvbPlay(Context_t  *context, char *type) {
    233     int32_t ret = cERR_LINUXDVB_NO_ERROR;
    234     Writer_t *writer;
    235 
    236     uint8_t video = !strcmp("video", type);
    237     uint8_t audio = !strcmp("audio", type);
     229int LinuxDvbPlay(Context_t  *context, char * type) {
     230    int ret = cERR_LINUXDVB_NO_ERROR;
     231    Writer_t* writer;
     232
     233    unsigned char video = !strcmp("video", type);
     234    unsigned char audio = !strcmp("audio", type);
    238235
    239236    linuxdvb_printf(10, "v%d a%d\n", video, audio);
    240237
    241238    if (video && videofd != -1) {
    242         char *Encoding = NULL;
     239        char * Encoding = NULL;
    243240        context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding);
    244241
     
    246243
    247244        writer = getWriter(Encoding);
     245       
     246        // SULGE VU 4K dont like this
     247        /*
     248        if (0 != ioctl(videofd, VIDEO_STOP))
     249        {
     250            linuxdvb_err("ioctl failed with errno %d\n", errno);
     251            linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno));
     252            ret = cERR_LINUXDVB_ERROR;
     253        }
     254        */
     255
    248256        if (writer == NULL)
    249257        {
     
    256264            if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1)
    257265            {
    258                 linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno));
     266                linuxdvb_err("ioctl failed with errno %d\n", errno);
     267                linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno));
    259268                ret = cERR_LINUXDVB_ERROR;
    260269            }
     
    264273        if (0 != ioctl(videofd, VIDEO_PLAY))
    265274        {
    266             linuxdvb_err("VIDEO_PLAY: ERROR %d, %s\n", errno, strerror(errno));
     275            linuxdvb_err("ioctl failed with errno %d\n", errno);
     276            linuxdvb_err("VIDEO_PLAY: %s\n", strerror(errno));
    267277            ret = cERR_LINUXDVB_ERROR;
    268278        }
     
    270280        if (ioctl(videofd, VIDEO_CONTINUE) == -1)
    271281        {
    272             linuxdvb_err("VIDEO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno));
     282            linuxdvb_err("ioctl failed with errno %d\n", errno);
     283            linuxdvb_err("VIDEO_CONTINUE: %s\n", strerror(errno));
    273284        }
    274285       
    275286        if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1)
    276287        {
    277             linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     288            linuxdvb_err("ioctl failed with errno %d\n", errno);
     289            linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno));
    278290        }
    279291    }
     
    286298        writer = getWriter(Encoding);
    287299       
     300        // SULGE VU 4K dont like this
     301        /*
     302        if (0 != ioctl(audiofd, AUDIO_STOP))
     303        {
     304            linuxdvb_err("ioctl failed with errno %d\n", errno);
     305            linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno));
     306            ret = cERR_LINUXDVB_ERROR;
     307        }
     308        */
     309
    288310        if (writer == NULL)
    289311        {
     
    296318            if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) < 0)
    297319            {
    298                 linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno));
     320                linuxdvb_err("ioctl failed with errno %d\n", errno);
     321                linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno));
    299322                ret = cERR_LINUXDVB_ERROR;
    300323            }
     
    303326        if (ioctl(audiofd, AUDIO_PLAY) < 0)
    304327        {
    305             linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno));
     328            linuxdvb_err("ioctl failed with errno %d\n", errno);
     329            linuxdvb_err("AUDIO_PLAY: %s\n", strerror(errno));
    306330            ret = cERR_LINUXDVB_ERROR;
    307331        }
     
    309333        if (ioctl(audiofd, AUDIO_CONTINUE) < 0)
    310334        {
    311             linuxdvb_err("AUDIO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno));
     335            linuxdvb_err("ioctl failed with errno %d\n", errno);
     336            linuxdvb_err("AUDIO_CONTINUE: %s\n", strerror(errno));
    312337            ret = cERR_LINUXDVB_ERROR;
    313338        }
     
    333358        if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1)
    334359        {
    335             linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     360            linuxdvb_err("ioctl failed with errno %d\n", errno);
     361            linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno));
    336362        }
    337363       
    338364        if (ioctl(videofd, VIDEO_STOP) == -1)
    339365        {
    340             linuxdvb_err("VIDEO_STOP: ERROR %d, %s\n", errno, strerror(errno));
     366            linuxdvb_err("ioctl failed with errno %d\n", errno);
     367            linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno));
    341368            ret = cERR_LINUXDVB_ERROR;
    342369        }
     
    344371        ioctl(videofd, VIDEO_SLOWMOTION, 0);
    345372        ioctl(videofd, VIDEO_FAST_FORWARD, 0);
     373
    346374        ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
    347375    }
     
    349377        if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1)
    350378        {
    351             linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
    352         }
    353 
     379            linuxdvb_err("ioctl failed with errno %d\n", errno);
     380            linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno));
     381        }
     382
     383        /* set back to normal speed (end trickmodes) */
     384        // if (ioctl(audiofd, AUDIO_SET_SPEED, DVB_SPEED_NORMAL_PLAY) == -1)
     385        // {
     386            // linuxdvb_err("ioctl failed with errno %d\n", errno);
     387            // linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno));
     388        // }
    354389        if (ioctl(audiofd, AUDIO_STOP) == -1)
    355390        {
    356             linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno));
     391            linuxdvb_err("ioctl failed with errno %d\n", errno);
     392            linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno));
    357393            ret = cERR_LINUXDVB_ERROR;
    358394        }
     
    365401}
    366402
    367 int LinuxDvbPause(Context_t  *context __attribute__((unused)), char *type) {
    368     int32_t ret = cERR_LINUXDVB_NO_ERROR;
    369     uint8_t video = !strcmp("video", type);
    370     uint8_t audio = !strcmp("audio", type);
     403int LinuxDvbPause(Context_t  *context __attribute__((unused)), char * type) {
     404    int ret = cERR_LINUXDVB_NO_ERROR;
     405    unsigned char video = !strcmp("video", type);
     406    unsigned char audio = !strcmp("audio", type);
    371407
    372408    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     
    374410    getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
    375411
    376     if (video && videofd != -1)
    377     {
     412    if (video && videofd != -1) {
    378413        if (ioctl(videofd, VIDEO_FREEZE, NULL) == -1)
    379414        {
    380             linuxdvb_err("VIDEO_FREEZE: ERROR %d, %s\n", errno, strerror(errno));
    381             ret = cERR_LINUXDVB_ERROR;
    382         }
    383     }
     415            linuxdvb_err("ioctl failed with errno %d\n", errno);
     416            linuxdvb_err("VIDEO_FREEZE: %s\n", strerror(errno));
     417            ret = cERR_LINUXDVB_ERROR;
     418        }
     419    }
     420    if (audio && audiofd != -1) {
     421        if (ioctl(audiofd, AUDIO_PAUSE, NULL) == -1)
     422        {
     423            linuxdvb_err("ioctl failed with errno %d\n", errno);
     424            linuxdvb_err("AUDIO_PAUSE: %s\n", strerror(errno));
     425            ret = cERR_LINUXDVB_ERROR;
     426        }
     427    }
     428
     429    releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     430
     431    return ret;
     432}
     433
     434int LinuxDvbContinue(Context_t  *context __attribute__((unused)), char * type) {
     435    int ret = cERR_LINUXDVB_NO_ERROR;
     436    unsigned char video = !strcmp("video", type);
     437    unsigned char audio = !strcmp("audio", type);
     438
     439    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     440
     441    if (video && videofd != -1) {
     442        if (ioctl(videofd, VIDEO_CONTINUE, NULL) == -1)
     443        {
     444            linuxdvb_err("ioctl failed with errno %d\n", errno);
     445            linuxdvb_err("VIDEO_CONTINUE: %s\n", strerror(errno));
     446            ret = cERR_LINUXDVB_ERROR;
     447        }
     448    }
     449    if (audio && audiofd != -1) {
     450        if (ioctl(audiofd, AUDIO_CONTINUE, NULL) == -1)
     451        {
     452            linuxdvb_err("ioctl failed with errno %d\n", errno);
     453            linuxdvb_err("AUDIO_CONTINUE: %s\n", strerror(errno));
     454            ret = cERR_LINUXDVB_ERROR;
     455        }
     456    }
     457
     458    linuxdvb_printf(10, "exiting\n");
     459
     460
     461    return ret;
     462}
     463
     464int LinuxDvbReverseDiscontinuity(Context_t  *context __attribute__((unused)), int* surplus) {
     465    int ret = cERR_LINUXDVB_NO_ERROR;
     466    // int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus;
    384467   
    385     if (audio && audiofd != -1)
    386     {
    387         if (ioctl(audiofd, AUDIO_PAUSE, NULL) == -1)
    388         {
    389             linuxdvb_err("AUDIO_PAUSE: ERROR %d, %s\n", errno, strerror(errno));
    390             ret = cERR_LINUXDVB_ERROR;
    391         }
    392     }
    393 
    394     releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
    395 
    396     return ret;
    397 }
    398 
    399 int LinuxDvbContinue(Context_t  *context __attribute__((unused)), char * type) {
    400     int32_t ret = cERR_LINUXDVB_NO_ERROR;
    401     uint8_t video = !strcmp("video", type);
    402     uint8_t audio = !strcmp("audio", type);
    403 
    404     linuxdvb_printf(10, "v%d a%d\n", video, audio);
    405 
    406     if (video && videofd != -1)
    407     {
    408         if (ioctl(videofd, VIDEO_CONTINUE, NULL) == -1)
    409         {
    410             linuxdvb_err("VIDEO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno));
    411             ret = cERR_LINUXDVB_ERROR;
    412         }
    413     }
    414    
    415     if (audio && audiofd != -1)
    416     {
    417         if (ioctl(audiofd, AUDIO_CONTINUE, NULL) == -1)
    418         {
    419             linuxdvb_err("AUDIO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno));
    420             ret = cERR_LINUXDVB_ERROR;
    421         }
    422     }
    423    
    424     if (isBufferedOutput)
    425         LinuxDvbBuffResume(context);
    426 
    427     linuxdvb_printf(10, "exiting\n");
    428    
     468    // linuxdvb_printf(50, "\n");
     469
     470    // if (ioctl( videofd, VIDEO_DISCONTINUITY, (void*) dis_type) == -1)
     471    // {
     472        // linuxdvb_err("ioctl failed with errno %d\n", errno);
     473        // linuxdvb_err("VIDEO_DISCONTINUITY: %s\n", strerror(errno));
     474    // }
     475
     476    // linuxdvb_printf(50, "exiting\n");
     477
    429478    return ret;
    430479}
     
    438487        if(*flag == '1')
    439488        {
     489            //AUDIO_SET_MUTE has no effect with new player
     490            //if (ioctl(audiofd, AUDIO_SET_MUTE, 1) == -1)
    440491            if (ioctl(audiofd, AUDIO_STOP, NULL) == -1)
    441492            {
    442                 linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno));
     493                linuxdvb_err("ioctl failed with errno %d\n", errno);
     494                //linuxdvb_err("AUDIO_SET_MUTE: %s\n", strerror(errno));
     495                linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno));
    443496                ret = cERR_LINUXDVB_ERROR;
    444497            }
     
    446499        else
    447500        {
     501            //AUDIO_SET_MUTE has no effect with new player
     502            //if (ioctl(audiofd, AUDIO_SET_MUTE, 0) == -1)
    448503            if (ioctl(audiofd, AUDIO_PLAY) == -1)
    449504            {
    450                 linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno));
     505                linuxdvb_err("ioctl failed with errno %d\n", errno);
     506                //linuxdvb_err("AUDIO_SET_MUTE: %s\n", strerror(errno));
     507                linuxdvb_err("AUDIO_PLAY: %s\n", strerror(errno));
    451508                ret = cERR_LINUXDVB_ERROR;
    452509            }
     
    458515    return ret;
    459516}
     517
    460518
    461519int LinuxDvbFlush(Context_t  *context __attribute__((unused)), char * type)
    462520{
     521    // unsigned char video = !strcmp("video", type);
     522    // unsigned char audio = !strcmp("audio", type);
     523
     524    // linuxdvb_printf(10, "v%d a%d\n", video, audio);
     525
     526    // if ( (video && videofd != -1) || (audio && audiofd != -1) ) {
     527        // getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     528
     529        // if (video && videofd != -1) {
     530            // if (ioctl(videofd, VIDEO_FLUSH, NULL) == -1)
     531            // {
     532                // linuxdvb_err("ioctl failed with errno %d\n", errno);
     533                // linuxdvb_err("VIDEO_FLUSH: %s\n", strerror(errno));
     534            // }
     535        // }
     536
     537        // if (audio && audiofd != -1) {
     538            // if (ioctl(audiofd, AUDIO_FLUSH, NULL) == -1)
     539            // {
     540                // linuxdvb_err("ioctl failed with errno %d\n", errno);
     541                // linuxdvb_err("AUDIO_FLUSH: %s\n", strerror(errno));
     542            // }
     543        // }
     544
     545        // releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     546    // }
     547
     548    // linuxdvb_printf(10, "exiting\n");
     549
    463550    return cERR_LINUXDVB_NO_ERROR;
    464551}
    465552
     553#ifndef use_set_speed_instead_ff
     554int LinuxDvbFastForward(Context_t  *context, char * type) {
     555    int ret = cERR_LINUXDVB_NO_ERROR;
     556
     557    unsigned char video = !strcmp("video", type);
     558    unsigned char audio = !strcmp("audio", type);
     559
     560    linuxdvb_printf(10, "v%d a%d speed %d\n", video, audio, context->playback->Speed);
     561
     562    if (video && videofd != -1) {
     563
     564        getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     565
     566        /* konfetti comment: speed is a value given in skipped frames */
     567
     568        if (ioctl(videofd, VIDEO_FAST_FORWARD, context->playback->Speed) == -1)
     569        {
     570            linuxdvb_err("ioctl failed with errno %d\n", errno);
     571            linuxdvb_err("VIDEO_FAST_FORWARD: %s\n", strerror(errno));
     572            ret = cERR_LINUXDVB_ERROR;
     573        }
     574
     575        releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     576    }
     577
     578    linuxdvb_printf(10, "exiting with value %d\n", ret);
     579
     580    return ret;
     581}
     582#else
     583
     584static unsigned int SpeedList[] =
     585{
     586    1000, 1100, 1200, 1300, 1500,
     587    2000, 3000, 4000, 5000, 8000,
     588    12000, 16000,
     589    125, 250, 500, 700, 800, 900
     590};
     591
     592int LinuxDvbFastForward(Context_t  *context, char * type) {
     593    int ret = cERR_LINUXDVB_NO_ERROR;
     594    int speedIndex;
     595    unsigned char video = !strcmp("video", type);
     596    unsigned char audio = !strcmp("audio", type);
     597
     598    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     599
     600    if (video && videofd != -1) {
     601
     602        getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     603
     604        speedIndex = context->playback->Speed % (sizeof (SpeedList) / sizeof (int));
     605
     606        linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
     607
     608        // if (ioctl(videofd, VIDEO_SET_SPEED, SpeedList[speedIndex]) == -1)
     609        // {
     610            // linuxdvb_err("ioctl failed with errno %d\n", errno);
     611            // linuxdvb_err("VIDEO_SET_SPEED: %s\n", strerror(errno));
     612            // ret = cERR_LINUXDVB_ERROR;
     613        // }
     614
     615        releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     616    }
     617
     618    if (audio && audiofd != -1) {
     619
     620        getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     621
     622        speedIndex = context->playback->Speed % (sizeof (SpeedList) / sizeof (int));
     623
     624        linuxdvb_printf(1, "speedIndex %d\n", speedIndex);
     625
     626        // if (ioctl(audiofd, AUDIO_SET_SPEED, SpeedList[speedIndex]) == -1)
     627        // {
     628            // linuxdvb_err("ioctl failed with errno %d\n", errno);
     629            // linuxdvb_err("AUDIO_SET_SPEED: %s\n", strerror(errno));
     630            // ret = cERR_LINUXDVB_ERROR;
     631        // }
     632
     633        releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     634    }
     635
     636    linuxdvb_printf(10, "exiting with value %d\n", ret);
     637
     638    return ret;
     639}
     640#endif
     641
     642
     643int LinuxDvbReverse(Context_t  *context __attribute__((unused)), char * type __attribute__((unused))) {
     644    int ret = cERR_LINUXDVB_NO_ERROR;
     645    return ret;
     646}
     647
    466648int LinuxDvbSlowMotion(Context_t  *context, char * type) {
    467     int32_t ret = cERR_LINUXDVB_NO_ERROR;
    468 
    469     uint8_t video = !strcmp("video", type);
    470     uint8_t audio = !strcmp("audio", type);
     649    int ret = cERR_LINUXDVB_NO_ERROR;
     650
     651    unsigned char video = !strcmp("video", type);
     652    unsigned char audio = !strcmp("audio", type);
    471653
    472654    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     
    478660            if (ioctl(videofd, VIDEO_SLOWMOTION, context->playback->SlowMotion) == -1)
    479661            {
    480                 linuxdvb_err("VIDEO_SLOWMOTION: ERROR %d, %s\n", errno, strerror(errno));
     662                linuxdvb_err("ioctl failed with errno %d\n", errno);
     663                linuxdvb_err("VIDEO_SLOWMOTION: %s\n", strerror(errno));
    481664                ret = cERR_LINUXDVB_ERROR;
    482665            }
     
    491674}
    492675
    493 int LinuxDvbAVSync(Context_t  *context, char *type __attribute__((unused))) {
    494     int32_t ret = cERR_LINUXDVB_NO_ERROR;
     676int LinuxDvbAVSync(Context_t  *context, char * type __attribute__((unused))) {
     677    int ret = cERR_LINUXDVB_NO_ERROR;
    495678    /* konfetti: this one is dedicated to audiofd so we
    496679     * are ignoring what is given by type! I think we should
     
    504687        if (ioctl(audiofd, AUDIO_SET_AV_SYNC, 0) == -1) //context->playback->AVSync) == -1)
    505688        {
    506             linuxdvb_err("AUDIO_SET_AV_SYNC: ERROR %d, %s\n", errno, strerror(errno));
     689            linuxdvb_err("ioctl failed with errno %d\n", errno);
     690            linuxdvb_err("AUDIO_SET_AV_SYNC: %s\n", strerror(errno));
    507691            ret = cERR_LINUXDVB_ERROR;
    508692        }
     
    514698}
    515699
    516 int LinuxDvbClear(Context_t  *context __attribute__((unused)), char *type)
     700int LinuxDvbClear(Context_t  *context __attribute__((unused)), char * type)
    517701{
    518702    int32_t ret = cERR_LINUXDVB_NO_ERROR;
     
    520704    uint8_t audio = !strcmp("audio", type);
    521705
    522     linuxdvb_printf(10, "LinuxDvbClear v%d a%d\n", video, audio);
     706    linuxdvb_printf(10, ">>>>>>>>>>LinuxDvbClear v%d a%d\n", video, audio);
    523707
    524708    if ( (video && videofd != -1) || (audio && audiofd != -1) )
     
    530714            if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1)
    531715            {
    532                 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     716                linuxdvb_err("ioctl failed with errno %d\n", errno);
     717                linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno));
    533718                ret = cERR_LINUXDVB_ERROR;
    534719            }
     
    538723            if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1)
    539724            {
    540                 linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     725                linuxdvb_err("ioctl failed with errno %d\n", errno);
     726                linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno));
    541727                ret = cERR_LINUXDVB_ERROR;
    542728            }
     
    552738
    553739int LinuxDvbPts(Context_t  *context __attribute__((unused)), unsigned long long int* pts) {
    554     int32_t ret = cERR_LINUXDVB_ERROR;
     740    int ret = cERR_LINUXDVB_ERROR;
    555741   
    556742    linuxdvb_printf(50, "\n");
    557743
    558     // GET_PTS is immutable call, so it can be done in parallel to other requests
     744    // pts is a non writting requests and can be done in parallel to other requests
     745    //getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     746
    559747    if (videofd > -1 && !ioctl(videofd, VIDEO_GET_PTS, (void*)&sCURRENT_PTS))
    560748    {
     
    563751    else
    564752    {
    565         linuxdvb_err("VIDEO_GET_PTS: ERROR %d, %s\n", errno, strerror(errno));
     753        linuxdvb_err("VIDEO_GET_PTS: %d (%s)\n", errno, strerror(errno));
    566754    }
    567755
     
    574762        else
    575763        {
    576             linuxdvb_err("AUDIO_GET_PTS: ERROR %d, %s\n", errno, strerror(errno));
     764            linuxdvb_err("AUDIO_GET_PTS: %d (%s)\n", errno, strerror(errno));
    577765        }
    578766    }
     
    584772
    585773    *((unsigned long long int *)pts)=(unsigned long long int)sCURRENT_PTS;
     774
     775    //releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);
     776
    586777    return ret;
    587778}
     
    589780int LinuxDvbGetFrameCount(Context_t  *context __attribute__((unused)), unsigned long long int* frameCount)
    590781{
    591     return cERR_LINUXDVB_NO_ERROR;
    592 }
    593 
    594 int LinuxDvbSwitch(Context_t  *context, char *type)
     782    int ret = cERR_LINUXDVB_NO_ERROR;
     783    return ret;
     784}
     785
     786int LinuxDvbSwitch(Context_t  *context, char * type)
    595787{
    596     uint8_t audio = !strcmp("audio", type);
    597     uint8_t video = !strcmp("video", type);
    598     Writer_t *writer;
     788    unsigned char audio = !strcmp("audio", type);
     789    unsigned char video = !strcmp("video", type);
     790    Writer_t* writer;
    599791
    600792    linuxdvb_printf(10, "v%d a%d\n", video, audio);
     
    614806                if (ioctl(audiofd, AUDIO_STOP ,NULL) == -1)
    615807                {
    616                     linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno));
     808                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     809                    linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno));
     810
    617811                }
    618812
    619813                if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1)
    620814                {
    621                     linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     815                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     816                    linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno));
     817
    622818                }
    623819
     
    625821                {
    626822                    linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding);
    627                 }
    628                 else
     823                    // if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) AUDIO_ENCODING_MP3) == -1)
     824                    // {
     825                        // linuxdvb_err("ioctl failed with errno %d\n", errno);
     826                        // linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno));
     827                    // }
     828                } else
    629829                {
    630830                    linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
    631831                    if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) == -1)
    632832                    {
    633                         linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno));
     833                        linuxdvb_err("ioctl failed with errno %d\n", errno);
     834                        linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno));
    634835                    }
    635836                }
     
    637838                if (ioctl(audiofd, AUDIO_PLAY) == -1)
    638839                {
    639                     linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno));
     840                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     841                    linuxdvb_err("AUDIO_PLAY: %s\n", strerror(errno));
    640842                }
    641843                free(Encoding);
     
    652854                if (ioctl(videofd, VIDEO_STOP ,NULL) == -1)
    653855                {
    654                     linuxdvb_err("VIDEO_STOP: ERROR %d, %s\n", errno, strerror(errno));
     856                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     857                    linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno));
    655858                }
    656859
    657860                if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1)
    658861                {
    659                     linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno));
     862                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     863                    linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno));
    660864                }
    661865
     
    667871                {
    668872                    linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding);
    669                 }
    670                 else
     873                    // if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) VIDEO_ENCODING_AUTO) == -1)
     874                    // {
     875                        // linuxdvb_err("ioctl failed with errno %d\n", errno);
     876                        // linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno));
     877                    // }
     878                } else
    671879                {
    672880                    linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding);
    673881                    if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1)
    674882                    {
    675                         linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno));
     883                        linuxdvb_err("ioctl failed with errno %d\n", errno);
     884                        linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno));
    676885                    }
    677886                }
     
    682891                     * return an error here and stop the playback mode
    683892                     */
    684                     linuxdvb_err("VIDEO_PLAY:ERROR %d, %s\n", errno, strerror(errno));
     893                    linuxdvb_err("ioctl failed with errno %d\n", errno);
     894                    linuxdvb_err("VIDEO_PLAY: %s\n", strerror(errno));
    685895                }
    686896                free(Encoding);
     
    699909}
    700910
    701 static int Write(void  *_context, void *_out)
     911static int Write(void  *_context, void* _out)
    702912{
    703913    Context_t          *context  = (Context_t  *) _context;
    704914    AudioVideoOut_t    *out      = (AudioVideoOut_t*) _out;
    705     int32_t            ret       = cERR_LINUXDVB_NO_ERROR;
    706     int32_t            res       = 0;
    707     uint8_t            video     = 0;
    708     uint8_t            audio     = 0;
    709     Writer_t           *writer   = NULL;
     915    int                ret       = cERR_LINUXDVB_NO_ERROR;
     916    int                res       = 0;
     917    unsigned char      video     = 0;
     918    unsigned char      audio     = 0;
     919    Writer_t*          writer;
    710920    WriterAVCallData_t call;
    711921
     
    725935    if (video)
    726936    {
    727         char *Encoding = NULL;
     937        char * Encoding = NULL;
    728938        context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding);
    729939
     
    8011011            call.Height       = out->height;
    8021012            call.InfoFlags    = out->infoFlags;
    803             call.Version      = 0;
    804             call.WriteV       = isBufferedOutput ? BufferingWriteV : writev_with_retry;
     1013            call.Version      = 0; // is unsingned char
    8051014
    8061015            if (writer->writeData)
     
    8211030    else if (audio)
    8221031    {
    823         char *Encoding = NULL;
     1032        char * Encoding = NULL;
    8241033        context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding);
    8251034
     
    8511060            call.FrameScale     = out->timeScale;
    8521061            call.InfoFlags      = out->infoFlags;
    853             call.Version        = 0;
    854             call.WriteV         = isBufferedOutput ? BufferingWriteV : writev_with_retry;
     1062            call.Version        = 0; /* -1; unsigned char cannot be negative */
    8551063
    8561064            if (writer->writeData)
     
    9091117    free(Encoding);
    9101118
    911     if (isBufferedOutput)
    912         LinuxDvbBuffFlush(context);
    913    
    9141119    return ret;
    9151120}
     
    10061211        ret = cERR_LINUXDVB_NO_ERROR;
    10071212        *((int*)argument) = videoInfo.progressive;
    1008         break;
    1009     }
    1010     case OUTPUT_SET_BUFFER_SIZE: {
    1011         ret = cERR_LINUXDVB_ERROR;
    1012         if (!isBufferedOutput)
    1013         {
    1014             uint32_t bufferSize = *((uint32_t*)argument);
    1015             ret = cERR_LINUXDVB_NO_ERROR;
    1016             if (bufferSize > 0)
    1017             {
    1018                 WriteSetBufferingSize(bufferSize);
    1019                 isBufferedOutput = true;
    1020             }
    1021         }
    10221213        break;
    10231214    }
  • titan/libeplayer3/output/output.c

    r42162 r42177  
    530530        }
    531531        break;
    532     }
    533532    case OUTPUT_GET_PROGRESSIVE:
    534533    {
     
    546545        break;
    547546    }
    548     case OUTPUT_SET_BUFFER_SIZE:
    549     {
    550         if (context && context->playback)
    551         {
    552             if (context->output->video)
    553             {
    554                 return context->output->video->Command(context, OUTPUT_SET_BUFFER_SIZE, argument);
    555             }
    556             else if (context->output->audio)
    557             {
    558                 return context->output->audio->Command(context, OUTPUT_SET_BUFFER_SIZE, argument);
    559             }
    560         }
    561         else
    562         {
    563             ret = cERR_OUTPUT_INTERNAL_ERROR;
    564         }
    565         break;
    566547    }
    567548    default:
  • titan/libeplayer3/output/writer/mipsel/aac.c

    r42162 r42177  
    182182            return 0;
    183183        }
    184        
    185         // STB can handle only AAC LC profile
    186         if (0 == (call->data[2] & 0xC0))
    187         {
    188             // change profile AAC Main -> AAC LC (Low Complexity)
    189             aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header");
    190             call->data[2] = (call->data[2] & 0x1F) | 0x40;
    191         }
    192184    }
    193185    else // check LOAS header
     
    212204    iov[1].iov_base = call->data;
    213205    iov[1].iov_len = call->len;
    214     return call->WriteV(call->fd, iov, 2);
     206    return writev_with_retry(call->fd, iov, 2);
    215207}
    216208
     
    242234        HasADTSHeader(call->data, call->len) )
    243235    {
    244         //printf("%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx\n", call->data[0], call->data[1], call->data[2], call->data[3], call->data[4], call->data[5], call->data[6], call->data[7]);
    245236        return _writeData(_call, 0);
    246237    }
     
    283274    iov[1].iov_len = call->len;
    284275   
    285     return call->WriteV(call->fd, iov, 2);
     276    return writev_with_retry(call->fd, iov, 2);
    286277}
    287278
     
    353344    iov[2].iov_len  = pLATMCtx->len;
    354345   
    355     return call->WriteV(call->fd, iov, 3);
     346    return writev_with_retry(call->fd, iov, 3);
    356347}
    357348
  • titan/libeplayer3/output/writer/mipsel/ac3.c

    r42162 r42177  
    139139    ac3_printf(40, "PES HEADER LEN %d\n", iov[0].iov_len);
    140140
    141     return call->WriteV(call->fd, iov, 2);
     141    return writev_with_retry(call->fd, iov, 2);
    142142}
    143143
  • titan/libeplayer3/output/writer/mipsel/amr.c

    r42162 r42177  
    158158    iov[1].iov_len = call->len;
    159159   
    160     int len = call->WriteV(call->fd, iov, 2);
     160    int len = writev_with_retry(call->fd, iov, 2);
    161161
    162162    amr_printf(10, "amr_Write-< len=%d\n", len);
  • titan/libeplayer3/output/writer/mipsel/divx3.c

    r42162 r42177  
    183183    iov[ic++].iov_len = call->len;
    184184
    185     int len = call->WriteV(call->fd, iov, ic);
     185    int len = writev_with_retry(call->fd, iov, ic);
    186186
    187187    divx_printf(10, "xvid_Write < len=%d\n", len);
  • titan/libeplayer3/output/writer/mipsel/dts.c

    r42162 r42177  
    162162    iov[1].iov_len = Size;
    163163
    164     int32_t len = call->WriteV(call->fd, iov, 2);
     164    int32_t len = writev_with_retry(call->fd, iov, 2);
    165165    dts_printf(10, "< len %d\n", len);
    166166    return len;
  • titan/libeplayer3/output/writer/mipsel/h263.c

    r42162 r42177  
    135135    iov[1].iov_base = call->data;
    136136    iov[1].iov_len = call->len;
    137     len = call->WriteV(call->fd, iov, 2);
     137    len = writev_with_retry(call->fd, iov, 2);
    138138
    139139    h263_printf(10, "< len %d\n", len);
  • titan/libeplayer3/output/writer/mipsel/h264.c

    r42162 r42177  
    5656/* Makros/Constants              */
    5757/* ***************************** */
    58 #define H264_SILENT
    5958//#define H264_DEBUG
    6059#ifdef H264_DEBUG
     
    8988static unsigned int            CodecDataLen   = 0;
    9089static int                     avc3 = 0;
    91 static int                     sps_pps_in_stream = 0;
    9290/* ***************************** */
    9391/* Prototypes                    */
     
    301299    initialHeader = 1;
    302300    avc3 = 0;
    303     sps_pps_in_stream = 0;
    304301    return 0;
    305302}
     
    347344        (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
    348345    {
    349         uint32_t i = 0;
    350         uint8_t InsertPrivData = !sps_pps_in_stream;
    351346        uint32_t PacketLength = 0;
    352347        uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE;
     348       
    353349        iov[ic++].iov_base = PesHeader;
    354        
    355         while (InsertPrivData && i < 36 && (call->len - i) > 5)
    356         {
    357             if ( (call->data[i] == 0x00 && call->data[i+1] == 0x00 && call->data[i+2] == 0x00 && call->data[i+3] == 0x01 && (call->data[i+4] == 0x67 || call->data[i+4] == 0x68)) )
    358             {
    359                 InsertPrivData = 0;
    360                 sps_pps_in_stream = 1;
    361             }
    362             i += 1;
    363         }
    364        
    365         if (InsertPrivData && call->private_size > 0 /*&& initialHeader*/) // some rtsp streams can update codec data at runtime
     350        initialHeader = 0;
     351        if (initialHeader)
    366352        {
    367353            initialHeader = 0;
     
    370356            PacketLength     += call->private_size;
    371357        }
     358
     359        iov[ic].iov_base = "";
     360        iov[ic++].iov_len = 1;
    372361       
    373362        iov[ic].iov_base  = call->data;
     
    375364        PacketLength     += call->len;
    376365       
     366        /*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than
     367                          data is available. The content of this byte does not matter. It will be ignored
     368                          by the player */
     369//obi
     370        iov[ic].iov_base = "\0";
     371        iov[ic++].iov_len = 1;
     372//obi (end)
    377373        iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode);
    378374       
    379         return call->WriteV(call->fd, iov, ic);
     375        return writev_with_retry(call->fd, iov, ic);
    380376    }
    381377    else if (!call->private_data || call->private_size < 7 || 1 != call->private_data[0])
     
    390386    iov[ic++].iov_base = PesHeader;
    391387   
    392     if (!avc3)
     388    if (initialHeader)
    393389    {
    394390        if (CodecData)
     
    462458        iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
    463459       
    464         len = call->WriteV(call->fd, iov, ic);
     460        len = writev_with_retry(call->fd, iov, ic);
    465461        PacketLength += iov[0].iov_len;
    466462        if (PacketLength != len)
  • titan/libeplayer3/output/writer/mipsel/h265.c

    r42162 r42177  
    5656/* Makros/Constants              */
    5757/* ***************************** */
    58 #define H264_SILENT
    5958//#define H265_DEBUG
    6059#ifdef H265_DEBUG
     
    235234        iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode);
    236235       
    237         return call->WriteV(call->fd, iov, ic);
     236        return writev_with_retry(call->fd, iov, ic);
    238237    }
    239238
     
    304303        iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
    305304       
    306         len = call->WriteV(call->fd, iov, ic);
     305        len = writev_with_retry(call->fd, iov, ic);
    307306        PacketLength += iov[0].iov_len;
    308307        if (PacketLength != len)
  • titan/libeplayer3/output/writer/mipsel/lpcm.c

    r42162 r42177  
    257257        iov[1].iov_base = frame;
    258258        iov[1].iov_len  = i_frame_size;
    259         i_ret_size += call->WriteV(call->fd, iov, 2);
     259        i_ret_size += writev_with_retry(call->fd, iov, 2);
    260260    }
    261261   
  • titan/libeplayer3/output/writer/mipsel/mp3.c

    r42162 r42177  
    134134    iov[1].iov_len = call->len;
    135135
    136     int len = call->WriteV(call->fd, iov, 2);
     136    int len = writev_with_retry(call->fd, iov, 2);
    137137
    138138    mp3_printf(10, "mp3_Write-< len=%d\n", len);
  • titan/libeplayer3/output/writer/mipsel/mpeg2.c

    r42162 r42177  
    138138        iov[1].iov_len = PacketLength;
    139139
    140         ssize_t l = call->WriteV(call->fd, iov, 2);
     140        ssize_t l = writev_with_retry(call->fd, iov, 2);
    141141        if (l < 0) {
    142142            len = l;
  • titan/libeplayer3/output/writer/mipsel/mpeg4.c

    r42162 r42177  
    134134    }
    135135
    136     struct iovec iov[3];
     136    struct iovec iov[2];
    137137    int ic = 0;
    138138    iov[ic].iov_base = PesHeader;
     
    148148    iov[ic++].iov_len = call->len;
    149149
    150     int len = call->WriteV(call->fd, iov, ic);
     150    int len = writev_with_retry(call->fd, iov, ic);
    151151
    152152    mpeg4_printf(10, "xvid_Write < len=%d\n", len);
  • titan/libeplayer3/output/writer/mipsel/pcm.c

    r42162 r42177  
    284284        iov[1].iov_base = fixed_buffer;
    285285        iov[1].iov_len  = fixed_buffersize;
    286         call->WriteV(call->fd, iov, 2);
     286        writev_with_retry(call->fd, iov, 2);
    287287        fixed_buffertimestamp += fixed_bufferduration;
    288288       
    289289        int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT |
    290290        O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
    291         call->WriteV(g_fd_dump, iov, 2);
     291        writev_with_retry(g_fd_dump, iov, 2);
    292292        close(g_fd_dump);
    293293    }
  • titan/libeplayer3/output/writer/mipsel/vc1.c

    r42162 r42177  
    190190    }
    191191   
    192     return call->WriteV(call->fd, iov, ic);
     192    return writev_with_retry(call->fd, iov, ic);
    193193}
    194194
  • titan/libeplayer3/output/writer/mipsel/vp.c

    r42162 r42177  
    9797}
    9898
    99 static int writeData(void *_call, int is_vp6)
     99static int writeData(void* _call, int is_vp6)
    100100{
    101101    WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
     
    145145    iov[1].iov_len = call->len;
    146146   
    147     return call->WriteV(call->fd, iov, 2);
     147    return writev_with_retry(call->fd, iov, 2);
    148148}
    149149
  • titan/libeplayer3/output/writer/mipsel/wma.c

    r42162 r42177  
    173173    iov[1].iov_len  = call->len;
    174174
    175     return call->WriteV(call->fd, iov, 2);
     175    return writev_with_retry(call->fd, iov, 2);
    176176}
    177177
  • titan/libeplayer3/output/writer/mipsel/wmv.c

    r42162 r42177  
    197197    }
    198198   
    199     return call->WriteV(call->fd, iov, ic);
     199    return writev_with_retry(call->fd, iov, ic);
    200200}
    201201
  • titan/libeplayer3/output/writer/mipsel/writer.c

    r42162 r42177  
    2929#include "misc.h"
    3030#include "writer.h"
    31 #include "common.h"
    3231
    3332/* ***************************** */
     
    9998/*  Functions                    */
    10099/* ***************************** */
    101 static void FlusPipe(int pipefd)
    102 {
    103     char tmp;
    104     while(1 == read(pipefd, &tmp, 1));
    105 }
    106 
    107 ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, const void *buf, size_t size)
    108 {
    109     fd_set rfds;
    110     fd_set wfds;
    111    
    112     ssize_t ret;
    113     int retval = -1;
    114     int maxFd = pipefd > fd ? pipefd : fd;
    115     struct timeval tv;
    116    
    117     while(size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking)
    118     {
    119         FD_ZERO(&rfds);
    120         FD_ZERO(&wfds);
    121 
    122         FD_SET(pipefd, &rfds);
    123         FD_SET(fd, &wfds);
    124 
    125         /* When we PAUSE LINUX DVB outputs buffers then audio/video buffers
    126          * will be filled to full unfortunately, in such case after resume
    127          * select never return with fd set - bug in DVB drivers?
    128          * So, there will be to workarounds:
    129          *   1. write to pipe pipe at resume to exit select immediately
    130          *   2. even if fd is not set exit from select after 0,1s
    131          *      (it seems that second workaround is not needed)
    132          */
    133         //tv.tv_sec = 0;
    134         //tv.tv_usec = 100000; // 100ms
    135        
    136         retval = select(maxFd + 1, &rfds, &wfds, NULL, NULL); //&tv);
    137         if (retval < 0)
    138         {
    139             break;
    140         }
    141        
    142         //if (retval == 0)
    143         //{
    144         //    //printf("RETURN FROM SELECT DUE TO TIMEOUT TIMEOUT\n");
    145         //    continue;
    146         //}
    147        
    148         if(FD_ISSET(pipefd, &rfds))
    149         {
    150             FlusPipe(pipefd);
    151             //printf("RETURN FROM SELECT DUE TO pipefd SET\n");
    152             continue;
    153         }
    154        
    155         if(FD_ISSET(fd, &wfds))
    156         {
    157             ret = write(fd, buf, size);
    158             if (ret < 0)
    159             {
    160                 switch(errno)
    161                 {
    162                     case EINTR:
    163                     case EAGAIN:
    164                         continue;
    165                     default:
    166                         retval = -3;
    167                         break;
    168                 }
    169                 if (retval < 0)
    170                 {
    171                     break;
    172                 }
    173                
    174                 return ret;
    175             }
    176             else if (ret == 0)
    177             {
    178                 //printf("This should not happen. Select return fd ready to write, but write return 0, errno [%d]\n", errno);
    179                 tv.tv_sec = 0;
    180                 tv.tv_usec = 10000; // 10ms
    181                 retval = select(pipefd + 1, &rfds, NULL, NULL, &tv);
    182                 if (retval)
    183                     FlusPipe(pipefd);
    184                 continue;
    185             }
    186            
    187             size -= ret;
    188             buf += ret;
    189         }
    190     }
    191     return 0;
    192 }
    193 
    194100ssize_t write_with_retry(int fd, const void *buf, size_t size)
    195101{
  • titan/libeplayer3/output/writer/sh4/aac.c

    r42162 r42177  
    181181            return 0;
    182182        }
    183        
    184         // STB can handle only AAC LC profile
    185         if (0 == (call->data[2] & 0xC0))
    186         {
    187             // change profile AAC Main -> AAC LC (Low Complexity)
    188             aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header");
    189             call->data[2] = (call->data[2] & 0x1F) | 0x40;
    190         }
    191183    }
    192184    else // check LOAS header
  • titan/libeplayer3/output/writer/sh4/h264.c

    r42162 r42177  
    5353/* Makros/Constants              */
    5454/* ***************************** */
     55//#define H264_DEBUG
     56
    5557#ifdef SAM_WITH_DEBUG
    5658#define H264_DEBUG
     
    100102static uint32_t  NalLengthBytes = 1;
    101103static int       avc3 = 0;
    102 static int       sps_pps_in_stream = 0;
    103104/* ***************************** */
    104105/* Prototypes                    */
     
    259260        (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
    260261    {
    261         uint32_t i = 0;
    262         uint8_t InsertPrivData = !sps_pps_in_stream;
    263262        uint32_t PacketLength = 0;
    264         uint32_t FakeStartCode = PES_VERSION_FAKE_START_CODE;
     263        uint32_t FakeStartCode = /*(call->Version << 8) | */PES_VERSION_FAKE_START_CODE;
     264       
    265265        iov[ic++].iov_base = PesHeader;
    266        
    267         while (InsertPrivData && i < 36 && (call->len - i) > 5)
    268         {
    269             if ( (call->data[i] == 0x00 && call->data[i+1] == 0x00 && call->data[i+2] == 0x00 && call->data[i+3] == 0x01 && (call->data[i+4] == 0x67 || call->data[i+4] == 0x68)) )
    270             {
    271                 InsertPrivData = 0;
    272                 sps_pps_in_stream = 1;
    273             }
    274             i += 1;
    275         }
    276        
    277         if (InsertPrivData && call->private_size > 0 /*&& initialHeader*/) // some rtsp streams can update codec data at runtime
     266        initialHeader = 0;
     267        if (initialHeader)
    278268        {
    279269            initialHeader = 0;
     
    306296    }
    307297
    308     if (!avc3)
     298    if (initialHeader)
    309299    {
    310300        uint8_t  *private_data = call->private_data;
  • titan/libeplayer3/playback/playback.c

    r42162 r42177  
    5858#define cMaxSpeed_fr   -320 /* fixme: revise */
    5959
    60 #define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10
    61 
    6260/* ***************************** */
    6361/* Varaibles                     */
     
    7068static int32_t PlaybackTerminate(Context_t  *context);
    7169
    72 static int8_t dieNow = 0;
    73 static PlaybackDieNowCallback playbackDieNowCallbacks[MAX_PLAYBACK_DIE_NOW_CALLBACKS] = {NULL};
    74 
    7570/* ***************************** */
    7671/* MISC Functions                */
     
    7873int8_t PlaybackDieNow(int8_t val)
    7974{
    80     if(val && dieNow == 0)
    81     {
    82         uint32_t i = 0;
     75    static int8_t dieNow = 0;
     76    if(val)
     77    {
    8378        dieNow = 1;
    84         while (i < MAX_PLAYBACK_DIE_NOW_CALLBACKS)
    85         {
    86             if (playbackDieNowCallbacks[i] == NULL)
    87             {
    88                 break;
    89             }
    90             playbackDieNowCallbacks[i]();
    91             i += 1;
    92         }
    9379    }
    9480    return dieNow;
    95 }
    96 
    97 bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback)
    98 {
    99     bool ret = false;
    100     if (callback)
    101     {
    102         uint32_t i = 0;
    103         while (i < MAX_PLAYBACK_DIE_NOW_CALLBACKS)
    104         {
    105             if (playbackDieNowCallbacks[i] == callback)
    106             {
    107                 ret = true;
    108                 break;
    109             }
    110            
    111             if (playbackDieNowCallbacks[i] == NULL)
    112             {
    113                 playbackDieNowCallbacks[i] = callback;
    114                 ret = true;
    115                 break;
    116             }
    117             i += 1;
    118         }
    119     }
    120     return ret;
    12181}
    12282
Note: See TracChangeset for help on using the changeset viewer.