Files
mapmap/Paint.cpp
Vasilis Liaskovitis f3e94f743c Support shmsrc (live source)
If the imported file is a socket path, we mark the media as "live". We
continuously poll for the socket path (in case e.g. it disappears / reappears).
As soon as the source socket patch exists, we connect a shmsrc ! gdpdepay
pipeline  (instead of a normal uridecodebin element for file-based media) and we
set the pipeline state to PLAYING (playAction button is not needed at the moment
for live sources, but we can change behaviour to only start the pipeline if
play is selected, like with normal file-based media)

In case of a GST_MESSAGE_ERROR, the polling function keeps looking for the
socket path until it exists again. The existing shmsrc pipeline is re-used
once the live source is transmitting again.

Tested with live source gst-launch-1.0:

gst-launch-1.0 uridecodebin uri=file:////opt/Videos/test.avi !  queue !
videoconvert ! video/x-raw, format="RGBA" ! gdppay ! shmsink
socket-path=/tmp/sock  shm-size=100000000

The live source was interrupted and restarted again, and the shmsrc in mapmap is
able to pick up the reappearing media stream.

Signed-off-by: Vasilis Liaskovitis <vliaskov@gmail.com>
2014-10-13 16:07:50 +02:00

128 lines
2.3 KiB
C++

/*
* Paint.cpp
*
* (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Paint.h"
#include "MediaImpl.h"
#include <iostream>
UidAllocator Paint::allocator;
Paint::Paint(uid id)
{
if (id == NULL_UID)
id = allocator.allocate();
else
{
Q_ASSERT(!allocator.exists(id));
allocator.reserve(id);
}
// Assign id.
_id = id;
}
Paint::~Paint()
{
allocator.free(_id);
}
bool Image::setUri(const QString &uri)
{
this->uri = uri;
build();
return true;
}
/* Implementation of the Video class */
Media::Media(const QString uri_, bool live, uid id):
Texture(id),
uri(uri_),
impl_(NULL)
{
impl_ = new MediaImpl(uri_, live);
}
// vertigo
Media::~Media()
{
delete impl_;
}
void Media::build()
{
this->impl_->build();
}
int Media::getWidth() const
{
// Wait for impl to be ready.
while (!this->impl_->isReady());
return this->impl_->getWidth();
}
int Media::getHeight() const
{
// Wait for impl to be ready.
while (!this->impl_->isReady());
return this->impl_->getHeight();
}
void Media::update() {
if (impl_->runVideo())
bitsChanged = true;
}
void Media::play()
{
impl_->setPlayState(true);
}
void Media::pause()
{
impl_->setPlayState(false);
}
void Media::rewind()
{
impl_->resetMovie();
}
const uchar* Media::_getBits() const
{
return this->impl_->getBits();
}
bool Media::hasVideoSupport()
{
return MediaImpl::hasVideoSupport();
}
bool Media::setUri(const QString &uri)
{
bool success = false;
this->uri = uri;
success = this->impl_->loadMovie(uri);
if (! success)
qDebug() << "Cannot load movie " << uri << "." << endl;
return success;
}