網頁

2016年4月14日 星期四

VLC 之 VLCLIB 新增錄影功能

以下參考 https://patches.videolan.org/patch/606/

vi include/vlc/libvlc_events.h
enum libvlc_event_e {
    libvlc_MediaPlayerMediaChanged=0x100,
    libvlc_MediaPlayerRecordableChanged,
    libvlc_MediaPlayerRecordingFinished,

    libvlc_MediaListItemAdded=0x200,
};
typedef struct libvlc_event_t
{
    union
    {
        struct
        {
            int new_recordable;
        } media_player_recordable_changed;
        struct
        {
            char *psz_filename;
        } media_player_recording_finished;
    } u;
} libvlc_event_t;

vi include/vlc/libvlc_media_player.h
/** @} audio */

/**
 * Can the media player record the current media?
 *
 * Media must be buffering or playing before it can be recorded.
 *
 * The media player event manager will emit a libvlc_MediaPlayerRecordableChanged event
 * when the recordable state changes after starting media playback. The event data will
 * describe the new recordable state, so invocation of this API method is not strictly
 * necessary to determine when recording can be started.
 *
 * A libvlc_MediaPlayerRecordableChanged event will not be emitted if the media is
 * stopped (notified by a libvlc_MediaPlayerStoppedEvent) or finishes normally (notified
 * by a libvlc_MediaPlayerFinished event).
 *
 * A calling application should therefore register an event callback for those events
 * so that it may query the new recordable state and manage recording at the appropriate
 * time.
 *
 * \param p_mi media player
 * \return true if the media player can record, false if it can not
 * \version LibVLC 2.1.0 or later
 */
LIBVLC_API bool libvlc_media_player_is_recordable( libvlc_media_player_t *p_mi );

/**
 * Is the current media being recorded?
 *
 * \param p_mi media player
 * \return true if recording, false if not
 * \version LibVLC 2.1.0 or later
 */
LIBVLC_API bool libvlc_media_player_is_recording( libvlc_media_player_t *p_mi );

/**
 * Start recording the current media.
 *
 * Media must be buffering or playing before it can be recorded. A calling application
 * can begin recording immediately on receipt of a libvlc_MediaPlayerRecordableChanged
 * event sent via the media player event manager (if recording is possible for the
 * currently playing media), and any time thereafter until the media stops.
 *
 * Media will be saved to the file path denoted by the psz_filename parameter if it is
 * supplied. Any such supplied filename should not include a file extension as the
 * correct file extension will automatically be appended when the file is created. This
 * filename may denote a full path name, but each directory in the path must already
 * exist or recording will silently fail. If the calling application chooses to specify
 * the filename then it is the responsibility of that application to take account of
 * this and itself make sure any needed directories are created.
 *
 * Alternatively, a calling application need not supply a filename and so instead let
 * vlc automatically generate a unique filename. This will cause vlc to create a new
 * file in the appropriate media directory for the user - for example "~/Videos". The
 * actual filename used will be sent in an event when the recording is complete.
 *
 * When recording has finished and the new file has been completely saved, a
 * libvlc_MediaPlayerRecordingFinished event will be sent via the media player event
 * manager. The event data will contain the filename of the newly recorded file - this
 * will either be the filename as specified by the calling application or a filename
 * generated by vlc if the application did not supply a filename. In either case, this
 * filename will include the automatically appended file extension.
 *
 * The saved media file will not be immediately available or visible until recording
 * has completely finished and the libvlc_MediaPlayerRecordingFinished event has been
 * received, or the media has stopped or finished normally.
 *
 * Recording can be stopped and started on-the-fly once the recordable state is set;
 * each time recording is stopped and restarted a new file will be created so a calling
 * application should take care to provide unique filenames, or defer to vlc to create
 * unique filenames.
 *
 * Recording will be stopped when the media stops playing, and must be explicitly
 * started again to restart recording, i.e. the recording state is not automatically
 * preserved when playing media subsequently.
 *
 * Media player functionailty such as next/previous chapter, set time or position and
 * so on are ineffective when recording is enabled. However, pausing the media is
 * possible and will pause the recording; unpausing the media will resume playback and
 * recording.
 *
 * Recording of the primary media or sub-items is possible.
 *
 * \param p_mi media player
 * \param psz_filename name of the file to save the media to, not including any file extension,
 *                     or NULL if vlc should generate the filename automatically
 * \return 0 if recording was started, -1 on error
 * \version LibVLC 2.1.0 or later
 */
