| 727 | desc_list_t extract_atsc_desc(const tvct_vec_t &tvct, const cvct_vec_t &cvct, |
| 728 | uint pnum) |
| 729 | { |
| 730 | desc_list_t desc; |
| 731 | |
| 732 | vector<const VirtualChannelTable*> vct; |
| 733 | |
| 734 | for (uint i = 0; i < tvct.size(); i++) |
| 735 | vct.push_back(tvct[i]); |
| 736 | for (uint i = 0; i < cvct.size(); i++) |
| 737 | vct.push_back(cvct[i]); |
| 738 | |
| 739 | for (uint i = 0; i < tvct.size(); i++) |
| 740 | { |
| 741 | for (uint j = 0; j < vct[i]->ChannelCount(); j++) |
| 742 | { |
| 743 | if (vct[i]->ProgramNumber(j) == pnum) |
| 744 | { |
| 745 | desc_list_t ldesc = MPEGDescriptor::ParseOnlyInclude( |
| 746 | vct[i]->Descriptors(j), vct[i]->DescriptorsLength(j), |
| 747 | DescriptorID::caption_service); |
| 748 | |
| 749 | if (ldesc.size()) |
| 750 | desc.insert(desc.end(), ldesc.begin(), ldesc.end()); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | if (0 != vct[i]->GlobalDescriptorsLength()) |
| 755 | { |
| 756 | desc_list_t vdesc = MPEGDescriptor::ParseOnlyInclude( |
| 757 | vct[i]->GlobalDescriptors(), |
| 758 | vct[i]->GlobalDescriptorsLength(), |
| 759 | DescriptorID::caption_service); |
| 760 | |
| 761 | if (vdesc.size()) |
| 762 | desc.insert(desc.end(), vdesc.begin(), vdesc.end()); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | return desc; |
| 767 | } |
| 768 | |
| 783 | // If there is no caption descriptor in PMT, copy any caption |
| 784 | // descriptor found in VCT to global descriptors... |
| 785 | ATSCStreamData *sd = dynamic_cast<ATSCStreamData*>(GetStreamData()); |
| 786 | tvct_vec_t tvct; |
| 787 | cvct_vec_t cvct; |
| 788 | if (sd && !MPEGDescriptor::Find(gdesc, DescriptorID::caption_service)) |
| 789 | { |
| 790 | tvct = sd->GetAllCachedTVCTs(); |
| 791 | cvct = sd->GetAllCachedCVCTs(); |
| 792 | |
| 793 | desc_list_t vdesc = extract_atsc_desc( |
| 794 | tvct, cvct, _input_pmt->ProgramNumber()); |
| 795 | |
| 796 | if (vdesc.size()) |
| 797 | gdesc.insert(gdesc.end(), vdesc.begin(), vdesc.end()); |
| 798 | } |
| 799 | |