Changeset 44970
- Timestamp:
- 12/08/20 20:33:22 (19 months ago)
- Location:
- titan/libeplayer3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/libeplayer3/container/container_ffmpeg.c
r44958 r44970 69 69 * std library. 70 70 */ 71 #define USE_CUSTOM_IO71 //#define USE_CUSTOM_IO 72 72 73 73 /* Error Constants */ … … 860 860 uint32_t bufferSize = 0; 861 861 context->output->Command(context, OUTPUT_GET_BUFFER_SIZE, &bufferSize); 862 ffmpeg_printf(10, " bufferSize [%u]\n", bufferSize);862 ffmpeg_printf(10, "2bufferSize [%u]\n", bufferSize); 863 863 864 864 int8_t isWaitingForFinish = 0; … … 1656 1656 PlaybackHandler_t *p = (PlaybackHandler_t *)ctx; 1657 1657 //obi 1658 return p->abortRequested || PlaybackDieNow(0);1659 //return p->abortRequested;1658 // return p->abortRequested || PlaybackDieNow(0); 1659 return p->abortRequested; 1660 1660 //obi (end) 1661 1661 } … … 2071 2071 av_dict_set(&avio_opts, "timeout", "20000000", 0); //20sec 2072 2072 //obi 2073 /* 2073 2074 2074 char* cookie = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL, *tmpstr4 = NULL, *headers = NULL, *useragent = NULL; 2075 2075 int count = 0, count1 = 0, count2 = 0, count3 = 0, i = 0, i1 = 0, i2 = 0, i3 = 0, usetslivemode = 0; … … 2224 2224 context->playback->isTSLiveMode = 1; 2225 2225 } 2226 */2227 2226 //obi (end) 2228 2227 … … 2302 2301 if(ffmpeg_buf != NULL) 2303 2302 { 2304 ffmpeg_printf(10, " buffer size=%d\n", ffmpeg_buf_size);2303 ffmpeg_printf(10, "1buffer size=%d\n", ffmpeg_buf_size); 2305 2304 2306 2305 ffmpeg_read_org = avContextTab[AVIdx]->pb->read_packet; -
titan/libeplayer3/include/output.h
r44958 r44970 29 29 OUTPUT_SET_BUFFER_SIZE, 30 30 OUTPUT_GET_BUFFER_SIZE, 31 //obi 32 OUTPUT_GET_BUFFER_STATUS, 33 //obi 31 34 } OutputCmd_t; 32 35 -
titan/libeplayer3/output/linuxdvb_buffering.c
r44958 r44970 78 78 static uint32_t maxBufferingDataSize = 0; 79 79 static uint32_t bufferingDataSize = 0; 80 80 //obi 81 static uint32_t chunkSize = 0; 82 //obi 81 83 static int videofd = -1; 82 84 static int audiofd = -1; … … 229 231 return maxBufferingDataSize; 230 232 } 231 233 //obi 234 uint32_t LinuxDvbBuffGetStatus() 235 { 236 return chunkSize; 237 } 238 //obi 232 239 int32_t LinuxDvbBuffOpen(Context_t *context, char *type, int outfd, void *mtx) 233 240 { … … 395 402 BufferingNode_t *nodePtr = NULL; 396 403 uint8_t *dataPtr = NULL; 397 uint32_t chunkSize = 0; 404 //obi 405 // uint32_t chunkSize = 0; 398 406 uint32_t i = 0; 399 407 -
titan/libeplayer3/output/linuxdvb_mipsel.c
r44958 r44970 1175 1175 break; 1176 1176 } 1177 //obi 1178 case OUTPUT_GET_BUFFER_STATUS: { 1179 ret = cERR_LINUXDVB_NO_ERROR; 1180 *((uint32_t*)argument) = LinuxDvbBuffGetStatus(); 1181 break; 1182 } 1183 //obi 1177 1184 default: 1178 1185 linuxdvb_err("ContainerCmd %d not supported!\n", command); -
titan/libeplayer3/output/output.c
r44958 r44970 544 544 break; 545 545 } 546 case OUTPUT_GET_BUFFER_SIZE: 546 //obi 547 case OUTPUT_GET_BUFFER_STATUS: 547 548 { 548 549 if (context && context->playback) … … 550 551 if (context->output->video) 551 552 { 552 return context->output->video->Command(context, OUTPUT_GET_BUFFER_S IZE, argument);553 return context->output->video->Command(context, OUTPUT_GET_BUFFER_STATUS, argument); 553 554 } 554 555 else if (context->output->audio) 555 556 { 556 return context->output->audio->Command(context, OUTPUT_GET_BUFFER_SIZE, argument); 557 } 558 } 559 else 560 { 561 ret = cERR_OUTPUT_INTERNAL_ERROR; 562 } 563 break; 564 } 557 return context->output->audio->Command(context, OUTPUT_GET_BUFFER_STATUS, argument); 558 } 559 } 560 else 561 { 562 ret = cERR_OUTPUT_INTERNAL_ERROR; 563 } 564 break; 565 } 566 //obi 565 567 default: 566 568 output_err("%s::%s OutputCmd %d not supported!\n", FILENAME, __FUNCTION__, command); -
titan/libeplayer3/output/writer/common/writer.c
r44960 r44970 26 26 #include <string.h> 27 27 #include <errno.h> 28 #include <pthread.h> 28 29 29 30 #include "misc.h" 30 31 #include "writer.h" 32 #include "common.h" 31 33 #include "debug.h" 32 #include "common.h"33 34 34 35 /* ***************************** */ 35 36 /* Makros/Constants */ 36 37 /* ***************************** */ 38 #define getDVBMutex(pmtx) do { if (pmtx) pthread_mutex_lock(pmtx);} while(false); 39 #define releaseDVBMutex(pmtx) do { if (pmtx) pthread_mutex_unlock(pmtx);} while(false); 37 40 38 41 /* ***************************** */ 39 42 /* Types */ 40 43 /* ***************************** */ 44 typedef enum { 45 DVB_STS_UNKNOWN, 46 DVB_STS_SEEK, 47 DVB_STS_PAUSE, 48 DVB_STS_EXIT 49 } DVBState_t; 41 50 42 51 /* ***************************** */ … … 44 53 /* ***************************** */ 45 54 55 static Writer_t * AvailableWriter[] = { 56 &WriterAudioAAC, 57 &WriterAudioAACLATM, 58 &WriterAudioAACPLUS, 59 &WriterAudioAC3, 60 &WriterAudioEAC3, 61 &WriterAudioMP3, 62 &WriterAudioMPEGL3, 63 &WriterAudioPCM, 64 &WriterAudioIPCM, 65 &WriterAudioLPCM, 66 &WriterAudioDTS, 67 &WriterAudioWMA, 68 &WriterAudioWMAPRO, 69 &WriterAudioOPUS, 70 &WriterAudioVORBIS, 71 72 &WriterVideoH264, 73 &WriterVideoH265, 74 &WriterVideoH263, 75 &WriterVideoMPEG4, 76 &WriterVideoMPEG2, 77 &WriterVideoMPEG1, 78 &WriterVideoVC1, 79 &WriterVideoDIVX3, 80 &WriterVideoVP6, 81 &WriterVideoVP8, 82 &WriterVideoVP9, 83 &WriterVideoFLV, 84 &WriterVideoWMV, 85 &WriterVideoMJPEG, 86 &WriterVideoRV40, 87 &WriterVideoRV30, 88 &WriterVideoAVS2, 89 NULL 90 }; 91 46 92 /* ***************************** */ 47 93 /* Prototypes */ … … 51 97 /* Functions */ 52 98 /* ***************************** */ 53 void FlushPipe(int pipefd) 54 { 55 char tmp; 56 while(1 == read(pipefd, &tmp, 1)); 57 } 58 59 ssize_t WriteExt(WriteV_t _call, int fd, void *data, size_t size) 60 { 61 struct iovec iov[1]; 62 iov[0].iov_base = data; 63 iov[0].iov_len = size; 64 return _call(fd, iov, 1); 65 } 99 ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, void *pDVBMtx, const void *buf, int size) 100 { 101 fd_set rfds; 102 fd_set wfds; 103 104 ssize_t ret; 105 int retval = -1; 106 int maxFd = pipefd > fd ? pipefd : fd; 107 struct timeval tv; 108 109 // while(size > 0 && !context->playback->isSeeking) 110 while(size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) 111 { 112 FD_ZERO(&rfds); 113 FD_ZERO(&wfds); 114 115 FD_SET(pipefd, &rfds); 116 FD_SET(fd, &wfds); 117 118 /* When we PAUSE LINUX DVB outputs buffers, then audio/video buffers 119 * will continue to be filled. Unfortunately, in such case after resume 120 * select() will never return with fd set - bug in DVB drivers? 121 * There are to workarounds possible: 122 * 1. write to pipe at resume to return from select() immediately 123 * 2. make timeout select(), limit max time spend in the select() 124 * to for example 0,1s 125 * (at now first workaround is used) 126 */ 127 //tv.tv_sec = 0; 128 //tv.tv_usec = 100000; // 100ms 129 130 retval = select(maxFd + 1, &rfds, &wfds, NULL, NULL); //&tv); 131 if (retval < 0) 132 { 133 break; 134 } 135 136 //if (retval == 0) 137 //{ 138 // //printf("RETURN FROM SELECT DUE TO TIMEOUT\n"); 139 // continue; 140 //} 141 142 if(FD_ISSET(pipefd, &rfds)) 143 { 144 FlushPipe(pipefd); 145 //printf("RETURN FROM SELECT DUE TO pipefd SET\n"); 146 continue; 147 } 148 149 if(FD_ISSET(fd, &wfds)) 150 { 151 ret = write(fd, buf, size); 152 if (ret < 0) 153 { 154 switch(errno) 155 { 156 case EINTR: 157 case EAGAIN: 158 continue; 159 default: 160 retval = -3; 161 break; 162 } 163 if (retval < 0) 164 { 165 break; 166 } 167 168 return ret; 169 } 170 else if (ret == 0) 171 { 172 // printf("This should not happen. Select return fd ready to write, but write return 0, errno [%d]\n", errno); 173 // wait 10ms before next try 174 tv.tv_sec = 0; 175 tv.tv_usec = 10000; // 10ms 176 retval = select(pipefd + 1, &rfds, NULL, NULL, &tv); 177 if (retval) 178 FlushPipe(pipefd); 179 continue; 180 } 181 182 size -= ret; 183 buf += ret; 184 } 185 } 186 return 0; 187 } 188 189 ssize_t write_with_retry(int fd, const void *buf, int size) 190 { 191 ssize_t ret; 192 int retval = 0; 193 // while(size > 0 && 0 == PlaybackDieNow(0)) 194 while(size > 0) 195 { 196 ret = write(fd, buf, size); 197 if (ret < 0) 198 { 199 switch(errno) 200 { 201 case EINTR: 202 case EAGAIN: 203 usleep(1000); 204 continue; 205 default: 206 retval = -3; 207 break; 208 } 209 if (retval < 0) 210 { 211 break; 212 } 213 } 214 215 if (ret < 0) 216 { 217 return ret; 218 } 219 220 size -= ret; 221 buf += ret; 222 223 if(size > 0) 224 { 225 if( usleep(1000) ) 226 { 227 writer_err("usleep error \n"); 228 } 229 } 230 } 231 return 0; 232 } 233 234 ssize_t writev_with_retry(int fd, const struct iovec *iov, int ic) 235 { 236 ssize_t len = 0; 237 int i = 0; 238 for(i=0; i<ic; ++i) 239 { 240 write_with_retry(fd, iov[i].iov_base, iov[i].iov_len); 241 len += iov[i].iov_len; 242 if(PlaybackDieNow(0)) 243 { 244 // return -1; 245 } 246 } 247 return len; 248 } 249 250 Writer_t* getWriter(char* encoding) 251 { 252 int i; 253 254 for (i = 0; AvailableWriter[i] != NULL; i++) 255 { 256 if (strcmp(AvailableWriter[i]->caps->textEncoding, encoding) == 0) 257 { 258 writer_printf(50, "%s: found writer \"%s\" for \"%s\"\n", __func__, AvailableWriter[i]->caps->name, encoding); 259 return AvailableWriter[i]; 260 } 261 } 262 263 writer_printf(1, "%s: no writer found for \"%s\"\n", __func__, encoding); 264 265 return NULL; 266 } 267 268 Writer_t* getDefaultVideoWriter() 269 { 270 int i; 271 272 for (i = 0; AvailableWriter[i] != NULL; i++) 273 { 274 if (strcmp(AvailableWriter[i]->caps->textEncoding, "V_MPEG2") == 0) 275 { 276 writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name); 277 return AvailableWriter[i]; 278 } 279 } 280 281 writer_printf(1, "%s: no writer found\n", __func__); 282 283 return NULL; 284 } 285 286 Writer_t* getDefaultAudioWriter() 287 { 288 int i; 289 290 for (i = 0; AvailableWriter[i] != NULL; i++) 291 { 292 if (strcmp(AvailableWriter[i]->caps->textEncoding, "A_MP3") == 0) 293 { 294 writer_printf(50, "%s: found writer \"%s\"\n", __func__, AvailableWriter[i]->caps->name); 295 return AvailableWriter[i]; 296 } 297 } 298 299 writer_printf(1, "%s: no writer found\n", __func__); 300 301 return NULL; 302 } 303 -
titan/libeplayer3/playback/playback.c
r44958 r44970 70 70 } 71 71 } 72 return 0;72 // return 0; 73 73 return dieNow; 74 74 }
Note: See TracChangeset
for help on using the changeset viewer.