General understanding of libvlc_video_set_callbacks

This forum is about all development around libVLC.
zack
Blank Cone
Blank Cone
Posts: 13
Joined: 21 Sep 2014 16:53

Re: General understanding of libvlc_video_set_callbacks

Postby zack » 25 Sep 2014 11:34

I know shared_ptr. But I still don't get it.
You have to explain what happens here: m_videoFrame = frame;
Imagine that the video surface does not copy VideoFrame(so no increased count usage, he directly use it, and render its content)
m_videoSurface->present( newFrame );
the present method take it as const reference

Take a look at the following code, maybe then you see my problem:

Code: Select all

void render(const std::shared_ptr<int>& foo) { std::cout << foo.use_count(); // this would be zero, when called at the same time, although the ptr goes in with use count 1 } int main() { std::shared_ptr<int> p1( new int( 0 ) ); p1.reset(new int( 1 )); // the same like m_videoFrame = frame; render(p1); // imagine that this is called at the same time like the statement above return 0; }

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: General understanding of libvlc_video_set_callbacks

Postby RSATom » 25 Sep 2014 11:45

ok, I think I understand what you mean. You think that QVideoFrame always travel as pointer or reference - it's invalid assumption.

trick is here https://github.com/RSATom/QmlVlc/blob/m ... t.cpp#L116 (link was edited)

When Qt pass instance of QVideoFrame to another thread - it has to make _copy_ of it internally. It can't use reference or pointer for it. It's how data transmission between threads works in Qt.

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: General understanding of libvlc_video_set_callbacks

Postby RSATom » 25 Sep 2014 11:50

This means that instance of QVideoFrame that go to QMetaObject::invokeMethod ( https://github.com/RSATom/QmlVlc/blob/m ... t.cpp#L116 ) is different from instance that come to QmlVlcMmVideoOutput::presentFrame ( https://github.com/RSATom/QmlVlc/blob/m ... t.cpp#L129 ). They share same data (until some time point), but it's two different instances of QVideoFrame definitely.

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: General understanding of libvlc_video_set_callbacks

Postby RSATom » 25 Sep 2014 11:52

and when I do m_videoFrame = frame; I break sharing, and only renderer has reference to previous frame after this point.

So synchronization is there, it's just not so obvious.

zack
Blank Cone
Blank Cone
Posts: 13
Joined: 21 Sep 2014 16:53

Re: General understanding of libvlc_video_set_callbacks

Postby zack » 25 Sep 2014 15:03

I looked into the source of:
qmemoryvideobuffer.cpp
There is no VRAM on the gpu provided, its just some simple system memory.
So they must to the same, upload the system memory to the GPU every frame update

Thats why I wonder whether it is really possible like you said to provide some PBO for libvlc directly?

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: General understanding of libvlc_video_set_callbacks

Postby RSATom » 25 Sep 2014 15:07

qt has some platform specific code too: https://qt.gitorious.org/qt/qtmultimedi ... rc/plugins

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: General understanding of libvlc_video_set_callbacks

Postby RSATom » 25 Sep 2014 15:07

about PBO, it's just need some time to play with it...

zack
Blank Cone
Blank Cone
Posts: 13
Joined: 21 Sep 2014 16:53

Re: General understanding of libvlc_video_set_callbacks

Postby zack » 26 Sep 2014 23:24

PBO cannot be used under OpenGL ES 2.0. So I think the upload of three textures is the way to go at the moment.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 68 guests