コード例 #1
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::select_subtitle_stream(int subtitle_stream)
{
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    assert(subtitle_stream >= -1);
    assert(subtitle_stream < subtitle_streams());
    _active_subtitle_stream = subtitle_stream;
    int o = -1, s = -1;
    if (_active_subtitle_stream >= 0)
    {
        get_subtitle_stream(_active_subtitle_stream, o, s);
    }
    for (size_t i = 0; i < _media_objects.size(); i++)
    {
        for (int j = 0; j < _media_objects[i].subtitle_streams(); j++)
        {
            _media_objects[i].subtitle_stream_set_active(j, (i == static_cast<size_t>(o) && j == s));
        }
    }
    // Re-set subtitle box template
    if (_active_subtitle_stream >= 0)
        _subtitle_box = _media_objects[o].subtitle_box_template(s);
    else
        _subtitle_box = subtitle_box();
}
コード例 #2
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::select_audio_stream(int audio_stream)
{
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    assert(audio_stream >= 0);
    assert(audio_stream < audio_streams());
    _active_audio_stream = audio_stream;
    int o, s;
    get_audio_stream(_active_audio_stream, o, s);
    for (size_t i = 0; i < _media_objects.size(); i++)
    {
        for (int j = 0; j < _media_objects[i].audio_streams(); j++)
        {
            _media_objects[i].audio_stream_set_active(j, (i == static_cast<size_t>(o) && j == s));
        }
    }
    // Re-set audio blob template
    _audio_blob = _media_objects[o].audio_blob_template(s);
}
コード例 #3
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::select_video_stream(int video_stream)
{
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    assert(video_stream >= 0);
    assert(video_stream < video_streams());
    if (_video_frame.stereo_layout == parameters::layout_separate)
    {
        _active_video_stream = 0;
        for (size_t i = 0; i < _media_objects.size(); i++)
        {
            for (int j = 0; j < _media_objects[i].video_streams(); j++)
            {
                _media_objects[i].video_stream_set_active(j, true);
            }
        }
    }
    else
    {
        _active_video_stream = video_stream;
        int o, s;
        get_video_stream(_active_video_stream, o, s);
        for (size_t i = 0; i < _media_objects.size(); i++)
        {
            for (int j = 0; j < _media_objects[i].video_streams(); j++)
            {
                _media_objects[i].video_stream_set_active(j, (i == static_cast<size_t>(o) && j == s));
            }
        }
    }
    // Re-set video frame template
    parameters::stereo_layout_t stereo_layout_bak = _video_frame.stereo_layout;
    bool stereo_layout_swap_bak = _video_frame.stereo_layout_swap;
    int o, s;
    get_video_stream(_active_video_stream, o, s);
    _video_frame = _media_objects[o].video_frame_template(s);
    _video_frame.stereo_layout = stereo_layout_bak;
    _video_frame.stereo_layout_swap = stereo_layout_swap_bak;
    _video_frame.set_view_dimensions();
}
コード例 #4
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::seek(int64_t pos)
{
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    for (size_t i = 0; i < _media_objects.size(); i++)
    {
        _media_objects[i].seek(pos);
    }
}
コード例 #5
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::close()
{
    try
    {
        if (_have_active_video_read)
        {
            (void)finish_video_frame_read();
        }
        if (_have_active_audio_read)
        {
            (void)finish_audio_blob_read();
        }
        if (_have_active_subtitle_read)
        {
            (void)finish_subtitle_box_read();
        }
        for (size_t i = 0; i < _media_objects.size(); i++)
        {
            _media_objects[i].close();
        }
    }
    catch (...)
    {
    }
    _is_device = false;
    _id = "";
    _media_objects.clear();
    _tag_names.clear();
    _tag_values.clear();
    _video_stream_names.clear();
    _audio_stream_names.clear();
    _subtitle_stream_names.clear();
    _active_video_stream = -1;
    _active_audio_stream = -1;
    _active_subtitle_stream = -1;
    _initial_skip = 0;
    _duration = -1;
    _video_frame = video_frame();
    _audio_blob = audio_blob();
    _subtitle_box = subtitle_box();
}
コード例 #6
0
ファイル: media_input.cpp プロジェクト: KrisLee/bino
void media_input::select_video_stream(int video_stream)
{
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    assert(video_stream >= 0);
    assert(video_stream < video_streams());
    if (_video_frame.stereo_layout == video_frame::separate)
    {
        _active_video_stream = 0;
        for (size_t i = 0; i < _media_objects.size(); i++)
        {
            for (int j = 0; j < _media_objects[i].video_streams(); j++)
            {
                _media_objects[i].video_stream_set_active(j, true);
            }
        }
    }
    else
    {
        _active_video_stream = video_stream;
        int o, s;
        get_video_stream(_active_video_stream, o, s);
        for (size_t i = 0; i < _media_objects.size(); i++)
        {
            for (int j = 0; j < _media_objects[i].video_streams(); j++)
            {
                _media_objects[i].video_stream_set_active(j, (i == static_cast<size_t>(o) && j == s));
            }
        }
    }
}
コード例 #7
0
ファイル: media_input.cpp プロジェクト: GiR-Zippo/bino
void media_input::set_stereo_layout(parameters::stereo_layout_t layout, bool swap)
{
    assert(stereo_layout_is_supported(layout, swap));
    if (_have_active_video_read)
    {
        (void)finish_video_frame_read();
    }
    if (_have_active_audio_read)
    {
        (void)finish_audio_blob_read();
    }
    if (_have_active_subtitle_read)
    {
        (void)finish_subtitle_box_read();
    }
    int o, s;
    get_video_stream(_active_video_stream, o, s);
    const video_frame &t = _media_objects[o].video_frame_template(s);
    _video_frame = t;
    _video_frame.stereo_layout = layout;
    _video_frame.stereo_layout_swap = swap;
    _video_frame.set_view_dimensions();
    // Reset active stream in case we switched to or from 'separate'.
    select_video_stream(_active_video_stream);
    if (layout == parameters::layout_separate)
    {
        // If we switched the layout to 'separate', then we have to seek to the
        // position of the first video stream, or else the second video stream
        // is out of sync.
        int64_t pos = _media_objects[o].tell();
        if (pos > std::numeric_limits<int64_t>::min())
        {
            seek(pos);
        }
    }
}