Changeset 42177 for titan/libeplayer3
- Timestamp:
- 04/14/18 13:20:15 (6 years ago)
- Location:
- titan/libeplayer3
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/libeplayer3/container/container_ffmpeg.c
r42162 r42177 146 146 static int32_t seek_target_flag = 0; 147 147 148 static int32_t mutexInitialized = 0;149 150 148 /* ***************************** */ 151 149 /* Prototypes */ … … 166 164 progressive_playback = val; 167 165 } 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 protect201 * avformat structures, during write time202 */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 210 166 211 167 #include "buff_ffmpeg.c" … … 470 426 } 471 427 472 //static int32_t mutexInitialized = 0;428 static int32_t mutexInitialized = 0; 473 429 474 430 void sel_program_id_set(const int32_t val) … … 540 496 { 541 497 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); 542 525 } 543 526 … … 720 703 pts = INVALID_PTS_VALUE; 721 704 } 722 else723 {724 pts &= 0x01FFFFFFFF; // PES header can handle only 33 bit PTS725 }726 705 727 706 return pts; … … 819 798 while ( context && context->playback && context->playback->isPlaying ) 820 799 { 821 /* When user press PAUSE we call pause on AUDIO and VIDEO decoders,822 * we will not wait here because we can still fill823 * DVB drivers buffers at PAUSE time824 *825 * In the future we can add buffering queue before injection in to826 * AUDIO, VIDEO decoders, so we can not wait here827 */828 #ifdef __sh__829 800 //IF MOVIE IS PAUSED, WAIT 830 801 if (context->playback->isPaused) … … 835 806 continue; 836 807 } 837 #endif838 808 839 809 if (context->playback->isSeeking) … … 959 929 960 930 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"); 981 935 } 982 936 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 983 947 ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, pid); 984 948 … … 1073 1037 } 1074 1038 1075 if ( Write(context->output->video->Write, context, &avOut, pts) < 0)1039 if (context->output->video->Write(context, &avOut) < 0) 1076 1040 { 1077 1041 ffmpeg_err("writing data to video device failed\n"); … … 1149 1113 avOut.type = "audio"; 1150 1114 1151 if ( Write(context->output->audio->Write, context, &avOut, pts) < 0)1115 if (context->output->audio->Write(context, &avOut) < 0) 1152 1116 { 1153 1117 ffmpeg_err("(raw pcm) writing data to audio device failed\n"); … … 1344 1308 avOut.type = "audio"; 1345 1309 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) 1347 1311 { 1348 1312 ffmpeg_err("writing data to audio device failed\n"); … … 1367 1331 avOut.type = "audio"; 1368 1332 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) 1370 1334 { 1371 1335 ffmpeg_err("(aac) writing data to audio device failed\n"); … … 1385 1349 avOut.type = "audio"; 1386 1350 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) 1388 1352 { 1389 1353 ffmpeg_err("writing data to audio device failed\n"); … … 1433 1397 //obi (end) 1434 1398 1435 if ( Write(context->output->subtitle->Write, context, &subOut, pts) < 0)1399 if (context->output->subtitle->Write(context, &subOut) < 0) 1436 1400 { 1437 1401 ffmpeg_err("writing data to teletext fifo failed\n"); … … 1581 1545 1582 1546 #ifdef SAM_CUSTOM_IO 1583 typedef struct CustomIOCtx_t1584 {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 1597 1547 int SAM_ReadFunc(void *ptr, uint8_t *buffer, int lSize) 1598 1548 { 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 1554 int64_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 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; 1613 1573 } 1614 1574 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; 1628 1579 } 1629 1580 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; 1669 1583 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 { 1715 1587 return NULL; 1716 1588 } 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; 1733 1595 } 1734 1596 #endif 1735 1597 1736 int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uint64_t fileSize, char *moovAtomFile, uint64_t moovAtomOffset,int32_t AVIdx)1598 int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, int32_t AVIdx) 1737 1599 { 1738 1600 int32_t err = 0; … … 1746 1608 0 == strncmp(filename, "file://", 7)) 1747 1609 { 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); 1758 1611 if(avio_ctx) 1759 1612 { … … 1763 1616 else 1764 1617 { 1765 free(custom_io_tab[AVIdx]);1766 custom_io_tab[AVIdx] = NULL;1767 1618 return cERR_CONTAINER_FFMPEG_OPEN; 1768 1619 } … … 2303 2154 2304 2155 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); 2307 2157 if(0 != res) 2308 2158 { … … 2310 2160 } 2311 2161 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); 2316 2165 } 2317 2166 … … 2334 2183 int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32_t initial) 2335 2184 { 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; 2339 2187 2340 2188 if (terminating) … … 2343 2191 } 2344 2192 2345 getMutex(__FILE__, __FUNCTION__,__LINE__);2346 2347 2193 if (initial && context->manager->subtitle) 2348 2194 { 2349 context->manager->subtitle->Command(context, MANAGER_GET_TRACK, & currSubtitleTrack);2195 context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &subtitleTrack); 2350 2196 } 2351 2197 2352 2198 if (context->manager->audio) 2353 2199 { 2354 context->manager->audio->Command(context, MANAGER_GET_TRACK, & currAudioTrack);2200 context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack); 2355 2201 } 2356 2202 … … 2371 2217 } 2372 2218 #endif 2219 2373 2220 2374 2221 ffmpeg_printf(20, "dump format\n"); … … 2448 2295 } 2449 2296 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) 2453 2298 continue; // skip this stream 2454 }2455 2299 } 2456 2300 … … 2485 2329 case AVMEDIA_TYPE_VIDEO: 2486 2330 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 2488 2332 if (encoding != NULL) 2489 2333 { … … 2565 2409 ffmpeg_err("failed to add track %d\n", n); 2566 2410 } 2567 else2568 {2569 if (addedVideoTracksCount == 0) /* at now we can handle only first video track */2570 {2571 stream->discard = AVDISCARD_DEFAULT;2572 }2573 addedVideoTracksCount += 1;2574 }2575 2411 } 2576 2412 } … … 2582 2418 case AVMEDIA_TYPE_AUDIO: 2583 2419 ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n",get_codecpar(stream)->codec_type); 2584 stream->discard = AVDISCARD_ALL; 2420 2585 2421 if (encoding != NULL) 2586 2422 { … … 2954 2790 case AVMEDIA_TYPE_NB: 2955 2791 default: 2956 stream->discard = AVDISCARD_ALL;2957 2792 ffmpeg_err("not handled or unknown codec_type %d\n", get_codecpar(stream)->codec_type); 2958 2793 break; … … 2961 2796 2962 2797 } 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 3002 2799 return cERR_CONTAINER_FFMPEG_NO_ERROR; 3003 2800 } … … 3322 3119 } 3323 3120 3324 //getMutex(__FILE__, __FUNCTION__,__LINE__);3121 getMutex(__FILE__, __FUNCTION__,__LINE__); 3325 3122 3326 3123 if (!context->playback || !context->playback->isPlaying) … … 3341 3138 */ 3342 3139 3343 getMutex(__FILE__, __FUNCTION__,__LINE__);3344 3140 off_t pos = avio_tell(avContextTab[0]->pb); 3345 releaseMutex(__FILE__, __FUNCTION__,__LINE__);3346 3141 3347 3142 ffmpeg_printf(10, "pos %lld %d\n", pos, avContextTab[0]->bit_rate); … … 3377 3172 } 3378 3173 3379 //releaseMutex(__FILE__, __FUNCTION__,__LINE__);3174 releaseMutex(__FILE__, __FUNCTION__,__LINE__); 3380 3175 return cERR_CONTAINER_FFMPEG_NO_ERROR; 3381 3176 } … … 3438 3233 { 3439 3234 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__);3458 3235 3459 3236 /* Hellmaster1024: nothing to do here!*/ 3460 int64_t sec = - 1;3237 int64_t sec = -5; 3461 3238 context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec); 3462 3239 return cERR_CONTAINER_FFMPEG_NO_ERROR; … … 3472 3249 * but now we will not ignore subtitle frame 3473 3250 */ 3474 int64_t sec = - 1;3251 int64_t sec = -5; 3475 3252 context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec); 3476 3253 //obi -
titan/libeplayer3/container/flv2mpeg4_ffmpeg.c
r42162 r42177 39 39 avOut.type = "video"; 40 40 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) 42 42 { 43 43 ffmpeg_err("writing data to video device failed\n"); -
titan/libeplayer3/container/mpeg4p2_ffmpeg.c
r42162 r42177 112 112 avOut.type = "video"; 113 113 114 if ( Write(ctx->output->video->Write, ctx, &avOut, avOut.pts) < 0)114 if (ctx->output->video->Write(ctx, &avOut) < 0) 115 115 { 116 116 ffmpeg_err("writing data to video device failed\n"); -
titan/libeplayer3/include/common.h
r42162 r42177 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;24 18 } PlayFiles_t; 25 19 -
titan/libeplayer3/include/manager.h
r42162 r42177 18 18 MANAGER_UPDATED_TRACK_INFO, 19 19 MANAGER_REGISTER_UPDATED_TRACK_INFO, 20 MANAGER_REF_LIST,21 MANAGER_REF_LIST_SIZE,22 20 } ManagerCmd_t; 23 21 -
titan/libeplayer3/include/output.h
r42162 r42177 27 27 OUTPUT_GET_FRAME_COUNT, 28 28 OUTPUT_GET_PROGRESSIVE, 29 OUTPUT_SET_BUFFER_SIZE,30 29 } OutputCmd_t; 31 30 … … 69 68 char * Name; 70 69 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); 72 71 char ** Capabilities; 73 72 -
titan/libeplayer3/include/playback.h
r42162 r42177 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);9 5 10 6 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
r42162 r42177 5 5 #include <stdio.h> 6 6 #include <stdint.h> 7 #include "common.h"8 7 9 8 typedef enum { eNone, eAudio, eVideo} eWriterType_t; … … 23 22 unsigned char Version; 24 23 unsigned int InfoFlags; 25 ssize_t (* WriteV) (int, const struct iovec *, size_t);26 24 } WriterAVCallData_t; 27 25 … … 89 87 ssize_t write_with_retry(int fd, const void *buf, size_t size); 90 88 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);93 89 #endif -
titan/libeplayer3/main/exteplayer.c
r42162 r42177 85 85 } 86 86 87 static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread and kbhit*/87 static int g_pfd[2] = {-1, -1}; /* Used to wake terminate thread */ 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 }95 90 96 91 static void *TermThreadFun(void *arg) … … 141 136 if (FD_ISSET(fd, &readfds)) 142 137 { 138 /* 139 if ( (cl = accept(fd, NULL, NULL)) == -1) 140 { 141 perror("TermThreadFun accept error"); 142 goto finish; 143 } 144 */ 145 143 146 pthread_mutex_lock(&playbackStartMtx); 144 147 PlaybackDieNow(1); … … 181 184 { 182 185 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)) 193 195 { 194 196 return 0; 195 197 } 196 198 197 if(FD_ISSET(0, &readfds))199 if(FD_ISSET(0,&read_fd)) 198 200 { 199 201 return 1; … … 367 369 } 368 370 369 static int ParseParams(int argc,char* argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB)371 static int ParseParams(int argc,char* argv[], char *file, char *audioFile, int *pAudioTrackIdx, int *subtitleTrackIdx) 370 372 { 371 373 int ret = 0; … … 374 376 int aopt = 0, bopt = 0; 375 377 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) 377 379 { 378 380 switch (c) … … 435 437 break; 436 438 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); 445 441 break; 446 442 case 'h': … … 490 486 break; 491 487 } 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;511 488 default: 512 489 printf ("?? getopt returned character code 0%o ??\n", c); … … 518 495 { 519 496 ret = 0; 520 playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH); 521 playbackFiles->szFirstFile[0] = '\0'; 497 522 498 if(NULL == strstr(argv[optind], "://")) 523 499 { 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); 530 505 ++optind; 531 506 } … … 541 516 pthread_t termThread; 542 517 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)); 543 523 544 524 int audioTrackIdx = -1; 545 525 int subtitleTrackIdx = -1; 546 547 uint32_t linuxDvbBufferSizeMB = 0;548 526 549 527 char argvBuff[256]; … … 551 529 int commandRetVal = -1; 552 530 /* 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)) 558 534 { 559 535 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");561 536 printf("[-a 0|1|2|3] AAC software decoding - 1 bit - AAC ADTS, 2 - bit AAC LATM\n"); 562 537 printf("[-e] EAC3 software decoding\n"); … … 585 560 printf("[-1 idx] audio MPEG-DASH representation index\n"); 586 561 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 590 563 exit(1); 591 564 } … … 626 599 isTermThreadStarted = 1; 627 600 } while(0); 628 601 629 602 g_player->playback = &PlaybackHandler; 630 603 g_player->output = &OutputHandler; … … 641 614 g_player->output->Command(g_player, OUTPUT_ADD, "video"); 642 615 g_player->output->Command(g_player, OUTPUT_ADD, "subtitle"); 643 644 //Set LINUX DVB additional write buffer size645 if (linuxDvbBufferSizeMB)646 g_player->output->Command(g_player, OUTPUT_SET_BUFFER_SIZE, &linuxDvbBufferSizeMB);647 648 616 649 617 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)) 651 619 { 652 620 g_player->playback->noprobe = 1; 653 621 } 654 622 623 PlayFiles_t playbackFiles = {file, NULL}; 624 if('\0' != audioFile[0]) 625 { 626 playbackFiles.szSecondFile = audioFile; 627 } 628 655 629 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); 657 631 if(commandRetVal < 0) 658 632 { … … 676 650 if (g_player->playback->isPlaying) 677 651 { 678 PlaybackDieNowRegisterCallback(TerminateWakeUp);679 680 652 HandleTracks(g_player->manager->video, (PlaybackCmd_t)-1, "vc"); 681 653 HandleTracks(g_player->manager->audio, (PlaybackCmd_t)-1, "al"); … … 698 670 } 699 671 700 while(g_player->playback->isPlaying && 0 == PlaybackDieNow(0))672 while(g_player->playback->isPlaying) 701 673 { 702 674 /* we made fgets non blocking */ … … 876 848 if (0 == commandRetVal) 877 849 { 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); 893 851 } 894 852 break; … … 947 905 close(g_pfd[0]); 948 906 close(g_pfd[1]); 949 907 908 //printOutputCapabilities(); 909 950 910 exit(0); 951 911 } -
titan/libeplayer3/manager/audio.c
r42162 r42177 220 220 break; 221 221 } 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 233 222 case MANAGER_GET: 234 223 { -
titan/libeplayer3/output/linuxdvb_mipsel.c
r42162 r42177 26 26 #include <stdlib.h> 27 27 #include <unistd.h> 28 #include <stdbool.h>29 28 #include <fcntl.h> 30 29 #include <sys/types.h> … … 54 53 #define LINUXDVB_SILENT 55 54 56 static u int16_t debug_level = 0;55 static unsigned short debug_level = 0; 57 56 58 57 static const char FILENAME[] = __FILE__; … … 74 73 #define cERR_LINUXDVB_ERROR -1 75 74 76 static const char VIDEODEV[] = "/dev/dvb/adapter0/video0";77 static const char AUDIODEV[] = "/dev/dvb/adapter0/audio0";75 static const char VIDEODEV[] = "/dev/dvb/adapter0/video0"; 76 static const char AUDIODEV[] = "/dev/dvb/adapter0/audio0"; 78 77 79 78 static int videofd = -1; … … 90 89 91 90 unsigned long long int sCURRENT_PTS = 0; 92 bool isBufferedOutput = false;93 91 94 92 pthread_mutex_t LinuxDVBmutex; … … 97 95 /* Prototypes */ 98 96 /* ***************************** */ 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 107 97 int LinuxDvbStop(Context_t *context, char * type); 108 98 … … 111 101 /* ***************************** */ 112 102 113 void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) 114 { 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 115 107 pthread_mutex_lock(&LinuxDVBmutex); 108 109 linuxdvb_printf(250, "received mutex\n"); 116 110 } 117 111 118 112 void releaseLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) { 119 113 pthread_mutex_unlock(&LinuxDVBmutex); 114 115 linuxdvb_printf(250, "released mutex\n"); 116 120 117 } 121 118 122 119 static int LinuxDvbMapBypassMode(int bypass) 123 120 { 124 if (0x30 == bypass && IsDreambox())121 if( 0x30 == bypass && IsDreambox() ) 125 122 { 126 123 return 0x0f; … … 129 126 } 130 127 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); 128 int LinuxDvbOpen(Context_t *context __attribute__((unused)), char * type) { 129 unsigned char video = !strcmp("video", type); 130 unsigned char audio = !strcmp("audio", type); 135 131 136 132 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 142 138 if (videofd < 0) 143 139 { 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)); 146 142 return cERR_LINUXDVB_ERROR; 147 143 } … … 149 145 if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1) 150 146 { 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)); 152 149 } 153 150 154 151 if (ioctl( videofd, VIDEO_SELECT_SOURCE, (void*)VIDEO_SOURCE_MEMORY) == -1) 155 152 { 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)); 157 155 } 158 156 159 157 if (ioctl(videofd, VIDEO_FREEZE) == -1) 160 158 { 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 166 163 } 167 164 if (audio && audiofd < 0) … … 171 168 if (audiofd < 0) 172 169 { 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 174 173 return cERR_LINUXDVB_ERROR; 175 174 } … … 177 176 if (ioctl( audiofd, AUDIO_CLEAR_BUFFER) == -1) 178 177 { 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)); 180 180 } 181 181 182 182 if (ioctl( audiofd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) == -1) 183 183 { 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)); 185 186 } 186 187 187 188 if (ioctl( audiofd, AUDIO_PAUSE) == -1) 188 189 { 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)); 190 192 } 191 193 192 if (isBufferedOutput)193 LinuxDvbBuffOpen(context, type, audiofd);194 194 } 195 195 … … 197 197 } 198 198 199 int LinuxDvbClose(Context_t *context, char * type)199 int LinuxDvbClose(Context_t *context, char * type) 200 200 { 201 u int8_tvideo = !strcmp("video", type);202 u int8_taudio = !strcmp("audio", type);201 unsigned char video = !strcmp("video", type); 202 unsigned char 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);216 213 217 214 if (video && videofd != -1) … … 226 223 } 227 224 228 releaseLinuxDVBMutex(FILENAME, __FUNCTION__, 225 releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 229 226 return cERR_LINUXDVB_NO_ERROR; 230 227 } 231 228 232 int LinuxDvbPlay(Context_t *context, char * type) {233 int 32_tret = cERR_LINUXDVB_NO_ERROR;234 Writer_t *writer;235 236 u int8_tvideo = !strcmp("video", type);237 u int8_taudio = !strcmp("audio", type);229 int 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); 238 235 239 236 linuxdvb_printf(10, "v%d a%d\n", video, audio); 240 237 241 238 if (video && videofd != -1) { 242 char * Encoding = NULL;239 char * Encoding = NULL; 243 240 context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); 244 241 … … 246 243 247 244 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 248 256 if (writer == NULL) 249 257 { … … 256 264 if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1) 257 265 { 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)); 259 268 ret = cERR_LINUXDVB_ERROR; 260 269 } … … 264 273 if (0 != ioctl(videofd, VIDEO_PLAY)) 265 274 { 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)); 267 277 ret = cERR_LINUXDVB_ERROR; 268 278 } … … 270 280 if (ioctl(videofd, VIDEO_CONTINUE) == -1) 271 281 { 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)); 273 284 } 274 285 275 286 if (ioctl( videofd, VIDEO_CLEAR_BUFFER) == -1) 276 287 { 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)); 278 290 } 279 291 } … … 286 298 writer = getWriter(Encoding); 287 299 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 288 310 if (writer == NULL) 289 311 { … … 296 318 if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) < 0) 297 319 { 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)); 299 322 ret = cERR_LINUXDVB_ERROR; 300 323 } … … 303 326 if (ioctl(audiofd, AUDIO_PLAY) < 0) 304 327 { 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)); 306 330 ret = cERR_LINUXDVB_ERROR; 307 331 } … … 309 333 if (ioctl(audiofd, AUDIO_CONTINUE) < 0) 310 334 { 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)); 312 337 ret = cERR_LINUXDVB_ERROR; 313 338 } … … 333 358 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 334 359 { 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)); 336 362 } 337 363 338 364 if (ioctl(videofd, VIDEO_STOP) == -1) 339 365 { 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)); 341 368 ret = cERR_LINUXDVB_ERROR; 342 369 } … … 344 371 ioctl(videofd, VIDEO_SLOWMOTION, 0); 345 372 ioctl(videofd, VIDEO_FAST_FORWARD, 0); 373 346 374 ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); 347 375 } … … 349 377 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 350 378 { 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 // } 354 389 if (ioctl(audiofd, AUDIO_STOP) == -1) 355 390 { 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)); 357 393 ret = cERR_LINUXDVB_ERROR; 358 394 } … … 365 401 } 366 402 367 int LinuxDvbPause(Context_t *context __attribute__((unused)), char * type) {368 int 32_tret = cERR_LINUXDVB_NO_ERROR;369 u int8_tvideo = !strcmp("video", type);370 u int8_taudio = !strcmp("audio", type);403 int 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); 371 407 372 408 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 374 410 getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 375 411 376 if (video && videofd != -1) 377 { 412 if (video && videofd != -1) { 378 413 if (ioctl(videofd, VIDEO_FREEZE, NULL) == -1) 379 414 { 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 434 int 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 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; 384 467 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 429 478 return ret; 430 479 } … … 438 487 if(*flag == '1') 439 488 { 489 //AUDIO_SET_MUTE has no effect with new player 490 //if (ioctl(audiofd, AUDIO_SET_MUTE, 1) == -1) 440 491 if (ioctl(audiofd, AUDIO_STOP, NULL) == -1) 441 492 { 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)); 443 496 ret = cERR_LINUXDVB_ERROR; 444 497 } … … 446 499 else 447 500 { 501 //AUDIO_SET_MUTE has no effect with new player 502 //if (ioctl(audiofd, AUDIO_SET_MUTE, 0) == -1) 448 503 if (ioctl(audiofd, AUDIO_PLAY) == -1) 449 504 { 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)); 451 508 ret = cERR_LINUXDVB_ERROR; 452 509 } … … 458 515 return ret; 459 516 } 517 460 518 461 519 int LinuxDvbFlush(Context_t *context __attribute__((unused)), char * type) 462 520 { 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 463 550 return cERR_LINUXDVB_NO_ERROR; 464 551 } 465 552 553 #ifndef use_set_speed_instead_ff 554 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 #else 583 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, 900 590 }; 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 #endif 641 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 466 648 int LinuxDvbSlowMotion(Context_t *context, char * type) { 467 int 32_tret = cERR_LINUXDVB_NO_ERROR;468 469 u int8_tvideo = !strcmp("video", type);470 u int8_taudio = !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); 471 653 472 654 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 478 660 if (ioctl(videofd, VIDEO_SLOWMOTION, context->playback->SlowMotion) == -1) 479 661 { 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)); 481 664 ret = cERR_LINUXDVB_ERROR; 482 665 } … … 491 674 } 492 675 493 int LinuxDvbAVSync(Context_t *context, char * type __attribute__((unused))) {494 int 32_tret = cERR_LINUXDVB_NO_ERROR;676 int LinuxDvbAVSync(Context_t *context, char * type __attribute__((unused))) { 677 int ret = cERR_LINUXDVB_NO_ERROR; 495 678 /* konfetti: this one is dedicated to audiofd so we 496 679 * are ignoring what is given by type! I think we should … … 504 687 if (ioctl(audiofd, AUDIO_SET_AV_SYNC, 0) == -1) //context->playback->AVSync) == -1) 505 688 { 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)); 507 691 ret = cERR_LINUXDVB_ERROR; 508 692 } … … 514 698 } 515 699 516 int LinuxDvbClear(Context_t *context __attribute__((unused)), char * type)700 int LinuxDvbClear(Context_t *context __attribute__((unused)), char * type) 517 701 { 518 702 int32_t ret = cERR_LINUXDVB_NO_ERROR; … … 520 704 uint8_t audio = !strcmp("audio", type); 521 705 522 linuxdvb_printf(10, " LinuxDvbClear v%d a%d\n", video, audio);706 linuxdvb_printf(10, ">>>>>>>>>>LinuxDvbClear v%d a%d\n", video, audio); 523 707 524 708 if ( (video && videofd != -1) || (audio && audiofd != -1) ) … … 530 714 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 531 715 { 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)); 533 718 ret = cERR_LINUXDVB_ERROR; 534 719 } … … 538 723 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 539 724 { 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)); 541 727 ret = cERR_LINUXDVB_ERROR; 542 728 } … … 552 738 553 739 int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long int* pts) { 554 int 32_tret = cERR_LINUXDVB_ERROR;740 int ret = cERR_LINUXDVB_ERROR; 555 741 556 742 linuxdvb_printf(50, "\n"); 557 743 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 559 747 if (videofd > -1 && !ioctl(videofd, VIDEO_GET_PTS, (void*)&sCURRENT_PTS)) 560 748 { … … 563 751 else 564 752 { 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)); 566 754 } 567 755 … … 574 762 else 575 763 { 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)); 577 765 } 578 766 } … … 584 772 585 773 *((unsigned long long int *)pts)=(unsigned long long int)sCURRENT_PTS; 774 775 //releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); 776 586 777 return ret; 587 778 } … … 589 780 int LinuxDvbGetFrameCount(Context_t *context __attribute__((unused)), unsigned long long int* frameCount) 590 781 { 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 786 int LinuxDvbSwitch(Context_t *context, char * type) 595 787 { 596 u int8_taudio = !strcmp("audio", type);597 u int8_tvideo = !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; 599 791 600 792 linuxdvb_printf(10, "v%d a%d\n", video, audio); … … 614 806 if (ioctl(audiofd, AUDIO_STOP ,NULL) == -1) 615 807 { 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 617 811 } 618 812 619 813 if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) 620 814 { 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 622 818 } 623 819 … … 625 821 { 626 822 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 629 829 { 630 830 linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); 631 831 if (ioctl( audiofd, AUDIO_SET_BYPASS_MODE, (void*) LinuxDvbMapBypassMode(writer->caps->dvbStreamType)) == -1) 632 832 { 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)); 634 835 } 635 836 } … … 637 838 if (ioctl(audiofd, AUDIO_PLAY) == -1) 638 839 { 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)); 640 842 } 641 843 free(Encoding); … … 652 854 if (ioctl(videofd, VIDEO_STOP ,NULL) == -1) 653 855 { 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)); 655 858 } 656 859 657 860 if (ioctl(videofd, VIDEO_CLEAR_BUFFER) == -1) 658 861 { 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)); 660 864 } 661 865 … … 667 871 { 668 872 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 671 879 { 672 880 linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); 673 881 if (ioctl( videofd, VIDEO_SET_STREAMTYPE, (void*) writer->caps->dvbStreamType) == -1) 674 882 { 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)); 676 885 } 677 886 } … … 682 891 * return an error here and stop the playback mode 683 892 */ 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)); 685 895 } 686 896 free(Encoding); … … 699 909 } 700 910 701 static int Write(void *_context, void *_out)911 static int Write(void *_context, void* _out) 702 912 { 703 913 Context_t *context = (Context_t *) _context; 704 914 AudioVideoOut_t *out = (AudioVideoOut_t*) _out; 705 int 32_tret = cERR_LINUXDVB_NO_ERROR;706 int 32_tres = 0;707 u int8_tvideo = 0;708 u int8_taudio = 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; 710 920 WriterAVCallData_t call; 711 921 … … 725 935 if (video) 726 936 { 727 char * Encoding = NULL;937 char * Encoding = NULL; 728 938 context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); 729 939 … … 801 1011 call.Height = out->height; 802 1012 call.InfoFlags = out->infoFlags; 803 call.Version = 0; 804 call.WriteV = isBufferedOutput ? BufferingWriteV : writev_with_retry; 1013 call.Version = 0; // is unsingned char 805 1014 806 1015 if (writer->writeData) … … 821 1030 else if (audio) 822 1031 { 823 char * Encoding = NULL;1032 char * Encoding = NULL; 824 1033 context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); 825 1034 … … 851 1060 call.FrameScale = out->timeScale; 852 1061 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 */ 855 1063 856 1064 if (writer->writeData) … … 909 1117 free(Encoding); 910 1118 911 if (isBufferedOutput)912 LinuxDvbBuffFlush(context);913 914 1119 return ret; 915 1120 } … … 1006 1211 ret = cERR_LINUXDVB_NO_ERROR; 1007 1212 *((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 }1022 1213 break; 1023 1214 } -
titan/libeplayer3/output/output.c
r42162 r42177 530 530 } 531 531 break; 532 }533 532 case OUTPUT_GET_PROGRESSIVE: 534 533 { … … 546 545 break; 547 546 } 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 else562 {563 ret = cERR_OUTPUT_INTERNAL_ERROR;564 }565 break;566 547 } 567 548 default: -
titan/libeplayer3/output/writer/mipsel/aac.c
r42162 r42177 182 182 return 0; 183 183 } 184 185 // STB can handle only AAC LC profile186 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 }192 184 } 193 185 else // check LOAS header … … 212 204 iov[1].iov_base = call->data; 213 205 iov[1].iov_len = call->len; 214 return call->WriteV(call->fd, iov, 2);206 return writev_with_retry(call->fd, iov, 2); 215 207 } 216 208 … … 242 234 HasADTSHeader(call->data, call->len) ) 243 235 { 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]);245 236 return _writeData(_call, 0); 246 237 } … … 283 274 iov[1].iov_len = call->len; 284 275 285 return call->WriteV(call->fd, iov, 2);276 return writev_with_retry(call->fd, iov, 2); 286 277 } 287 278 … … 353 344 iov[2].iov_len = pLATMCtx->len; 354 345 355 return call->WriteV(call->fd, iov, 3);346 return writev_with_retry(call->fd, iov, 3); 356 347 } 357 348 -
titan/libeplayer3/output/writer/mipsel/ac3.c
r42162 r42177 139 139 ac3_printf(40, "PES HEADER LEN %d\n", iov[0].iov_len); 140 140 141 return call->WriteV(call->fd, iov, 2);141 return writev_with_retry(call->fd, iov, 2); 142 142 } 143 143 -
titan/libeplayer3/output/writer/mipsel/amr.c
r42162 r42177 158 158 iov[1].iov_len = call->len; 159 159 160 int len = call->WriteV(call->fd, iov, 2);160 int len = writev_with_retry(call->fd, iov, 2); 161 161 162 162 amr_printf(10, "amr_Write-< len=%d\n", len); -
titan/libeplayer3/output/writer/mipsel/divx3.c
r42162 r42177 183 183 iov[ic++].iov_len = call->len; 184 184 185 int len = call->WriteV(call->fd, iov, ic);185 int len = writev_with_retry(call->fd, iov, ic); 186 186 187 187 divx_printf(10, "xvid_Write < len=%d\n", len); -
titan/libeplayer3/output/writer/mipsel/dts.c
r42162 r42177 162 162 iov[1].iov_len = Size; 163 163 164 int32_t len = call->WriteV(call->fd, iov, 2);164 int32_t len = writev_with_retry(call->fd, iov, 2); 165 165 dts_printf(10, "< len %d\n", len); 166 166 return len; -
titan/libeplayer3/output/writer/mipsel/h263.c
r42162 r42177 135 135 iov[1].iov_base = call->data; 136 136 iov[1].iov_len = call->len; 137 len = call->WriteV(call->fd, iov, 2);137 len = writev_with_retry(call->fd, iov, 2); 138 138 139 139 h263_printf(10, "< len %d\n", len); -
titan/libeplayer3/output/writer/mipsel/h264.c
r42162 r42177 56 56 /* Makros/Constants */ 57 57 /* ***************************** */ 58 #define H264_SILENT59 58 //#define H264_DEBUG 60 59 #ifdef H264_DEBUG … … 89 88 static unsigned int CodecDataLen = 0; 90 89 static int avc3 = 0; 91 static int sps_pps_in_stream = 0;92 90 /* ***************************** */ 93 91 /* Prototypes */ … … 301 299 initialHeader = 1; 302 300 avc3 = 0; 303 sps_pps_in_stream = 0;304 301 return 0; 305 302 } … … 347 344 (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))) 348 345 { 349 uint32_t i = 0;350 uint8_t InsertPrivData = !sps_pps_in_stream;351 346 uint32_t PacketLength = 0; 352 347 uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE; 348 353 349 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) 366 352 { 367 353 initialHeader = 0; … … 370 356 PacketLength += call->private_size; 371 357 } 358 359 iov[ic].iov_base = ""; 360 iov[ic++].iov_len = 1; 372 361 373 362 iov[ic].iov_base = call->data; … … 375 364 PacketLength += call->len; 376 365 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) 377 373 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode); 378 374 379 return call->WriteV(call->fd, iov, ic);375 return writev_with_retry(call->fd, iov, ic); 380 376 } 381 377 else if (!call->private_data || call->private_size < 7 || 1 != call->private_data[0]) … … 390 386 iov[ic++].iov_base = PesHeader; 391 387 392 if ( !avc3)388 if (initialHeader) 393 389 { 394 390 if (CodecData) … … 462 458 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); 463 459 464 len = call->WriteV(call->fd, iov, ic);460 len = writev_with_retry(call->fd, iov, ic); 465 461 PacketLength += iov[0].iov_len; 466 462 if (PacketLength != len) -
titan/libeplayer3/output/writer/mipsel/h265.c
r42162 r42177 56 56 /* Makros/Constants */ 57 57 /* ***************************** */ 58 #define H264_SILENT59 58 //#define H265_DEBUG 60 59 #ifdef H265_DEBUG … … 235 234 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode); 236 235 237 return call->WriteV(call->fd, iov, ic);236 return writev_with_retry(call->fd, iov, ic); 238 237 } 239 238 … … 304 303 iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); 305 304 306 len = call->WriteV(call->fd, iov, ic);305 len = writev_with_retry(call->fd, iov, ic); 307 306 PacketLength += iov[0].iov_len; 308 307 if (PacketLength != len) -
titan/libeplayer3/output/writer/mipsel/lpcm.c
r42162 r42177 257 257 iov[1].iov_base = frame; 258 258 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); 260 260 } 261 261 -
titan/libeplayer3/output/writer/mipsel/mp3.c
r42162 r42177 134 134 iov[1].iov_len = call->len; 135 135 136 int len = call->WriteV(call->fd, iov, 2);136 int len = writev_with_retry(call->fd, iov, 2); 137 137 138 138 mp3_printf(10, "mp3_Write-< len=%d\n", len); -
titan/libeplayer3/output/writer/mipsel/mpeg2.c
r42162 r42177 138 138 iov[1].iov_len = PacketLength; 139 139 140 ssize_t l = call->WriteV(call->fd, iov, 2);140 ssize_t l = writev_with_retry(call->fd, iov, 2); 141 141 if (l < 0) { 142 142 len = l; -
titan/libeplayer3/output/writer/mipsel/mpeg4.c
r42162 r42177 134 134 } 135 135 136 struct iovec iov[ 3];136 struct iovec iov[2]; 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 = call->WriteV(call->fd, iov, ic);150 int len = writev_with_retry(call->fd, iov, ic); 151 151 152 152 mpeg4_printf(10, "xvid_Write < len=%d\n", len); -
titan/libeplayer3/output/writer/mipsel/pcm.c
r42162 r42177 284 284 iov[1].iov_base = fixed_buffer; 285 285 iov[1].iov_len = fixed_buffersize; 286 call->WriteV(call->fd, iov, 2);286 writev_with_retry(call->fd, iov, 2); 287 287 fixed_buffertimestamp += fixed_bufferduration; 288 288 289 289 int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT | 290 290 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); 292 292 close(g_fd_dump); 293 293 } -
titan/libeplayer3/output/writer/mipsel/vc1.c
r42162 r42177 190 190 } 191 191 192 return call->WriteV(call->fd, iov, ic);192 return writev_with_retry(call->fd, iov, ic); 193 193 } 194 194 -
titan/libeplayer3/output/writer/mipsel/vp.c
r42162 r42177 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 call->WriteV(call->fd, iov, 2);147 return writev_with_retry(call->fd, iov, 2); 148 148 } 149 149 -
titan/libeplayer3/output/writer/mipsel/wma.c
r42162 r42177 173 173 iov[1].iov_len = call->len; 174 174 175 return call->WriteV(call->fd, iov, 2);175 return writev_with_retry(call->fd, iov, 2); 176 176 } 177 177 -
titan/libeplayer3/output/writer/mipsel/wmv.c
r42162 r42177 197 197 } 198 198 199 return call->WriteV(call->fd, iov, ic);199 return writev_with_retry(call->fd, iov, ic); 200 200 } 201 201 -
titan/libeplayer3/output/writer/mipsel/writer.c
r42162 r42177 29 29 #include "misc.h" 30 30 #include "writer.h" 31 #include "common.h"32 31 33 32 /* ***************************** */ … … 99 98 /* Functions */ 100 99 /* ***************************** */ 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 buffers126 * will be filled to full unfortunately, in such case after resume127 * 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 immediately130 * 2. even if fd is not set exit from select after 0,1s131 * (it seems that second workaround is not needed)132 */133 //tv.tv_sec = 0;134 //tv.tv_usec = 100000; // 100ms135 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; // 10ms181 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 194 100 ssize_t write_with_retry(int fd, const void *buf, size_t size) 195 101 { -
titan/libeplayer3/output/writer/sh4/aac.c
r42162 r42177 181 181 return 0; 182 182 } 183 184 // STB can handle only AAC LC profile185 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 }191 183 } 192 184 else // check LOAS header -
titan/libeplayer3/output/writer/sh4/h264.c
r42162 r42177 53 53 /* Makros/Constants */ 54 54 /* ***************************** */ 55 //#define H264_DEBUG 56 55 57 #ifdef SAM_WITH_DEBUG 56 58 #define H264_DEBUG … … 100 102 static uint32_t NalLengthBytes = 1; 101 103 static int avc3 = 0; 102 static int sps_pps_in_stream = 0;103 104 /* ***************************** */ 104 105 /* Prototypes */ … … 259 260 (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))) 260 261 { 261 uint32_t i = 0;262 uint8_t InsertPrivData = !sps_pps_in_stream;263 262 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 265 265 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) 278 268 { 279 269 initialHeader = 0; … … 306 296 } 307 297 308 if ( !avc3)298 if (initialHeader) 309 299 { 310 300 uint8_t *private_data = call->private_data; -
titan/libeplayer3/playback/playback.c
r42162 r42177 58 58 #define cMaxSpeed_fr -320 /* fixme: revise */ 59 59 60 #define MAX_PLAYBACK_DIE_NOW_CALLBACKS 1061 62 60 /* ***************************** */ 63 61 /* Varaibles */ … … 70 68 static int32_t PlaybackTerminate(Context_t *context); 71 69 72 static int8_t dieNow = 0;73 static PlaybackDieNowCallback playbackDieNowCallbacks[MAX_PLAYBACK_DIE_NOW_CALLBACKS] = {NULL};74 75 70 /* ***************************** */ 76 71 /* MISC Functions */ … … 78 73 int8_t PlaybackDieNow(int8_t val) 79 74 { 80 if(val && dieNow == 0)81 {82 uint32_t i = 0;75 static int8_t dieNow = 0; 76 if(val) 77 { 83 78 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 }93 79 } 94 80 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;121 81 } 122 82
Note: See TracChangeset
for help on using the changeset viewer.