LIBVLC_API int libvlc_media_player_record_start( libvlc_media_player_t *p_mi, const char *psz_filename );

/**
 * Stop recording the current media.
 *
 * This method requests that the recording stop, and will return immediately. Recording
 * will not stop immediately.
 *
 * When the recording actually stops some short time later and the new file has
 * finished being written, a libvlc_MediaPlayerRecordingFinished event will be sent via
 * the media player event manager. The newly recorded file will not be visible or
 * available until after this event has been sent.
 *
 * The event data will contain the full name of the file that was created. The filename
 * will either be that as was specified by the calling application on invoking
 * libvlc_media_player_record_start(), or the filename that vlc automatically generated
 * if the calling application did not supply its own filename. In either case the
 * filename will contain the automatically appended file extension.
 *
 * There is no need to invoke this method to stop the recording if the media is stopped
 * or finishes playing normally.
 *
 * \param p_mi media player
 * \return 0 if recording was stopped, -1 on error
 * \version LibVLC 2.1.0 or later
 */
LIBVLC_API int libvlc_media_player_record_stop( libvlc_media_player_t *p_mi );

/**
/** @} media_player */

vi lib/event.c
static const event_name_t event_list[] = {
    DEF(MediaPlayerAudioDevice)
    DEF(MediaPlayerRecordableChanged)
    DEF(MediaPlayerRecordingFinished)

vi lib/libvlc.sym
libvlc_media_player_has_vout
libvlc_media_player_is_recordable
libvlc_media_player_is_recording
libvlc_media_player_is_seekable

libvlc_media_player_previous_chapter
libvlc_media_player_record_start
libvlc_media_player_record_stop
libvlc_media_player_release

vi lib/media_player.c
static int
input_recordable_changed( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval,
                          void *p_userdata );
static int
file_recording_finished( vlc_object_t *p_this, char const *psz_cmd,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data );
static void release_input_thread( libvlc_media_player_t *p_mi )
{
    var_DelCallback( p_input_thread, "can-record",
                     input_recordable_changed, p_mi );
}
static int
input_recordable_changed( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval,
                          void *p_userdata )
{
    VLC_UNUSED(p_this);
    VLC_UNUSED(psz_cmd);
    VLC_UNUSED(oldval);

    libvlc_media_player_t *p_mi = p_userdata;
    libvlc_event_t event;

    event.type = libvlc_MediaPlayerRecordableChanged;
    event.u.media_player_recordable_changed.new_recordable = newval.b_bool;

    libvlc_event_send( p_mi->p_event_manager, &event );
    return VLC_SUCCESS;
}
static int file_recording_finished(vlc_object_t *p_this, char const *psz_cmd,
                                   vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    VLC_UNUSED(p_this);
    VLC_UNUSED(psz_cmd);
    VLC_UNUSED(oldval);

    libvlc_media_player_t *p_mi = p_data;
    libvlc_event_t event;

    event.type = libvlc_MediaPlayerRecordingFinished;
    event.u.media_player_recording_finished.psz_filename = newval.psz_string;

    libvlc_event_send(p_mi->p_event_manager, &event);
    return VLC_SUCCESS;
}
libvlc_media_player_new( libvlc_instance_t *instance )
{
    var_Create (mp, "recording-finished", VLC_VAR_STRING);
    var_AddCallback (mp, "recording-finished", file_recording_finished, mp);
}
static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
{
    var_DelCallback( p_mi, "recording-finished", file_recording_finished, p_mi );
}
int libvlc_media_player_play( libvlc_media_player_t *p_mi )
{
    var_AddCallback( p_input_thread, "can-record", input_recordable_changed, p_mi );
    if( input_Start( p_input_thread ) )
    {
        var_DelCallback( p_input_thread, "can-record", input_recordable_changed, p_mi );
    }
}
bool libvlc_media_player_is_recordable( libvlc_media_player_t *p_mi )
{
    input_thread_t *p_input_thread;
    bool b_can_record;

    p_input_thread = libvlc_get_input_thread( p_mi );
    if( !p_input_thread )
        return false;

    b_can_record = var_GetBool( p_input_thread, "can-record" );

    vlc_object_release( p_input_thread );
    return b_can_record;
}
bool libvlc_media_player_is_recording( libvlc_media_player_t *p_mi )
{
    input_thread_t *p_input_thread;
    bool b_record;

    p_input_thread = libvlc_get_input_thread( p_mi );
    if( !p_input_thread )
        return false;

    b_record = var_GetBool( p_input_thread, "record" );

    vlc_object_release( p_input_thread );
    return b_record;
}
int libvlc_media_player_record_start( libvlc_media_player_t *p_mi, const char* psz_filename )
{
    input_thread_t *p_input_thread;

    p_input_thread = libvlc_get_input_thread( p_mi );
    if( !p_input_thread )
        return -1;

    var_SetString( p_input_thread, "input-record-path", psz_filename );
    var_SetBool( p_input_thread, "record", true );

    vlc_object_release( p_input_thread );
    return 0;
}
int libvlc_media_player_record_stop( libvlc_media_player_t *p_mi )
{
    input_thread_t *p_input_thread;

    p_input_thread = libvlc_get_input_thread( p_mi );
    if( !p_input_thread )
        return -1;

    var_SetBool( p_input_thread, "record", false );

    vlc_object_release( p_input_thread );
    return 0;
}

vi modules/stream_out/record.c
struct sout_stream_sys_t
{
    char *psz_record_file;
};
static int Open( vlc_object_t *p_this )
{
    p_sys->psz_record_file = NULL;

    return VLC_SUCCESS;
}
static void Close( vlc_object_t * p_this )
{
    if( p_sys->psz_record_file ) {
        for( vlc_object_t *p_mp = p_stream->p_parent; p_mp; p_mp = p_mp->p_parent )
        {
            if( var_Type( p_mp, "recording-finished" ) )
            {
                var_SetString( p_mp, "recording-finished", p_sys->psz_record_file );
                break;
            }
        }

        free( p_sys->psz_record_file );
    }
    TAB_CLEAN( p_sys->i_id, p_sys->id );
    free( p_sys->psz_prefix );
    free( p_sys );
}
static int OutputNew( sout_stream_t *p_stream,
                      const char *psz_muxer, const char *psz_prefix, const char *psz_extension  )
{
    if( psz_file && psz_extension )
    {
        p_sys->psz_record_file = strdup( psz_file );
        var_SetString( p_stream->p_libvlc, "record-file", psz_file );
    }
}

vi src/input/var.c 
void input_ControlVarInit ( input_thread_t *p_input )
{
    /* ES Out */
    var_Create( p_input, "input-record-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
}

2016年4月11日 星期一

VLC 延遲 錄影 抓圖

延遲主串流到新串流
vlc.exe --sout=#rtp{sdp=rtsp://:8554/ch1} --sout-all --sout-keep rtsp://169.254.1.168:554/live2.sdp --network-caching=5000 --intf telnet --telnet-host="0.0.0.0" --telnet-port="4212" --telnet-password="1234" --verbose=2 --file-logging --logfile=vlc-log-4212.txt

抓圖
vlc.exe rtsp://localhost:8554/ch1 --vout dummy --intf telnet --telnet-host="0.0.0.0" --telnet-port="4213" --telnet-password="1234" --verbose=2 --file-logging --logfile=vlc-log-4213.txt
telnet localhost 4213
snapshot
shutdown

錄影
vlc.exe --intf telnet --telnet-host="0.0.0.0" --telnet-port="4214" --telnet-password="1234" --verbose=2 --file-logging --logfile=vlc-log-4214.txt
telnet localhost 4214
new ch1 broadcast enabled
setup ch1 input rtsp://localhost:8554/ch1
setup ch1 output #file{mux=ps,dst='R:\temp\aaa.ps'}
control ch1 play
control ch1 stop
shutdown

延遲主串流,可直接抓圖
vlc.exe rtsp://169.254.1.168:554/live2.sdp --network-caching=5000 --vout dummy --intf telnet --telnet-host="0.0.0.0" --telnet-port="4212" --telnet-password="1234" --verbose=2 --file-logging --logfile=vlc-log.txt
telnet localhost 4212
snapshot
shutdown

2016年4月8日 星期五

在 VLC 的 log 上增加時間

vi modules/logger/file.c

static void LogText(void *opaque, int type, const vlc_log_t *meta,
                    const char *format, va_list ap)

    struct timespec ts;
    struct tm curtime;
    char tmBuf[128];
    timespec_get(&ts, TIME_UTC);
    if (localtime_r(&ts.tv_sec, &curtime) == NULL) {
        gmtime_r(&ts.tv_sec, &curtime);
    }
    if (strftime(tmBuf, sizeof(tmBuf), "%M%S", &curtime) == 0) {
        strcpy(tmBuf, "no time");
    }
    fprintf(stream, "%s.%03d %s%s: ", tmBuf, (int)(ts.tv_nsec / 1000000), meta->psz_module, msg_type[type]);

2016年4月6日 星期三

三 VideoLAN Compile 成熟篇

不了解 git 即使能編譯完成,那也只是幸運!
apt-get install apt-show-version

git clone 會取得完整的程式庫,clone 後你就可以使用下列命令

$ git tag -n
列出主要版本 tag
$ git log --pretty=format:'%H %h %ci' -n 10
列出最近的10個版本
$ git log --tags --simplify-by-decoration --pretty="format:%ci %h %d %H"

$ git checkout tags/<tag_name>
使的整的程式庫呈現,tag版本的狀態
$ git checkout master
$ git checkout 035d652
$ git checkout 'master@{2016-03-24 10:02:16}'
$ git checkout -- HEAD

$ git reset --hard
$ git clean -f -d
完整地回復到最後版本,並且刪除不必要的檔案

針對某一檔案
$ git log filename
$ git --no-pager diff 99388eb:filename bdc798c:filename
$ git archive -o foo.tar 99388eb


話說回到 VideoLAN,因為整個計畫太大,所以將一些子計畫放入 contrib 目錄
而 make prebuilt 就是使用編譯好的子計畫
主計畫和子計畫並不一定能同步,據我的經驗要同步很難,所以編譯不過是正常的
真正的重點就是調整計畫的版本

以下是遇到的問題紀錄
add-apt-repository ppa:ubuntu-wine/ppa
add-apt-repository ppa:n-muench/vlc
apt-get update
apt-get install wine1.8-dev
apt-get install libsidplay2-dev
apt-get install libdvd-pkg
apt-get install libdvdread-dev

LUA 要使用32位元的版本,否則會遇下列問題
checking for LUA... no
configure: WARNING: No package 'lua5.2' found, trying lua 5.1 instead
checking for LUA... no
configure: WARNING: No package 'lua5.1' found, trying lua >= 5.1 instead
checking for LUA... yes
checking for luac... luac
configure: error: You need 32-bits luac when using lua from contrib.

32位元版本的安裝就是加上 :i386
apt-get install lua5.2:i386
apt-get install lua5.2-dev:i386
apt-get install liblua5.2:i386
apt-get install liblua5.2-dev:i386

在 contrib 下的 lua 要回復到 5.1 版,之後的版本會遇到 module 的問題
如 lua/modules/common.lua 之
module("common",package.seeall)

下列命令可以測試 lua 版本
contrib/i686-w64-mingw32/bin# ./luac -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio

主程式版本
d445720262fbc0eb6c7e3e1244280aee2c492e08 d445720 2016-03-23 14:47:50 +0100

LUA 回復版本
git checkout c433918ec056f0b6a1b6ecbce01e03f62bc68ebf contrib/src/lua

ffmpeg 回復版本
vi contrib/src/ffmpeg/rules.mak
ifdef USE_FFMPEG
else
#HASH=HEAD
HASH=73b0324


2016年3月16日 星期三

VLC 追蹤之五 VoutCreate

載入 avcodec, 並登記 pf_vout_format_update
src/input/decoder.c
input_DecoderNew -> decoder_New -> CreateDecoder
    p_dec->pf_vout_format_update = vout_update_format;
input_DecoderNew -> decoder_New -> CreateDecoder -> LoadDecoder
p_dec->p_module = module_need( p_dec, "decoder", "$codec", false );

載入 avcodec 時, 登記 pf_decode_video, get_format
modules/codec/avcodec/avcodec.c
    set_capability( "decoder", 70 )
    set_callbacks( OpenDecoder, CloseDecoder )

OpenDecoder
    ret = InitVideoDec( p_dec, avctx, p_codec );

modules/codec/avcodec/video.c
InitVideoDec
    p_context->get_format = ffmpeg_GetFormat;
    p_dec->pf_decode_video = DecodeVideo;

透過 pf_decode_video 執行 DecodeVideo
src/input/es_out.c
input_DecoderNew -> decoder_New -> vlc_clone(DecoderThread)
src/input/decoder.c
DecoderThread -> DecoderProcess -> DecoderProcessVideo -> DecoderDecodeVideo
    while( (p_pic = p_dec->pf_decode_video( p_dec, pp_block ) ) )

modules/codec/avcodec/video.c
DecodeVideo -> lavc_UpdateVideoFormat
    return decoder_UpdateVideoFormat(dec);

透過 pf_vout_format_update 執行 vout_update_format
include/vlc_codec.h
decoder_UpdateVideoFormat
    return dec->pf_vout_format_update( dec );

src/input/decoder.c
vout_update_format
    p_vout = input_resource_RequestVout( p_owner->p_resource,

src/input/resource.c
input_resource_RequestVout -> RequestVout
    p_vout = vout_Request( p_resource->p_parent, &cfg );

src/video_output/video_output.c
vout_Request -> VoutCreate
    vout->p->spu = spu_Create(vout);

src/video_output/vout_subpictures.c
spu_Create -> sys->text = SpuRenderCreateAndLoadText
    text->p_module = module_need(text, "text renderer", "$text-renderer", false);
在此載入 freetype
spu_Create -> sys->scale = SpuRenderCreateAndLoadScale
    scale->p_module = module_need(scale, "video filter2", NULL, false);
在此載入 swscale
spu_Create -> sys->scale_yuvp = SpuRenderCreateAndLoadScale
    scale->p_module = module_need(scale, "video filter2", NULL, false);
在此載入 yuvp

src/video_output/video_output.c
vout_Request -> VoutCreate -> vout_display_window_New
src/video_output/window.c
vout_display_window_New -> vout_window_New -> vlc_module_load(vout window)
在此載入 qt4

src/video_output/video_output.c
vout_Request -> VoutCreate -> vlc_clone(Thread)
Thread -> ThreadControl -> ThreadStart -> vout_OpenWrapper
src/video_output/vout_wrapper.c
vout_OpenWrapper -> vout_NewDisplay
src/video_output/display.c
vout_NewDisplay -> DisplayNew -> vout_display_New -> module_need(vout display)
在此載入 direct3d9

src/video_output/video_output.c
vout_Request -> VoutCreate -> spu_Attach
src/video_output/vout_subpictures.c
spu_Attach -> spu->p->text = SpuRenderCreateAndLoadText
    text->p_module = module_need(text, "text renderer", "$text-renderer", false);
在此載入 freetype


2016年3月15日 星期二

VLC 追蹤之四 aout stream

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)

載入 mmdevice 時登記了 start
modules/audio_output/mmdevice.c
    set_capability("audio output", 150)
    set_callbacks(Open, Close)
static int Open(vlc_object_t *obj)
    aout->start = Start;

src/input/decoder.c
input_DecoderNew -> decoder_New -> CreateDecoder
    p_dec->pf_aout_format_update = aout_update_format;
    p_dec->pf_vout_format_update = vout_update_format;
input_DecoderNew -> decoder_New -> CreateDecoder -> LoadDecoder
    p_dec->p_module = module_need( p_dec, "decoder", "$codec", false );
此時載入了 avcodec, 並登記了 pf_vout_format_update

載入 g711 時登記了 pf_decode_audio
modules/codec/g711.c
    set_capability( "decoder", 100 )
    set_callbacks( DecoderOpen, DecoderClose )
static int DecoderOpen( vlc_object_t *p_this )
    p_dec->pf_decode_audio = DecodeBlock;

透過 pf_decode_audio 執行 DecodeBlock
src/input/es_out.c
input_DecoderNew -> decoder_New -> vlc_clone(DecoderThread)
src/input/decoder.c
DecoderThread -> DecoderProcess -> DecoderProcessAudio -> DecoderDecodeAudio
static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
    while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) )

