網頁

2016年2月19日 星期五

RTSP 協定

很棒的例子

Albert 的筆記本 RTSP例子


messages.c 追蹤&使 log 不錯亂

vlc_LogPreinit
vlc_LogEarlyOpen

vlc_LogInit
if (early_sys != NULL)
vlc_LogEarlyClose

vlc_Log
vlc_vaLog
Win32DebugOutputMsg
OutputDebugStringW

vlc_LogDeinit
vlc_LogEarlyClose

vlc_LogEarlyClose
vlc_LogCallback
vlc_vaLogCallback
vlc_vaLogEarly


src/libvlc.c/libvlc_InternalInit
vlc_LogPreinit
vlc_LogInit
src/libvlc.c/libvlc_InternalCleanup
vlc_LogDeinit

include/vlc_messages.h
msg_Info
msg_Err
msg_Warn
msg_Dbg
vlc_Log


1. messages.c 中的 vlc_logger_t 新增變數
vlc_mutex_t line_lock;
2. 在 vlc_Log 函數中使用 mutex_lock, 括住 va_start 和 va_end
vlc_logger_t *logger = libvlc_priv(obj->p_libvlc)->logger;
if (logger) vlc_mutex_lock(&logger->line_lock);
if (logger) vlc_mutex_unlock(&logger->line_lock);
3. 在 vlc_LogInit 函數的最後增加
vlc_mutex_init(&logger->line_lock);
4. 在 vlc_LogDeinit 函數的最開頭增加
vlc_mutex_destroy(&logger->line_lock);




2016年2月16日 星期二

apt 指令

apt-get update
軟體資料庫同步:apt-get update 會根據 /etc/apt/sources.list 中設定到 APT Server 去更新軟體資料庫,在任何更新之前最好都先做這一個動作,讓軟體資料保持在最新的狀況之下。/etc/apt/sources.list 可以用 apt-setup 來設定。

apt-get install
軟體安裝:安裝軟體最怕的就是軟體間的相依、相斥關係,但是在 Debian 裡頭安裝軟體是一件非常愉悅的事情,只要 『 apt-get install 』一行指令簡簡單單輕輕鬆鬆即可完成,所有相依、相斥 Debian 都會幫我們自動解決,您只要回答 『 Y 』就可以。依照預設值,透過 sudo apt-get install 安裝軟體時,會將檔案暫存在 /var/cache/apt/archives/ 目錄裡

apt-get install vsftpd=2.3.5-3ubuntu1
安裝指定版本

apt-cache showpkg
顯示套件資訊

apt-cache pkgnames
查詢所有可安裝的軟件包

apt-cache pkgnames mingw
查詢包含特定開頭名稱的軟件包

sudo apt-cache search mingw
查詢包含特定名稱的軟件包,並且簡略說明

apt-cache show gcc-mingw-w64-x86-64
顯示軟件包的詳細說明

apt-cache madison gcc-mingw-w64-x86-64
顯示軟件包的所有版本

apt-cache showpkg gcc-mingw-w64-x86-64
顯示軟件包的相依資料


VLC 追蹤

vlc.exe rtsp://169.254.1.168:554/live2.sdp --sout 'rtp{dst=127.0.0.1,port=1234,sdp=rtsp://localhost:8080/test.sdp}' --verbose=2 --file-logging --logfile=vlc-log.txt

VLC 進入點
bin/winvlc.c -> WinMain
    libvlc_instance_t *vlc;
    vlc = libvlc_new (argc, (const char **)argv);
    if (vlc != NULL)
    {
        libvlc_set_app_id (vlc, "org.VideoLAN.VLC", PACKAGE_VERSION,
                           PACKAGE_NAME);
        libvlc_set_user_agent (vlc, "VLC media player", "VLC/"PACKAGE_VERSION);
        libvlc_add_intf (vlc, "hotkeys,none");
        libvlc_add_intf (vlc, "globalhotkeys,none");
        libvlc_add_intf (vlc, NULL);
        libvlc_playlist_play (vlc, -1, 0, NULL);
        libvlc_wait (vlc);
        libvlc_release (vlc);
    }


