Changeset 42162
- Timestamp:
- 04/12/18 15:06:43 (5 years ago)
- Location:
- titan/libeplayer3
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/libeplayer3/container/container_ffmpeg.c
r41899 r42162 146 146 static int32_t seek_target_flag = 0; 147 147 148 static int32_t mutexInitialized = 0; 149 148 150 /* ***************************** */ 149 151 /* Prototypes */ … … 164 166 progressive_playback = val; 165 167 } 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 166 210 167 211 #include "buff_ffmpeg.c" … … 426 470 } 427 471 428 static int32_t mutexInitialized = 0;472 //static int32_t mutexInitialized = 0; 429 473 430 474 void sel_program_id_set(const int32_t val) … … 496 540 { 497 541 return av_dict_set(&avio_opts, key, value, flags); 498 }499 500 static void initMutex(void)501 {502 pthread_mutex_init(&mutex, NULL);503 mutexInitialized = 1;504 }505 506 static 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 520 static 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);525 542 } 526 543 … … 703 720 pts = INVALID_PTS_VALUE; 704 721 } 722 else 723 { 724 pts &= 0x01FFFFFFFF; // PES header can handle only 33 bit PTS 725 } 705 726 706 727 return pts; … … 798 819 while ( context && context->playback && context->playback->isPlaying ) 799 820 { 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__ 800 829 //IF MOVIE IS PAUSED, WAIT 801 830 if (context->playback->isPaused) … … 806 835 continue; 807 836 } 837 #endif 808 838 809 839 if (context->playback->isSeeking) … … 929 959 930 960 reset_finish_timeout(); 931 932 if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0) 933 { 934 ffmpeg_err("error getting video track\n"); 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); 935 981 } 936 982 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 947 983 ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, pid); 948 984 … … 1037 1073 } 1038 1074 1039 if ( context->output->video->Write(context, &avOut) < 0)1075 if (Write(context->output->video->Write, context, &avOut, pts) < 0) 1040 1076 { 1041 1077 ffmpeg_err("writing data to video device failed\n"); … … 1113 1149 avOut.type = "audio"; 1114 1150 1115 if ( context->output->audio->Write(context, &avOut) < 0)1151 if (Write(context->output->audio->Write, context, &avOut, pts) < 0) 1116 1152 { 1117 1153 ffmpeg_err("(raw pcm) writing data to audio device failed\n"); … … 1308 1344 avOut.type = "audio"; 1309 1345 1310 if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)1346 if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0) 1311 1347 { 1312 1348 ffmpeg_err("writing data to audio device failed\n"); … … 1331 1367 avOut.type = "audio"; 1332 1368 1333 if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)1369 if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0) 1334 1370 { 1335 1371 ffmpeg_err("(aac) writing data to audio device failed\n"); … … 1349 1385 avOut.type = "audio"; 1350 1386 1351 if (!context->playback->BackWard && context->output->audio->Write(context, &avOut) < 0)1387 if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0) 1352 1388 { 1353 1389 ffmpeg_err("writing data to audio device failed\n"); … … 1397 1433 //obi (end) 1398 1434 1399 if ( context->output->subtitle->Write(context, &subOut) < 0)1435 if (Write(context->output->subtitle->Write, context, &subOut, pts) < 0) 1400 1436 { 1401 1437 ffmpeg_err("writing data to teletext fifo failed\n"); … … 1545 1581 1546 1582 #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 1547 1597 int SAM_ReadFunc(void *ptr, uint8_t *buffer, int lSize) 1548 1598 { 1549 size_t ret = fread ( (void *) buffer, (size_t) 1, (size_t) lSize, (FILE *)ptr ); 1550 return (int)ret; 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; 1613 } 1614 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 ); 1628 } 1629 1630 io->iOffset += ret; 1631 } 1632 return ret; 1551 1633 } 1552 1634 1553 1635 // whence: SEEK_SET, SEEK_CUR, SEEK_END (like fseek) and AVSEEK_SIZE 1554 int64_t SAM_SeekFunc(void *ptr, int64_t pos, int whence)1636 int64_t SAM_SeekFunc(void *ptr, int64_t pos, int whence) 1555 1637 { 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); 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 } 1669 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 } 1564 1691 } 1565 1692 return ret; 1566 1693 } 1567 1694 1568 AVIOContext* container_ffmpeg_get_avio_context(char *filename, size_t avio_ctx_buffer_size) 1569 { 1570 if(strstr(filename, "file://") == filename) 1571 { 1572 filename += 7; 1573 } 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; 1574 1710 1575 FILE *pFile = fopen(filename, "rb"); 1576 if(NULL == pFile) 1577 { 1711 custom_io->pMoovFile = fopen(custom_io->szMoovAtomFile, "rb"); 1712 if(NULL == custom_io->pMoovFile) 1713 { 1714 fclose(custom_io->pFile); 1578 1715 return NULL; 1579 1716 } 1580 1581 AVIOContext *avio_ctx = NULL; 1582 uint8_t *avio_ctx_buffer = NULL; 1583 1584 avio_ctx_buffer = av_malloc(avio_ctx_buffer_size); 1585 if (!avio_ctx_buffer) 1586 { 1587 return NULL; 1588 } 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; 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; 1595 1733 } 1596 1734 #endif 1597 1735 1598 int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int32_t AVIdx)1736 int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uint64_t fileSize, char *moovAtomFile, uint64_t moovAtomOffset, int32_t AVIdx) 1599 1737 { 1600 1738 int32_t err = 0; … … 1608 1746 0 == strncmp(filename, "file://", 7)) 1609 1747 { 1610 AVIOContext *avio_ctx = container_ffmpeg_get_avio_context(filename, 4096); 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); 1611 1758 if(avio_ctx) 1612 1759 { … … 1616 1763 else 1617 1764 { 1765 free(custom_io_tab[AVIdx]); 1766 custom_io_tab[AVIdx] = NULL; 1618 1767 return cERR_CONTAINER_FFMPEG_OPEN; 1619 1768 } … … 2154 2303 2155 2304 context->playback->abortRequested = 0; 2156 int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, 0); 2305 int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \ 2306 playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0); 2157 2307 if(0 != res) 2158 2308 { … … 2160 2310 } 2161 2311 2162 if(playFilesNames->szSecondFile) 2163 { 2164 res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, 1); 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); 2165 2316 } 2166 2317 … … 2183 2334 int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32_t initial) 2184 2335 { 2185 Track_t *audioTrack = NULL; 2186 Track_t *subtitleTrack = NULL; 2336 Track_t *currAudioTrack = NULL; 2337 Track_t *currSubtitleTrack = NULL; 2338 uint32_t addedVideoTracksCount = 0; 2187 2339 2188 2340 if (terminating) … … 2191 2343 } 2192 2344 2345 getMutex(__FILE__, __FUNCTION__,__LINE__); 2346 2193 2347 if (initial && context->manager->subtitle) 2194 2348 { 2195 context->manager->subtitle->Command(context, MANAGER_GET_TRACK, & subtitleTrack);2349 context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &currSubtitleTrack); 2196 2350 } 2197 2351 2198 2352 if (context->manager->audio) 2199 2353 { 2200 context->manager->audio->Command(context, MANAGER_GET_TRACK, & audioTrack);2354 context->manager->audio->Command(context, MANAGER_GET_TRACK, &currAudioTrack); 2201 2355 } 2202 2356 … … 2217 2371 } 2218 2372 #endif 2219 2220 2373 2221 2374 ffmpeg_printf(20, "dump format\n"); … … 2295 2448 } 2296 2449 2297 if (!isStreamFromSelProg) 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); 2298 2453 continue; // skip this stream 2454 } 2299 2455 } 2300 2456 … … 2329 2485 case AVMEDIA_TYPE_VIDEO: 2330 2486 ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type); 2331 2487 stream->discard = AVDISCARD_ALL; /* by default we discard all video streams */ 2332 2488 if (encoding != NULL) 2333 2489 { … … 2409 2565 ffmpeg_err("failed to add track %d\n", n); 2410 2566 } 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 } 2411 2575 } 2412 2576 } … … 2418 2582 case AVMEDIA_TYPE_AUDIO: 2419 2583 ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n",get_codecpar(stream)->codec_type); 2420 2584 stream->discard = AVDISCARD_ALL; 2421 2585 if (encoding != NULL) 2422 2586 { … … 2790 2954 case AVMEDIA_TYPE_NB: 2791 2955 default: 2956 stream->discard = AVDISCARD_ALL; 2792 2957 ffmpeg_err("not handled or unknown codec_type %d\n", get_codecpar(stream)->codec_type); 2793 2958 break; … … 2796 2961 2797 2962 } 2798 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__); 2799 3002 return cERR_CONTAINER_FFMPEG_NO_ERROR; 2800 3003 } … … 3119 3322 } 3120 3323 3121 getMutex(__FILE__, __FUNCTION__,__LINE__);3324 // getMutex(__FILE__, __FUNCTION__,__LINE__); 3122 3325 3123 3326 if (!context->playback || !context->playback->isPlaying) … … 3138 3341 */ 3139 3342 3343 getMutex(__FILE__, __FUNCTION__,__LINE__); 3140 3344 off_t pos = avio_tell(avContextTab[0]->pb); 3345 releaseMutex(__FILE__, __FUNCTION__,__LINE__); 3141 3346 3142 3347 ffmpeg_printf(10, "pos %lld %d\n", pos, avContextTab[0]->bit_rate); … … 3172 3377 } 3173 3378 3174 releaseMutex(__FILE__, __FUNCTION__,__LINE__);3379 // releaseMutex(__FILE__, __FUNCTION__,__LINE__); 3175 3380 return cERR_CONTAINER_FFMPEG_NO_ERROR; 3176 3381 } … … 3233 3438 { 3234 3439 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__); 3235 3458 3236 3459 /* Hellmaster1024: nothing to do here!*/ 3237 int64_t sec = - 5;3460 int64_t sec = -1; 3238 3461 context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec); 3239 3462 return cERR_CONTAINER_FFMPEG_NO_ERROR; … … 3249 3472 * but now we will not ignore subtitle frame 3250 3473 */ 3251 int64_t sec = - 5;3474 int64_t sec = -1; 3252 3475 context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec); 3253 3476 //obi -
titan/libeplayer3/container/flv2mpeg4_ffmpeg.c
r40322 r42162 39 39 avOut.type = "video"; 40 40 41 if ( ctx->out_ctx->output->video->Write(ctx->out_ctx, &avOut) < 0)41 if (Write(ctx->out_ctx->output->video->Write, ctx->out_ctx, &avOut, avOut.pts) < 0) 42 42 { 43 43 ffmpeg_err("writing data to video device failed\n"); -
titan/libeplayer3/container/mpeg4p2_ffmpeg.c
r40322 r42162 112 112 avOut.type = "video"; 113 113 114 if ( ctx->output->video->Write(ctx, &avOut) < 0)114 if (Write(ctx->output->video->Write, ctx, &avOut, avOut.pts) < 0) 115 115 { 116 116 ffmpeg_err("writing data to video device failed\n"); -
titan/libeplayer3/include/common.h
r41347 r42162 10 10 #include <pthread.h> 11 11 12 typedef char PlayFilesTab_t[2];12 //typedef char PlayFilesTab_t[2]; 13 13 14 14 typedef struct PlayFiles_t … … 16 16 char *szFirstFile; 17 17 char *szSecondFile; 18 char *szFirstMoovAtomFile; 19 char *szSecondMoovAtomFile; 20 uint64_t iFirstFileSize; 21 uint64_t iSecondFileSize; 22 uint64_t iFirstMoovAtomOffset; 23 uint64_t iSecondMoovAtomOffset; 18 24 } PlayFiles_t; 19 25 -
titan/libeplayer3/include/manager.h
r41347 r42162 18 18 MANAGER_UPDATED_TRACK_INFO, 19 19 MANAGER_REGISTER_UPDATED_TRACK_INFO, 20 MANAGER_REF_LIST, 21 MANAGER_REF_LIST_SIZE, 20 22 } ManagerCmd_t; 21 23 -
titan/libeplayer3/include/output.h
r40322 r42162 27 27 OUTPUT_GET_FRAME_COUNT, 28 28 OUTPUT_GET_PROGRESSIVE, 29 OUTPUT_SET_BUFFER_SIZE, 29 30 } OutputCmd_t; 30 31 … … 68 69 char * Name; 69 70 int32_t (* Command) (/*Context_t*/void *, OutputCmd_t, void *); 70 int32_t (* Write) (/*Context_t*/void *, void * privateData);71 int32_t (* Write) (/*Context_t*/void *, void *); 71 72 char ** Capabilities; 72 73 -
titan/libeplayer3/include/playback.h
r40322 r42162 3 3 #include <sys/types.h> 4 4 #include <stdint.h> 5 #include <stdbool.h> 6 7 typedef void( * PlaybackDieNowCallback )(); 8 bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback); 5 9 6 10 typedef 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
r40322 r42162 5 5 #include <stdio.h> 6 6 #include <stdint.h> 7 #include "common.h" 7 8 8 9 typedef enum { eNone, eAudio, eVideo} eWriterType_t; … … 22 23 unsigned char Version; 23 24 unsigned int InfoFlags; 25 ssize_t (* WriteV) (int, const struct iovec *, size_t); 24 26 } WriterAVCallData_t; 25 27 … … 87 89 ssize_t write_with_retry(int fd, const void *buf, size_t size); 88 90 ssize_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); 89 93 #endif -
titan/libeplayer3/main/exteplayer.c
r41219 r42162 85 85 } 86 86 87 static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread */87 static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread and kbhit */ 88 88 static int isPlaybackStarted = 0; 89 89 static pthread_mutex_t playbackStartMtx; 90 91 static void TerminateWakeUp() 92 { 93 write(g_pfd[1], "x", 1); 94 } 90 95 91 96 static void *TermThreadFun(void *arg) … … 136 141 if (FD_ISSET(fd, &readfds)) 137 142 { 138 /*139 if ( (cl = accept(fd, NULL, NULL)) == -1)140 {141 perror("TermThreadFun accept error");142 goto finish;143 }144 */145 146 143 pthread_mutex_lock(&playbackStartMtx); 147 144 PlaybackDieNow(1); … … 184 181 { 185 182 struct timeval 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)) 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)) 195 193 { 196 194 return 0; 197 195 } 198 196 199 if(FD_ISSET(0, &read_fd))197 if(FD_ISSET(0, &readfds)) 200 198 { 201 199 return 1; … … 369 367 } 370 368 371 static int ParseParams(int argc,char* argv[], char *file, char *audioFile, int *pAudioTrackIdx, int *subtitleTrackIdx)369 static int ParseParams(int argc,char* argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB) 372 370 { 373 371 int ret = 0; … … 376 374 int aopt = 0, bopt = 0; 377 375 char *copt = 0, *dopt = 0; 378 while ( (c = getopt(argc, argv, "we3dlsrimva:n:x:u:c:h:o:p:P:t:9:0:1:4:f: ")) != -1)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) 379 377 { 380 378 switch (c) … … 437 435 break; 438 436 case 'x': 439 strncpy(audioFile, optarg, IPTV_MAX_FILE_PATH-1); 440 map_inter_file_path(audioFile); 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 } 441 445 break; 442 446 case 'h': … … 486 490 break; 487 491 } 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; 488 511 default: 489 512 printf ("?? getopt returned character code 0%o ??\n", c); … … 495 518 { 496 519 ret = 0; 497 520 playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH); 521 playbackFiles->szFirstFile[0] = '\0'; 498 522 if(NULL == strstr(argv[optind], "://")) 499 523 { 500 strcpy(file, "file://"); 501 } 502 strcat(file, argv[optind]); 503 map_inter_file_path(file); 504 printf("file: [%s]\n", file); 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); 505 530 ++optind; 506 531 } … … 516 541 pthread_t termThread; 517 542 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));523 543 524 544 int audioTrackIdx = -1; 525 545 int subtitleTrackIdx = -1; 546 547 uint32_t linuxDvbBufferSizeMB = 0; 526 548 527 549 char argvBuff[256]; … … 529 551 int commandRetVal = -1; 530 552 /* inform client that we can handle additional commands */ 531 fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 36); 532 533 if (0 != ParseParams(argc, argv, file, audioFile, &audioTrackIdx, &subtitleTrackIdx)) 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)) 534 558 { 535 559 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"); 536 561 printf("[-a 0|1|2|3] AAC software decoding - 1 bit - AAC ADTS, 2 - bit AAC LATM\n"); 537 562 printf("[-e] EAC3 software decoding\n"); … … 560 585 printf("[-1 idx] audio MPEG-DASH representation index\n"); 561 586 printf("[-f ffopt=ffval] any other ffmpeg option\n"); 562 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"); 563 590 exit(1); 564 591 } … … 599 626 isTermThreadStarted = 1; 600 627 } while(0); 601 628 602 629 g_player->playback = &PlaybackHandler; 603 630 g_player->output = &OutputHandler; … … 614 641 g_player->output->Command(g_player, OUTPUT_ADD, "video"); 615 642 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 616 648 617 649 g_player->manager->video->Command(g_player, MANAGER_REGISTER_UPDATED_TRACK_INFO, UpdateVideoTrack); 618 if (strncmp( file, "rtmp", 4) && strncmp(file, "ffrtmp", 4))650 if (strncmp(playbackFiles.szFirstFile, "rtmp", 4) && strncmp(playbackFiles.szFirstFile, "ffrtmp", 4)) 619 651 { 620 652 g_player->playback->noprobe = 1; 621 653 } 622 654 623 PlayFiles_t playbackFiles = {file, NULL};624 if('\0' != audioFile[0])625 {626 playbackFiles.szSecondFile = audioFile;627 }628 629 655 commandRetVal = g_player->playback->Command(g_player, PLAYBACK_OPEN, &playbackFiles); 630 fprintf(stderr, "{\"PLAYBACK_OPEN\":{\"OutputName\":\"%s\", \"file\":\"%s\", \"sts\":%d}}\n", g_player->output->Name, file, commandRetVal);656 fprintf(stderr, "{\"PLAYBACK_OPEN\":{\"OutputName\":\"%s\", \"file\":\"%s\", \"sts\":%d}}\n", g_player->output->Name, playbackFiles.szFirstFile, commandRetVal); 631 657 if(commandRetVal < 0) 632 658 { … … 650 676 if (g_player->playback->isPlaying) 651 677 { 678 PlaybackDieNowRegisterCallback(TerminateWakeUp); 679 652 680 HandleTracks(g_player->manager->video, (PlaybackCmd_t)-1, "vc"); 653 681 HandleTracks(g_player->manager->audio, (PlaybackCmd_t)-1, "al"); … … 670 698 } 671 699 672 while(g_player->playback->isPlaying )700 while(g_player->playback->isPlaying && 0 == PlaybackDieNow(0)) 673 701 { 674 702 /* we made fgets non blocking */ … … 848 876 if (0 == commandRetVal) 849 877 { 850 fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90, commandRetVal); 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 } 851 893 } 852 894 break; … … 905 947 close(g_pfd[0]); 906 948 close(g_pfd[1]); 907 908 //printOutputCapabilities(); 909 949 910 950 exit(0); 911 951 } -
titan/libeplayer3/output/linuxdvb_mipsel.c
r40348 r42162 26 26 #include <stdlib.h> 27 27 #include <unistd.h> 28 #include <stdbool.h> 28 29 #include <fcntl.h> 29 30 #include <sys/types.h> … … 53 54 #define LINUXDVB_SILENT 54 55 55 static u nsigned short debug_level = 0;56 static uint16_t debug_level = 0; 56 57 57 58 static const char FILENAME[] = __FILE__; … … 73 74 #define cERR_LINUXDVB_ERROR -1 74 75 75 static const char VIDEODEV[] 76 static const char AUDIODEV[] 76 static const char VIDEODEV[] = "/dev/dvb/adapter0/video0"; 77 static const char AUDIODEV[] = "/dev/dvb/adapter0/audio0"; 77 78 78 79 static int videofd = -1; … … 89 90 90 91 unsigned long long int sCURRENT_PTS = 0; 92 bool isBufferedOutput = false; 91 93 92 94 pthread_mutex_t LinuxDVBmutex; … … 95 97 /* Prototypes */ 96 98 /* ***************************** */ 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 97 107 int LinuxDvbStop(Context_t *context, char * type); 98 108 … … 101 111 /* ***************************** */ 102 112 103 void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) { 104 105 linuxdvb_printf(250, "requesting mutex\n"); 106 113 void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) 114 { 107 115 pthread_mutex_lock(&LinuxDVBmutex); 108 109 linuxdvb_printf(250, "received mutex\n");110 116 } 111 117 112 118 void releaseLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) { 113 119 pthread_mutex_unlock(&LinuxDVBmutex); 114 115 linuxdvb_printf(250, "released mutex\n");116 117 120 } 118 121 119 122 static int LinuxDvbMapBypassMode(int bypass) 120 123 { 121 if ( 0x30 == bypass && IsDreambox())124 if (0x30 == bypass && IsDreambox()) 122 125 { 123 126 return 0x0f; … … 126 129 } 127 130 128 int LinuxDvbOpen(Context_t *context __attribute__((unused)), char * type) { 129 unsigned char video = !strcmp("video", type); 130 unsigned char audio = !strcmp("audio", type); 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); 131 135 132 136 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 138 142 if (videofd < 0) 139 143 { 140 linuxdvb_err("failed to open %s - errno %d \n", VIDEODEV, errno);141 linuxdvb_err("%s\n", strerror(errno));144 linuxdvb_err("failed to open %s - errno %d, %s\n", VIDEODEV, errno, strerror(errno)); 145 linuxdvb_err("%s\n", ); 142 146 return cERR_LINUXDVB_ERROR; 143 147 } … … 145 149 if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1) 146 150 { 147 linuxdvb_err("ioctl failed with errno %d\n", errno); 148 linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno)); 151 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 149 152 } 150 153 151 154 if (ioctl( videofd, VIDEO_SELECT_SOURCE, (void*)VIDEO_SOURCE_MEMORY) == -1) 152 155 { 153 linuxdvb_err("ioctl failed with errno %d\n", errno); 154 linuxdvb_err("VIDEO_SELECT_SOURCE: %s\n", strerror(errno)); 156 linuxdvb_err("VIDEO_SELECT_SOURCE: ERROR %d, %s\n", errno, strerror(errno)); 155 157 } 156 158 157 159 if (ioctl(videofd, VIDEO_FREEZE) == -1) 158 160 { 159 linuxdvb_err("ioctl failed with errno %d\n", errno); 160 linuxdvb_err("VIDEO_FREEZE: %s\n", strerror(errno)); 161 } 162 161 linuxdvb_err("VIDEO_FREEZE: ERROR %d, %s\n", errno, strerror(errno)); 162 } 163 164 if (isBufferedOutput) 165 LinuxDvbBuffOpen(context, type, videofd); 163 166 } 164 167 if (audio && audiofd < 0) … … 168 171 if (audiofd < 0) 169 172 { 170 linuxdvb_err("failed to open %s - errno %d\n", AUDIODEV, errno); 171 linuxdvb_err("%s\n", strerror(errno)); 172 173 linuxdvb_err("failed to open %s - errno %d, %s\n", AUDIODEV, errno, strerror(errno)); 173 174 return cERR_LINUXDVB_ERROR; 174 175 } … … 176 177 if (ioctl( audiofd, AUDIO_CLEAR_BUFFER) == -1) 177 178 { 178 linuxdvb_err("ioctl failed with errno %d\n", errno); 179 linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno)); 179 linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 180 180 } 181 181 182 182 if (ioctl( audiofd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) == -1) 183 183 { 184 linuxdvb_err("ioctl failed with errno %d\n", errno); 185 linuxdvb_err("AUDIO_SELECT_SOURCE: %s\n", strerror(errno)); 184 linuxdvb_err("AUDIO_SELECT_SOURCE: ERROR %d, %s\n", errno, strerror(errno)); 186 185 } 187 186 188 187 if (ioctl( audiofd, AUDIO_PAUSE) == -1) 189 188 { 190 linuxdvb_err("ioctl failed with errno %d\n", errno); 191 linuxdvb_err("AUDIO_PAUSE: %s\n", strerror(errno)); 189 linuxdvb_err("AUDIO_PAUSE: ERROR %d, %s\n", errno, strerror(errno)); 192 190 } 193 191 192 if (isBufferedOutput) 193 LinuxDvbBuffOpen(context, type, audiofd); 194 194 } 195 195 … … 197 197 } 198 198 199 int LinuxDvbClose(Context_t *context, char * 200 { 201 u nsigned charvideo = !strcmp("video", type);202 u nsigned charaudio = !strcmp("audio", type);199 int LinuxDvbClose(Context_t *context, char *type) 200 { 201 uint8_t video = !strcmp("video", type); 202 uint8_t audio = !strcmp("audio", type); 203 203 204 204 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 211 211 212 212 getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 213 214 if (isBufferedOutput) 215 LinuxDvbBuffClose(context); 213 216 214 217 if (video && videofd != -1) … … 223 226 } 224 227 225 releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__);228 releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); 226 229 return cERR_LINUXDVB_NO_ERROR; 227 230 } 228 231 229 int LinuxDvbPlay(Context_t *context, char * 230 int ret = cERR_LINUXDVB_NO_ERROR;231 Writer_t *writer;232 233 u nsigned charvideo = !strcmp("video", type);234 u nsigned charaudio = !strcmp("audio", type);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); 235 238 236 239 linuxdvb_printf(10, "v%d a%d\n", video, audio); 237 240 238 241 if (video && videofd != -1) { 239 char * 242 char *Encoding = NULL; 240 243 context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); 241 244 … … 243 246 244 247 writer = getWriter(Encoding); 245 246 // SULGE VU 4K dont like this247 /*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 256 248 if (writer == NULL) 257 249 { … … 264 256 if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1) 265 257 { 266 linuxdvb_err("ioctl failed with errno %d\n", errno); 267 linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno)); 258 linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno)); 268 259 ret = cERR_LINUXDVB_ERROR; 269 260 } … … 273 264 if (0 != ioctl(videofd, VIDEO_PLAY)) 274 265 { 275 linuxdvb_err("ioctl failed with errno %d\n", errno); 276 linuxdvb_err("VIDEO_PLAY: %s\n", strerror(errno)); 266 linuxdvb_err("VIDEO_PLAY: ERROR %d, %s\n", errno, strerror(errno)); 277 267 ret = cERR_LINUXDVB_ERROR; 278 268 } … … 280 270 if (ioctl(videofd, VIDEO_CONTINUE) == -1) 281 271 { 282 linuxdvb_err("ioctl failed with errno %d\n", errno); 283 linuxdvb_err("VIDEO_CONTINUE: %s\n", strerror(errno)); 272 linuxdvb_err("VIDEO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno)); 284 273 } 285 274 286 275 if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1) 287 276 { 288 linuxdvb_err("ioctl failed with errno %d\n", errno); 289 linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno)); 277 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 290 278 } 291 279 } … … 298 286 writer = getWriter(Encoding); 299 287 300 // SULGE VU 4K dont like this301 /*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 310 288 if (writer == NULL) 311 289 { … … 318 296 if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) < 0) 319 297 { 320 linuxdvb_err("ioctl failed with errno %d\n", errno); 321 linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno)); 298 linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno)); 322 299 ret = cERR_LINUXDVB_ERROR; 323 300 } … … 326 303 if (ioctl(audiofd, AUDIO_PLAY) < 0) 327 304 { 328 linuxdvb_err("ioctl failed with errno %d\n", errno); 329 linuxdvb_err("AUDIO_PLAY: %s\n", strerror(errno)); 305 linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno)); 330 306 ret = cERR_LINUXDVB_ERROR; 331 307 } … … 333 309 if (ioctl(audiofd, AUDIO_CONTINUE) < 0) 334 310 { 335 linuxdvb_err("ioctl failed with errno %d\n", errno); 336 linuxdvb_err("AUDIO_CONTINUE: %s\n", strerror(errno)); 311 linuxdvb_err("AUDIO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno)); 337 312 ret = cERR_LINUXDVB_ERROR; 338 313 } … … 358 333 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 359 334 { 360 linuxdvb_err("ioctl failed with errno %d\n", errno); 361 linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno)); 335 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 362 336 } 363 337 364 338 if (ioctl(videofd, VIDEO_STOP) == -1) 365 339 { 366 linuxdvb_err("ioctl failed with errno %d\n", errno); 367 linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno)); 340 linuxdvb_err("VIDEO_STOP: ERROR %d, %s\n", errno, strerror(errno)); 368 341 ret = cERR_LINUXDVB_ERROR; 369 342 } … … 371 344 ioctl(videofd, VIDEO_SLOWMOTION, 0); 372 345 ioctl(videofd, VIDEO_FAST_FORWARD, 0); 373 374 346 ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); 375 347 } … … 377 349 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 378 350 { 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 // } 351 linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 352 } 353 389 354 if (ioctl(audiofd, AUDIO_STOP) == -1) 390 355 { 391 linuxdvb_err("ioctl failed with errno %d\n", errno); 392 linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno)); 356 linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno)); 393 357 ret = cERR_LINUXDVB_ERROR; 394 358 } … … 401 365 } 402 366 403 int LinuxDvbPause(Context_t *context __attribute__((unused)), char * 404 int ret = cERR_LINUXDVB_NO_ERROR;405 u nsigned charvideo = !strcmp("video", type);406 u nsigned charaudio = !strcmp("audio", type);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); 407 371 408 372 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 410 374 getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 411 375 412 if (video && videofd != -1) { 376 if (video && videofd != -1) 377 { 413 378 if (ioctl(videofd, VIDEO_FREEZE, NULL) == -1) 414 379 { 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) { 380 linuxdvb_err("VIDEO_FREEZE: ERROR %d, %s\n", errno, strerror(errno)); 381 ret = cERR_LINUXDVB_ERROR; 382 } 383 } 384 385 if (audio && audiofd != -1) 386 { 421 387 if (ioctl(audiofd, AUDIO_PAUSE, NULL) == -1) 422 388 { 423 linuxdvb_err("ioctl failed with errno %d\n", errno); 424 linuxdvb_err("AUDIO_PAUSE: %s\n", strerror(errno)); 389 linuxdvb_err("AUDIO_PAUSE: ERROR %d, %s\n", errno, strerror(errno)); 425 390 ret = cERR_LINUXDVB_ERROR; 426 391 } … … 433 398 434 399 int LinuxDvbContinue(Context_t *context __attribute__((unused)), char * type) { 435 int ret = cERR_LINUXDVB_NO_ERROR;436 u nsigned charvideo = !strcmp("video", type);437 u nsigned charaudio = !strcmp("audio", type);400 int32_t ret = cERR_LINUXDVB_NO_ERROR; 401 uint8_t video = !strcmp("video", type); 402 uint8_t audio = !strcmp("audio", type); 438 403 439 404 linuxdvb_printf(10, "v%d a%d\n", video, audio); 440 405 441 if (video && videofd != -1) { 406 if (video && videofd != -1) 407 { 442 408 if (ioctl(videofd, VIDEO_CONTINUE, NULL) == -1) 443 409 { 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) { 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 { 450 417 if (ioctl(audiofd, AUDIO_CONTINUE, NULL) == -1) 451 418 { 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 } 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); 457 426 458 427 linuxdvb_printf(10, "exiting\n"); 459 460 461 return ret;462 }463 464 int LinuxDvbReverseDiscontinuity(Context_t *context __attribute__((unused)), int* surplus) {465 int ret = cERR_LINUXDVB_NO_ERROR;466 // int dis_type = VIDEO_DISCONTINUITY_CONTINUOUS_REVERSE | *surplus;467 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 478 429 return ret; 479 430 } … … 487 438 if(*flag == '1') 488 439 { 489 //AUDIO_SET_MUTE has no effect with new player490 //if (ioctl(audiofd, AUDIO_SET_MUTE, 1) == -1)491 440 if (ioctl(audiofd, AUDIO_STOP, NULL) == -1) 492 441 { 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)); 442 linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno)); 496 443 ret = cERR_LINUXDVB_ERROR; 497 444 } … … 499 446 else 500 447 { 501 //AUDIO_SET_MUTE has no effect with new player502 //if (ioctl(audiofd, AUDIO_SET_MUTE, 0) == -1)503 448 if (ioctl(audiofd, AUDIO_PLAY) == -1) 504 449 { 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)); 450 linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno)); 508 451 ret = cERR_LINUXDVB_ERROR; 509 452 } … … 516 459 } 517 460 518 519 461 int LinuxDvbFlush(Context_t *context __attribute__((unused)), char * type) 520 462 { 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 550 463 return cERR_LINUXDVB_NO_ERROR; 551 464 } 552 465 553 #ifndef use_set_speed_instead_ff554 int 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 #else583 584 static 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, 900590 };591 592 int 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 #endif641 642 643 int LinuxDvbReverse(Context_t *context __attribute__((unused)), char * type __attribute__((unused))) {644 int ret = cERR_LINUXDVB_NO_ERROR;645 return ret;646 }647 648 466 int LinuxDvbSlowMotion(Context_t *context, char * type) { 649 int ret = cERR_LINUXDVB_NO_ERROR;650 651 u nsigned charvideo = !strcmp("video", type);652 u nsigned charaudio = !strcmp("audio", type);467 int32_t ret = cERR_LINUXDVB_NO_ERROR; 468 469 uint8_t video = !strcmp("video", type); 470 uint8_t audio = !strcmp("audio", type); 653 471 654 472 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 660 478 if (ioctl(videofd, VIDEO_SLOWMOTION, context->playback->SlowMotion) == -1) 661 479 { 662 linuxdvb_err("ioctl failed with errno %d\n", errno); 663 linuxdvb_err("VIDEO_SLOWMOTION: %s\n", strerror(errno)); 480 linuxdvb_err("VIDEO_SLOWMOTION: ERROR %d, %s\n", errno, strerror(errno)); 664 481 ret = cERR_LINUXDVB_ERROR; 665 482 } … … 674 491 } 675 492 676 int LinuxDvbAVSync(Context_t *context, char * 677 int ret = cERR_LINUXDVB_NO_ERROR;493 int LinuxDvbAVSync(Context_t *context, char *type __attribute__((unused))) { 494 int32_t ret = cERR_LINUXDVB_NO_ERROR; 678 495 /* konfetti: this one is dedicated to audiofd so we 679 496 * are ignoring what is given by type! I think we should … … 687 504 if (ioctl(audiofd, AUDIO_SET_AV_SYNC, 0) == -1) //context->playback->AVSync) == -1) 688 505 { 689 linuxdvb_err("ioctl failed with errno %d\n", errno); 690 linuxdvb_err("AUDIO_SET_AV_SYNC: %s\n", strerror(errno)); 506 linuxdvb_err("AUDIO_SET_AV_SYNC: ERROR %d, %s\n", errno, strerror(errno)); 691 507 ret = cERR_LINUXDVB_ERROR; 692 508 } … … 698 514 } 699 515 700 int LinuxDvbClear(Context_t *context __attribute__((unused)), char * 516 int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type) 701 517 { 702 518 int32_t ret = cERR_LINUXDVB_NO_ERROR; … … 704 520 uint8_t audio = !strcmp("audio", type); 705 521 706 linuxdvb_printf(10, " >>>>>>>>>>LinuxDvbClear v%d a%d\n", video, audio);522 linuxdvb_printf(10, "LinuxDvbClear v%d a%d\n", video, audio); 707 523 708 524 if ( (video && videofd != -1) || (audio && audiofd != -1) ) … … 714 530 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 715 531 { 716 linuxdvb_err("ioctl failed with errno %d\n", errno); 717 linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno)); 532 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 718 533 ret = cERR_LINUXDVB_ERROR; 719 534 } … … 723 538 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 724 539 { 725 linuxdvb_err("ioctl failed with errno %d\n", errno); 726 linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno)); 540 linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 727 541 ret = cERR_LINUXDVB_ERROR; 728 542 } … … 738 552 739 553 int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long int* pts) { 740 int ret = cERR_LINUXDVB_ERROR;554 int32_t ret = cERR_LINUXDVB_ERROR; 741 555 742 556 linuxdvb_printf(50, "\n"); 743 557 744 // pts is a non writting requests and can be done in parallel to other requests 745 //getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 746 558 // GET_PTS is immutable call, so it can be done in parallel to other requests 747 559 if (videofd > -1 && !ioctl(videofd, VIDEO_GET_PTS, (void*)&sCURRENT_PTS)) 748 560 { … … 751 563 else 752 564 { 753 linuxdvb_err("VIDEO_GET_PTS: %d (%s)\n", errno, strerror(errno));565 linuxdvb_err("VIDEO_GET_PTS: ERROR %d, %s\n", errno, strerror(errno)); 754 566 } 755 567 … … 762 574 else 763 575 { 764 linuxdvb_err("AUDIO_GET_PTS: %d (%s)\n", errno, strerror(errno));576 linuxdvb_err("AUDIO_GET_PTS: ERROR %d, %s\n", errno, strerror(errno)); 765 577 } 766 578 } … … 772 584 773 585 *((unsigned long long int *)pts)=(unsigned long long int)sCURRENT_PTS; 774 775 //releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__);776 777 586 return ret; 778 587 } … … 780 589 int LinuxDvbGetFrameCount(Context_t *context __attribute__((unused)), unsigned long long int* frameCount) 781 590 { 782 int ret = cERR_LINUXDVB_NO_ERROR; 783 return ret; 784 } 785 786 int LinuxDvbSwitch(Context_t *context, char * type) 787 { 788 unsigned char audio = !strcmp("audio", type); 789 unsigned char video = !strcmp("video", type); 790 Writer_t* writer; 591 return cERR_LINUXDVB_NO_ERROR; 592 } 593 594 int LinuxDvbSwitch(Context_t *context, char *type) 595 { 596 uint8_t audio = !strcmp("audio", type); 597 uint8_t video = !strcmp("video", type); 598 Writer_t *writer; 791 599 792 600 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 806 614 if (ioctl(audiofd, AUDIO_STOP ,NULL) == -1) 807 615 { 808 linuxdvb_err("ioctl failed with errno %d\n", errno); 809 linuxdvb_err("AUDIO_STOP: %s\n", strerror(errno)); 810 616 linuxdvb_err("AUDIO_STOP: ERROR %d, %s\n", errno, strerror(errno)); 811 617 } 812 618 813 619 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 814 620 { 815 linuxdvb_err("ioctl failed with errno %d\n", errno); 816 linuxdvb_err("AUDIO_CLEAR_BUFFER: %s\n", strerror(errno)); 817 621 linuxdvb_err("AUDIO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 818 622 } 819 623 … … 821 625 { 822 626 linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); 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 627 } 628 else 829 629 { 830 630 linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); 831 631 if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) == -1) 832 632 { 833 linuxdvb_err("ioctl failed with errno %d\n", errno); 834 linuxdvb_err("AUDIO_SET_BYPASS_MODE: %s\n", strerror(errno)); 633 linuxdvb_err("AUDIO_SET_BYPASS_MODE: ERROR %d, %s\n", errno, strerror(errno)); 835 634 } 836 635 } … … 838 637 if (ioctl(audiofd, AUDIO_PLAY) == -1) 839 638 { 840 linuxdvb_err("ioctl failed with errno %d\n", errno); 841 linuxdvb_err("AUDIO_PLAY: %s\n", strerror(errno)); 639 linuxdvb_err("AUDIO_PLAY: ERROR %d, %s\n", errno, strerror(errno)); 842 640 } 843 641 free(Encoding); … … 854 652 if (ioctl(videofd, VIDEO_STOP ,NULL) == -1) 855 653 { 856 linuxdvb_err("ioctl failed with errno %d\n", errno); 857 linuxdvb_err("VIDEO_STOP: %s\n", strerror(errno)); 654 linuxdvb_err("VIDEO_STOP: ERROR %d, %s\n", errno, strerror(errno)); 858 655 } 859 656 860 657 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 861 658 { 862 linuxdvb_err("ioctl failed with errno %d\n", errno); 863 linuxdvb_err("VIDEO_CLEAR_BUFFER: %s\n", strerror(errno)); 659 linuxdvb_err("VIDEO_CLEAR_BUFFER: ERROR %d, %s\n", errno, strerror(errno)); 864 660 } 865 661 … … 871 667 { 872 668 linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); 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 669 } 670 else 879 671 { 880 672 linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); 881 673 if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1) 882 674 { 883 linuxdvb_err("ioctl failed with errno %d\n", errno); 884 linuxdvb_err("VIDEO_SET_STREAMTYPE: %s\n", strerror(errno)); 675 linuxdvb_err("VIDEO_SET_STREAMTYPE: ERROR %d, %s\n", errno, strerror(errno)); 885 676 } 886 677 } … … 891 682 * return an error here and stop the playback mode 892 683 */ 893 linuxdvb_err("ioctl failed with errno %d\n", errno); 894 linuxdvb_err("VIDEO_PLAY: %s\n", strerror(errno)); 684 linuxdvb_err("VIDEO_PLAY:ERROR %d, %s\n", errno, strerror(errno)); 895 685 } 896 686 free(Encoding); … … 909 699 } 910 700 911 static int Write(void *_context, void *_out)701 static int Write(void *_context, void *_out) 912 702 { 913 703 Context_t *context = (Context_t *) _context; 914 704 AudioVideoOut_t *out = (AudioVideoOut_t*) _out; 915 int 916 int 917 u nsigned charvideo = 0;918 u nsigned charaudio = 0;919 Writer_t * writer;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; 920 710 WriterAVCallData_t call; 921 711 … … 935 725 if (video) 936 726 { 937 char * 727 char *Encoding = NULL; 938 728 context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); 939 729 … … 1011 801 call.Height = out->height; 1012 802 call.InfoFlags = out->infoFlags; 1013 call.Version = 0; // is unsingned char 803 call.Version = 0; 804 call.WriteV = isBufferedOutput ? BufferingWriteV : writev_with_retry; 1014 805 1015 806 if (writer->writeData) … … 1030 821 else if (audio) 1031 822 { 1032 char * 823 char *Encoding = NULL; 1033 824 context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); 1034 825 … … 1060 851 call.FrameScale = out->timeScale; 1061 852 call.InfoFlags = out->infoFlags; 1062 call.Version = 0; /* -1; unsigned char cannot be negative */ 853 call.Version = 0; 854 call.WriteV = isBufferedOutput ? BufferingWriteV : writev_with_retry; 1063 855 1064 856 if (writer->writeData) … … 1117 909 free(Encoding); 1118 910 911 if (isBufferedOutput) 912 LinuxDvbBuffFlush(context); 913 1119 914 return ret; 1120 915 } … … 1211 1006 ret = cERR_LINUXDVB_NO_ERROR; 1212 1007 *((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 } 1213 1022 break; 1214 1023 } -
titan/libeplayer3/output/output.c
r40322 r42162 530 530 } 531 531 break; 532 } 532 533 case OUTPUT_GET_PROGRESSIVE: 533 534 { … … 545 546 break; 546 547 } 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; 547 566 } 548 567 default: -
titan/libeplayer3/output/writer/mipsel/aac.c
r40322 r42162 182 182 return 0; 183 183 } 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 } 184 192 } 185 193 else // check LOAS header … … 204 212 iov[1].iov_base = call->data; 205 213 iov[1].iov_len = call->len; 206 return writev_with_retry(call->fd, iov, 2);214 return call->WriteV(call->fd, iov, 2); 207 215 } 208 216 … … 234 242 HasADTSHeader(call->data, call->len) ) 235 243 { 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]); 236 245 return _writeData(_call, 0); 237 246 } … … 274 283 iov[1].iov_len = call->len; 275 284 276 return writev_with_retry(call->fd, iov, 2);285 return call->WriteV(call->fd, iov, 2); 277 286 } 278 287 … … 344 353 iov[2].iov_len = pLATMCtx->len; 345 354 346 return writev_with_retry(call->fd, iov, 3);355 return call->WriteV(call->fd, iov, 3); 347 356 } 348 357 -
titan/libeplayer3/output/writer/mipsel/h264.c
r40362 r42162 56 56 /* Makros/Constants */ 57 57 /* ***************************** */ 58 #define H264_SILENT 58 59 //#define H264_DEBUG 59 60 #ifdef H264_DEBUG … … 88 89 static unsigned int CodecDataLen = 0; 89 90 static int avc3 = 0; 91 static int sps_pps_in_stream = 0; 90 92 /* ***************************** */ 91 93 /* Prototypes */ … … 299 301 initialHeader = 1; 300 302 avc3 = 0; 303 sps_pps_in_stream = 0; 301 304 return 0; 302 305 } … … 344 347 (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))) 345 348 { 349 uint32_t i = 0; 350 uint8_t InsertPrivData = !sps_pps_in_stream; 346 351 uint32_t PacketLength = 0; 347 352 uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE; 348 349 353 iov[ic++].iov_base = PesHeader; 350 initialHeader = 0; 351 if (initialHeader) 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 352 366 { 353 367 initialHeader = 0; … … 356 370 PacketLength += call->private_size; 357 371 } 358 359 iov[ic].iov_base = "";360 iov[ic++].iov_len = 1;361 372 362 373 iov[ic].iov_base = call->data; … … 364 375 PacketLength += call->len; 365 376 366 /*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than367 data is available. The content of this byte does not matter. It will be ignored368 by the player */369 //obi370 iov[ic].iov_base = "\0";371 iov[ic++].iov_len = 1;372 //obi (end)373 377 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode); 374 378 375 return writev_with_retry(call->fd, iov, ic);379 return call->WriteV(call->fd, iov, ic); 376 380 } 377 381 else if (!call->private_data || call->private_size < 7 || 1 != call->private_data[0]) … … 386 390 iov[ic++].iov_base = PesHeader; 387 391 388 if ( initialHeader)392 if (!avc3) 389 393 { 390 394 if (CodecData) … … 458 462 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); 459 463 460 len = writev_with_retry(call->fd, iov, ic);464 len = call->WriteV(call->fd, iov, ic); 461 465 PacketLength += iov[0].iov_len; 462 466 if (PacketLength != len) -
titan/libeplayer3/output/writer/mipsel/h265.c
r40329 r42162 56 56 /* Makros/Constants */ 57 57 /* ***************************** */ 58 #define H264_SILENT 58 59 //#define H265_DEBUG 59 60 #ifdef H265_DEBUG … … 234 235 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode); 235 236 236 return writev_with_retry(call->fd, iov, ic);237 return call->WriteV(call->fd, iov, ic); 237 238 } 238 239 … … 303 304 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); 304 305 305 len = writev_with_retry(call->fd, iov, ic);306 len = call->WriteV(call->fd, iov, ic); 306 307 PacketLength += iov[0].iov_len; 307 308 if (PacketLength != len) -
titan/libeplayer3/output/writer/mipsel/lpcm.c
r40322 r42162 257 257 iov[1].iov_base = frame; 258 258 iov[1].iov_len = i_frame_size; 259 i_ret_size += writev_with_retry(call->fd, iov, 2);259 i_ret_size += call->WriteV(call->fd, iov, 2); 260 260 } 261 261 -
titan/libeplayer3/output/writer/mipsel/mpeg4.c
r40322 r42162 134 134 } 135 135 136 struct iovec iov[ 2];136 struct iovec iov[3]; 137 137 int ic = 0; 138 138 iov[ic].iov_base = PesHeader; … … 148 148 iov[ic++].iov_len = call->len; 149 149 150 int len = writev_with_retry(call->fd, iov, ic);150 int len = call->WriteV(call->fd, iov, ic); 151 151 152 152 mpeg4_printf(10, "xvid_Write < len=%d\n", len); -
titan/libeplayer3/output/writer/mipsel/vp.c
r40329 r42162 97 97 } 98 98 99 static int writeData(void *_call, int is_vp6)99 static int writeData(void *_call, int is_vp6) 100 100 { 101 101 WriterAVCallData_t* call = (WriterAVCallData_t*) _call; … … 145 145 iov[1].iov_len = call->len; 146 146 147 return writev_with_retry(call->fd, iov, 2);147 return call->WriteV(call->fd, iov, 2); 148 148 } 149 149 -
titan/libeplayer3/output/writer/mipsel/wmv.c
r40322 r42162 197 197 } 198 198 199 return writev_with_retry(call->fd, iov, ic);199 return call->WriteV(call->fd, iov, ic); 200 200 } 201 201 -
titan/libeplayer3/output/writer/mipsel/writer.c
r40362 r42162 29 29 #include "misc.h" 30 30 #include "writer.h" 31 #include "common.h" 31 32 32 33 /* ***************************** */ … … 98 99 /* Functions */ 99 100 /* ***************************** */ 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 100 194 ssize_t write_with_retry(int fd, const void *buf, size_t size) 101 195 { -
titan/libeplayer3/output/writer/sh4/aac.c
r40322 r42162 181 181 return 0; 182 182 } 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 } 183 191 } 184 192 else // check LOAS header -
titan/libeplayer3/output/writer/sh4/h264.c
r40348 r42162 53 53 /* Makros/Constants */ 54 54 /* ***************************** */ 55 //#define H264_DEBUG56 57 55 #ifdef SAM_WITH_DEBUG 58 56 #define H264_DEBUG … … 102 100 static uint32_t NalLengthBytes = 1; 103 101 static int avc3 = 0; 102 static int sps_pps_in_stream = 0; 104 103 /* ***************************** */ 105 104 /* Prototypes */ … … 260 259 (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))) 261 260 { 261 uint32_t i = 0; 262 uint8_t InsertPrivData = !sps_pps_in_stream; 262 263 uint32_t PacketLength = 0; 263 uint32_t FakeStartCode = /*(call->Version << 8) | */PES_VERSION_FAKE_START_CODE; 264 264 uint32_t FakeStartCode = PES_VERSION_FAKE_START_CODE; 265 265 iov[ic++].iov_base = PesHeader; 266 initialHeader = 0; 267 if (initialHeader) 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 268 278 { 269 279 initialHeader = 0; … … 296 306 } 297 307 298 if ( initialHeader)308 if (!avc3) 299 309 { 300 310 uint8_t *private_data = call->private_data; -
titan/libeplayer3/playback/playback.c
r40364 r42162 58 58 #define cMaxSpeed_fr -320 /* fixme: revise */ 59 59 60 #define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10 61 60 62 /* ***************************** */ 61 63 /* Varaibles */ … … 68 70 static int32_t PlaybackTerminate(Context_t *context); 69 71 72 static int8_t dieNow = 0; 73 static PlaybackDieNowCallback playbackDieNowCallbacks[MAX_PLAYBACK_DIE_NOW_CALLBACKS] = {NULL}; 74 70 75 /* ***************************** */ 71 76 /* MISC Functions */ … … 73 78 int8_t PlaybackDieNow(int8_t val) 74 79 { 75 static int8_t dieNow = 0;76 if(val)77 {80 if(val && dieNow == 0) 81 { 82 uint32_t i = 0; 78 83 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 } 79 93 } 80 94 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; 81 121 } 82 122
Note: See TracChangeset
for help on using the changeset viewer.