//--------------------------------------------------------------------------- void File_Ttml::Read_Buffer_Continue() { #if MEDIAINFO_DEMUX Demux(Buffer, Buffer_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX // Output #if MEDIAINFO_EVENTS for (; p; p=p->NextSiblingElement()) { //p if (!strcmp(p->Value(), "p")) { const char* Attribute; int64u DTS_Begin=(int64u)-1; Attribute=p->Attribute("begin"); if (Attribute) DTS_Begin=Ttml_str2timecode(Attribute); int64u DTS_End=(int64u)-1; Attribute=p->Attribute("end"); if (Attribute) DTS_End=Ttml_str2timecode(Attribute); Ztring Content; if (p->FirstChild()) Content.From_UTF8(p->FirstChild()->Value()); Frame_Count++; } } #endif MEDIAINFO_EVENTS Buffer_Offset=Buffer_Size; }
//--------------------------------------------------------------------------- void File_Ttml::Read_Buffer_Continue() { tinyxml2::XMLDocument document; if (!FileHeader_Begin_XML(document)) return; XMLElement* Root=document.FirstChildElement("tt"); if (!Root) { Reject(); return; } if (!Status[IsAccepted]) { Accept(); #if MEDIAINFO_EVENTS MuxingMode=(int8u)-1; if (StreamIDs_Size>=2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mpeg4) MuxingMode=11; //MPEG-4 #endif MEDIAINFO_EVENTS } tinyxml2::XMLElement* div=NULL; #if MEDIAINFO_EVENTS tinyxml2::XMLElement* p=NULL; #endif //MEDIAINFO_EVENTS for (XMLElement* tt_element=Root->FirstChildElement(); tt_element; tt_element=tt_element->NextSiblingElement()) { //body if (!strcmp(tt_element->Value(), "body")) { for (XMLElement* body_element=tt_element->FirstChildElement(); body_element; body_element=body_element->NextSiblingElement()) { //div if (!strcmp(body_element->Value(), "div")) { for (XMLElement* div_element=body_element->FirstChildElement(); div_element; div_element=div_element->NextSiblingElement()) { //p if (!strcmp(div_element->Value(), "p")) { div=body_element; #if MEDIAINFO_EVENTS p=div_element; #endif //MEDIAINFO_EVENTS break; } } if (div) break; } } if (div) break; } } #if MEDIAINFO_DEMUX Demux(Buffer, Buffer_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX // Output #if MEDIAINFO_EVENTS for (; p; p=p->NextSiblingElement()) { //p if (!strcmp(p->Value(), "p")) { const char* Attribute; int64u DTS_Begin=(int64u)-1; Attribute=p->Attribute("begin"); if (Attribute) DTS_Begin=Ttml_str2timecode(Attribute); int64u DTS_End=(int64u)-1; Attribute=p->Attribute("end"); if (Attribute) DTS_End=Ttml_str2timecode(Attribute); Ztring Content; if (p->FirstChild()) Content.From_UTF8(p->FirstChild()->Value()); Frame_Count++; } } #endif MEDIAINFO_EVENTS Buffer_Offset=Buffer_Size; }
//--------------------------------------------------------------------------- void File_Ttml::Read_Buffer_Continue() { tinyxml2::XMLDocument document; if (!FileHeader_Begin_XML(document)) return; XMLElement* Root=document.FirstChildElement("tt"); if (!Root) { Reject(); return; } if (!Status[IsAccepted]) { Accept(); #if MEDIAINFO_EVENTS MuxingMode=(int8u)-1; if (StreamIDs_Size>=2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mpeg4) MuxingMode=11; //MPEG-4 if (StreamIDs_Size>2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mxf) //Only if referenced MXF MuxingMode=13; //MXF #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet()) return; // Waiting for NextPacket #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } tinyxml2::XMLElement* div=NULL; #if MEDIAINFO_EVENTS tinyxml2::XMLElement* p=NULL; #endif //MEDIAINFO_EVENTS for (XMLElement* tt_element=Root->FirstChildElement(); tt_element; tt_element=tt_element->NextSiblingElement()) { //body if (!strcmp(tt_element->Value(), "body")) { for (XMLElement* body_element=tt_element->FirstChildElement(); body_element; body_element=body_element->NextSiblingElement()) { //div if (!strcmp(body_element->Value(), "div")) { for (XMLElement* div_element=body_element->FirstChildElement(); div_element; div_element=div_element->NextSiblingElement()) { //p if (!strcmp(div_element->Value(), "p")) { div=body_element; #if MEDIAINFO_EVENTS p=div_element; #endif //MEDIAINFO_EVENTS break; } } if (div) break; } } if (div) break; } } #if MEDIAINFO_DEMUX Demux(Buffer, Buffer_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX // Output #if MEDIAINFO_EVENTS for (; p; p=p->NextSiblingElement()) { //p if (!strcmp(p->Value(), "p")) { int64u DTS_Begin=(int64u)-1; const char* Attribute=p->Attribute("begin"); if (Attribute) DTS_Begin=Ttml_str2timecode(Attribute); int64u DTS_End=(int64u)-1; Attribute=p->Attribute("end"); if (Attribute) DTS_End=Ttml_str2timecode(Attribute); string ContentUtf8; XMLPrinter printer; p->Accept(&printer); ContentUtf8+=printer.CStr(); while (!ContentUtf8.empty() && (ContentUtf8[ContentUtf8.size()-1]=='\r' || ContentUtf8[ContentUtf8.size()-1]=='\n')) ContentUtf8.resize(ContentUtf8.size()-1); Ztring Content; Content.From_UTF8(ContentUtf8.c_str()); Frame_Count_NotParsedIncluded=Frame_Count; EVENT_BEGIN (Global, SimpleText, 0) //Hack: remove "p", "span", "br" Content.FindAndReplace(__T("\r"), Ztring(), 0, ZenLib::Ztring_Recursive); Content.FindAndReplace(__T("\n"), Ztring(), 0, ZenLib::Ztring_Recursive); for (;;) { size_t Span_Begin=Content.find(__T("<p")); if (Span_Begin==string::npos) break; size_t Span_End=Content.find(__T(">"), Span_Begin+5); if (Span_End==string::npos) break; size_t ShlashSpan_Begin=Content.find(__T("</p>"), Span_End+1); if (ShlashSpan_Begin==string::npos) break; Content.erase(ShlashSpan_Begin, 7); Content.erase(Span_Begin, Span_End-Span_Begin+1); } for (;;) { size_t Span_Begin=Content.find(__T("<span")); if (Span_Begin==string::npos) break; size_t Span_End=Content.find(__T(">"), Span_Begin+5); if (Span_End==string::npos) break; size_t ShlashSpan_Begin=Content.find(__T("</span>"), Span_End+1); if (ShlashSpan_Begin==string::npos) break; Content.erase(ShlashSpan_Begin, 7); Content.erase(Span_Begin, Span_End-Span_Begin+1); } Content.FindAndReplace(__T("<br>"), EOL, 0, ZenLib::Ztring_Recursive); Content.FindAndReplace(__T("<br/>"), EOL, 0, ZenLib::Ztring_Recursive); Content.FindAndReplace(__T("<br />"), EOL, 0, ZenLib::Ztring_Recursive); Event.DTS=DTS_Begin; Event.PTS=Event.DTS; Event.DUR=DTS_End-DTS_Begin; Event.Content=Content.c_str(); Event.Flags=0; Event.MuxingMode=MuxingMode; Event.Service=(int8u)Element_Code; Event.Row_Max=0; Event.Column_Max=0; Event.Row_Values=NULL; Event.Row_Attributes=NULL; EVENT_END () EVENT_BEGIN (Global, SimpleText, 0) Event.DTS=DTS_End; Event.PTS=Event.DTS; Event.DUR=0; Event.Content=__T(""); Event.Flags=0; Event.MuxingMode=MuxingMode; Event.Service=(int8u)Element_Code; Event.Row_Max=0; Event.Column_Max=0; Event.Row_Values=NULL; Event.Row_Attributes=NULL; EVENT_END () Frame_Count++; } } #endif //MEDIAINFO_EVENTS Buffer_Offset=Buffer_Size; }