Commit dc3c38f6 authored by Tristan Matthews's avatar Tristan Matthews

* #26544: dbus: improve recording API

Namely by telling the client who triggered recording whether or not
recording has started.
parent 342b7e70
......@@ -234,14 +234,15 @@ bool AudioRecord::isRecording() const
return recordingEnabled_;
}
void AudioRecord::setRecording()
bool AudioRecord::toggleRecording()
{
if (isOpenFile()) {
recordingEnabled_ = !recordingEnabled_;
} else {
openFile();
recordingEnabled_ = true; // once opend file, start recording
recordingEnabled_ = true;
}
return recordingEnabled_;
}
void AudioRecord::stopRecording()
......
......@@ -88,9 +88,9 @@ class AudioRecord {
bool isRecording() const;
/**
* Set recording flag
* Toggle recording state
*/
void setRecording();
bool toggleRecording();
/**
* Stop recording flag
......
......@@ -51,7 +51,7 @@ class Recordable {
* This method must be implemented for this interface as calls and conferences
* have different behavior.
*/
virtual bool setRecording() = 0;
virtual bool toggleRecording() = 0;
/**
* Stop recording
......
......@@ -148,15 +148,13 @@ Call::getLocalVideoPort()
}
bool
Call::setRecording()
Call::toggleRecording()
{
bool recordStatus = Recordable::recAudio_.isRecording();
Recordable::recAudio_.setRecording();
const bool startRecording = Recordable::recAudio_.toggleRecording();
MainBuffer &mbuffer = Manager::instance().getMainBuffer();
std::string process_id = Recordable::recorder_.getRecorderID();
if (!recordStatus) {
if (startRecording) {
mbuffer.bindHalfDuplexOut(process_id, id_);
mbuffer.bindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
......@@ -168,7 +166,7 @@ Call::setRecording()
Manager::instance().getMainBuffer().dumpInfo();
return recordStatus;
return startRecording;
}
void Call::time_stop()
......
......@@ -228,7 +228,7 @@ class Call : public Recordable {
virtual std::map<std::string, std::string>
createHistoryEntry() const;
virtual bool setRecording();
virtual bool toggleRecording();
private:
std::string getTypeStr() const;
......
......@@ -99,17 +99,15 @@ ParticipantSet Conference::getParticipantList() const
return participants_;
}
bool Conference::setRecording()
bool Conference::toggleRecording()
{
bool recordStatus = Recordable::recAudio_.isRecording();
Recordable::recAudio_.setRecording();
const bool startRecording = Recordable::recAudio_.toggleRecording();
MainBuffer &mbuffer = Manager::instance().getMainBuffer();
std::string process_id(Recordable::recorder_.getRecorderID());
// start recording
if (!recordStatus) {
if (startRecording) {
for (ParticipantSet::const_iterator iter = participants_.begin(); iter != participants_.end(); ++iter)
mbuffer.bindHalfDuplexOut(process_id, *iter);
......@@ -123,7 +121,7 @@ bool Conference::setRecording()
mbuffer.unBindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
}
return recordStatus;
return startRecording;
}
std::string Conference::getConfID() const {
......
......@@ -89,7 +89,7 @@ class Conference : public Recordable {
/**
* Start/stop recording toggle
*/
virtual bool setRecording();
virtual bool toggleRecording();
private:
std::string id_;
ConferenceState confState_;
......
......@@ -325,7 +325,24 @@
</arg>
</method>
<method name="toggleRecording" tp:name-for-bindings="toggleRecording">
<tp:docstring>
Toggle recording for a call.
</tp:docstring>
<arg type="s" name="callID" direction="in">
<tp:docstring>
The ID of the call to start/stop recording.
</tp:docstring>
</arg>
<arg type="b" name="isRecording" direction="out">
<tp:docstring>
Returns true is the call is being recorded. False otherwise.
</tp:docstring>
</arg>
</method>
<method name="setRecording" tp:name-for-bindings="setRecording">
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<tp:docstring>
Start recording a call.
</tp:docstring>
......
......@@ -232,10 +232,16 @@ CallManager::stopRecordedFilePlayback(const std::string& filepath)
Manager::instance().stopRecordedFilePlayback(filepath);
}
bool
CallManager::toggleRecording(const std::string& callID)
{
return Manager::instance().toggleRecordingCall(callID);
}
void
CallManager::setRecording(const std::string& callID)
{
Manager::instance().setRecordingCall(callID);
toggleRecording(callID);
}
void
......
......@@ -107,7 +107,10 @@ class CallManager
/* General audio methods */
void setVolume(const std::string& device, const double& value);
double getVolume(const std::string& device);
bool toggleRecording(const std::string& callID);
/* DEPRECATED */
void setRecording(const std::string& callID);
void recordPlaybackSeek(const double& value);
bool getIsRecording(const std::string& callID);
std::string getCurrentAudioCodecName(const std::string& callID);
......
......@@ -388,7 +388,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
// Start recording if set in preference
if (audioPreference.getIsAlwaysRecording())
setRecordingCall(call_id);
toggleRecordingCall(call_id);
// update call state on client side
dbus_.getCallManager()->callStateChanged(call_id, "CURRENT");
......@@ -1630,7 +1630,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id)
}
if (audioPreference.getIsAlwaysRecording())
setRecordingCall(id);
toggleRecordingCall(id);
dbus_.getCallManager()->callStateChanged(id, "CURRENT");
}
......@@ -2064,16 +2064,16 @@ void ManagerImpl::setIsAlwaysRecording(bool isAlwaysRec)
return audioPreference.setIsAlwaysRecording(isAlwaysRec);
}
void ManagerImpl::setRecordingCall(const std::string& id)
bool ManagerImpl::toggleRecordingCall(const std::string& id)
{
Recordable* rec = NULL;
ConferenceMap::const_iterator it(conferenceMap_.find(id));
if (it == conferenceMap_.end()) {
DEBUG("Set recording for call %s", id.c_str());
DEBUG("toggle recording for call %s", id.c_str());
rec = getCallFromCallID(id);
} else {
DEBUG("Set recording for conference %s", id.c_str());
DEBUG("toggle recording for conference %s", id.c_str());
Conference *conf = it->second;
if (conf) {
......@@ -2087,11 +2087,12 @@ void ManagerImpl::setRecordingCall(const std::string& id)
if (rec == NULL) {
ERROR("Could not find recordable instance %s", id.c_str());
return;
return false;
}
rec->setRecording();
const bool result = rec->toggleRecording();
dbus_.getCallManager()->recordPlaybackFilepath(id, rec->getFilename());
return result;
}
bool ManagerImpl::isRecording(const std::string& id)
......
......@@ -606,8 +606,9 @@ class ManagerImpl {
* Set recording on / off
* Start recording
* @param id The call identifier
* Returns true if the call was set to record
*/
void setRecordingCall(const std::string& id);
bool toggleRecordingCall(const std::string& id);
/**
* Return true if the call is currently recorded
......
......@@ -812,19 +812,19 @@ sflphone_add_main_participant(const conference_obj_t * c)
dbus_add_main_participant(c->_confID);
}
void
gboolean
sflphone_rec_call(SFLPhoneClient *client)
{
gboolean result = FALSE;
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls_tab);
conference_obj_t * selectedConf = calltab_get_selected_conf(current_calls_tab);
if (selectedCall) {
g_debug("Set record for selected call");
dbus_set_record(selectedCall->_callID);
result = dbus_toggle_recording(selectedCall->_callID);
calltree_update_call(current_calls_tab, selectedCall, client, TRUE);
} else if (selectedConf) {
g_debug("Set record for selected conf");
dbus_set_record(selectedConf->_confID);
result = dbus_toggle_recording(selectedConf->_confID);
switch (selectedConf->_state) {
case CONFERENCE_STATE_ACTIVE_ATTACHED:
......@@ -851,6 +851,7 @@ sflphone_rec_call(SFLPhoneClient *client)
} else {
update_actions(client);
}
return result;
}
void
......
......@@ -187,7 +187,7 @@ void sflphone_fill_codec_list_per_account(account_t *);
void sflphone_add_participant();
void sflphone_rec_call(SFLPhoneClient *client);
gboolean sflphone_rec_call(SFLPhoneClient *client);
void sflphone_mute_call(void);
......
......@@ -325,7 +325,24 @@
</arg>
</method>
<method name="toggleRecording" tp:name-for-bindings="toggleRecording">
<tp:docstring>
Toggle recording for a call.
</tp:docstring>
<arg type="s" name="callID" direction="in">
<tp:docstring>
The ID of the call to start/stop recording.
</tp:docstring>
</arg>
<arg type="b" name="isRecording" direction="out">
<tp:docstring>
Returns true is the call is being recorded. False otherwise.
</tp:docstring>
</arg>
</method>
<method name="setRecording" tp:name-for-bindings="setRecording">
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<tp:docstring>
Start recording a call.
</tp:docstring>
......
......@@ -1533,12 +1533,14 @@ dbus_join_conference(const gchar *sel_confID, const gchar *drag_confID)
check_error(error);
}
void
dbus_set_record(const gchar *id)
gboolean
dbus_toggle_recording(const gchar *id)
{
GError *error = NULL;
org_sflphone_SFLphone_CallManager_set_recording(call_proxy, id, &error);
gboolean isRecording;
org_sflphone_SFLphone_CallManager_toggle_recording(call_proxy, id, &isRecording, &error);
check_error(error);
return isRecording;
}
gboolean
......
......@@ -439,7 +439,7 @@ gchar *dbus_get_conference_id(const gchar *callID);
/**
* Toggle recording for this instance, may be call or conference
*/
void dbus_set_record(const gchar *id);
gboolean dbus_toggle_recording(const gchar *id);
/**
* Set the path where the recorded audio files will be stored
......
......@@ -748,7 +748,10 @@ static void
call_record(G_GNUC_UNUSED GtkAction *action, SFLPhoneClient *client)
{
g_debug("Record button pressed");
sflphone_rec_call(client);
/* Ensure that button is set to correct state, but suppress signal */
g_signal_handler_block(recordWidget_, recordButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), sflphone_rec_call(client));
g_signal_handler_unblock(recordWidget_, recordButtonConnId_);
}
static void
......
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