Skip to content
Snippets Groups Projects

[Draft] demux/mkv: implement LogMsg command

Open Khalid Masum requested to merge hello-mkvmsglog into master
6 unresolved threads

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.

Edited by Khalid Masum

Merge request reports

Checking pipeline status.

Ready to merge by members who can write to the target branch.
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Khalid Masum changed the description

    changed the description

  • 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>
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on an outdated change in commit 66f88ef8
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;
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on an outdated change in commit 66f88ef8
  • 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++)
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on commit 66f88ef8
  • 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)
    • We should probably hardcode a table with an association: command name string <-> static method to call.

    • I agree, current way to do this is ugly.

      Should I use DVD commands in dvd_command_interpretor_c as an example to do this?

    • The DVD code also doesn't have a table matching a CMD_DVD_xxx to a function to call..

    • I am a bit confused about how the table should be created. It would be great if you could refer to one example.

    • 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
    • That's right. I'm not sure how JS/ECMAScript is usually bound to a DOM, but that's probably something like that (plus defining the parameters for each function).

    • Please register or sign in to reply
  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on commit 66f88ef8
  • 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";
  • Good job. You got how the text we put in the MKV file (via muxing the chapter file) ends up calling code in VLC.

  • Khalid Masum added 1 commit

    added 1 commit

    • 4b17b249 - demux/mkv: implement LogMsg command

    Compare with previous version

  • 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();
  • Khalid Masum added 1 commit

    added 1 commit

    • 96f66fc3 - demux/mkv: implement LogMsg command

    Compare with previous version

  • Khalid Masum added 1 commit

    added 1 commit

    • 8e85d082 - demux/mkv: implement LogMsg command

    Compare with previous version

  • Khalid Masum added 1 commit

    added 1 commit

    • b978e9e3 - demux/mkv: implement LogMsg command

    Compare with previous version

  • 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);
  • Khalid Masum added 1 commit

    added 1 commit

    • 6e26771a - demux/mkv: implement LogMsg command

    Compare with previous version

  • Steve Lhomme
    Steve Lhomme @robUx4 started a thread on commit 6e26771a
  • 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
    Please register or sign in to reply
    Loading