Commit 9fb15b5b authored by Adrien Béraud's avatar Adrien Béraud
parents 29b40b54 bbe1c73d
......@@ -37,6 +37,8 @@
#include <pthread.h>
#include "audiobuffer.h"
#include "mainbuffer.h"
#include "noncopyable.h"
class RingBuffer;
......@@ -99,6 +101,7 @@ class MainBuffer {
void dumpInfo();
private:
NON_COPYABLE(MainBuffer);
CallIDSet* getCallIDSet(const std::string &call_id);
......
......@@ -127,9 +127,8 @@ void
PresenceManager::setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris)
{
SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID);
for (auto u:uris) {
sipaccount->getPresence()->subscribeClient(u,true);
}
for (const auto &u : uris)
sipaccount->getPresence()->subscribeClient(u, true);
}
......
......@@ -128,7 +128,6 @@ void
PresenceManager::setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris)
{
SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID);
for (auto u:uris) {
for (const auto &u : uris)
sipaccount->getPresence()->subscribeClient(u,true);
}
}
\ No newline at end of file
}
......@@ -59,8 +59,10 @@ Conference::Conference()
Conference::~Conference()
{
for (auto participant_id : participants_)
remove(participant_id);
#ifdef SFL_VIDEO
for (const auto &participant_id : participants_)
SIPVoIPLink::instance()->getSipCall(participant_id)->getVideoRtp().exitConference();
#endif // SFL_VIDEO
}
Conference::ConferenceState Conference::getState() const
......@@ -93,7 +95,7 @@ void Conference::remove(const std::string &participant_id)
void Conference::bindParticipant(const std::string &participant_id)
{
auto mainBuffer = Manager::instance().getMainBuffer();
auto &mainBuffer = Manager::instance().getMainBuffer();
for (const auto &item : participants_) {
if (participant_id != item)
......
......@@ -417,7 +417,7 @@ void SIPAccount::unserialize(const Conf::YamlNode &mapNode)
} else {
vector<map<string, string> > videoCodecDetails;
for (auto it : *seq) {
for (const auto &it : *seq) {
MappingNode *codec = static_cast<MappingNode *>(it);
map<string, string> codecMap;
codec->getValue(VIDEO_CODEC_NAME, &codecMap[VIDEO_CODEC_NAME]);
......@@ -486,7 +486,7 @@ void SIPAccount::unserialize(const Conf::YamlNode &mapNode)
SequenceNode *credSeq = static_cast<SequenceNode *>(credNode);
Sequence *seq = credSeq->getSequence();
for (auto it : *seq) {
for (const auto &it : *seq) {
MappingNode *cred = static_cast<MappingNode *>(it);
std::string user;
std::string pass;
......
......@@ -197,7 +197,7 @@ class SIPPresence {
return enabled_;
}
const std::list< PresSubClient *> getClientSubscriptions() {
std::list< PresSubClient *> getClientSubscriptions() {
return pres_sub_client_list_;
}
......
......@@ -202,6 +202,53 @@ void VideoFrame::copy(VideoFrame &dst)
frame_->height);
}
void VideoFrame::clear()
{
// FIXME: beurk!!!!
memset(frame_->data[0], 0, frame_->linesize[0]*frame_->height);
memset(frame_->data[1], 0, frame_->linesize[1]*frame_->height/2);
memset(frame_->data[2], 0, frame_->linesize[2]*frame_->height/2);
}
int VideoFrame::mirror() {
if (frame_->format != PIX_FMT_YUV420P) {
ERROR("Unsupported pixel format");
return -1;
}
uint8_t *data;
ssize_t stride;
// Y
stride = frame_->linesize[0];
data = frame_->data[0];
for (int i = 0; i < frame_->height; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]);
data += stride;
}
// U
stride = frame_->linesize[1];
data = frame_->data[1];
for (int i = 0; i < frame_->height / 2; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]);
data += stride;
}
// V
stride = frame_->linesize[2];
data = frame_->data[2];
for (int i = 0; i < frame_->height / 2; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]);
data += stride;
}
return 0;
}
void VideoFrame::test()
{
memset(frame_->data[0], 0xaa, frame_->linesize[0]*frame_->height/2);
......
......@@ -203,6 +203,8 @@ public:
bool allocBuffer(int width, int height, int pix_fmt);
int blit(VideoFrame& src, int xoff, int yoff);
void copy(VideoFrame &src);
void clear();
int mirror();
void test();
private:
......
......@@ -132,7 +132,8 @@ int VideoCamera::interruptCb(void *data)
bool VideoCamera::captureFrame()
{
int ret = decoder_->decode(getNewFrame());
VideoFrame& frame = getNewFrame();
int ret = decoder_->decode(frame);
if (ret <= 0) {
if (ret < 0)
......@@ -140,6 +141,7 @@ bool VideoCamera::captureFrame()
return false;
}
frame.mirror();
publishFrame();
return true;
}
......
......@@ -136,6 +136,11 @@ void VideoMixer::setDimensions(int width, int height)
width_ = width;
height_ = height;
// cleanup the previous frame to have a nice copy in rendering method
VideoFrameSP previous_p=obtainLastFrame();
if (previous_p)
previous_p->clear();
stop_sink();
start_sink();
}
......
......@@ -57,7 +57,7 @@ VideoReceiveThread::VideoReceiveThread(const std::string& id,
, stream_(args_["receiving_sdp"])
, sdpContext_(SDP_BUFFER_SIZE, false, &readFunction, 0, 0, this)
, demuxContext_()
, sink_()
, sink_(id+"_RX")
, requestKeyFrameCallback_(0)
{}
......@@ -139,6 +139,8 @@ bool VideoReceiveThread::setup()
dstHeight_ = videoDecoder_->getHeight();
}
EXIT_IF_FAIL(sink_.start(), "RX: sink startup failed");
auto conf = Manager::instance().getConferenceFromCallID(id_);
if (!conf)
exitConference();
......@@ -153,13 +155,13 @@ void VideoReceiveThread::cleanup()
{
if (detach(&sink_))
Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName());
sink_.stop();
if (videoDecoder_)
delete videoDecoder_;
if (demuxContext_)
delete demuxContext_;
}
// This callback is used by libav internally to break out of blocking calls
......@@ -226,7 +228,7 @@ void VideoReceiveThread::enterConference()
if (detach(&sink_)) {
Manager::instance().getVideoControls()->stoppedDecoding(id_+"RX", sink_.openedName());
sink_.stop();
DEBUG("RX: shm sink <%s> detached", sink_.openedName().c_str());
}
}
......@@ -235,11 +237,12 @@ void VideoReceiveThread::exitConference()
if (!isRunning())
return;
EXIT_IF_FAIL(sink_.start(), "RX: sink startup failed");
if (attach(&sink_)) {
Manager::instance().getVideoControls()->startedDecoding(id_+"RX", sink_.openedName(), dstWidth_, dstHeight_);
DEBUG("RX: shm sink <%s> started: size = %dx%d",
sink_.openedName().c_str(), dstWidth_, dstHeight_);
if (dstWidth_ > 0 && dstHeight_ > 0) {
if (attach(&sink_)) {
Manager::instance().getVideoControls()->startedDecoding(id_+"RX", sink_.openedName(), dstWidth_, dstHeight_);
DEBUG("RX: shm sink <%s> started: size = %dx%d",
sink_.openedName().c_str(), dstWidth_, dstHeight_);
}
}
}
......
......@@ -154,6 +154,10 @@ void VideoRtpSession::start(int localPort)
sender_.reset(new VideoSender(callID_, txArgs_, *socketPair_));
} else {
DEBUG("Video sending disabled");
if (videoLocal_)
videoLocal_->detach(sender_.get());
if (videoMixerSP_)
videoMixerSP_->detach(sender_.get());
sender_.reset();
}
......@@ -166,6 +170,8 @@ void VideoRtpSession::start(int localPort)
receiveThread_->start();
} else {
DEBUG("Video receiving disabled");
if (receiveThread_)
receiveThread_->detach(videoMixerSP_.get());
receiveThread_.reset();
}
......@@ -186,7 +192,8 @@ void VideoRtpSession::stop()
if (videoMixerSP_) {
videoMixerSP_->detach(sender_.get());
receiveThread_->detach(videoMixerSP_.get());
if (receiveThread_)
receiveThread_->detach(videoMixerSP_.get());
}
if (socketPair_.get())
......
......@@ -288,12 +288,12 @@ void VideoV4l2ListThread::delDevice(const string &node)
{
ScopedLock lock(mutex_);
for (auto itr = devices_.begin(); itr != devices_.end(); ++itr) {
if (itr->device == node) {
devices_.erase(itr);
Manager::instance().getVideoControls()->deviceEvent();
return;
}
const auto itr = std::find_if(devices_.begin(), devices_.end(),
[&] (const VideoV4l2Device &d) { return d.device == node; });
if (itr != devices_.end()) {
devices_.erase(itr);
Manager::instance().getVideoControls()->deviceEvent();
}
}
......
......@@ -1422,7 +1422,7 @@ show_account_window(account_t *account, SFLPhoneClient *client, gboolean is_new)
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_APPLY,
GTK_RESPONSE_ACCEPT,
GTK_RESPONSE_APPLY,
NULL);
gtk_container_set_border_width(GTK_CONTAINER(dialog), 0);
......@@ -1438,19 +1438,16 @@ show_account_window(account_t *account, SFLPhoneClient *client, gboolean is_new)
/* General Settings */
GtkWidget *basic_tab = create_basic_tab(account, is_new);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), basic_tab, gtk_label_new(_("Basic")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), basic_tab);
}
/* Audio Codecs */
GtkWidget *audiocodecs_tab = create_audiocodecs_configuration(account);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), audiocodecs_tab, gtk_label_new(_("Audio")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), audiocodecs_tab);
#ifdef SFL_VIDEO
/* Video Codecs */
GtkWidget *videocodecs_tab = create_videocodecs_configuration(account);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), videocodecs_tab, gtk_label_new(_("Video")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), videocodecs_tab);
#endif
// Do not need advanced or security one for the IP2IP account
......@@ -1458,17 +1455,14 @@ show_account_window(account_t *account, SFLPhoneClient *client, gboolean is_new)
/* Advanced */
advanced_tab = create_advanced_tab(account);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), advanced_tab);
/* Security */
security_tab = create_security_tab(account, client);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), security_tab);
} else {
/* Custom tab for the IP to IP profile */
GtkWidget *ip_tab = create_direct_ip_calls_tab(account);
gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), ip_tab, gtk_label_new(_("Network")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), ip_tab);
}
// Emit signal to hide advanced and security tabs in case of IAX
......@@ -1480,12 +1474,11 @@ show_account_window(account_t *account, SFLPhoneClient *client, gboolean is_new)
/* Run dialog, this blocks */
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
// If anything but "Apply" button is pressed
if (response != GTK_RESPONSE_ACCEPT) {
if (response == GTK_RESPONSE_APPLY) {
return dialog;
} else {
gtk_widget_destroy(dialog);
return NULL;
} else {
return dialog;
}
}
......@@ -121,8 +121,10 @@ run_account_dialog(const gchar *selected_accountID, SFLPhoneClient *client, gboo
{
account_t *account = account_list_get_by_id(selected_accountID);
GtkWidget *dialog = show_account_window(account, client, is_new);
update_account_from_dialog(dialog, account);
account_store_fill();
if (dialog) {
update_account_from_dialog(dialog, account);
account_store_fill();
}
}
static void row_activated_cb(GtkTreeView *view,
......
......@@ -426,7 +426,9 @@ void sfl_seekslider_update_scale(SFLSeekSlider *seekslider, guint current, guint
void sfl_seekslider_set_display(SFLSeekSlider *seekslider, SFLSeekSliderDisplay display) {
if (seekslider == NULL)
if (seekslider == NULL || !seekslider->priv ||
!GTK_IS_WIDGET(seekslider->priv->playRecordWidget) ||
!GTK_IS_WIDGET(seekslider->priv->stopRecordWidget))
return;
switch (display) {
......
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