透過 pf_aout_format_update 執行 aout_update_format
modules/codec/g711.c -> DecodeBlock -> decoder_NewAudioBuffer
include/vlc_codec.h -> decoder_UpdateAudioFormat
    return dec->pf_aout_format_update( dec );

透過 start 執行 Start
src/input/decoder.c -> aout_update_format -> aout_DecNew
src/audio_output/dec.c -> aout_DecNew -> aout_OutputNew
src/audio_output/output.c -> aout_OutputNew
    aout->start (aout, fmt)

最後載入 aout stream
modules/audio_output/mmdevice.c -> Start ->vlc_module_load(aout stream)

順便一提,之後載入 audio volume
src/audio_output/dec.c -> aout_DecNew -> aout_volume_SetFormat
src/audio_output/volume.c -> aout_volume_SetFormat -> module_need(audio volume)

載入 audio filter
src/audio_output/dec.c -> aout_DecNew -> aout_FiltersNew
src/audio_output/filters.c -> aout_FiltersNew -> AppendFilter(audio filter) -> CreateFilter(audio filter) -> module_need(audio filter)


載入 audio converter(audio_format)
src/audio_output/filters.c -> AppendFilter -> aout_FiltersPipelineCreate (Format) -> TryFormat -> FindConvert -> CreateFilter(audio converter) -> module_need(audio converter) -> audio_format

