Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (3)
......@@ -61,6 +61,67 @@ public:
return mBuffers[m_idx_display].get();
}
void onResize(QSize size)
{
QMutexLocker lock(&m_cb_lock);
m_windowSize = size;
if (!report_size_change)
return;
report_size_change(reportOpaque, size.width(), size.height());
}
void onMouseMove(QPoint pos)
{
QMutexLocker lock(&m_cb_lock);
if (!report_mouse_move)
return;
report_mouse_move(reportOpaque, pos.x(), pos.y());
}
void onMousePress(Qt::MouseButton button)
{
QMutexLocker lock(&m_cb_lock);
if (!report_mouse_press)
return;
bool ok;
auto vlcButton = qtToVlcMouseButton(button, &ok);
if (!ok)
return;
report_mouse_press(reportOpaque, vlcButton);
}
void onMouseRelease(Qt::MouseButton button)
{
QMutexLocker lock(&m_cb_lock);
if (!report_mouse_release)
return;
bool ok;
auto vlcButton = qtToVlcMouseButton(button, &ok);
if (!ok)
return;
report_mouse_release(reportOpaque, vlcButton);
}
static void setReportCallbacks(void* data,
libvlc_video_output_resize_cb report_size_change,
libvlc_video_output_mouse_move_cb report_mouse_move,
libvlc_video_output_mouse_press_cb report_mouse_press,
libvlc_video_output_mouse_release_cb report_mouse_release,
void* reportOpaque)
{
VLCVideo* that = static_cast<VLCVideo*>(data);
QMutexLocker lock(&that->m_cb_lock);
that->reportOpaque = reportOpaque;
that->report_size_change = report_size_change;
that->report_mouse_move = report_mouse_move;
that->report_mouse_press = report_mouse_press;
that->report_mouse_release = report_mouse_release;
//report initial window size
if (report_size_change && that->m_windowSize.isValid())
report_size_change(that->reportOpaque, that->m_windowSize.width(), that->m_windowSize.height());
}
/// this callback will create the surfaces and FBO used by VLC to perform its rendering
static bool resizeRenderTextures(void* data, const libvlc_video_render_cfg_t *cfg,
libvlc_video_output_cfg_t *render_cfg)
......@@ -159,6 +220,24 @@ public:
}
private:
libvlc_video_output_mouse_button_t qtToVlcMouseButton(Qt::MouseButton button, bool* ok)
{
assert(ok != nullptr);
*ok = true;
switch (button)
{
case Qt::LeftButton:
return libvlc_video_output_mouse_button_left;
case Qt::RightButton:
return libvlc_video_output_mouse_button_right;
case Qt::MiddleButton:
return libvlc_video_output_mouse_button_middle;
default:
*ok = false;
return libvlc_video_output_mouse_button_left;
}
}
QtVLCWidget *mWidget;
QOpenGLContext *mContext;
QOffscreenSurface *mSurface;
......@@ -173,6 +252,16 @@ private:
size_t m_idx_swap = 1;
size_t m_idx_display = 2;
bool m_updated = false;
QSize m_windowSize;
QMutex m_cb_lock;
void* reportOpaque = nullptr;
libvlc_video_output_resize_cb report_size_change = nullptr;
libvlc_video_output_mouse_move_cb report_mouse_move = nullptr;
libvlc_video_output_mouse_press_cb report_mouse_press = nullptr;
libvlc_video_output_mouse_release_cb report_mouse_release = nullptr;
};
......@@ -181,6 +270,8 @@ QtVLCWidget::QtVLCWidget(QWidget *parent)
vertexBuffer(QOpenGLBuffer::VertexBuffer),
vertexIndexBuffer(QOpenGLBuffer::IndexBuffer)
{
setMouseTracking(true);
// --transparent causes the clear color to be transparent. Therefore, on systems that
// support it, the widget will become transparent apart from the logo.
......@@ -209,7 +300,7 @@ bool QtVLCWidget::playMedia(const char* url)
// Define the opengl rendering callbacks
libvlc_video_set_output_callbacks(m_mp,
mVLC->isOpenGLES() ? libvlc_video_engine_gles2 : libvlc_video_engine_opengl,
VLCVideo::setup, VLCVideo::cleanup, nullptr, VLCVideo::resizeRenderTextures, VLCVideo::swap,
VLCVideo::setup, VLCVideo::cleanup, VLCVideo::setReportCallbacks, VLCVideo::resizeRenderTextures, VLCVideo::swap,
VLCVideo::make_current, VLCVideo::get_proc_address, nullptr, nullptr,
mVLC.get());
......@@ -371,7 +462,23 @@ void QtVLCWidget::paintGL()
void QtVLCWidget::resizeGL(int w, int h)
{
Q_UNUSED(w);
Q_UNUSED(h);
/* TODO */
mVLC->onResize(QSize(w, h));
}
void QtVLCWidget::mouseMoveEvent(QMouseEvent *event)
{
QOpenGLWidget::mouseMoveEvent(event);
mVLC->onMouseMove(event->pos());
}
void QtVLCWidget::mousePressEvent(QMouseEvent *event)
{
QOpenGLWidget::mousePressEvent(event);
mVLC->onMousePress(event->button());
}
void QtVLCWidget::mouseReleaseEvent(QMouseEvent *event)
{
QOpenGLWidget::mouseReleaseEvent(event);
mVLC->onMouseRelease(event->button());
}
......@@ -31,6 +31,10 @@ protected:
void paintGL() override;
void resizeGL(int width, int height) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
private:
QOpenGLVertexArrayObject m_vao;
std::unique_ptr<QOpenGLShaderProgram> m_program;
......
......@@ -11,6 +11,7 @@
*/
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <cassert>
......@@ -81,6 +82,9 @@ struct render_context
unsigned width, height;
} client_area;
libvlc_video_output_resize_cb ReportSize;
libvlc_video_output_mouse_move_cb MouseMove;
libvlc_video_output_mouse_press_cb MousePress;
libvlc_video_output_mouse_release_cb MouseRelease;
void *ReportOpaque;
};
......@@ -498,13 +502,19 @@ static void CleanupDevice_cb( void *opaque )
}
// receive the libvlc callback to call when we want to change the libvlc output size
static void SetResize_cb( void *opaque,
static void SetReport_cb( void *opaque,
libvlc_video_output_resize_cb report_size_change,
libvlc_video_output_mouse_move_cb report_mouse_move,
libvlc_video_output_mouse_press_cb report_mouse_press,
libvlc_video_output_mouse_release_cb report_mouse_release,
void *report_opaque )
{
struct render_context *ctx = static_cast<struct render_context *>( opaque );
AcquireSRWLockExclusive(&ctx->sizeLock);
ctx->ReportSize = report_size_change;
ctx->MouseMove = report_mouse_move;
ctx->MousePress = report_mouse_press;
ctx->MouseRelease = report_mouse_release;
ctx->ReportOpaque = report_opaque;
if (ctx->ReportSize != nullptr)
......@@ -515,6 +525,25 @@ static void SetResize_cb( void *opaque,
ReleaseSRWLockExclusive(&ctx->sizeLock);
}
static libvlc_video_output_mouse_button_t windowsButtonToVLC(UINT message)
{
switch (message)
{
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
return libvlc_video_output_mouse_button_left;
case WM_MBUTTONUP:
case WM_MBUTTONDOWN:
return libvlc_video_output_mouse_button_middle;
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:
return libvlc_video_output_mouse_button_right;
default:
//should not happen
return libvlc_video_output_mouse_button_right;
}
}
static const char *AspectRatio = NULL;
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
......@@ -572,6 +601,42 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
}
break;
case WM_MOUSEMOVE:
{
int mouseX = int(GET_X_LPARAM(lParam) - ctx->client_area.width * (BORDER_LEFT + 1)/2.0f);
int mouseY = int(GET_Y_LPARAM(lParam) - ctx->client_area.width * (1 - BORDER_TOP) / 2.0f);
AcquireSRWLockExclusive(&ctx->sizeLock);
if (ctx->MouseMove != nullptr)
ctx->MouseMove(ctx->ReportOpaque, mouseX, mouseY);
ReleaseSRWLockExclusive(&ctx->sizeLock);
}
break;
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_LBUTTONDOWN:
{
auto button = windowsButtonToVLC(message);
AcquireSRWLockExclusive(&ctx->sizeLock);
if (ctx->MousePress != nullptr)
ctx->MousePress(ctx->ReportOpaque, button);
ReleaseSRWLockExclusive(&ctx->sizeLock);
}
break;
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_LBUTTONUP:
{
auto button = windowsButtonToVLC(message);
AcquireSRWLockExclusive(&ctx->sizeLock);
if (ctx->MouseRelease != nullptr)
ctx->MouseRelease(ctx->ReportOpaque, button);
ReleaseSRWLockExclusive(&ctx->sizeLock);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
......@@ -681,7 +746,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
/* Tell VLC to render into our D3D11 environment */
libvlc_video_set_output_callbacks( Context.p_mp, libvlc_video_engine_d3d11,
SetupDevice_cb, CleanupDevice_cb, SetResize_cb,
SetupDevice_cb, CleanupDevice_cb, SetReport_cb,
UpdateOutput_cb, Swap_cb, StartRendering_cb,
nullptr, nullptr, SelectPlane_cb,
&Context );
......
......@@ -222,9 +222,12 @@ static void CleanupDevice_cb( void *opaque )
}
}
static void SetResize_cb( void *opaque,
libvlc_video_output_resize_cb report_size_change,
void *report_opaque )
static void SetReport_cb( void *opaque,
libvlc_video_output_resize_cb report_size_change,
libvlc_video_output_mouse_move_cb report_mouse_move,
libvlc_video_output_mouse_press_cb report_mouse_press,
libvlc_video_output_mouse_release_cb report_mouse_release,
void *report_opaque )
{
struct render_context *ctx = opaque;
EnterCriticalSection(&ctx->sizeLock);
......@@ -416,7 +419,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
/* Tell VLC to render into our D3D9 environment */
libvlc_video_set_output_callbacks( Context.p_mp, libvlc_video_engine_d3d9,
SetupDevice_cb, CleanupDevice_cb, SetResize_cb,
SetupDevice_cb, CleanupDevice_cb, SetReport_cb,
UpdateOutput_cb, Swap_cb, StartRendering_cb,
NULL, NULL, NULL,
&Context );
......
......@@ -717,32 +717,92 @@ typedef enum libvlc_video_engine_t {
/** Callback type that can be called to request a render size changes.
*
* libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_resize_cb.
*
* \param report_opaque parameter passed to \ref libvlc_video_output_set_resize_cb. [IN]
*
* libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb.
*
* \param report_opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN]
* \param width new rendering width requested. [IN]
* \param height new rendering height requested. [IN]
*/
typedef void( *libvlc_video_output_resize_cb )( void *report_opaque, unsigned width, unsigned height );
/**
* Enumeration of the different mouse buttons that can be reported for user interaction
* can be passed to \ref libvlc_video_output_mouse_press_cb and \ref libvlc_video_output_mouse_release_cb.
*/
typedef enum libvlc_video_output_mouse_button_t {
libvlc_video_output_mouse_button_left = 0,
libvlc_video_output_mouse_button_middle = 1,
libvlc_video_output_mouse_button_right = 2
} libvlc_video_output_mouse_button_t;
/** Callback type that can be called to notify the mouse position when hovering the render surface.
*
* libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb.
*
* The position (0,0) denotes the top left corner, bottom right corner position
* is (width,height) as reported by \ref libvlc_video_output_resize_cb.
*
* \param report_opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN]
* \param x horizontal mouse positon in \ref libvlc_video_output_resize_cb coordinates. [IN]
* \param y vertical mouse positon in \ref libvlc_video_output_resize_cb coordinates. [IN]
*/
typedef void (*libvlc_video_output_mouse_move_cb)(void *opaque, int x, int y);
/** Callback type that can be called to notify when a mouse button is pressed in the rendering surface.
*
* libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb.
*
* The button event will be reported at the last position provided by \ref libvlc_video_output_mouse_move_cb
*
* \param report_opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN]
* \param button represent the button pressed, see \ref libvlc_video_output_mouse_button_t for available buttons. [IN]
*/
typedef void (*libvlc_video_output_mouse_press_cb)(void *opaque, libvlc_video_output_mouse_button_t button);
/** Callback type that can be called to notify when a mouse button is released in the rendering surface.
*
* libvlc will provide a callback of this type when calling \ref libvlc_video_output_set_window_cb.
*
* The button event will be reported at the last position provided by \ref libvlc_video_output_mouse_move_cb.
*
* \param report_opaque parameter passed to \ref libvlc_video_output_set_window_cb. [IN]
* \param button represent the button released, see \ref libvlc_video_output_mouse_button_t for available buttons. [IN]
*/
typedef void (*libvlc_video_output_mouse_release_cb)(void *opaque, libvlc_video_output_mouse_button_t button);
/** Set the callback to call when the host app resizes the rendering area.
*
* This allows text rendering and aspect ratio to be handled properly when the host
* rendering size changes.
* rendering size changes and to provide mouse.
*
* It may be called before the \ref libvlc_video_output_setup_cb callback.
*
* \warning These callbacks cannot be called concurently, the caller is responsible for serialization
*
* \param[in] opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb()
* \param[in] report_size_change callback which must be called when the host size changes.
* The callback is valid until another call to \ref libvlc_video_output_set_resize_cb
* is done. This may be called from any thread.
* \param[in] report_mouse_move callback which must be called when the mouse position change on the video surface.
* The coordinates are relative to the size reported through the report_size_change.
* This may be called from any thread.
* \param[in] report_mouse_pressed callback which must be called when a mouse button is pressed on the video surface,
* The position of the event is the last position reported by the report_mouse_move callback. This may be
* called from any thread.
* \param[in] report_mouse_released callback which must be called when a mouse button is released on the video surface,
* The position of the event is the last position reported by the report_mouse_move callback. This may be
* called from any thread.
* \param[in] report_opaque private pointer to pass to the \ref report_size_change callback.
*/
typedef void( *libvlc_video_output_set_resize_cb )( void *opaque,
libvlc_video_output_resize_cb report_size_change,
void *report_opaque );
typedef void( *libvlc_video_output_set_window_cb )( void *opaque,
libvlc_video_output_resize_cb report_size_change,
libvlc_video_output_mouse_move_cb report_mouse_move,
libvlc_video_output_mouse_press_cb report_mouse_pressed,
libvlc_video_output_mouse_release_cb report_mouse_released,
void *report_opaque );
/** Tell the host the rendering for the given plane is about to start
*
......@@ -801,7 +861,7 @@ bool libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
libvlc_video_engine_t engine,
libvlc_video_output_setup_cb setup_cb,
libvlc_video_output_cleanup_cb cleanup_cb,
libvlc_video_output_set_resize_cb resize_cb,
libvlc_video_output_set_window_cb window_cb,
libvlc_video_update_output_cb update_output_cb,
libvlc_video_swap_cb swap_cb,
libvlc_video_makeCurrent_cb makeCurrent_cb,
......
......@@ -634,7 +634,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create( mp, "vout-cb-opaque", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-setup", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-cleanup", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-resize-cb", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-window-cb", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-update-output", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-swap", VLC_VAR_ADDRESS );
var_Create( mp, "vout-cb-get-proc-address", VLC_VAR_ADDRESS );
......@@ -1062,7 +1062,7 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
libvlc_video_engine_t engine,
libvlc_video_output_setup_cb setup_cb,
libvlc_video_output_cleanup_cb cleanup_cb,
libvlc_video_output_set_resize_cb resize_cb,
libvlc_video_output_set_window_cb set_window_cb,
libvlc_video_update_output_cb update_output_cb,
libvlc_video_swap_cb swap_cb,
libvlc_video_makeCurrent_cb makeCurrent_cb,
......@@ -1108,7 +1108,7 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
var_SetAddress( mp, "vout-cb-opaque", opaque );
var_SetAddress( mp, "vout-cb-setup", setup_cb );
var_SetAddress( mp, "vout-cb-cleanup", cleanup_cb );
var_SetAddress( mp, "vout-cb-resize-cb", resize_cb );
var_SetAddress( mp, "vout-cb-window-cb", set_window_cb );
var_SetAddress( mp, "vout-cb-update-output", update_output_cb );
var_SetAddress( mp, "vout-cb-swap", swap_cb );
var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
......
......@@ -48,7 +48,7 @@ vlc_module_end()
typedef struct {
void *opaque;
libvlc_video_output_set_resize_cb setResizeCb;
libvlc_video_output_set_window_cb setWindowCb;
} wextern_t;
static void WindowResize(void *opaque, unsigned width, unsigned height)
......@@ -57,13 +57,34 @@ static void WindowResize(void *opaque, unsigned width, unsigned height)
vlc_window_ReportSize(window, width, height);
}
static void WindowMouseMoved(void *opaque, int x, int y)
{
vlc_window_t *window = opaque;
vlc_window_ReportMouseMoved(window, x, y);
}
static void WindowMousePress(void *opaque, libvlc_video_output_mouse_button_t button)
{
vlc_window_t *window = opaque;
vlc_window_ReportMousePressed(window, button);
}
static void WindowMouseRelease(void *opaque, libvlc_video_output_mouse_button_t button)
{
vlc_window_t *window = opaque;
vlc_window_ReportMouseReleased(window, button);
}
static int Enable(struct vlc_window *wnd, const vlc_window_cfg_t *wcfg)
{
wextern_t *sys = wnd->sys;
if ( sys->setResizeCb != NULL )
if ( sys->setWindowCb != NULL )
/* bypass the size handling as the window doesn't handle the size */
sys->setResizeCb( sys->opaque, WindowResize, wnd );
sys->setWindowCb( sys->opaque,
WindowResize,
WindowMouseMoved, WindowMousePress, WindowMouseRelease,
wnd );
(void) wcfg;
return VLC_SUCCESS;
......@@ -73,8 +94,8 @@ static void Disable(struct vlc_window *wnd)
{
wextern_t *sys = wnd->sys;
if ( sys->setResizeCb != NULL )
sys->setResizeCb( sys->opaque, NULL, NULL );
if ( sys->setWindowCb != NULL )
sys->setWindowCb( sys->opaque, NULL, NULL, NULL, NULL, NULL );
}
static const struct vlc_window_operations ops = {
......@@ -89,11 +110,13 @@ static int Open(vlc_window_t *wnd)
wextern_t *sys = vlc_obj_malloc(VLC_OBJECT(wnd), sizeof(*sys));
if (unlikely(sys==NULL))
return VLC_ENOMEM;
sys->opaque = var_InheritAddress( wnd, "vout-cb-opaque" );
sys->setResizeCb = var_InheritAddress( wnd, "vout-cb-resize-cb" );
sys->setWindowCb = var_InheritAddress( wnd, "vout-cb-window-cb" );
wnd->sys = sys;
wnd->type = VLC_WINDOW_TYPE_DUMMY;
wnd->ops = &ops;
wnd->info.has_double_click = false;
return VLC_SUCCESS;
}