lib/core.c -> libvlc_new
    libvlc_int_t *p_libvlc_int = libvlc_InternalCreate();
    if (libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv ))
    {
        libvlc_InternalDestroy( p_libvlc_int );
        goto error;
    }

src/libvlc.c -> libvlc_InternalCreate
src/libvlc.c -> libvlc_InternalInit
    vlc_LogPreinit(p_libvlc); // 除錯資料先放記憶體
    vlc_LogInit(p_libvlc); // 除錯 從此開始
    GetFilenames( p_libvlc, i_argc - vlc_optind, ppsz_argv + vlc_optind );

src/misc/messages.c -> vlc_LogPreinit
src/misc/messages.c -> vlc_LogInit -> vlc_module_load(logger, "logger"...)

src/libvlc.c -> GetFilenames -> intf_InsertItem
src/interface/interface.c -> intf_InsertItem -> playlist_AddExt -> intf_GetPlaylist  -> playlist_Create
src/playlist/engine.c -> playlist_Create -> playlist_MLLoad
src/playlist/loadsave.c -> playlist_MLLoad -> input_Read
src/input/input.c -> input_Read -> Create
src/input/input.c -> input_Read -> Init -> InputSourceNew -> input_DemuxNew
src/input/demux.c -> input_DemuxNew -> demux_NewAdvanced -> module_need(access_demux)
src/input/demux.c -> input_DemuxNew -> stream_AccessNew
src/input/access.c -> stream_AccessNew -> access_New -> module_need(access)
src/input/access.c -> stream_AccessNew -> stream_FilterChainNew
src/input/stream_filter.c -> stream_FilterChainNew -> stream_FilterNew -> module_need(stream_filter)
src/input/demux.c -> input_DemuxNew -> stream_FilterAutoNew
src/input/stream_filter.c -> stream_FilterAutoNew -> stream_FilterNew
src/input/input.c -> input_Read -> Init -> InputSourceMeta -> module_need(meta reader)
src/input/input.c -> input_Read -> MainLoop ->MainLoopDemux -> demux_Demux
modules/demux/playlist/xspf.c -> Demux -> xml_ReaderCreate
src/misc/xml.c -> xml_ReaderCreate -> module_need(xml reader)
src/playlist/engine.c -> playlist_Create -> input_resource_GetAout
src/input/resource.c -> input_resource_GetAout -> aout_New
src/audio_output/output.c -> aout_New -> module_need(audio output)
src/playlist/engine.c -> playlist_Create -> playlist_Activate
src/playlist/thread.c -> playlist_Activate -> vlc_clone(Thread)
// 建立新 thread,往下執行
// 舊 thread 返回 playlist_Activate -> playlist_Create
src/playlist/thread.c -> Thread
        vlc_cond_wait( &p_sys->signal, &p_sys->lock );
        // 這個 thread 會等到 libvlc_playlist_play 送出 vlc_cond_signal, 才執行
        while( !p_sys->killed && Next( p_playlist ) )
        {   /* Playlist in running state */
            assert(p_sys->p_input != NULL);

            do
                LoopInput( p_playlist );
            while( p_sys->p_input != NULL );
        }

src/interface/interface.c -> intf_InsertItem -> playlist_AddExt
src/playlist/item.c -> playlist_AddExt -> playlist_AddInput -> GoAndPreparse -> playlist_preparser_Push
src/playlist/preparser.c -> playlist_preparser_Push -> vlc_clone_detach(Thread)
src/playlist/preparser.c -> Thread -> Art -> playlist_fetcher_Push
src/playlist/fetcher.c -> playlist_fetcher_Push -> vlc_clone_detach(Thread)
src/playlist/fetcher.c -> Thread -> FetchMeta -> module_need("meta fetcher")
src/playlist/fetcher.c -> Thread -> FindArt


