use CallRecordingRepository

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-12-05 16:57:12 +01:00
parent 6365554692
commit bb53982dd1
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
10 changed files with 244 additions and 4 deletions

View File

@ -230,7 +230,7 @@ public class CallActivity extends CallBaseActivity {
private Disposable signalingDisposable;
private List<PeerConnection.IceServer> iceServers;
private CameraEnumerator cameraEnumerator;
private String roomToken;
public String roomToken;
private User conversationUser;
private String conversationName;
private String callSession;
@ -2881,6 +2881,10 @@ public class CallActivity extends CallBaseActivity {
eventBus.post(new ConfigurationChangeEvent());
}
public void showCallRecordingIndicator(){
binding.callRecordingIndicator.setVisibility(View.VISIBLE);
}
private class SelfVideoTouchListener implements View.OnTouchListener {
@SuppressLint("ClickableViewAccessibility")

View File

@ -573,4 +573,12 @@ public interface NcApi {
Observable<OpenGraphOverall> getOpenGraph(@Header("Authorization") String authorization,
@Url String url,
@Query("reference") String urlToFindPreviewFor);
@POST
Observable<GenericOverall> startRecording(@Header("Authorization") String authorization,
@Url String url);
@POST
Observable<GenericOverall> stopRecording(@Header("Authorization") String authorization,
@Url String url);
}

View File

@ -35,6 +35,8 @@ import com.nextcloud.talk.polls.repositories.PollRepository
import com.nextcloud.talk.polls.repositories.PollRepositoryImpl
import com.nextcloud.talk.remotefilebrowser.repositories.RemoteFileBrowserItemsRepository
import com.nextcloud.talk.remotefilebrowser.repositories.RemoteFileBrowserItemsRepositoryImpl
import com.nextcloud.talk.repositories.callrecording.CallRecordingRepository
import com.nextcloud.talk.repositories.callrecording.CallRecordingRepositoryImpl
import com.nextcloud.talk.repositories.conversations.ConversationsRepository
import com.nextcloud.talk.repositories.conversations.ConversationsRepositoryImpl
import com.nextcloud.talk.repositories.reactions.ReactionsRepository
@ -92,4 +94,9 @@ class RepositoryModule {
fun provideReactionsRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): ReactionsRepository {
return ReactionsRepositoryImpl(ncApi, userProvider)
}
@Provides
fun provideCallRecordingRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): CallRecordingRepository {
return CallRecordingRepositoryImpl(ncApi, userProvider)
}
}

View File

@ -0,0 +1,25 @@
/*
* Nextcloud Talk application
*
* @author Marcel Hibbe
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
*
* 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/>.
*/
package com.nextcloud.talk.models.domain
data class StartCallRecordingModel(
var success: Boolean
)

View File

@ -0,0 +1,25 @@
/*
* Nextcloud Talk application
*
* @author Marcel Hibbe
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
*
* 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/>.
*/
package com.nextcloud.talk.models.domain
data class StopCallRecordingModel(
var success: Boolean
)

View File

