home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Submit: Bug Reports
[MP2-819] MP2 Server crashes on ATSC OTA channel scan
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mm1352000" data-source="post: 1265087" data-attributes="member: 82144"><p>[USER=48495]@morpheus_xx[/USER] </p><p>I've had a quick look. In my opinion, the issue isn't directly caused by the unsupported compression/encoding scheme. Rather, it is caused by the fact that the channel's extended name has more than one segment.</p><ol> <li data-xf-list-type="ol">DecodeMultipleStrings() is not producing the correct output. Instead of producing <numberStrings> strings in <strings>, it is putting all the segments from all the strings directly in <strings>. In other words, for this particular example, it is producing 9 strings (which is the number of segments in string 0) instead of 1.</li> <li data-xf-list-type="ol"><a href="https://github.com/MediaPortal/MediaPortal-1/blob/master/DirectShowFilters/TsWriter/source/LvctParser.cpp#L217-L257" target="_blank">The loop</a> after DecodeMultipleStrings() is not combining names correctly. Intention is to combine the short name with the first extended name that is not the same as the short name, in the format "<extended name> (<short name>)".</li> </ol><p>Fixing point (1) would require fixing DecodeMultipleStrings(). You could try this code:</p><p>[code]</p><p>void CLvctParser::DecodeMultipleStrings(byte* b, int length, vector<char*>* strings)</p><p>{</p><p> if (length < 1)</p><p> {</p><p> LogDebug("LvctParser: invalid multiple strings structure length = %d", length);</p><p> return;</p><p> }</p><p> try</p><p> {</p><p> int numberStrings = b[0];</p><p></p><p> //LogDebug("LvctParser: parse multiple strings, number of strings = %d", numberStrings);</p><p> int pointer = 1;</p><p> for (int i = 0; i < numberStrings && pointer + 3 < length; i++)</p><p> {</p><p> unsigned int iso639LanguageCode = b[pointer] + (b[pointer + 1] << 8) + (b[pointer + 2] << 16);</p><p> pointer += 3;</p><p> int numberSegments = b[pointer++];</p><p> //LogDebug("LvctParser: string %d, number of segments = %d", i, numberSegments);</p><p></p><p> vector<char*> segments;</p><p> int segmentCharCount = 0;</p><p> for (int j = 0; j < numberSegments && pointer + 2 < length; j++)</p><p> {</p><p> int compressionType = b[pointer++];</p><p> int mode = b[pointer++];</p><p> int numberBytes = b[pointer++];</p><p> //LogDebug("LvctParser: segment %d, compression type = 0x%x, mode = 0x%x, number of bytes = %d", j, compressionType, mode, numberBytes);</p><p> if (pointer + numberBytes > length)</p><p> {</p><p> LogDebug("LvctParser: invalid string length %d in multiple string structure, pointer = %d, number of bytes = %d, structure length = %d", pointer, numberBytes, length);</p><p> return;</p><p> }</p><p></p><p> char* segment = NULL;</p><p> DecodeString(&b[pointer], compressionType, mode, numberBytes, &segment);</p><p> if (segment != NULL)</p><p> {</p><p> segments.push_back(segment);</p><p> segmentCharCount += strlen(segment);</p><p> }</p><p></p><p> pointer += numberBytes;</p><p> }</p><p></p><p> // combine the segments to produce the final string</p><p> if (segments.size() == 0)</p><p> {</p><p> continue;</p><p> }</p><p> if (segments.size() == 1)</p><p> {</p><p> strings->push_back(segments[0]);</p><p> continue;</p><p> }</p><p></p><p> char* string = new char[segmentCharCount + 1];</p><p> if (string == NULL)</p><p> {</p><p> LogDebug("LvctParser: failed to allocate %d bytes in DecodeMultipleStrings()", segmentCharCount + 1);</p><p> continue;</p><p> }</p><p></p><p> string[0] = 0; // start with an empty string</p><p> for (vector<char*>::iterator it = segments.begin(); it != segments.end(); it++)</p><p> {</p><p> strcat(string, *it);</p><p> delete[] *it;</p><p> }</p><p> strings->push_back(string);</p><p> }</p><p> }</p><p> catch (...)</p><p> {</p><p> LogDebug("LvctParser: unhandled exception in DecodeMultipleStrings()");</p><p> }</p><p>}</p><p>[/code]</p><p></p><p>Fixing point (2) would require changing <a href="https://github.com/MediaPortal/MediaPortal-1/blob/master/DirectShowFilters/TsWriter/source/LvctParser.cpp#L223-L257" target="_blank">the loop in OnNewSection()</a>. You could try this code:</p><p>[code]</p><p> for (size_t i = 0; i < extendedNames.size(); i++)</p><p> {</p><p> int extendedNameLength = strlen(extendedNames[i]);</p><p> if (extendedNameLength == shortNameLength && strcmp(name, extendedNames[i]) == 0)</p><p> {</p><p> continue;</p><p> }</p><p> int nameBufferSize = 0;</p><p> if (name != NULL)</p><p> {</p><p> nameBufferSize += strlen(" ()") + shortNameLength;</p><p> }</p><p> nameBufferSize += extendedNameLength + 1; // + 1 for NULL termination</p><p> char* newName = new char[nameBufferSize];</p><p> if (newName == NULL)</p><p> {</p><p> LogDebug("LvctParser: failed to allocate %d bytes for the extended name", nameBufferSize);</p><p> continue;</p><p> }</p><p> strcpy(newName, extendedNames[i]);</p><p> if (name != NULL)</p><p> {</p><p> strcat(newName, " (");</p><p> strcat(newName, name);</p><p> strcat(newName, ")");</p><p> delete[] name;</p><p> }</p><p> name = newName;</p><p> break;</p><p> }</p><p> for (vector<char*>::iterator it = extendedNames.begin(); it != extendedNames.end(); it++)</p><p> {</p><p> delete[] *it;</p><p> }</p><p>[/code]</p><p></p><p></p><p>Please note:</p><ol> <li data-xf-list-type="ol">The above code excerpts are untested. They may have syntax and/or memory management (ie. memory access violation or leak) errors.</li> <li data-xf-list-type="ol">The code for point 1 does <strong>not </strong>add support for compression type 0 mode 0x20.</li> <li data-xf-list-type="ol">My TVE 3.5 TsWriter code is not affected by this issue, and has support for compression type 0 mode 0x20.</li> </ol></blockquote><p></p>
[QUOTE="mm1352000, post: 1265087, member: 82144"] [USER=48495]@morpheus_xx[/USER] I've had a quick look. In my opinion, the issue isn't directly caused by the unsupported compression/encoding scheme. Rather, it is caused by the fact that the channel's extended name has more than one segment. [LIST=1] [*]DecodeMultipleStrings() is not producing the correct output. Instead of producing <numberStrings> strings in <strings>, it is putting all the segments from all the strings directly in <strings>. In other words, for this particular example, it is producing 9 strings (which is the number of segments in string 0) instead of 1. [*][URL='https://github.com/MediaPortal/MediaPortal-1/blob/master/DirectShowFilters/TsWriter/source/LvctParser.cpp#L217-L257']The loop[/URL] after DecodeMultipleStrings() is not combining names correctly. Intention is to combine the short name with the first extended name that is not the same as the short name, in the format "<extended name> (<short name>)". [/LIST] Fixing point (1) would require fixing DecodeMultipleStrings(). You could try this code: [code] void CLvctParser::DecodeMultipleStrings(byte* b, int length, vector<char*>* strings) { if (length < 1) { LogDebug("LvctParser: invalid multiple strings structure length = %d", length); return; } try { int numberStrings = b[0]; //LogDebug("LvctParser: parse multiple strings, number of strings = %d", numberStrings); int pointer = 1; for (int i = 0; i < numberStrings && pointer + 3 < length; i++) { unsigned int iso639LanguageCode = b[pointer] + (b[pointer + 1] << 8) + (b[pointer + 2] << 16); pointer += 3; int numberSegments = b[pointer++]; //LogDebug("LvctParser: string %d, number of segments = %d", i, numberSegments); vector<char*> segments; int segmentCharCount = 0; for (int j = 0; j < numberSegments && pointer + 2 < length; j++) { int compressionType = b[pointer++]; int mode = b[pointer++]; int numberBytes = b[pointer++]; //LogDebug("LvctParser: segment %d, compression type = 0x%x, mode = 0x%x, number of bytes = %d", j, compressionType, mode, numberBytes); if (pointer + numberBytes > length) { LogDebug("LvctParser: invalid string length %d in multiple string structure, pointer = %d, number of bytes = %d, structure length = %d", pointer, numberBytes, length); return; } char* segment = NULL; DecodeString(&b[pointer], compressionType, mode, numberBytes, &segment); if (segment != NULL) { segments.push_back(segment); segmentCharCount += strlen(segment); } pointer += numberBytes; } // combine the segments to produce the final string if (segments.size() == 0) { continue; } if (segments.size() == 1) { strings->push_back(segments[0]); continue; } char* string = new char[segmentCharCount + 1]; if (string == NULL) { LogDebug("LvctParser: failed to allocate %d bytes in DecodeMultipleStrings()", segmentCharCount + 1); continue; } string[0] = 0; // start with an empty string for (vector<char*>::iterator it = segments.begin(); it != segments.end(); it++) { strcat(string, *it); delete[] *it; } strings->push_back(string); } } catch (...) { LogDebug("LvctParser: unhandled exception in DecodeMultipleStrings()"); } } [/code] Fixing point (2) would require changing [URL='https://github.com/MediaPortal/MediaPortal-1/blob/master/DirectShowFilters/TsWriter/source/LvctParser.cpp#L223-L257']the loop in OnNewSection()[/URL]. You could try this code: [code] for (size_t i = 0; i < extendedNames.size(); i++) { int extendedNameLength = strlen(extendedNames[i]); if (extendedNameLength == shortNameLength && strcmp(name, extendedNames[i]) == 0) { continue; } int nameBufferSize = 0; if (name != NULL) { nameBufferSize += strlen(" ()") + shortNameLength; } nameBufferSize += extendedNameLength + 1; // + 1 for NULL termination char* newName = new char[nameBufferSize]; if (newName == NULL) { LogDebug("LvctParser: failed to allocate %d bytes for the extended name", nameBufferSize); continue; } strcpy(newName, extendedNames[i]); if (name != NULL) { strcat(newName, " ("); strcat(newName, name); strcat(newName, ")"); delete[] name; } name = newName; break; } for (vector<char*>::iterator it = extendedNames.begin(); it != extendedNames.end(); it++) { delete[] *it; } [/code] Please note: [LIST=1] [*]The above code excerpts are untested. They may have syntax and/or memory management (ie. memory access violation or leak) errors. [*]The code for point 1 does [B]not [/B]add support for compression type 0 mode 0x20. [*]My TVE 3.5 TsWriter code is not affected by this issue, and has support for compression type 0 mode 0x20. [/LIST] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Submit: Bug Reports
[MP2-819] MP2 Server crashes on ATSC OTA channel scan
Contact us
RSS
Top
Bottom