#include "VLCWrapperImpl.h"
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <QRect>
#include <vector>
VLCWrapperImpl::VLCWrapperImpl()
: m_pVLCInstance(nullptr)
, m_pMediaPlayer(nullptr)
, m_pMedia(nullptr)
, m_pEventMgr(nullptr)
, m_eventHandler(nullptr)
, m_playHwnd(nullptr)
{
const char * const vlc_args[] = {
"-I", "dumy", // No special interface
"--directx-hw-yuv",
"--no-directx-hw-yuv",
"--ignore-config", // Don't use VLC's config
"--plugin-path=./plugins",
"--network-caching=1000"
};
m_pVLCInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
// Create a media player playing environement
m_pMediaPlayer = libvlc_media_player_new(m_pVLCInstance);
// Create an event manager for the player for handling e.g. time change events
m_pEventMgr = libvlc_media_player_event_manager(m_pMediaPlayer);
}
VLCWrapperImpl::VLCWrapperImpl(int nBuffer)
: m_pVLCInstance(nullptr)
, m_pMediaPlayer(nullptr)
, m_pMedia(nullptr)
, m_pEventMgr(nullptr)
, m_eventHandler(nullptr)
, m_playHwnd(nullptr)
{
std::ostringstream ssBuffer;
ssBuffer << "--network-caching=" << nBuffer;
std::string strBuffer = ssBuffer.str();
const char * const vlc_args[] = {
"-I", "dumy", // No special interface
"--directx-hw-yuv",
"--no-directx-hw-yuv",
"--ignore-config", // Don't use VLC's config
"--plugin-path=./plugins",
strBuffer.c_str()
};
m_pVLCInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
// Create a media player playing environement
m_pMediaPlayer = libvlc_media_player_new(m_pVLCInstance);
// Create an event manager for the player for handling e.g. time change events
m_pEventMgr = libvlc_media_player_event_manager(m_pMediaPlayer);
}
VLCWrapperImpl::~VLCWrapperImpl()
{
libvlc_media_player_release(m_pMediaPlayer);
libvlc_release(m_pVLCInstance);
}
void VLCWrapperImpl::SetOutputWindow(HWND pHwnd)
{
// Set the output window
if (m_playHwnd != pHwnd)
{
libvlc_media_player_set_hwnd(m_pMediaPlayer, pHwnd);
m_playHwnd = pHwnd;
}
}
void VLCWrapperImpl::SetEventHandler(VLCEventHandler event, void* pUserData)
{
std::vector <libvlc_event_e> events = {
libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerEndReached,
libvlc_MediaPlayerTimeChanged
};
m_eventHandler = event;
for (int i = 0; i < (int)events.size(); i++)
{
libvlc_event_attach(m_pEventMgr, events[i], m_eventHandler, pUserData); //添加事件
}
}
void VLCWrapperImpl::DeleteEventHandler(VLCEventHandler event, void* pUserData)
{
std::vector <libvlc_event_e> events = {
libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerEndReached,
libvlc_MediaPlayerTimeChanged
};
m_eventHandler = event;
for (int i = 0; i < (int)events.size(); i++)
{
libvlc_event_detach(m_pEventMgr, events[i], m_eventHandler, pUserData); //添加事件
}
}
bool VLCWrapperImpl::OpenMedia(const std::string & url)
{
m_pMedia = libvlc_media_new_location(m_pVLCInstance, url.c_str());
//m_pMedia = libvlc_media_new_path(m_pVLCInstance, url.c_str());
if (nullptr != m_pMedia)
{
libvlc_media_player_set_media(m_pMediaPlayer, m_pMedia);
libvlc_media_release(m_pMedia);//20151106
return true;
}
return false;
}
bool VLCWrapperImpl::Play(int width, int height)
{
bool bRet = (0 == libvlc_media_player_play(m_pMediaPlayer));
if (bRet)
{
std::ostringstream os;
os << width << ":" << height;
libvlc_video_set_aspect_ratio(m_pMediaPlayer, os.str().c_str());
}
return bRet;
}
void VLCWrapperImpl::Stop()
{
//if (IsPlaying())
{
libvlc_media_player_stop(m_pMediaPlayer);
}
}
int VLCWrapperImpl::SnapShot(unsigned num, const char *psz_filepath, unsigned int i_width, unsigned int i_height)
{
int iRet = 0;
iRet = libvlc_video_take_snapshot(m_pMediaPlayer, num, psz_filepath, i_width, i_height);
return iRet;
}
int VLCWrapperImpl::IsPlaying()
{
return libvlc_media_player_is_playing(m_pMediaPlayer);
}
libvlc_state_t VLCWrapperImpl::MediaGetState()
{
return libvlc_media_get_state(m_pMedia);
}
没有合适的资源?快使用搜索试试~ 我知道了~
qt播放视频界面添加绘制
共891个文件
dll:747个
h:92个
qm:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 153 浏览量
2024-01-08
15:51:19
上传
评论
收藏 119.44MB ZIP 举报
温馨提示
qt播放视频界面添加绘制
资源推荐
资源详情
资源评论
收起资源包目录
qt播放视频界面添加绘制 (891个子文件)
VLCWrapperImpl.cpp 4KB
DialogDrawShieldArea.cpp 3KB
mainwindow.cpp 3KB
main.cpp 183B
plugins.dat 27B
plugins.dat 27B
libqt_plugin.dll 16.43MB
libqt_plugin.dll 16.43MB
libavcodec_plugin.dll 15.05MB
libavcodec_plugin.dll 15.05MB
opengl32sw.dll 14.52MB
Qt5Guid.dll 10.03MB
Qt5Cored.dll 8.73MB
Qt5Widgetsd.dll 8.06MB
libGLESV2d.dll 6.91MB
D3Dcompiler_47.dll 3.31MB
libx265_plugin.dll 3.15MB
libx265_plugin.dll 3.15MB
libaccess_output_srt_plugin.dll 2.73MB
libaccess_output_srt_plugin.dll 2.73MB
libaccess_srt_plugin.dll 2.73MB
libaccess_srt_plugin.dll 2.73MB
libvpx_plugin.dll 2.59MB
libvpx_plugin.dll 2.59MB
libvlccore.dll 2.54MB
libvlccore.dll 2.54MB
liblibass_plugin.dll 2.37MB
liblibass_plugin.dll 2.37MB
libdcp_plugin.dll 2.32MB
libdcp_plugin.dll 2.32MB
libvnc_plugin.dll 2.24MB
libvnc_plugin.dll 2.24MB
libskins2_plugin.dll 2.14MB
libskins2_plugin.dll 2.14MB
libadaptive_plugin.dll 2.1MB
libadaptive_plugin.dll 2.1MB
libfreetype_plugin.dll 2.04MB
libfreetype_plugin.dll 2.04MB
qwindowsd.dll 1.94MB
liblibbluray_plugin.dll 1.88MB
liblibbluray_plugin.dll 1.88MB
libaom_plugin.dll 1.83MB
libaom_plugin.dll 1.83MB
libx26410b_plugin.dll 1.79MB
libx26410b_plugin.dll 1.79MB
libx264_plugin.dll 1.79MB
libx264_plugin.dll 1.79MB
libprojectm_plugin.dll 1.67MB
libprojectm_plugin.dll 1.67MB
libmkv_plugin.dll 1.66MB
libmkv_plugin.dll 1.66MB
libgnutls_plugin.dll 1.6MB
libgnutls_plugin.dll 1.6MB
libtaglib_plugin.dll 1.53MB
libtaglib_plugin.dll 1.53MB
libsamplerate_plugin.dll 1.44MB
libsamplerate_plugin.dll 1.44MB
libzvbi_plugin.dll 1.41MB
libzvbi_plugin.dll 1.41MB
libstream_out_chromaprint_plugin.dll 1.19MB
libstream_out_chromaprint_plugin.dll 1.19MB
libsid_plugin.dll 1.18MB
libsid_plugin.dll 1.18MB
libschroedinger_plugin.dll 1.17MB
libschroedinger_plugin.dll 1.17MB
libstream_out_chromecast_plugin.dll 1.07MB
libstream_out_chromecast_plugin.dll 1.07MB
libspatialaudio_plugin.dll 1.03MB
libspatialaudio_plugin.dll 1.03MB
libupnp_plugin.dll 1015KB
libupnp_plugin.dll 1015KB
libxml_plugin.dll 999KB
libxml_plugin.dll 999KB
libdshow_plugin.dll 896KB
libdshow_plugin.dll 896KB
libdtv_plugin.dll 873KB
libdtv_plugin.dll 873KB
libswscale_plugin.dll 836KB
libswscale_plugin.dll 836KB
libcaca_plugin.dll 809KB
libcaca_plugin.dll 809KB
libdav1d_plugin.dll 731KB
libdav1d_plugin.dll 731KB
libvorbis_plugin.dll 722KB
libvorbis_plugin.dll 722KB
libsftp_plugin.dll 718KB
libsftp_plugin.dll 718KB
libsdl_image_plugin.dll 708KB
libsdl_image_plugin.dll 708KB
libstream_out_rtp_plugin.dll 675KB
libstream_out_rtp_plugin.dll 675KB
qtiffd.dll 618KB
qwebpd.dll 616KB
libts_plugin.dll 572KB
libts_plugin.dll 572KB
libremoteosd_plugin.dll 559KB
libremoteosd_plugin.dll 559KB
libaccess_output_livehttp_plugin.dll 553KB
libaccess_output_livehttp_plugin.dll 553KB
librtp_plugin.dll 546KB
共 891 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
烈日下的奔跑
- 粉丝: 1071
- 资源: 232
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功