Commit 44fde29b authored by Guillaume Roguez's avatar Guillaume Roguez

#29564: rename VideoPreview class into VideoCamera

parent 4c926410
......@@ -32,7 +32,7 @@
#include "video_controls.h"
#include "video/libav_utils.h"
#include "video/video_preview.h"
#include "video/video_camera.h"
#include "account.h"
#include "logger.h"
#include "manager.h"
......@@ -166,7 +166,7 @@ VideoControls::startPreview()
using std::string;
map<string, string> args(videoPreference_.getSettings());
preview_.reset(new sfl_video::VideoPreview(args));
preview_.reset(new sfl_video::VideoCamera(args));
}
void
......@@ -180,7 +180,7 @@ VideoControls::stopPreview()
}
}
sfl_video::VideoPreview* VideoControls::getVideoPreview()
sfl_video::VideoSource* VideoControls::getVideoPreview()
{
return preview_.get();
}
......
......@@ -55,18 +55,18 @@
#endif // HAVE_DBUS
#include <tr1/memory> // for shared_ptr
#include <memory> // for shared_ptr
#include "video/video_preferences.h"
namespace sfl_video {
class VideoPreview;
class VideoSource;
}
class VideoControls : public org::sflphone::SFLphone::VideoControls_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor {
private:
std::tr1::shared_ptr<sfl_video::VideoPreview> preview_;
std::shared_ptr<sfl_video::VideoSource> preview_;
VideoPreference videoPreference_;
public:
......@@ -126,7 +126,7 @@ class VideoControls : public org::sflphone::SFLphone::VideoControls_adaptor,
void startPreview();
void stopPreview();
bool hasPreviewStarted();
sfl_video::VideoPreview *getVideoPreview();
sfl_video::VideoSource *getVideoPreview();
};
#endif // VIDEO_CONTROLS_H_
......@@ -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_preview.cpp video_preview.h \
video_camera.cpp video_camera.h \
video_receive_thread.cpp video_receive_thread.h \
video_send_thread.cpp video_send_thread.h \
video_rtp_session.cpp video_rtp_session.h \
......
include ../../../globals.mak
TESTS=test_video_endpoint test_v4l2 test_shm
check_PROGRAMS=test_video_endpoint test_video_rtp test_video_preview test_v4l2 test_shm
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
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_preview_SOURCES=test_video_preview.cpp test_video_preview.h
test_video_preview_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_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)
......
......@@ -29,29 +29,29 @@
*/
#include <unistd.h> // for sleep
#include "test_video_preview.h"
#include "video_preview.h"
#include "test_video_camera.h"
#include "video_camera.h"
#include <map>
#include <string>
using namespace std;
void VideoPreviewTest::testPreview()
void VideoCameraTest::testCamera()
{
std::map<std::string, std::string> args;
args["input"] = "/dev/video0";
args["width"] = "640";
args["height"] = "480";
sfl_video::VideoPreview preview(args);
sfl_video::VideoCamera camera(args);
sleep(1);
}
int main ()
{
for (int i = 0; i < 20; ++i) {
VideoPreviewTest test;
test.testPreview();
VideoCameraTest test;
test.testCamera();
}
return 0;
}
......@@ -28,12 +28,12 @@
* as that of the covered work.
*/
#ifndef _VIDEO_PREVIEW_TEST_
#define _VIDEO_PREVIEW_TEST_
#ifndef _VIDEO_CAMERA_TEST_
#define _VIDEO_CAMERA_TEST_
class VideoPreviewTest {
class VideoCameraTest {
public:
void testPreview();
void testCamera();
};
#endif // _VIDEO_PREVIEW_TEST_
#endif // _VIDEO_CAMERA_TEST_
......@@ -28,7 +28,7 @@
* as that of the covered work.
*/
#include "video_preview.h"
#include "video_camera.h"
#include "video_decoder.h"
#include "check.h"
......@@ -42,7 +42,7 @@ namespace sfl_video {
using std::string;
VideoPreview::VideoPreview(const std::map<std::string, std::string> &args) :
VideoCamera::VideoCamera(const std::map<std::string, std::string> &args) :
VideoSource::VideoSource()
, id_("local")
, args_(args)
......@@ -58,13 +58,13 @@ VideoPreview::VideoPreview(const std::map<std::string, std::string> &args) :
start();
}
VideoPreview::~VideoPreview()
VideoCamera::~VideoCamera()
{
stop();
join();
}
bool VideoPreview::setup()
bool VideoCamera::setup()
{
// it's a v4l device if starting with /dev/video
static const char * const V4L_PATH = "/dev/video";
......@@ -120,26 +120,26 @@ bool VideoPreview::setup()
return true;
}
void VideoPreview::process()
void VideoCamera::process()
{
if (captureFrame() and isRunning())
renderFrame();
}
void VideoPreview::cleanup()
void VideoCamera::cleanup()
{
delete decoder_;
Manager::instance().getVideoControls()->stoppedDecoding(id_,
sink_.openedName());
}
int VideoPreview::interruptCb(void *data)
int VideoCamera::interruptCb(void *data)
{
VideoPreview *context = static_cast<VideoPreview*>(data);
VideoCamera *context = static_cast<VideoCamera*>(data);
return not context->isRunning();
}
bool VideoPreview::captureFrame()
bool VideoCamera::captureFrame()
{
int ret = decoder_->decode();
......@@ -152,7 +152,7 @@ bool VideoPreview::captureFrame()
return true;
}
void VideoPreview::renderFrame()
void VideoCamera::renderFrame()
{
// we want our rendering code to be called by the shm_sink,
// because it manages the shared memory synchronization
......@@ -163,21 +163,21 @@ void VideoPreview::renderFrame()
}
// This function is called by sink
void VideoPreview::fillBuffer(void *data)
void VideoCamera::fillBuffer(void *data)
{
frame_.setDestination(data);
decoder_->scale(scaler_, frame_);
}
void VideoPreview::setMixer(VideoMixer* mixer)
void VideoCamera::setMixer(VideoMixer* mixer)
{
mixer_ = mixer;
}
int VideoPreview::getWidth() const { return decoder_->getWidth(); }
int VideoPreview::getHeight() const { return decoder_->getHeight(); }
int VideoCamera::getWidth() const { return decoder_->getWidth(); }
int VideoCamera::getHeight() const { return decoder_->getHeight(); }
std::shared_ptr<VideoFrame> VideoPreview::waitNewFrame() { return decoder_->waitNewFrame(); }
std::shared_ptr<VideoFrame> VideoPreview::obtainLastFrame() { return decoder_->obtainLastFrame(); }
std::shared_ptr<VideoFrame> VideoCamera::waitNewFrame() { return decoder_->waitNewFrame(); }
std::shared_ptr<VideoFrame> VideoCamera::obtainLastFrame() { return decoder_->obtainLastFrame(); }
} // end namspace sfl_video
......@@ -30,8 +30,8 @@
* as that of the covered work.
*/
#ifndef __VIDEO_PREVIEW_H__
#define __VIDEO_PREVIEW_H__
#ifndef __VIDEO_CAMERA_H__
#define __VIDEO_CAMERA_H__
#include "noncopyable.h"
#include "shm_sink.h"
......@@ -48,11 +48,14 @@
namespace sfl_video {
using std::string;
class VideoPreview : public VideoProvider, public VideoSource, public SFLThread
class VideoCamera :
public VideoProvider,
public VideoSource,
public SFLThread
{
public:
VideoPreview(const std::map<string, string> &args);
~VideoPreview();
VideoCamera(const std::map<string, string> &args);
~VideoCamera();
int getWidth() const;
int getHeight() const;
VideoFrame *lockFrame();
......@@ -70,7 +73,7 @@ protected:
void cleanup();
private:
NON_COPYABLE(VideoPreview);
NON_COPYABLE(VideoCamera);
std::string id_;
std::map<string, string> args_;
......@@ -91,4 +94,4 @@ private:
}
#endif // __VIDEO_PREVIEW_H__
#endif // __VIDEO_CAMERA_H__
......@@ -31,7 +31,7 @@
#include "libav_deps.h"
#include "video_mixer.h"
#include "video_preview.h"
#include "video_camera.h"
#include "client/video_controls.h"
#include "manager.h"
#include "check.h"
......@@ -50,14 +50,14 @@ VideoMixer::VideoMixer() :
, width_(0)
, height_(0)
{
VideoPreview* vpreview;
VideoCamera* camera;
pthread_mutex_init(&updateMutex_, NULL);
pthread_cond_init(&updateCondition_, NULL);
start();
vpreview = Manager::instance().getVideoControls()->getVideoPreview();
sourceList_.push_front(vpreview);
vpreview->setMixer(this);
camera = dynamic_cast<VideoCamera*>(Manager::instance().getVideoControls()->getVideoPreview());
sourceList_.push_front(camera);
camera->setMixer(this);
}
VideoMixer::~VideoMixer()
......
......@@ -36,7 +36,6 @@
#include <tr1/memory>
#include "noncopyable.h"
#include "video_encoder.h"
#include "video_preview.h"
#include "video_mixer.h"
#include "sflthread.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment