Changeset 43055c96af0ccb6b70a449eba96bb2a2327a0194

Show
Ignore:
Timestamp:
04/06/08 19:00:26 (4 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1207501226 +0200
git-parent:

[4845f3da5342643c9b2d48d6a0acb4ee3e406cbb]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1207253473 +0200
Message:

Change input item options handling in the lua http interface. Fixes normal playlist mode option handling. The VLM part most likely needs to be fixed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • share/lua/http/dialogs/input

    rd8b6a43 r43055c9  
    3333  </div> 
    3434  <div class="controls"> 
    35     <label for="input_mrl">Input (MRL)</label> 
     35    <label for="input_mrl">Input</label> 
    3636    <?vlc if current_page == "vlm" then ?> 
    3737      <input type="text" name="input_mrl" id="input_mrl" size="60" onkeypress="if( event.keyCode == 13 ) vlm_input_change();"/> 
     38    <?vlc else ?> 
     39      <input type="text" name="input_mrl" id="input_mrl" size="60" onkeypress="if( event.keyCode == 13 ) in_play();"/> 
     40    <?vlc end ?> 
     41    <div> 
     42    Options 
     43    <!-- <input type="button" value="Refresh options" onclick="refresh_input_options_list();" /> --> 
     44    <input type="button" value="Add option" onclick="add_input_option(':option=value');" /> 
     45    <div id="input_options_list"></div> 
     46    </div> 
     47    <?vlc if current_page == "vlm" then ?> 
    3848      <input type="button" value="Ok" onclick="vlm_input_change();" /> 
    3949      <input type="button" value="Cancel" onclick="hide('input');" /> 
    4050      <input type="hidden" id="input_dest" value="" /> 
    4151    <?vlc else ?> 
    42       <input type="text" name="input_mrl" id="input_mrl" size="60" onkeypress="if( event.keyCode == 13 ) in_play();"/> 
    4352      <input type="button" value="Play" onclick="in_play();" /> 
    4453      <input type="button" value="Enqueue" onclick="in_enqueue();" /> 
  • share/lua/http/dialogs/sout

    rd8b6a43 r43055c9  
    3434  </div> 
    3535  <div class="controls"> 
    36     <label for="sout_mrl">Destination (MRL)</label> 
     36    <label for="sout_mrl">Destination</label> 
    3737    <?vlc if current_page == "vlm" then ?> 
    38       <input type="text" name="sout_mrl" id="sout_mrl" size="60" onkeypress="if( event.keyCode == 13 ) vlm_output_change();"/> 
     38      <input type="text" name="sout_mrl" id="sout_mrl" size="60" onkeypress="if( event.keyCode == 13 ) vlm_output_change();" disabled="disabled" /> 
    3939      <br/> 
    4040      <input type="button" value="Ok" onclick="vlm_output_change();" /> 
     
    4242      <input type="hidden" id="sout_dest" /> 
    4343    <?vlc else ?> 
    44       <input type="text" name="sout_mrl" id="sout_mrl" size="60" onkeypress="if( event.keyCode == 13 ) save_sout();" /> 
     44      <input type="text" name="sout_mrl" id="sout_mrl" size="60" onkeypress="if( event.keyCode == 13 ) save_sout();" disabled="disabled" /> 
    4545      <br/> 
    4646      <input type="button" value="Save" onclick="save_sout();" /> 
  • share/lua/http/flash.html

    rd8b6a43 r43055c9  
    1414// <![CDATA[ 
    1515host = document.location.toString().replace( /http:\/\//, '' ).replace( /[:/].*/, '' ); 
     16input_options.push( ":sout=#transcode{vcodec=FLV1,acodec=mp3,channels=2,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8081/stream.flv}" ); 
     17input_options.push( ":no-sout-keep" ); 
    1618// ]]> 
    1719</script> 
    1820</head> 
    1921 
    20 <body onload="hide('playlist');"> 
     22<body onload="hide('playlist'); refresh_input_options_list();"> 
    2123<?vlc 
    2224current_page = "index" 
    2325dialogs("browse","main","input","playlist") ?> 
    24  
    25   <input id="sout_mrl" type="hidden" value=":sout=#transcode{vcodec=FLV1,acodec=mp3,channels=2,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8081/stream.flv} :no-sout-keep" /> 
    2626 
    2727  <div style='height: 100%; width: 100%; text-align: center;'> 
  • share/lua/http/js/functions.js

    rd8b6a43 r43055c9  
    3737var slider_dx = 0; 
    3838 
     39var input_options = new Array(); 
     40 
    3941/* findPosX() from http://www.quirksmode.rg/js/indpos.html */ 
    4042function findPosX(obj) 
     
    284286 *********************************************************************/ 
    285287/* input actions */ 
    286 function in_play(
     288function in_playenqueue( cmd
    287289{ 
    288290    var input = value('input_mrl'); 
    289     if( value('sout_mrl') != '' ) 
    290         input += ' '+value('sout_mrl'); 
    291     var url = 'requests/status.xml?command=in_play&input='+encodeURIComponent( addslashes(escapebackslashes(input)) ); 
     291    var url = 'requests/status.xml?command=in_'+cmd+'&input='+encodeURIComponent( addslashes(escapebackslashes(input)) ); 
     292    for( i in input_options ) 
     293        if( input_options[i] != ':option=value' ) 
     294            url += '&option='+encodeURIComponent( addslashes(escapebackslashes(input_options[i]) )); 
    292295    loadXMLDoc( url, parse_status ); 
    293296    setTimeout( 'update_playlist()', 1000 ); 
    294297} 
     298 
     299function in_play() 
     300{ 
     301    in_playenqueue( 'play' ); 
     302} 
     303 
    295304function in_enqueue() 
    296305{ 
    297     var input = value('input_mrl'); 
    298     if( value('sout_mrl') != '' ) 
    299         input += ' '+value('sout_mrl'); 
    300     var url = 'requests/status.xml?command=in_enqueue&input='+encodeURIComponent( addslashes(escapebackslashes(input)) ); 
    301     loadXMLDoc( url, parse_status ); 
    302     setTimeout( 'update_playlist()', 1000 ); 
     306    in_playenqueue( 'enqueue' ); 
    303307} 
    304308 
     
    772776    } 
    773777 
     778    remove_input_options( ':sub-track' ); 
     779    remove_input_options( ':audio-track' ); 
     780 
    774781    if( type != "cdda" ) 
    775782    { 
    776783        if( subs != '' ) 
    777             mrl.value += " :sub-track="+subs
     784            add_input_option( ":sub-track="+subs )
    778785        if( audio != '' ) 
    779             mrl.value += " :audio-track="+audio
     786            add_input_option( ":audio-track="+audio )
    780787    } 
    781788 
     
    826833    } 
    827834 
     835    remove_input_options( ':access-filter' ); 
    828836    if( checked( "input_net_timeshift" ) ) 
    829         mrl.value += " :access-filter=timeshift"
     837        add_input_option( ":access-filter=timeshift" )
    830838} 
    831839 
     
    833841function update_input_fake() 
    834842{ 
     843    remove_input_options( ":fake" ); 
    835844    var mrl = document.getElementById( 'input_mrl' ); 
    836845 
    837846    mrl.value = "fake:"; 
    838     mrl.value += " :fake-file=" + value( "input_fake_filename" ); 
     847 
     848    add_input_option( ":fake-file=" + value( "input_fake_filename" ) ); 
    839849 
    840850    if( value( "input_fake_width" ) ) 
    841         mrl.value += " :fake-width=" + value( "input_fake_width" ); 
     851        add_input_option( ":fake-width=" + value( "input_fake_width" ) ); 
    842852    if( value( "input_fake_height" ) ) 
    843         mrl.value += " :fake-height=" + value( "input_fake_height" ); 
     853        add_input_option( ":fake-height=" + value( "input_fake_height" ) ); 
    844854    if( value( "input_fake_ar" ) ) 
    845         mrl.value += " :fake-ar=" + value( "input_fake_ar" ); 
     855        add_input_option( ":fake-ar=" + value( "input_fake_ar" ) ); 
    846856} 
    847857 
     
    868878function update_sout() 
    869879{ 
    870     var mrl = document.getElementById( 'sout_mrl' ); 
    871     mrl.value = ""; 
     880    var option = ""; 
     881    /* Remove all options starting with :sout since we're going to write them 
     882     * again. */ 
     883    remove_input_options( ":sout" ); 
    872884 
    873885    check_and_replace_int( 'sout_http_port', 8080 ); 
     
    893905    if( transcode ) 
    894906    { 
    895         mrl.value += ":sout=#transcode{"; 
     907        option = ":sout=#transcode{"; 
    896908        var alot = false; /* alot == at least one transcode */ 
    897909        if( checked( 'sout_vcodec_s' ) ) 
    898910        { 
    899             mrl.value += "vcodec="+value( 'sout_vcodec' )+",vb="+value( 'sout_vb' )+",scale="+value( 'sout_scale' ); 
     911            option += "vcodec="+value( 'sout_vcodec' )+",vb="+value( 'sout_vb' )+",scale="+value( 'sout_scale' ); 
    900912            alot = true; 
    901913        } 
    902914        if( checked( 'sout_acodec_s' ) ) 
    903915        { 
    904             if( alot ) mrl.value += ","; 
    905             mrl.value += "acodec="+value( 'sout_acodec' )+",ab="+value( 'sout_ab' ); 
     916            if( alot ) option += ","; 
     917            option += "acodec="+value( 'sout_acodec' )+",ab="+value( 'sout_ab' ); 
    906918            if( value( 'sout_channels' ) ) 
    907                 mrl.value += ",channels="+value( 'sout_channels' ); 
     919                option += ",channels="+value( 'sout_channels' ); 
    908920            alot = true; 
    909921        } 
    910922        if( checked( 'sout_soverlay' ) ) 
    911923        { 
    912             if( alot ) mrl.value += ","; 
    913             mrl.value += "soverlay"; 
     924            if( alot ) option += ","; 
     925            option += "soverlay"; 
    914926            alot = true; 
    915927        } 
    916928        else if( checked( 'sout_sub' ) ) 
    917929        { 
    918             if( alot ) mrl.value += ","; 
    919             mrl.value += "scodec="+value( 'sout_scodec' ); 
     930            if( alot ) option += ","; 
     931            option += "scodec="+value( 'sout_scodec' ); 
    920932            alot = true; 
    921933        } 
    922         mrl.value += value( 'sout_transcode_extra' ); 
     934        option += value( 'sout_transcode_extra' ); 
    923935             
    924         mrl.value += "}"; 
     936        option += "}"; 
     937 
    925938    } 
    926939 
     
    932945    { 
    933946        if( transcode ) 
    934             mrl.value += ":"; 
     947            option += ":"; 
    935948        else 
    936             mrl.value += ":sout=#"; 
     949            option += ":sout=#"; 
    937950        var aloo = false; /* aloo == at least one output */ 
    938951        var mux = radio_value( 'sout_mux' ); 
    939952        var ttl = parseInt( value( 'sout_ttl' ) ); 
    940         if( output > 1 ) mrl.value += "duplicate{"; 
     953        if( output > 1 ) option += "duplicate{"; 
    941954        if( checked( 'sout_display' ) ) 
    942955        { 
    943             if( output > 1 ) mrl.value += "dst=" 
    944             mrl.value += "display"; 
     956            if( output > 1 ) option += "dst=" 
     957            option += "display"; 
    945958            aloo = true; 
    946959        } 
    947960        if( checked( 'sout_file' ) ) 
    948961        { 
    949             if( aloo ) mrl.value += ","; 
    950             if( output > 1 ) mrl.value += "dst=" 
    951             mrl.value += "std{access=file,mux="+mux+",dst="+value( 'sout_file_filename' )+"}"; 
     962            if( aloo ) option += ","; 
     963            if( output > 1 ) option += "dst=" 
     964            option += "std{access=file,mux="+mux+",dst="+value( 'sout_file_filename' )+"}"; 
    952965            aloo = true; 
    953966        } 
    954967        if( checked( 'sout_http' ) ) 
    955968        { 
    956             if( aloo ) mrl.value += ","; 
    957             if( output > 1 ) mrl.value += "dst=" 
    958             mrl.value += "std{access=http,mux="+mux+",dst="+value( 'sout_http_addr' ); 
     969            if( aloo ) option += ","; 
     970            if( output > 1 ) option += "dst=" 
     971            option += "std{access=http,mux="+mux+",dst="+value( 'sout_http_addr' ); 
    959972            if( value( 'sout_http_port' ) ) 
    960                 mrl.value += ":"+value( 'sout_http_port' ); 
    961             mrl.value += "}"; 
     973                option += ":"+value( 'sout_http_port' ); 
     974            option += "}"; 
    962975            aloo = true; 
    963976        } 
    964977        if( checked( 'sout_mmsh' ) ) 
    965978        { 
    966             if( aloo ) mrl.value += ","; 
    967             if( output > 1 ) mrl.value += "dst=" 
    968             mrl.value += "std{access=mmsh,mux="+mux+",dst="+value( 'sout_mmsh_addr' ); 
     979            if( aloo ) option += ","; 
     980            if( output > 1 ) option += "dst=" 
     981            option += "std{access=mmsh,mux="+mux+",dst="+value( 'sout_mmsh_addr' ); 
    969982            if( value( 'sout_mmsh_port' ) ) 
    970                 mrl.value += ":"+value( 'sout_mmsh_port' ); 
    971             mrl.value += "}"; 
     983                option += ":"+value( 'sout_mmsh_port' ); 
     984            option += "}"; 
    972985            aloo = true; 
    973986        } 
    974987        if( checked( 'sout_rtp' ) ) 
    975988        { 
    976             if( aloo ) mrl.value += ","; 
    977             if( output > 1 ) mrl.value += "dst=" 
    978             mrl.value += "std{access=rtp"; 
    979             if( ttl ) mrl.value += "{ttl="+ttl+"}"; 
    980             mrl.value += ",mux="+mux+",dst="+value( 'sout_rtp_addr' ); 
     989            if( aloo ) option += ","; 
     990            if( output > 1 ) option += "dst=" 
     991            option += "std{access=rtp"; 
     992            if( ttl ) option += "{ttl="+ttl+"}"; 
     993            option += ",mux="+mux+",dst="+value( 'sout_rtp_addr' ); 
    981994            if( value( 'sout_rtp_port' ) ) 
    982                 mrl.value += ":"+value( 'sout_rtp_port' ); 
     995                option += ":"+value( 'sout_rtp_port' ); 
    983996            if( checked( 'sout_sap' ) ) 
    984997            { 
    985                 mrl.value += ",sap"; 
     998                option += ",sap"; 
    986999                if( value( 'sout_sap_group' ) != '' ) 
    9871000                { 
    988                     mrl.value += ",group=\""+value( 'sout_sap_group' )+"\""; 
     1001                    option += ",group=\""+value( 'sout_sap_group' )+"\""; 
    9891002                } 
    990                 mrl.value += ",name=\""+value( 'sout_sap_name' )+"\""; 
    991             } 
    992             mrl.value += "}"; 
     1003                option += ",name=\""+value( 'sout_sap_name' )+"\""; 
     1004            } 
     1005            option += "}"; 
    9931006            aloo = true; 
    9941007        } 
    9951008        if( checked( 'sout_udp' ) ) 
    9961009        { 
    997             if( aloo ) mrl.value += ","; 
    998             if( output > 1 ) mrl.value += "dst=" 
    999             mrl.value += "std{access=udp"; 
    1000             if( ttl ) mrl.value += "{ttl="+ttl+"}"; 
    1001             mrl.value += ",mux="+mux+",dst="+value( 'sout_udp_addr' ); 
     1010            if( aloo ) option += ","; 
     1011            if( output > 1 ) option += "dst=" 
     1012            option += "std{access=udp"; 
     1013            if( ttl ) option += "{ttl="+ttl+"}"; 
     1014            option += ",mux="+mux+",dst="+value( 'sout_udp_addr' ); 
    10021015            if( value('sout_udp_port' ) ) 
    1003                 mrl.value += ":"+value( 'sout_udp_port' ); 
     1016                option += ":"+value( 'sout_udp_port' ); 
    10041017            if( checked( 'sout_sap' ) ) 
    10051018            { 
    1006                 mrl.value += ",sap"; 
     1019                option += ",sap"; 
    10071020                if( value( 'sout_sap_group' ) != '' ) 
    10081021                { 
    1009                     mrl.value += ",group=\""+value( 'sout_sap_group' )+"\""; 
     1022                    option += ",group=\""+value( 'sout_sap_group' )+"\""; 
    10101023                } 
    1011                 mrl.value += ",name=\""+value( 'sout_sap_name' )+"\""; 
    1012             } 
    1013             mrl.value += "}"; 
     1024                option += ",name=\""+value( 'sout_sap_name' )+"\""; 
     1025            } 
     1026            option += "}"; 
    10141027            aloo = true; 
    10151028        } 
    1016         if( output > 1 ) mrl.value += "}"; 
    1017     } 
     1029        if( output > 1 ) option += "}"; 
     1030    } 
     1031 
     1032    if( option != "" ) 
     1033        input_options.push( option ); 
    10181034 
    10191035    if( ( transcode || output ) && checked( 'sout_all' ) ) 
    1020         mrl.value += " :sout-all"; 
     1036        input_options.push( ":sout-all" ); 
     1037 
     1038    /*var mrl = document.getElementById( 'sout_mrl' ); 
     1039    mrl.value = input_options.join( " " )*/ 
     1040 
     1041    refresh_input_options_list(); 
    10211042} 
    10221043 
     
    10321053    document.getElementById('sout_old_mrl').value = value('sout_mrl'); 
    10331054} 
     1055 
     1056function refresh_input_options_list() 
     1057{ 
     1058    var iol = document.getElementById( 'input_options_list' ); 
     1059    clear_children( iol ); 
     1060    input_options.sort(); 
     1061    for( i in input_options ) 
     1062    { 
     1063        var o = document.createElement( 'div' ); 
     1064        var ot = document.createElement( 'input' ); 
     1065        ot.setAttribute( 'type', 'text' ); 
     1066        ot.setAttribute( 'size', '60' ); 
     1067        ot.setAttribute( 'value', input_options[i] ); 
     1068        ot.setAttribute( 'id', 'input_option_item_'+i ); 
     1069        ot.setAttribute( 'onchange', 'javascript:save_input_option('+i+',this.value);' ); 
     1070        ot.setAttribute( 'onfocus', 'if( this.value == ":option=value" ) this.value = ":";' ); 
     1071        ot.setAttribute( 'onblur', 'if( this.value == ":" ) this.value = ":option=value";' ); 
     1072        o.appendChild( ot ); 
     1073        var od = document.createElement( 'a' ); 
     1074        od.setAttribute( 'href', 'javascript:delete_input_option('+i+');' ); 
     1075        var delimg = document.createElement( "img" ); 
     1076        delimg.setAttribute( 'src', 'images/delete_small.png' ); 
     1077        delimg.setAttribute( 'alt', '(delete)' ); 
     1078        od.appendChild( delimg ); 
     1079        o.appendChild( od ); 
     1080        iol.appendChild( o ); 
     1081    } 
     1082} 
     1083 
     1084function delete_input_option( i ) 
     1085{ 
     1086    input_options.splice(i,1); 
     1087    refresh_input_options_list(); 
     1088} 
     1089 
     1090function save_input_option( i, value ) 
     1091{ 
     1092    input_options[i] = value; 
     1093    refresh_input_options_list(); 
     1094} 
     1095 
     1096function add_input_option( value ) 
     1097{ 
     1098    input_options.push( value ); 
     1099    refresh_input_options_list(); 
     1100} 
     1101 
     1102function remove_input_options( prefix ) 
     1103{ 
     1104    for( i in input_options ) 
     1105        if( input_options[i].substring( 0, prefix.length ) == prefix ) 
     1106        { 
     1107            delete input_options[i]; 
     1108            i--; 
     1109        } 
     1110} 
     1111 
    10341112 
    10351113/********************************************************************** 
  • share/lua/http/requests/status.xml

    rd8b6a43 r43055c9  
    3131local id = tonumber(_GET['id'] or -1) 
    3232local val = _GET['val'] 
     33local options = _GET['option'] 
     34if type(options) ~= "table" then -- Deal with the 0 or 1 option case 
     35  options = { options } 
     36end 
    3337 
    34 --vlc.msg.err("requests/status.xml got:","input: "..tostring(input),"command: "..tostring(command),"id: "..tostring(id),"val: "..tostring(val)) 
     38---[[]] vlc.msg.err("requests/status.xml got:","input: "..tostring(input),"command: "..tostring(command),"id: "..tostring(id),"val: "..tostring(val)) 
    3539 
    3640local function stripslashes(s) 
     
    4145 
    4246if command == "in_play" then 
    43   local options = {} 
    44   for o in string.gmatch(input," :[^ ]*") do -- FIXME: options should be in seperate variables, not in the same string as the input. 
    45     table.insert(options,string.sub(o,3)) 
     47  ---[[ 
     48  vlc.msg.err( "<options>" ) 
     49  for a,b in ipairs(options) do 
     50    vlc.msg.err(b) 
    4651  end 
     52  vlc.msg.err( "</options>" ) 
     53  --]] 
    4754  vlc.playlist.add({{path=stripslashes(input),options=options}}) 
    4855elseif command == "in_enqueue" then 
    49   vlc.playlist.enqueue(stripslashes(input)
     56  vlc.playlist.enqueue({{path=stripslashes(input),options=options}}
    5057elseif command == "pl_play" then 
    5158  vlc.playlist.goto(id) 
  • share/lua/intf/http.lua

    rd8b6a43 r43055c9  
    3636require "common" 
    3737 
    38 vlc.msg.err("Lua HTTP interface") 
     38vlc.msg.info("Lua HTTP interface") 
    3939 
    4040open_tag = "<?vlc" 
     
    176176        local k_ = vlc.decode_uri(k) 
    177177        local v_ = vlc.decode_uri(v) 
    178         t[k_]=v_ 
     178        if t[k_] ~= nil then 
     179            local t2 
     180            if type(t[k_]) ~= "table" then 
     181                t2 = {} 
     182                table.insert(t2,t[k_]) 
     183                t[k_] = t2 
     184            else 
     185                t2 = t[k_] 
     186            end 
     187            table.insert(t2,v_) 
     188        else 
     189            t[k_] = v_ 
     190        end 
    179191    end 
    180192    return t