載入 audio converter(trivial)
src/audio_output/filters.c -> aout_FiltersNew -> aout_FiltersPipelineCreate (Remix channels) -> TryFormat -> FindConvert -> CreateFilter(audio converter) -> module_need(audio converter) -> trivial

載入 audio resampler(samplerate)
src/audio_output/filters.c -> aout_FiltersNew -> FindResampler -> CreateFilter(audio resampler) -> module_need(audio resampler) -> samplerate





2016年3月14日 星期一

VLC 追蹤之三 packetizer

設定 p_es_out_display->pf_control = EsOutControl
../src/input/input.c -> Create -> input_EsOutNew
    p_input->p->p_es_out_display = input_EsOutNew( p_input, p_input->p->i_rate );

../src/input/es_out.c
es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
    out->pf_control = EsOutControl;

設定 
    p_es_out->pf_control = Control
    p_es_out->p_out = p_es_out_display
../src/input/input.c -> Init
    p_input->p->p_es_out = input_EsOutTimeshiftNew( p_input, p_input->p->p_es_out_display, p_input->p->i_rate );

../src/input/es_out_timeshift.c
es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out, int i_rate )
    p_out->pf_control = Control;
    p_out->p_sys      = p_sys;
    p_sys->p_out = p_next_out;

觸發 pf_control, 此時是 es_out_timeshift.c 內的 Control
../src/input/input.c
Init -> InitPrograms -> es_out_SetMode
    es_out_SetMode( p_input->p->p_es_out, i_es_out_mode );
