Mercurial > pt1.oyama
comparison src/recpt1.c @ 183:27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Mon, 05 May 2014 22:08:21 +0900 |
parents | a0bc3700a496 |
children | dc0d3addfd18 |
comparison
equal
deleted
inserted
replaced
182:13f0666bd088 | 183:27e5f99f8991 |
---|---|
201 (strcmp(tdata->sid_list, sid_list) || | 201 (strcmp(tdata->sid_list, sid_list) || |
202 strcmp(tdata->ch, channel))) { | 202 strcmp(tdata->ch, channel))) { |
203 // $BJ*M}%A%c%s%M%kJQ99;~$K$O(B splitter $B$O6/@)E*$K:F5/F0$5$;$k(B | 203 // $BJ*M}%A%c%s%M%kJQ99;~$K$O(B splitter $B$O6/@)E*$K:F5/F0$5$;$k(B |
204 pthread_mutex_lock(&tdata->splitter_mutex); | 204 pthread_mutex_lock(&tdata->splitter_mutex); |
205 split_shutdown(splitter); | 205 split_shutdown(splitter); |
206 splitter = split_startup(sid_list, NULL, NULL); | 206 splitter = split_startup(sid_list); |
207 if (splitter->sid_list == NULL) { | 207 if (splitter->sid_list == NULL) { |
208 fprintf (stderr, "reader_func() splitter RESTART FAILED.\n"); | 208 fprintf (stderr, "reader_func() splitter RESTART FAILED.\n"); |
209 tdata->splitter = NULL; | 209 tdata->splitter = NULL; |
210 pthread_mutex_unlock(&tdata->splitter_mutex); | 210 pthread_mutex_unlock(&tdata->splitter_mutex); |
211 continue; | 211 continue; |
545 int sfd = -1; | 545 int sfd = -1; |
546 pthread_t signal_thread = data->signal_thread; | 546 pthread_t signal_thread = data->signal_thread; |
547 struct sockaddr_in *addr = NULL; | 547 struct sockaddr_in *addr = NULL; |
548 BUFSZ *qbuf; | 548 BUFSZ *qbuf; |
549 ARIB_STD_B25_BUFFER *eqbuf; | 549 ARIB_STD_B25_BUFFER *eqbuf; |
550 splitbuf_t splitbuf; | 550 static splitbuf_t splitbuf; |
551 ARIB_STD_B25_BUFFER sbuf, dbuf, buf; | 551 ARIB_STD_B25_BUFFER sbuf, dbuf, buf; |
552 int code; | 552 int code; |
553 | 553 |
554 if (use_splitter) | 554 if (use_splitter) |
555 time(&data->splitter->split_start_time); | 555 time(&data->splitter->split_start_time); |
556 | 556 |
557 buf.size = 0; | 557 buf.size = 0; |
558 buf.data = NULL; | 558 buf.data = NULL; |
559 splitbuf.size = 0; | |
560 splitbuf.buffer_length = 0; | |
561 splitbuf.buffer = NULL; | |
562 | 559 |
563 if(wfd == -1) | 560 if(wfd == -1) |
564 fileless = TRUE; | 561 fileless = TRUE; |
565 | 562 |
566 if(use_udp) { | 563 if(use_udp) { |
592 buf = dbuf; | 589 buf = dbuf; |
593 } | 590 } |
594 | 591 |
595 if(use_splitter) { | 592 if(use_splitter) { |
596 pthread_mutex_lock(&data->splitter_mutex); | 593 pthread_mutex_lock(&data->splitter_mutex); |
597 splitbuf.size = 0; | 594 splitbuf.buffer_filled = 0; |
598 if(splitbuf.buffer_length < buf.size && buf.size > 0) { | 595 /* allocate split buffer */ |
596 if(splitbuf.buffer_size < buf.size && buf.size > 0) { | |
599 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); | 597 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); |
600 if(NULL == splitbuf.buffer) { | 598 if(splitbuf.buffer == NULL) { |
601 fprintf(stderr, "splitbuf.buffer realloc failed\n"); | 599 fprintf(stderr, "split buffer allocation failed\n"); |
602 use_splitter = FALSE; | 600 use_splitter = FALSE; |
603 goto fin; | 601 goto fin; |
604 } | 602 } |
605 splitbuf.buffer_length = buf.size; | |
606 } | 603 } |
607 | 604 |
608 while(buf.size) { | 605 while(buf.size) { |
609 /* $BJ,N%BP>](BPID$B$NCj=P(B */ | 606 /* $BJ,N%BP>](BPID$B$NCj=P(B */ |
610 if(data->splitter->split_select_finish != TSS_SUCCESS) { | 607 if(data->splitter->split_select_finish != TSS_SUCCESS) { |
629 break; | 626 break; |
630 } | 627 } |
631 } | 628 } |
632 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ | 629 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
633 code = split_ts(data->splitter, &buf, &splitbuf); | 630 code = split_ts(data->splitter, &buf, &splitbuf); |
634 if(code != TSS_SUCCESS) { | 631 if(code == TSS_NULL) { |
632 fprintf(stderr, "PMT reading..\n"); | |
633 } else if(code != TSS_SUCCESS) { | |
635 fprintf(stderr, "split_ts failed\n"); | 634 fprintf(stderr, "split_ts failed\n"); |
636 break; | 635 break; |
637 } | 636 } |
638 | 637 |
639 break; | 638 break; |
640 } /* while */ | 639 } /* while */ |
641 | 640 |
642 buf.size = splitbuf.size; | 641 buf.size = splitbuf.buffer_size; |
643 buf.data = splitbuf.buffer; | 642 buf.data = splitbuf.buffer; |
644 fin: | 643 fin: |
645 pthread_mutex_unlock(&data->splitter_mutex); | 644 pthread_mutex_unlock(&data->splitter_mutex); |
646 } /* if */ | 645 } /* if */ |
647 | 646 |
734 } | 733 } |
735 | 734 |
736 if(use_splitter) { | 735 if(use_splitter) { |
737 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ | 736 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
738 code = split_ts(data->splitter, &buf, &splitbuf); | 737 code = split_ts(data->splitter, &buf, &splitbuf); |
739 if(code != TSS_SUCCESS) { | 738 if(code == TSS_NULL) { |
739 data->splitter->split_select_finish = TSS_ERROR; | |
740 fprintf(stderr, "PMT reading..\n"); | |
741 } | |
742 else if(code != TSS_SUCCESS) { | |
743 fprintf(stderr, "split_ts failed\n"); | |
740 break; | 744 break; |
741 } | 745 } |
742 | |
743 buf.data = splitbuf.buffer; | 746 buf.data = splitbuf.buffer; |
744 buf.size = splitbuf.size; | 747 buf.size = splitbuf.buffer_size; |
745 } | 748 } |
746 | 749 |
747 if(!fileless && !file_err) { | 750 if(!fileless && !file_err) { |
748 wc = write(wfd, buf.data, buf.size); | 751 wc = write(wfd, buf.data, buf.size); |
749 if(wc < 0) { | 752 if(wc < 0) { |
762 } | 765 } |
763 } | 766 } |
764 if(use_splitter) { | 767 if(use_splitter) { |
765 free(splitbuf.buffer); | 768 free(splitbuf.buffer); |
766 splitbuf.buffer = NULL; | 769 splitbuf.buffer = NULL; |
767 splitbuf.buffer_length = 0; | 770 //splitbuf.buffer_length = 0; |
768 } | 771 } |
769 | 772 |
770 break; | 773 break; |
771 } | 774 } |
772 } | 775 } |
1261 use_b25 = FALSE; | 1264 use_b25 = FALSE; |
1262 } | 1265 } |
1263 } | 1266 } |
1264 /* initialize splitter */ | 1267 /* initialize splitter */ |
1265 if(use_splitter) { | 1268 if(use_splitter) { |
1266 splitter = split_startup(sid_list, es_name_prefix, start_time); | 1269 splitter = split_startup(sid_list); |
1267 if(splitter->sid_list == NULL) { | 1270 if(splitter->sid_list == NULL) { |
1268 fprintf(stderr, "Cannot start TS splitter\n"); | 1271 fprintf(stderr, "Cannot start TS splitter\n"); |
1269 return 1; | 1272 return 1; |
1270 } | 1273 } |
1271 strncpy(tdata.sid_list, sid_list, sizeof(tdata.sid_list)); | 1274 strncpy(tdata.sid_list, sid_list, sizeof(tdata.sid_list)); |