[Draft] demux/mkv: implement LogMsg command
Implement LogMsg command for chapter_codedc.
The chapter.xml file will contain the command in ChapterProcessCommand section. VLC, upon processing it, will debug log the argument passed.
Merge request reports
Activity
Here is the chapter file source used to test this command:
<?xml version="1.0"?> <!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> --> <Chapters> <EditionEntry> <EditionFlagOrdered>1</EditionFlagOrdered> <EditionUID>10557460986751345252</EditionUID> <ChapterAtom> <ChapterProcess> <ChapterProcessCodecID>0</ChapterProcessCodecID> <ChapterProcessCommand> <ChapterProcessTime>2</ChapterProcessTime> <ChapterProcessData format="ascii">LogMsg("HelloWorld");</ChapterProcessData> </ChapterProcessCommand> </ChapterProcess> <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart> <ChapterTimeEnd>00:00:02.000000000</ChapterTimeEnd> <ChapterUID>5194952154627880090</ChapterUID> <ChapterDisplay> <ChapterString>Chapter 01</ChapterString> <ChapterLanguage>eng</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterProcess> <ChapterProcessCodecID>0</ChapterProcessCodecID> <ChapterProcessCommand> <ChapterProcessTime>2</ChapterProcessTime> <ChapterProcessData format="ascii">GotoAndPlay(8931792216749359896);</ChapterProcessData> </ChapterProcessCommand> </ChapterProcess> <ChapterTimeStart>00:00:02.000000000</ChapterTimeStart> <ChapterTimeEnd>00:00:04.000000000</ChapterTimeEnd> <ChapterUID>3537150726504939576</ChapterUID> <ChapterDisplay> <ChapterString>Chapter 02</ChapterString> <ChapterLanguage>eng</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterTimeStart>00:02:10.000000000</ChapterTimeStart> <ChapterTimeEnd>00:03:15.000000000</ChapterTimeEnd> <ChapterUID>3381520875822683357</ChapterUID> <ChapterDisplay> <ChapterString>Chapter 03</ChapterString> <ChapterLanguage>eng</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterTimeStart>00:03:15.000000000</ChapterTimeStart> <ChapterTimeEnd>00:04:20.000000000</ChapterTimeEnd> <ChapterUID>8931792216749359896</ChapterUID> <ChapterDisplay> <ChapterString>Chapter 04</ChapterString> <ChapterLanguage>eng</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterTimeStart>00:04:20.000000000</ChapterTimeStart> <ChapterTimeEnd>00:05:25.000000000</ChapterTimeEnd> <ChapterUID>14925502364269421373</ChapterUID> <ChapterDisplay> <ChapterString>Chapter 05</ChapterString> <ChapterLanguage>eng</ChapterLanguage> </ChapterDisplay> </ChapterAtom> </EditionEntry> </Chapters>
689 bool matroska_script_interpretor_c::Interpret( const binary * p_command, size_t i_size ) 690 691 bool matroska_script_interpretor_c::_execute_LogMsg(std::string arg) 690 692 { 691 bool b_result = false; 693 msg_Dbg(&sys.demuxer, "%s\n", arg.c_str()); 694 return true; 695 } 692 696 693 std::string sz_command( reinterpret_cast<const char*> (p_command), i_size ); 697 bool matroska_script_interpretor_c::_execute_GotoAndPlay(std::string arg) 698 { 699 bool b_result = false; 700 int64_t i_chapter_uid = atoll( arg.c_str() ); 701 702 virtual_segment_c *p_vsegment; changed this line in version 2 of the diff
727 msg_Dbg( &sys.demuxer, "Chapter %" PRId64 " not found", i_chapter_uid); 728 else 729 { 730 if ( !p_vchapter->EnterAndLeave( sys.p_current_vsegment->CurrentChapter() ) ) 731 p_vsegment->Seek( sys.demuxer, p_vchapter->i_mk_virtual_start_time, p_vchapter ); 732 b_result = true; 733 } 734 752 } 735 753 736 754 return b_result; 737 755 } 738 756 757 std::string matroska_script_interpretor_c::_extract_command_name(std::string sz_command) 758 { 759 size_t i = 0; 760 for (i = 0; i<sz_command.size(); i++) changed this line in version 2 of the diff
718 743 } 719 744 720 745 std::string st = sz_command.substr( i+1, j-i-1 ); 721 int64_t i_chapter_uid = atoll( st.c_str() ); 722 746 723 virtual_segment_c *p_vsegment; 724 virtual_chapter_c *p_vchapter = sys.FindChapter( i_chapter_uid, p_vsegment ); 747 if (compare_command.compare(CMD_MS_GOTO_AND_PLAY) == 0) I understand that it should be something like:
commands = { "GotoAndPlay": exec_gotoAndPlay, "LogMsg": exec_logMsg, "AddChoice": exec_AddChoice }
So that we can use it like this:
commands[InputCommandString](args);
Edited by Khalid Masum
683 683 } 684 684 685 685 const std::string matroska_script_interpretor_c::CMD_MS_GOTO_AND_PLAY = "GotoAndPlay"; 686 const std::string matroska_script_interpretor_c::CMD_MS_LOG_MSG = "LogMsg"; You're right: https://en.cppreference.com/w/cpp/string/basic_string/basic_string Nevermind then.
756 757 757 758 std::string matroska_script_interpretor_c::_extract_command_name(std::string sz_command) 758 759 { 759 size_t i = 0; 760 for (i = 0; i<sz_command.size(); i++) 761 { 762 if (sz_command[i] == '(') 763 break; 764 } 760 size_t parenthesis_position= 0; 761 parenthesis_position= strchr(sz_command.c_str(), '(') - sz_command.c_str(); changed this line in version 3 of the diff
265 265 266 266 class matroska_script_interpretor_c 267 267 { 268 private: 269 bool _interpret_by_command( std::string sz_command, std::string compare_command ); 270 std::string _extract_command_name( std::string sz_command); 271 272 bool _execute_GotoAndPlay(std::string arg); changed this line in version 6 of the diff
683 683 } 684 684 685 685 const std::string matroska_script_interpretor_c::CMD_MS_GOTO_AND_PLAY = "GotoAndPlay"; 686 const std::string matroska_script_interpretor_c::CMD_MS_LOG_MSG = "LogMsg"; 686 687 687 688 // see http://www.matroska.org/technical/specs/chapters/index.html#mscript BTW you may update this link to https://datatracker.ietf.org/doc/draft-ietf-cellar-chapter-codecs/
That's where the up to date document is. That's also where I will be adding new documentation. For now I'm adding things in this WIP branch: https://github.com/robUx4/matroska-specification/tree/script_choice
Got it. Will change the link.
Thanks! I shall check out the WIP branch. I will make some comments as well if that is okay?
Edited by Khalid Masum