----- Original Message -----
> From: "Vivien Didelot" <[email protected]>
> To: [email protected]
> Cc: "tristan matthews" <[email protected]>, "Vivien
> Didelot"
> <[email protected]>
> Sent: Thursday, February 13, 2014 1:21:23 PM
> Subject: [PATCH v2] * #40804: daemon: rename VideoCamera to VideoInput
>
> This patch renames the VideoCamera class to VideoInput.
> Note that the rename only affect the code currently, not the dbus
> API.
> This means that in the dbus API, we still have some VideoCamera
> methods.
> ---
> daemon/src/client/dbus/video_controls.cpp | 24 ++---
> daemon/src/client/video_controls.h | 4 +-
> daemon/src/conference.cpp | 2 +-
> daemon/src/video/Makefile.am | 2 +-
> daemon/src/video/test/Makefile.am | 8 +-
> daemon/src/video/test/test_video_camera.cpp | 12 +--
> daemon/src/video/test/test_video_camera.h | 10 +-
> daemon/src/video/video_camera.cpp | 160
> ---------------------------
> daemon/src/video/video_camera.h | 82 --------------
> daemon/src/video/video_input.cpp | 161
> ++++++++++++++++++++++++++++
> daemon/src/video/video_input.h | 83 ++++++++++++++
> daemon/src/video/video_mixer.cpp | 8 +-
> daemon/src/video/video_rtp_session.cpp | 8 +-
> 13 files changed, 283 insertions(+), 281 deletions(-)
> delete mode 100644 daemon/src/video/video_camera.cpp
> delete mode 100644 daemon/src/video/video_camera.h
> create mode 100644 daemon/src/video/video_input.cpp
> create mode 100644 daemon/src/video/video_input.h
>
> diff --git a/daemon/src/client/dbus/video_controls.cpp
> b/daemon/src/client/dbus/video_controls.cpp
> index b93e6c8..e2b61a1 100644
> --- a/daemon/src/client/dbus/video_controls.cpp
> +++ b/daemon/src/client/dbus/video_controls.cpp
> @@ -32,7 +32,7 @@
>
> #include "video_controls.h"
> #include "video/libav_utils.h"
> -#include "video/video_camera.h"
> +#include "video/video_input.h"
> #include "account.h"
> #include "logger.h"
> #include "manager.h"
> @@ -43,9 +43,9 @@ const char * const SERVER_PATH =
> "/org/sflphone/SFLphone/VideoControls";
>
> VideoControls::VideoControls(DBus::Connection& connection) :
> DBus::ObjectAdaptor(connection, SERVER_PATH)
> - , videoCamera_()
> + , videoInput_()
> , videoPreference_()
> - , cameraClients_(0)
> + , inputClients_(0)
> {
> // initialize libav libraries
> libav_utils::sfl_avcodec_init();
> @@ -160,8 +160,8 @@ VideoControls::getSettings() {
> void
> VideoControls::startCamera()
> {
> - cameraClients_++;
> - if (videoCamera_) {
> + inputClients_++;
> + if (videoInput_) {
> WARN("Video preview was already started!");
> return;
> }
> @@ -170,17 +170,17 @@ VideoControls::startCamera()
> using std::string;
>
> map<string, string> args(videoPreference_.getSettings());
> - videoCamera_.reset(new sfl_video::VideoCamera(args));
> + videoInput_.reset(new sfl_video::VideoInput(args));
> }
>
> void
> VideoControls::stopCamera()
> {
> - if (videoCamera_) {
> + if (videoInput_) {
> DEBUG("Stopping video preview");
> - cameraClients_--;
> - if (cameraClients_ <= 0)
> - videoCamera_.reset();
> + inputClients_--;
> + if (inputClients_ <= 0)
> + videoInput_.reset();
> } else {
> WARN("Video preview was already stopped");
> }
> @@ -189,14 +189,14 @@ VideoControls::stopCamera()
> std::weak_ptr<sfl_video::VideoFrameActiveWriter>
> VideoControls::getVideoCamera()
> {
> - return videoCamera_;
> + return videoInput_;
> }
>
> bool
> VideoControls::hasCameraStarted()
> {
> // see http://stackoverflow.com/a/7580064/21185
> - return static_cast<bool>(videoCamera_);
> + return static_cast<bool>(videoInput_);
> }
>
> std::string
> diff --git a/daemon/src/client/video_controls.h
> b/daemon/src/client/video_controls.h
> index 8d98dd5..0a5fc88 100644
> --- a/daemon/src/client/video_controls.h
> +++ b/daemon/src/client/video_controls.h
> @@ -63,10 +63,10 @@ class VideoControls : public
> org::sflphone::SFLphone::VideoControls_adaptor,
> public DBus::IntrospectableAdaptor,
> public DBus::ObjectAdaptor {
> private:
> - std::shared_ptr<sfl_video::VideoFrameActiveWriter>
> videoCamera_;
> + std::shared_ptr<sfl_video::VideoFrameActiveWriter>
> videoInput_;
> VideoPreference videoPreference_;
> // Only modified from main thread
> - int cameraClients_;
> + int inputClients_;
>
> public:
>
> diff --git a/daemon/src/conference.cpp b/daemon/src/conference.cpp
> index 70c38e3..90940de 100644
> --- a/daemon/src/conference.cpp
> +++ b/daemon/src/conference.cpp
> @@ -40,7 +40,7 @@
> #include "sip/sipvoiplink.h"
> #include "sip/sipcall.h"
> #include "client/video_controls.h"
> -#include "video/video_camera.h"
> +#include "video/video_input.h"
> #endif
>
> #include "logger.h"
> diff --git a/daemon/src/video/Makefile.am
> b/daemon/src/video/Makefile.am
> index 2187c8e..225be03 100644
> --- a/daemon/src/video/Makefile.am
> +++ b/daemon/src/video/Makefile.am
> @@ -14,7 +14,7 @@ libvideo_la_SOURCES = \
> video_mixer.cpp video_mixer.h \
> socket_pair.cpp socket_pair.h \
> shm_sink.cpp shm_sink.h \
> - video_camera.cpp video_camera.h \
> + video_input.cpp video_input.h \
> video_receive_thread.cpp video_receive_thread.h \
> video_sender.cpp video_sender.h \
> video_rtp_session.cpp video_rtp_session.h \
> diff --git a/daemon/src/video/test/Makefile.am
> b/daemon/src/video/test/Makefile.am
> index c0a731a..79a0847 100644
> --- a/daemon/src/video/test/Makefile.am
> +++ b/daemon/src/video/test/Makefile.am
> @@ -1,7 +1,7 @@
> include ../../../globals.mak
>
> -TESTS=test_video_endpoint test_v4l2 test_shm test_video_camera
> test_video_rtp
> -check_PROGRAMS=test_video_endpoint test_video_rtp test_video_camera
> test_v4l2 test_shm
> +TESTS=test_video_endpoint test_v4l2 test_shm test_video_input
> test_video_rtp
> +check_PROGRAMS=test_video_endpoint test_video_rtp test_video_input
> test_v4l2 test_shm
>
> test_video_endpoint_SOURCES=test_video_endpoint.cpp
> test_video_endpoint.h
> test_video_endpoint_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src/video/libvideo.la $(YAML_LIBS)
> @@ -9,8 +9,8 @@
> test_video_endpoint_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src
> test_video_rtp_SOURCES=test_video_rtp.cpp
> test_video_rtp_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src/video/libvideo.la $(YAML_LIBS)
>
> -test_video_camera_SOURCES=test_video_camera.cpp test_video_camera.h
> -test_video_camera_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src/video/libvideo.la $(YAML_LIBS)
> +test_video_input_SOURCES=test_video_input.cpp test_video_input.h
> +test_video_input_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src/video/libvideo.la $(YAML_LIBS)
>
> test_v4l2_SOURCES=test_v4l2.cpp $(top_srcdir)/src/logger.cpp
> test_v4l2_LDADD=$(top_builddir)/src/libsflphone.la
> $(top_builddir)/src/video/libvideo.la $(YAML_LIBS)
> diff --git a/daemon/src/video/test/test_video_camera.cpp
> b/daemon/src/video/test/test_video_camera.cpp
> index 51f656c..35922ec 100644
> --- a/daemon/src/video/test/test_video_camera.cpp
> +++ b/daemon/src/video/test/test_video_camera.cpp
> @@ -29,29 +29,29 @@
> */
>
> #include <unistd.h> // for sleep
> -#include "test_video_camera.h"
> -#include "video_camera.h"
> +#include "test_video_input.h"
> +#include "video_input.h"
> #include <map>
> #include <string>
>
> using namespace std;
>
> -void VideoCameraTest::testCamera()
> +void VideoInputTest::testInput()
> {
> std::map<std::string, std::string> args;
> args["input"] = "/dev/video0";
> args["width"] = "640";
> args["height"] = "480";
>
> - sfl_video::VideoCamera camera(args);
> + sfl_video::VideoInput camera(args);
> sleep(1);
> }
>
> int main ()
> {
> for (int i = 0; i < 20; ++i) {
> - VideoCameraTest test;
> - test.testCamera();
> + VideoInputTest test;
> + test.testInput();
> }
> return 0;
> }
> diff --git a/daemon/src/video/test/test_video_camera.h
> b/daemon/src/video/test/test_video_camera.h
> index 5db1e9c..d80768e 100644
> --- a/daemon/src/video/test/test_video_camera.h
> +++ b/daemon/src/video/test/test_video_camera.h
> @@ -28,12 +28,12 @@
> * as that of the covered work.
> */
>
> -#ifndef _VIDEO_CAMERA_TEST_
> -#define _VIDEO_CAMERA_TEST_
> +#ifndef _VIDEO_INPUT_TEST_
> +#define _VIDEO_INPUT_TEST_
>
> -class VideoCameraTest {
> +class VideoInputTest {
> public:
> - void testCamera();
> + void testInput();
> };
>
> -#endif // _VIDEO_CAMERA_TEST_
> +#endif // _VIDEO_INPUT_TEST_
> diff --git a/daemon/src/video/video_camera.cpp
> b/daemon/src/video/video_camera.cpp
> deleted file mode 100644
> index c4a45c5..0000000
> --- a/daemon/src/video/video_camera.cpp
> +++ /dev/null
> @@ -1,160 +0,0 @@
> -/*
> - * Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
> - * Author: Tristan Matthews <[email protected]>
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA.
> - *
> - * Additional permission under GNU GPL version 3 section 7:
> - *
> - * If you modify this program, or any covered work, by linking or
> - * combining it with the OpenSSL project's OpenSSL library (or a
> - * modified version of that library), containing parts covered by
> the
> - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
> - * grants you additional permission to convey the resulting work.
> - * Corresponding Source for a non-source form of such a combination
> - * shall include the source code for the parts of OpenSSL used as
> well
> - * as that of the covered work.
> - */
> -
> -#include "video_camera.h"
> -#include "video_decoder.h"
> -#include "check.h"
> -
> -#include "manager.h"
> -#include "client/video_controls.h"
> -
> -#include <map>
> -#include <string>
> -
> -#define SINK_ID "local"
> -
> -namespace sfl_video {
> -
> -using std::string;
> -
> -VideoCamera::VideoCamera(const std::map<std::string, std::string>
> &args) :
> - VideoGenerator::VideoGenerator()
> - , id_(SINK_ID)
> - , args_(args)
> - , decoder_(0)
> - , sink_()
> - , sinkWidth_(0)
> - , sinkHeight_(0)
> -{ start(); }
> -
> -VideoCamera::~VideoCamera()
> -{
> - stop();
> - join();
> -}
> -
> -bool VideoCamera::setup()
> -{
> - // it's a v4l device if starting with /dev/video
> - static const char * const V4L_PATH = "/dev/video";
> -
> - string format_str;
> - string input = args_["input"];
> -
> - decoder_ = new VideoDecoder();
> -
> - if (args_["input"].find(V4L_PATH) != std::string::npos) {
> - DEBUG("Using v4l2 format");
> - format_str = "video4linux2";
> - }
> - if (!args_["framerate"].empty())
> - decoder_->setOption("framerate",
> args_["framerate"].c_str());
> - if (!args_["video_size"].empty())
> - decoder_->setOption("video_size",
> args_["video_size"].c_str());
> - if (!args_["channel"].empty())
> - decoder_->setOption("channel", args_["channel"].c_str());
> -
> - decoder_->setInterruptCallback(interruptCb, this);
> -
> - EXIT_IF_FAIL(decoder_->openInput(input, format_str) >= 0,
> - "Could not open input \"%s\"", input.c_str());
> -
> - /* Data available, finish the decoding */
> - EXIT_IF_FAIL(!decoder_->setupFromVideoData(),
> - "decoder IO startup failed");
> -
> - /* Preview frame size? (defaults from decoder) */
> - if (!args_["width"].empty())
> - sinkWidth_ = atoi(args_["width"].c_str());
> - else
> - sinkWidth_ = decoder_->getWidth();
> - if (!args_["height"].empty())
> - sinkHeight_ = atoi(args_["height"].c_str());
> - else
> - sinkHeight_ = decoder_->getHeight();
> -
> - /* Sink setup */
> - EXIT_IF_FAIL(sink_.start(), "Cannot start shared memory sink");
> - if (attach(&sink_)) {
> - Manager::instance().getVideoControls()->startedDecoding(id_,
> sink_.openedName(), sinkWidth_, sinkHeight_);
> - DEBUG("LOCAL: shm sink <%s> started: size = %dx%d",
> - sink_.openedName().c_str(), sinkWidth_, sinkHeight_);
> - }
> -
> - return true;
> -}
> -
> -void VideoCamera::process()
> -{ captureFrame(); }
> -
> -void VideoCamera::cleanup()
> -{
> - if (detach(&sink_)) {
> - Manager::instance().getVideoControls()->stoppedDecoding(id_,
> sink_.openedName());
> - sink_.stop();
> - }
> -
> - delete decoder_;
> -}
> -
> -int VideoCamera::interruptCb(void *data)
> -{
> - VideoCamera *context = static_cast<VideoCamera*>(data);
> - return not context->isRunning();
> -}
> -
> -bool VideoCamera::captureFrame()
> -{
> - VideoFrame& frame = getNewFrame();
> - int ret = decoder_->decode(frame);
> -
> - if (ret <= 0) {
> - if (ret < 0)
> - stop();
> - return false;
> - }
> -
> - frame.mirror();
> - publishFrame();
> - return true;
> -}
> -
> -int VideoCamera::getWidth() const
> -{ return decoder_->getWidth(); }
> -
> -int VideoCamera::getHeight() const
> -{ return decoder_->getHeight(); }
> -
> -int VideoCamera::getPixelFormat() const
> -{ return decoder_->getPixelFormat(); }
> -
> -
> -
> -} // end namespace sfl_video
> diff --git a/daemon/src/video/video_camera.h
> b/daemon/src/video/video_camera.h
> deleted file mode 100644
> index 9a1e52a..0000000
> --- a/daemon/src/video/video_camera.h
> +++ /dev/null
> @@ -1,82 +0,0 @@
> -/*
> - * Copyright (C) 2011-2013 Savoir-Faire Linux Inc.
> - *
> - * Author: Tristan Matthews <[email protected]>
> - * Author: Guillaume Roguez <[email protected]>
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA.
> - *
> - * Additional permission under GNU GPL version 3 section 7:
> - *
> - * If you modify this program, or any covered work, by linking or
> - * combining it with the OpenSSL project's OpenSSL library (or a
> - * modified version of that library), containing parts covered by
> the
> - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
> - * grants you additional permission to convey the resulting work.
> - * Corresponding Source for a non-source form of such a combination
> - * shall include the source code for the parts of OpenSSL used as
> well
> - * as that of the covered work.
> - */
> -
> -#ifndef __VIDEO_CAMERA_H__
> -#define __VIDEO_CAMERA_H__
> -
> -#include "noncopyable.h"
> -#include "shm_sink.h"
> -#include "video_decoder.h"
> -#include "sflthread.h"
> -
> -#include <string>
> -#include <map>
> -
> -
> -namespace sfl_video {
> -using std::string;
> -
> -class VideoCamera :
> - public VideoGenerator,
> - public SFLThread
> -{
> -public:
> - VideoCamera(const std::map<string, string> &args);
> - ~VideoCamera();
> -
> - // as VideoGenerator
> - int getWidth() const;
> - int getHeight() const;
> - int getPixelFormat() const;
> -
> -private:
> - NON_COPYABLE(VideoCamera);
> -
> - std::string id_;
> - std::map<string, string> args_;
> - VideoDecoder *decoder_;
> - SHMSink sink_;
> - int sinkWidth_;
> - int sinkHeight_;
> -
> - // as SFLThread
> - bool setup();
> - void process();
> - void cleanup();
> -
> - static int interruptCb(void *ctx);
> - bool captureFrame();
> -};
> -
> -}
> -
> -#endif // __VIDEO_CAMERA_H__
> diff --git a/daemon/src/video/video_input.cpp
> b/daemon/src/video/video_input.cpp
> new file mode 100644
> index 0000000..1de4ba1
> --- /dev/null
> +++ b/daemon/src/video/video_input.cpp
> @@ -0,0 +1,161 @@
> +/*
> + * Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
> + * Author: Tristan Matthews <[email protected]>
> + * Author: Vivien Didelot <[email protected]>
> + *
> + * 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, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA.
> + *
> + * Additional permission under GNU GPL version 3 section 7:
> + *
> + * If you modify this program, or any covered work, by linking or
> + * combining it with the OpenSSL project's OpenSSL library (or a
> + * modified version of that library), containing parts covered by
> the
> + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
> + * grants you additional permission to convey the resulting work.
> + * Corresponding Source for a non-source form of such a combination
> + * shall include the source code for the parts of OpenSSL used as
> well
> + * as that of the covered work.
> + */
> +
> +#include "video_input.h"
> +#include "video_decoder.h"
> +#include "check.h"
> +
> +#include "manager.h"
> +#include "client/video_controls.h"
> +
> +#include <map>
> +#include <string>
> +
> +#define SINK_ID "local"
> +
> +namespace sfl_video {
> +
> +using std::string;
> +
> +VideoInput::VideoInput(const std::map<std::string, std::string>
> &args) :
> + VideoGenerator::VideoGenerator()
> + , id_(SINK_ID)
> + , args_(args)
> + , decoder_(0)
> + , sink_()
> + , sinkWidth_(0)
> + , sinkHeight_(0)
> +{ start(); }
> +
> +VideoInput::~VideoInput()
> +{
> + stop();
> + join();
> +}
> +
> +bool VideoInput::setup()
> +{
> + // it's a v4l device if starting with /dev/video
> + static const char * const V4L_PATH = "/dev/video";
> +
> + string format_str;
> + string input = args_["input"];
> +
> + decoder_ = new VideoDecoder();
> +
> + if (args_["input"].find(V4L_PATH) != std::string::npos) {
> + DEBUG("Using v4l2 format");
> + format_str = "video4linux2";
> + }
> + if (!args_["framerate"].empty())
> + decoder_->setOption("framerate",
> args_["framerate"].c_str());
> + if (!args_["video_size"].empty())
> + decoder_->setOption("video_size",
> args_["video_size"].c_str());
> + if (!args_["channel"].empty())
> + decoder_->setOption("channel", args_["channel"].c_str());
> +
> + decoder_->setInterruptCallback(interruptCb, this);
> +
> + EXIT_IF_FAIL(decoder_->openInput(input, format_str) >= 0,
> + "Could not open input \"%s\"", input.c_str());
> +
> + /* Data available, finish the decoding */
> + EXIT_IF_FAIL(!decoder_->setupFromVideoData(),
> + "decoder IO startup failed");
> +
> + /* Preview frame size? (defaults from decoder) */
> + if (!args_["width"].empty())
> + sinkWidth_ = atoi(args_["width"].c_str());
> + else
> + sinkWidth_ = decoder_->getWidth();
> + if (!args_["height"].empty())
> + sinkHeight_ = atoi(args_["height"].c_str());
> + else
> + sinkHeight_ = decoder_->getHeight();
> +
> + /* Sink setup */
> + EXIT_IF_FAIL(sink_.start(), "Cannot start shared memory sink");
> + if (attach(&sink_)) {
> + Manager::instance().getVideoControls()->startedDecoding(id_,
> sink_.openedName(), sinkWidth_, sinkHeight_);
> + DEBUG("LOCAL: shm sink <%s> started: size = %dx%d",
> + sink_.openedName().c_str(), sinkWidth_, sinkHeight_);
> + }
> +
> + return true;
> +}
> +
> +void VideoInput::process()
> +{ captureFrame(); }
> +
> +void VideoInput::cleanup()
> +{
> + if (detach(&sink_)) {
> + Manager::instance().getVideoControls()->stoppedDecoding(id_,
> sink_.openedName());
> + sink_.stop();
> + }
> +
> + delete decoder_;
> +}
> +
> +int VideoInput::interruptCb(void *data)
> +{
> + VideoInput *context = static_cast<VideoInput*>(data);
> + return not context->isRunning();
> +}
> +
> +bool VideoInput::captureFrame()
> +{
> + VideoFrame& frame = getNewFrame();
> + int ret = decoder_->decode(frame);
> +
> + if (ret <= 0) {
> + if (ret < 0)
> + stop();
> + return false;
> + }
> +
> + frame.mirror();
> + publishFrame();
> + return true;
> +}
> +
> +int VideoInput::getWidth() const
> +{ return decoder_->getWidth(); }
> +
> +int VideoInput::getHeight() const
> +{ return decoder_->getHeight(); }
> +
> +int VideoInput::getPixelFormat() const
> +{ return decoder_->getPixelFormat(); }
> +
> +
> +
> +} // end namespace sfl_video
> diff --git a/daemon/src/video/video_input.h
> b/daemon/src/video/video_input.h
> new file mode 100644
> index 0000000..655abfe
> --- /dev/null
> +++ b/daemon/src/video/video_input.h
> @@ -0,0 +1,83 @@
> +/*
> + * Copyright (C) 2011-2014 Savoir-Faire Linux Inc.
> + *
> + * Author: Tristan Matthews <[email protected]>
> + * Author: Guillaume Roguez <[email protected]>
> + * Author: Vivien Didelot <[email protected]>
> + *
> + * 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, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA.
> + *
> + * Additional permission under GNU GPL version 3 section 7:
> + *
> + * If you modify this program, or any covered work, by linking or
> + * combining it with the OpenSSL project's OpenSSL library (or a
> + * modified version of that library), containing parts covered by
> the
> + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
> + * grants you additional permission to convey the resulting work.
> + * Corresponding Source for a non-source form of such a combination
> + * shall include the source code for the parts of OpenSSL used as
> well
> + * as that of the covered work.
> + */
> +
> +#ifndef __VIDEO_INPUT_H__
> +#define __VIDEO_INPUT_H__
> +
> +#include "noncopyable.h"
> +#include "shm_sink.h"
> +#include "video_decoder.h"
> +#include "sflthread.h"
> +
> +#include <string>
> +#include <map>
> +
> +
> +namespace sfl_video {
> +using std::string;
> +
> +class VideoInput :
> + public VideoGenerator,
> + public SFLThread
> +{
> +public:
> + VideoInput(const std::map<string, string> &args);
> + ~VideoInput();
> +
> + // as VideoGenerator
> + int getWidth() const;
> + int getHeight() const;
> + int getPixelFormat() const;
> +
> +private:
> + NON_COPYABLE(VideoInput);
> +
> + std::string id_;
> + std::map<string, string> args_;
> + VideoDecoder *decoder_;
> + SHMSink sink_;
> + int sinkWidth_;
> + int sinkHeight_;
> +
> + // as SFLThread
> + bool setup();
> + void process();
> + void cleanup();
> +
> + static int interruptCb(void *ctx);
> + bool captureFrame();
> +};
> +
> +}
> +
> +#endif // __VIDEO_INPUT_H__
> diff --git a/daemon/src/video/video_mixer.cpp
> b/daemon/src/video/video_mixer.cpp
> index 16879b3..6e8bf2c 100644
> --- a/daemon/src/video/video_mixer.cpp
> +++ b/daemon/src/video/video_mixer.cpp
> @@ -52,20 +52,20 @@ VideoMixer::VideoMixer(const std::string &id) :
> , sink_(id + VIDEO_MIXER_SUFFIX)
> {
> auto videoCtrl = Manager::instance().getVideoControls();
> - if (!videoCtrl->hasCameraStarted()) {
> - videoCtrl->startCamera();
> + if (!videoCtrl->hasInputStarted()) {
> + videoCtrl->startInput();
> MYSLEEP(1);
> }
>
> // Local video camera is always attached
> - if (auto shared = videoCtrl->getVideoCamera().lock())
> + if (auto shared = videoCtrl->getVideoInput().lock())
> shared->attach(this);
> }
>
> VideoMixer::~VideoMixer()
> {
> auto videoCtrl = Manager::instance().getVideoControls();
> - if (auto shared = videoCtrl->getVideoCamera().lock())
> + if (auto shared = videoCtrl->getVideoInput().lock())
> shared->detach(this);
> stop_sink();
> }
> diff --git a/daemon/src/video/video_rtp_session.cpp
> b/daemon/src/video/video_rtp_session.cpp
> index c7986d8..6e7d865 100644
> --- a/daemon/src/video/video_rtp_session.cpp
> +++ b/daemon/src/video/video_rtp_session.cpp
> @@ -142,12 +142,12 @@ void VideoRtpSession::start(int localPort)
> if (sending_) {
> // Local video startup if needed
> auto videoCtrl = Manager::instance().getVideoControls();
> - const bool firstStart = not videoCtrl->hasCameraStarted();
> - videoCtrl->startCamera();
> + const bool firstStart = not videoCtrl->hasInputStarted();
> + videoCtrl->startInput();
> if (firstStart)
> MYSLEEP(1);
>
> - videoLocal_ = videoCtrl->getVideoCamera();
> + videoLocal_ = videoCtrl->getVideoInput();
> if (sender_)
> WARN("Restarting video sender");
>
> @@ -210,7 +210,7 @@ void VideoRtpSession::stop()
> sender_.reset();
> socketPair_.reset();
> auto videoCtrl = Manager::instance().getVideoControls();
> - videoCtrl->stopCamera();
> + videoCtrl->stopInput();
> }
>
> void VideoRtpSession::forceKeyFrame()
> --
> 1.8.5.4
>
>
You can't change VideoControls method names (for now), this fails to build:
if (!videoCtrl->hasInputStarted()) {
^
video_mixer.cpp:56:20: error: 'class VideoControls' has no member named
'startInput'
videoCtrl->startInput();
^
video_mixer.cpp:61:34: error: 'class VideoControls' has no member named
'getVideoInput'
if (auto shared = videoCtrl->getVideoInput().lock())
^
video_mixer.cpp: In destructor 'virtual sfl_video::VideoMixer::~VideoMixer()':
video_mixer.cpp:68:34: error: 'class VideoControls' has no member named
'getVideoInput'
if (auto shared = videoCtrl->getVideoInput().lock())
^
make[4]: *** [video_mixer.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
video_rtp_session.cpp: In member function 'void
sfl_video::VideoRtpSession::start(int)':
video_rtp_session.cpp:145:48: error: 'class VideoControls' has no member named
'hasInputStarted'
const bool firstStart = not videoCtrl->hasInputStarted();
^
video_rtp_session.cpp:146:20: error: 'class VideoControls' has no member named
'startInput'
videoCtrl->startInput();
^
video_rtp_session.cpp:150:34: error: 'class VideoControls' has no member named
'getVideoInput'
videoLocal_ = videoCtrl->getVideoInput();
^
video_rtp_session.cpp: In member function 'void
sfl_video::VideoRtpSession::stop()':
video_rtp_session.cpp:213:16: error: 'class VideoControls' has no member named
'stopInput'
videoCtrl->stopInput();
--
Tristan Matthews
Développeur de logiciels libres
[email protected]
Ligne directe: 514-276-5468 poste 190
Fax : 514-276-5465
7275 Saint Urbain
Bureau 200
Montréal, QC, H2R 2Y5
_______________________________________________
SFLphone mailing list
[email protected]
http://lists.savoirfairelinux.net/mailman/listinfo/sflphone