@ -0,0 +1,36 @@
/*
* Nextcloud Talk application
*
* @author Marcel Hibbe
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.repositories.callrecording
import com.nextcloud.talk.models.domain.StartCallRecordingModel
import com.nextcloud.talk.models.domain.StopCallRecordingModel
import io.reactivex.Observable
interface CallRecordingRepository {
fun startRecording(
roomToken: String
): Observable<StartCallRecordingModel>
fun stopRecording(
roomToken: String
): Observable<StopCallRecordingModel>
}

View File

@ -0,0 +1,94 @@
/*
* Nextcloud Talk application
*
* @author Marcel Hibbe
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.repositories.callrecording
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.models.domain.StartCallRecordingModel
import com.nextcloud.talk.models.domain.StopCallRecordingModel
import com.nextcloud.talk.models.json.generic.GenericMeta
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import io.reactivex.Observable
class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider: CurrentUserProviderNew) :
CallRecordingRepository {
val currentUser: User = currentUserProvider.currentUser.blockingGet()
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
var apiVersion = ApiUtils.getCallApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, 1))
override fun startRecording(
roomToken: String
): Observable<StartCallRecordingModel> {
return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
}
// override fun startRecording(
// roomToken: String
// ): Observable<StartCallRecordingModel> {
// return ncApi.startRecording(
// credentials,
// ApiUtils.getUrlForRecording(
// apiVersion,
// currentUser.baseUrl,
// roomToken
// )
// ).map { mapToStartCallRecordingModel(it.ocs?.meta!!) }
// }
override fun stopRecording(
roomToken: String
): Observable<StopCallRecordingModel> {
return ncApi.stopRecording(
credentials,
ApiUtils.getUrlForRecording(
apiVersion,
currentUser.baseUrl,
roomToken
)
).map { mapToStopCallRecordingModel(it.ocs?.meta!!) }
}
private fun mapToStartCallRecordingModel(
response: GenericMeta
): StartCallRecordingModel {
val success = response.statusCode == HTTP_OK
return StartCallRecordingModel(
success
)
}
private fun mapToStopCallRecordingModel(
response: GenericMeta
): StopCallRecordingModel {
val success = response.statusCode == HTTP_OK
return StopCallRecordingModel(
success
)
}
companion object {
private const val HTTP_OK: Int = 200
private const val HTTP_CREATED: Int = 201
}
}

View File

@ -21,6 +21,7 @@
package com.nextcloud.talk.ui.dialog
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.ViewGroup
import autodagger.AutoInjector
@ -30,7 +31,13 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.activities.CallActivity
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.DialogMoreCallActionsBinding
import com.nextcloud.talk.models.domain.StartCallRecordingModel
import com.nextcloud.talk.repositories.callrecording.CallRecordingRepository
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
@ -39,6 +46,9 @@ class MoreCallActionsDialog(val callActivity: CallActivity) : BottomSheetDialog(
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@Inject
lateinit var callRecordingRepository: CallRecordingRepository
private lateinit var binding: DialogMoreCallActionsBinding
override fun onCreate(savedInstanceState: Bundle?) {
@ -55,8 +65,11 @@ class MoreCallActionsDialog(val callActivity: CallActivity) : BottomSheetDialog(
private fun initClickListeners() {
binding.recordCall.setOnClickListener {
// callActivity.setAudioOutputChannel(WebRtcAudioManager.AudioDevice.BLUETOOTH)
dismiss()
callRecordingRepository.startRecording(callActivity.roomToken)
.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(CallStartRecordingObserver())
// dismiss()
}
}
@ -67,6 +80,27 @@ class MoreCallActionsDialog(val callActivity: CallActivity) : BottomSheetDialog(
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
inner class CallStartRecordingObserver : Observer<StartCallRecordingModel> {
override fun onSubscribe(d: Disposable) {
// unused atm
}
override fun onNext(startCallRecordingModel: StartCallRecordingModel) {
if (startCallRecordingModel.success) {
binding.recordCallText.text = "started"
callActivity.showCallRecordingIndicator()
}
}
override fun onError(e: Throwable) {
Log.e(TAG, "failure in CallStartRecordingObserver", e)
}
override fun onComplete() {
// dismiss()
}
}
companion object {
private const val TAG = "MoreCallActionsDialog"
}

View File

@ -494,4 +494,8 @@ public class ApiUtils {
public static String getUrlForOpenGraph(String baseUrl) {
return baseUrl + ocsApiVersion + "/references/resolve";
}
public static String getUrlForRecording(int version, String baseUrl, String token) {
return getUrlForCall(version, baseUrl, token) + "/recording";
}
}

View File

@ -99,10 +99,13 @@
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="@+id/call_recording_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/record_circle"
android:contentDescription="@null">
android:contentDescription="@null"
android:visibility="gone"
tools:visibility="visible">
</ImageView>
</LinearLayout>