../src/input/es_out.h
static inline void es_out_SetMode( es_out_t *p_out, int i_mode )
{
    int i_ret = es_out_Control( p_out, ES_OUT_SET_MODE, i_mode );
    assert( !i_ret );
}
../include/vlc_es_out.h
es_out_Control -> es_out_vaControl( out, i_query, args );
static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
{
    return out->pf_control( out, i_query, args );
}


一樣透過 es_out_Control 觸發 pf_control, 此時是 es_out.c 內的 EsOutControl
../src/input/es_out_timeshift.c
static int Control( es_out_t *p_out, int i_query, va_list args )
    i_ret = ControlLocked( p_out, i_query, args );
static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
    es_out_sys_t *p_sys = p_out->p_sys;
    int rt =  CmdExecuteControl( p_sys->p_out, &cmd );
static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
    int rt = es_out_Control( p_out, i_query, p_cmd->u.control.u.i_int );

../src/input/es_out.c
EsOutControl -> EsOutControlLocked -> EsSelect -> EsCreateDecoder -> input_DecoderNew
../src/input/decoder.c
input_DecoderNew -> decoder_New -> CreateDecoder -> LoadDecoder
    p_dec->p_module = module_need( p_dec, "packetizer", "$packetizer", false );

最後帶入 packetizer