lib/playlist.c -> libvlc_add_intf -> libvlc_InternalAddIntf
src/interface/interface.c -> libvlc_InternalAddIntf -> intf_Create -> module_need(interface)
modules/gui/qt4/gt4.cpp -> OpenIntf -> Open -> Thread -> MainInterface
modules/gui/qt4/main_interface.cpp -> MainInterface -> VLCMenuBar::createMenuBar
modules/gui/qt4/menus.cpp -> VLCMenuBar::createMenuBar -> ViewMenu -> ExtensionsMenu -> ExtensionsManager::loadExtensions
modules/gui/qt4/extensions_manager.cpp -> ExtensionsManager::loadExtensions -> module_need(extension)



lib/playlist.c -> libvlc_playlist_play -> libvlc_InternalPlay
src/interface/interface.c -> libvlc_InternalPlay -> playlist_Control
src/playlist/control.c -> playlist_Control -> playlist_vaControl -> vlc_cond_signal
src/win32/thread.c -> vlc_cond_signal

// 之前暫停的 thread 繼續執行
src/playlist/thread.c -> Thread -> Next -> NextItem -> ResetCurrentlyPlaying
src/playlist/thread.c -> Thread -> Next -> ResyncCurrentIndex
src/playlist/thread.c -> Thread -> Next -> PlayItem -> input_Create
src/playlist/thread.c -> Thread -> Next -> PlayItem -> var_AddCallback(... "intf-event", InputEvent..)
src/playlist/thread.c -> Thread -> Next -> PlayItem -> input_Start
src/input/input.c -> input_Create -> Create
src/input/input.c -> input_CreatePreparser -> Create
src/input/input.c -> Create -> input_SendEventMeta

src/input/input.c -> input_Start -> vlc_clone(Run)
src/input/input.c -> input_Start -> Run -> Init -> input_EsOutTimeshiftNew
src/input/es_out_timeshift.c -> input_EsOutTimeshiftNew
src/input/input.c -> input_Start -> Run -> Init -> input_SendEventCache
src/input/input.c -> input_Start -> Run -> Init -> InputSourceNew
src/input/input.c -> input_Start -> Run -> Init -> input_SendEventLength
src/input/input.c -> input_Start -> Run -> Init -> input_SendEventPosition
src/input/event.c -> input_SendEvent???? -> Trigger
    var_SetInteger( p_input, "intf-event", i_type );
src/playlist/thread.c -> InputEvent -> vlc_cond_signal
src/input/input.c -> input_Start -> Run -> Init -> IintPrograms
src/input/input.c -> input_Start -> Run -> MainLoop
src/playlist/thread.c -> Thread -> LoopInput -> vlc_cond_wait

src/input/resource.c -> input_resource_RequestSout -> RequestSout -> sout_NewInstance
src/stream_output/stream_output.c -> sout_NewInstance



2016年2月4日 星期四

VLC 之 http

vlc.exe --intf="http" --http-host 0.0.0.0 --http-port 8080 --http-password 1234

http://localhost:8080/requests/playlist.xml

http://localhost:8080/requests/status.xml?command=in_play&input=rtsp://169.254.1.168:554/live2.sdp

http://localhost:8080/requests/status.xml?command=snapshot

http://localhost:8080/requests/status.xml?command=pl_stop

http://localhost:8080/requests/vlm_cmd.xml?command=new ch1 broadcast enabled
http://localhost:8080/requests/vlm_cmd.xml?command=setup ch1 input rtsp://169.254.1.168:554/live2.sdp
http://localhost:8080/requests/vlm_cmd.xml?command=control ch1 play
http://localhost:8080/requests/vlm_cmd.xml?command=control ch1 stop

share/lua/intf/modules/httprequests.lua
processcommands = function ()
in_play
addsubtitle
in_enqueue
pl_play
pl_pause
pl_forcepause
pl_forceresume
pl_stop
pl_next
pl_previous
pl_delete
pl_empty
pl_sort
pl_loop
pl_repeat
pl_sd
fullscreen
snapshot
volume
seek
key
audiodelay
rate
subdelay
aspectratio
preamp
equalizer
enableeq
setpreset
title
chapter
audio_track
video_track
subtitle_track