Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/apps/mplayerc/Mpeg2SectionData.cpp')
-rw-r--r--src/apps/mplayerc/Mpeg2SectionData.cpp171
1 files changed, 170 insertions, 1 deletions
diff --git a/src/apps/mplayerc/Mpeg2SectionData.cpp b/src/apps/mplayerc/Mpeg2SectionData.cpp
index 69e81f483..26f178a72 100644
--- a/src/apps/mplayerc/Mpeg2SectionData.cpp
+++ b/src/apps/mplayerc/Mpeg2SectionData.cpp
@@ -170,10 +170,11 @@ HRESULT CMpeg2DataParser::ParseSDT(ULONG ulFreq)
Channel.SetSID (gb.BitRead(16)); // service_id uimsbf
gb.BitRead(6); // reserved_future_use bslbf
gb.BitRead(1); // EIT_schedule_flag bslbf
- gb.BitRead(1); // EIT_present_following_flag bslbf
+ Channel.SetNowNextFlag (gb.BitRead(1)); // EIT_present_following_flag bslbf
gb.BitRead(3); // running_status uimsbf
Channel.SetEncrypted (gb.BitRead(1)); // free_CA_mode bslbf
+ // Descriptors:
BeginEnumDescriptors(gb, nType, nLength)
{
switch (nType)
@@ -322,6 +323,174 @@ HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
}
+HRESULT CMpeg2DataParser::SetTime(CGolombBuffer& gb, PresentFollowing &NowNext)
+{
+ char DescBuffer[10];
+ time_t tTime1 ,tTime2;
+ tm tmTime1;
+ tm* ptmTime;
+ long nDuration;
+ long timezone;
+ int daylight;
+
+ // init tm structures
+ time( &tTime1 );
+ tmTime1 = *localtime( &tTime1 );
+ _tzset();
+ _get_timezone(&timezone);
+ if (_get_daylight(&daylight))
+ timezone -= daylight * 3600;
+
+ // Start time:
+ tmTime1.tm_hour = gb.BitRead(4)*10;
+ tmTime1.tm_hour += gb.BitRead(4);
+ tmTime1.tm_min = gb.BitRead(4)*10;
+ tmTime1.tm_min += gb.BitRead(4);
+ tmTime1.tm_sec = gb.BitRead(4)*10;
+ tmTime1.tm_sec += gb.BitRead(4);
+ tTime1 = mktime(&tmTime1) - timezone;
+ ptmTime = localtime(&tTime1);
+ tTime1 = mktime(ptmTime);
+ strftime (DescBuffer,6,"%H:%M",ptmTime);
+ DescBuffer[6] = 0;
+ NowNext.StartTime = static_cast<CString> (DescBuffer);
+
+ // Duration:
+ nDuration = 36000*gb.BitRead(4);
+ nDuration += 3600*gb.BitRead(4);
+ nDuration += 600*gb.BitRead(4);
+ nDuration += 60*gb.BitRead(4);
+ nDuration += 10*gb.BitRead(4);
+ nDuration += gb.BitRead(4);
+
+ tTime2 = tTime1 + nDuration;
+ ptmTime = localtime(&tTime2);
+ strftime (DescBuffer,6,"%H:%M",ptmTime);
+ DescBuffer[6] = 0;
+ NowNext.Duration = static_cast<CString> (DescBuffer);
+
+ return S_OK;
+}
+
+HRESULT CMpeg2DataParser::ParseEIT(ULONG ulSID, PresentFollowing &NowNext)
+{
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD nTotal;
+ WORD ulGetSID;
+ EventInformationSection InfoEvent;
+ int nLen;
+ int descriptorNumber;
+ int nbItems;
+ CString itemDesc, itemText;
+ CString text;
+
+ do
+ {
+ CheckNoLog (m_pData->GetSection (PID_EIT, SI_EIT_act, NULL, 5000, &pSectionList));
+
+ CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
+ CGolombBuffer gb ((BYTE*)data, dwLength);
+
+ InfoEvent.TableID = gb.BitRead(8);
+ InfoEvent.SectionSyntaxIndicator = gb.BitRead(1);
+ gb.BitRead(3);
+ InfoEvent.SectionLength = gb.BitRead(12);
+ ulGetSID = gb.BitRead(8);
+ ulGetSID += 0x100 * gb.BitRead(8);
+ InfoEvent.ServiceId = ulGetSID; // This is really strange, ServiceID should be uimsbf ???
+ gb.BitRead(2);
+ InfoEvent.VersionNumber = gb.BitRead(5);
+ InfoEvent.CurrentNextIndicator = gb.BitRead(1);
+
+ InfoEvent.SectionNumber = gb.BitRead(8);
+ InfoEvent.LastSectionNumber = gb.BitRead(8);
+ InfoEvent.TransportStreamID = gb.BitRead(16);
+ InfoEvent.OriginalNetworkID = gb.BitRead(16);
+ InfoEvent.SegmentLastSectionNumber = gb.BitRead(8);
+ InfoEvent.LastTableID = gb.BitRead(8);
+
+ // Info event
+ InfoEvent.EventID = gb.BitRead(16);
+ InfoEvent.StartDate = gb.BitRead(16);
+ SetTime(gb, NowNext);
+
+ InfoEvent.RunninStatus = gb.BitRead(3);
+ InfoEvent.FreeCAMode = gb.BitRead(1);
+
+ NowNext.ExtendedDescriptorsItems.RemoveAll();
+ NowNext.ExtendedDescriptorsTexts.RemoveAll();
+
+ if ((InfoEvent.ServiceId == ulSID) && (InfoEvent.CurrentNextIndicator == 1) && (InfoEvent.RunninStatus == 4))
+ {
+ // Descriptors:
+ BeginEnumDescriptors(gb, nType, nLength)
+ {
+ switch (nType)
+ {
+ case DT_SHORT_EVENT:
+ gb.BitRead(24); // ISO_639_language_code
+
+ nLen = gb.BitRead(8); // event_name_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ NowNext.cPresent = ConvertString(DescBuffer, nLen);
+
+ nLen = gb.BitRead(8); // text_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ NowNext.SummaryDesc = ConvertString(DescBuffer, nLen);
+ break;
+ case DT_EXTENDED_EVENT:
+ descriptorNumber = gb.BitRead(4); // descriptor_number
+ gb.BitRead(4); // last_descriptor_number
+ gb.BitRead(24); // ISO_639_language_code
+
+ nbItems = gb.BitRead(8); // length_of_items
+ for (int i=0; i<nbItems; i++)
+ {
+ nLen = gb.BitRead(8); // item_description_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemDesc = ConvertString(DescBuffer, nLen);
+ nLen = gb.BitRead(8); // item_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemText = ConvertString(DescBuffer, nLen);
+ NowNext.ExtendedDescriptorsItems.SetAt(itemDesc, itemText);
+ }
+
+ nLen = gb.BitRead(8); // text_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ text = ConvertString(DescBuffer, nLen);
+ if (descriptorNumber == 0) // new descriptor set
+ NowNext.ExtendedDescriptorsTexts.AddTail(text);
+ else
+ NowNext.ExtendedDescriptorsTexts.GetTail().Append(text);
+ break;
+ default:
+ SkipDescriptor (gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ }
+ m_Filter.SectionNumber++;
+ pSectionList.Release();
+ }
+ while (((InfoEvent.ServiceId != ulSID) || (InfoEvent.CurrentNextIndicator != 1) || (InfoEvent.RunninStatus != 4)) &&
+ (m_Filter.SectionNumber <= 22));
+
+ if (InfoEvent.ServiceId != ulSID)
+ {
+ NowNext.StartTime = _T("");
+ NowNext.Duration = _T("");
+ NowNext.cPresent = _T(" Info not available.");
+ NowNext.SummaryDesc = _T("");
+ NowNext.cFollowing = _T("");
+ }
+
+ return S_OK;
+}
+
HRESULT CMpeg2DataParser::ParseNIT()
{
HRESULT hr;